theory Regexp imports Main begin datatype regexp = Alt regexp regexp |Conc regexp regexp (infix "\" 60) |Star regexp |Neg regexp |Atom char type_synonym word = "char list" inductive_set star:: "word set \ word set" for L where star_e: "[] \ star L" | star_step: "y \L \ x \ star L \ x@y \ star L" definition conc :: "word set \ word set \ word set" where "conc l1 l2 \{ w1@w2 |w1 w2. w1 \ l1 \ w2 \ l2}" primrec lang:: "regexp \ word set" where "lang (Atom c) = {[c]}" |"lang (Alt e1 e2) = lang e1 \ lang e2" |"lang (Conc e1 e2) = conc (lang e1) (lang e2)" |"lang (Star e) = star (lang e)" |"lang (Neg e) = -lang e" primrec Rev::"regexp \ regexp" where "Rev (Atom c) = Atom c" |"Rev (Alt e1 e2) = Alt (Rev e1) (Rev e2)" |"Rev (Conc e1 e2) = Conc (Rev e2) (Rev e1)" |"Rev (Star e) = Star (Rev e)" |"Rev (Neg e) = Neg (Rev e)" lemma conc_rev: "conc (rev ` l2) (rev ` l1) = rev ` conc l1 l2" apply (rule equalityI) apply clarsimp apply (simp add: conc_def) thm image_eqI apply clarsimp find_theorems intro "_ \ _ ` _" apply (rule_tac x="xb@xa" in image_eqI) apply simp apply auto[1] apply (clarsimp simp: conc_def) apply auto done lemma star_app: "xa \ l \ xb \ star l \ xa @ xb \ star l" sorry lemma star_rev1: "x \ star (rev ` l) \ x \ rev ` star l " thm star.induct (*apply (erule star.induct)*) apply (induct rule: star.induct) apply (simp add: star_e) apply clarsimp apply (rule_tac x="xa@xb" in image_eqI) apply simp apply (simp add: star_app) done lemma star_rev: "star (rev ` l) = rev ` star l" apply (rule equalityI) apply (clarsimp simp: star_rev1) apply clarsimp sorry lemma rev_bij: "bij rev" sorry theorem "lang (Rev e) = rev ` (lang e)" apply (induct e) apply auto[1] apply (simp add: conc_rev) apply (simp add: star_rev) apply clarsimp apply (rule bij_image_Compl_eq[symmetric]) apply (rule rev_bij) find_theorems " _` (-_)" apply simp done end