Theory Simplifying3
theory Simplifying3
imports Lexer3
begin
section ‹Lexer including simplifications›
fun F_RIGHT where
"F_RIGHT f v = Right (f v)"
fun F_LEFT where
"F_LEFT f v = Left (f v)"
fun F_Plus where
"F_Plus f⇩1 f⇩2 (Right v) = Right (f⇩2 v)"
| "F_Plus f⇩1 f⇩2 (Left v) = Left (f⇩1 v)"
| "F_Plus f1 f2 v = v"
fun F_Times1 where
"F_Times1 f⇩1 f⇩2 v = Seq (f⇩1 Void) (f⇩2 v)"
fun F_Times2 where
"F_Times2 f⇩1 f⇩2 v = Seq (f⇩1 v) (f⇩2 Void)"
fun F_Times where
"F_Times f⇩1 f⇩2 (Seq v⇩1 v⇩2) = Seq (f⇩1 v⇩1) (f⇩2 v⇩2)"
| "F_Times f1 f2 v = v"