diff -r 7a8cef3f5234 -r 23818853a710 thys2/ClosedForms.thy --- a/thys2/ClosedForms.thy Sat Mar 26 11:24:36 2022 +0000 +++ b/thys2/ClosedForms.thy Mon Mar 28 00:59:42 2022 +0100 @@ -494,6 +494,117 @@ + +inductive frewrite:: "rrexp list \ rrexp list \ bool" ("_ \f _" [10, 10] 10) + where + "(RZERO # rs) \f rs" +| "((RALTS rs) # rsa) \f (rs @ rsa)" +| "rs1 \f rs2 \ (r # rs1) \f (r # rs2)" + + +inductive + frewrites:: "rrexp list \ rrexp list \ bool" ("_ \f* _" [10, 10] 10) +where + rs1[intro, simp]:"rs \f* rs" +| rs2[intro]: "\rs1 \f* rs2; rs2 \f rs3\ \ rs1 \f* rs3" + +lemma fr_in_rstar : "r1 \f r2 \ r1 \f* r2" + using frewrites.intros(1) frewrites.intros(2) by blast + +lemma freal_trans[trans]: + assumes a1: "r1 \f* r2" and a2: "r2 \f* r3" + shows "r1 \f* r3" + using a2 a1 + apply(induct r2 r3 arbitrary: r1 rule: frewrites.induct) + apply(auto) + done + + +lemma many_steps_later: "\r1 \f r2; r2 \f* r3 \ \ r1 \f* r3" + by (meson fr_in_rstar freal_trans) + + +lemma frewrite_append: + shows "\ rsa \f rsb \ \ rs @ rsa \f rs @ rsb" + apply(induct rs) + apply simp+ + oops + + +lemma frewrites_cons: + shows "\ rsa \f* rsb \ \ r # rsa \f* r # rsb" + + oops + +lemma frewrites_append: + shows " \rsa \f* rsb\ \ (rs @ rsa) \f* (rs @ rsb)" + apply(induct rsa rsb rule: frewrites.induct) + apply simp + oops + + + +lemma frewrites_concat: + shows "\rs1 \f rs2; rsa \f* rsb \ \ (rs1 @ rsa) \f* (rs2 @ rsb)" + apply(induct rs1 rs2 rule: frewrite.induct) + apply(simp) + apply(subgoal_tac "(RZERO # rs @ rsa) \f (rs @ rsa)") + prefer 2 + using frewrite.intros(1) apply blast + apply(subgoal_tac "(rs @ rsa) \f* (rs @ rsb)") + using many_steps_later apply blast + + + + + + + +lemma many_steps_later1: + shows " \rs1 \f* rs2\ + \ (RONE # rs1) \f* (RONE # rs2)" + oops + +lemma early_late_der_frewrites: + shows "map (rder x) (rflts rs) \f* rflts (map (rder x) rs)" + apply(induct rs) + apply simp + apply(case_tac a) + apply simp+ + using frewrite.intros(1) many_steps_later apply blast + apply(case_tac "x = x3") + apply simp + + + + + +fun alt_set:: "rrexp \ rrexp set" + where + "alt_set (RALTS rs) = set rs" +| "alt_set r = {r}" + + + +lemma rd_flts_set: + shows "rs1 \f* rs2 \ rdistinct rs1 (insert RZERO (rset \ (\(alt_set ` rset)))) \f* + rdistinct rs2 (rset \ (\(alt_set ` rset)))" + by (meson frewrite.intros(2) frewrites.simps) + +lemma rd_flts_set2: + shows "rs1 \f* rs2 \ rdistinct rs1 ((rset \ (\(alt_set ` rset)))) \f* + rdistinct rs2 (rset \ (\(alt_set ` rset)))" + using frewrite.intros(2) by blast + +lemma rd_flts_incorrect: + shows "rs1 \f* rs2 \ rdistinct rs1 rset \f* rdistinct rs2 rset" + sledgehammer + by (smt (verit, ccfv_threshold) frewrites.simps) + +lemma flts_does_rewrite: + shows "rs1 \f* rs2 \ rflts rs1 = rflts rs2" + oops + lemma rflts_fltsder_derflts: shows "rflts (map rsimp (rdistinct (map (rder x3) (rflts rs)) rset)) = rflts (map rsimp (rdistinct (rflts (map (rder x3) rs)) rset))" @@ -501,13 +612,15 @@ lemma simp_der_flts: - shows "rsimp (RALTS (rdistinct (map (rder x) (rflts rs)) rset))= - rsimp (RALTS (rdistinct (rflts (map (rder x) rs)) rset))" + shows "rsimp (RALTS (rdistinct (map (rder x) (rflts rs)) {})) = + rsimp (RALTS (rdistinct (rflts (map (rder x) rs)) {}))" - apply(induct rs arbitrary: rset) + apply(induct rs) apply simp apply(case_tac a) - apply simp + apply simp+ + prefer 2 + apply simp apply(case_tac "RZERO \ rset") apply simp+ using distinct_flts_no0 apply presburger @@ -522,8 +635,13 @@ lemma simp_der_pierce_flts: - shows " rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \ (\r. rders_simp r xs)) rs))) {})) = - rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) (map (rsimp \ (\r. rders_simp r xs)) rs))) {}))" + shows " rsimp ( +rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \ (\r. rders_simp r xs)) rs))) {}) +) = + rsimp ( +rsimp_ALTs (rdistinct (rflts (map (rder x) (map (rsimp \ (\r. rders_simp r xs)) rs))) {}) +)" + sorry