diff -r b2a8610cf110 -r 574749f5190b thys2/ClosedForms.thy --- a/thys2/ClosedForms.thy Mon Apr 04 23:56:40 2022 +0100 +++ b/thys2/ClosedForms.thy Thu Apr 07 21:31:29 2022 +0100 @@ -498,7 +498,17 @@ lemma grewrite_rdistinct_aux: shows "rs @ rdistinct rsa rset \g* rs @ rdistinct rsa (rset \ set rs)" - sorry + apply(induct rsa arbitrary: rs rset) + apply simp + apply(case_tac " a \ rset") + apply simp + apply(case_tac "a \ set rs") + apply simp + apply (metis Un_insert_left Un_insert_right gmany_steps_later grewrite_variant1 insert_absorb) + apply simp + apply(drule_tac x = "rs @ [a]" in meta_spec) + by (metis Un_insert_left Un_insert_right append.assoc append.right_neutral append_Cons append_Nil insert_absorb2 list.simps(15) set_append) + lemma grewrite_rdistinct_worth1: shows "(rsb @ [a]) @ rdistinct rs set1 \g* (rsb @ [a]) @ rdistinct rs (insert a set1)" @@ -540,11 +550,37 @@ lemma flts_gstar: shows "rs \g* rflts rs" - sorry + apply(induct rs) + apply simp + apply(case_tac "a = RZERO") + apply simp + using gmany_steps_later grewrite.intros(1) apply blast + apply(case_tac "\rsa. a = RALTS rsa") + apply(erule exE) + apply simp + apply (meson grewrite.intros(2) grewrites.simps grewrites_cons) + by (simp add: grewrites_cons rflts_def_idiot) + -lemma create_nonexistent_distinct_set: +lemma wrong1: shows "a \ set rs1 \ rs1 @ (rdistinct rs (insert a rset)) \g* rs1 @ (rdistinct rs (rset))" - sorry + + oops + +lemma more_distinct1: + shows " \\rsb rset rset2. + rset2 \ set rsb \ rsb @ rdistinct rs rset \g* rsb @ rdistinct rs (rset \ rset2); + rset2 \ set rsb; a \ rset; a \ rset2\ + \ rsb @ a # rdistinct rs (insert a rset) \g* rsb @ rdistinct rs (rset \ rset2)" + apply(subgoal_tac "rsb @ a # rdistinct rs (insert a rset) \g* rsb @ rdistinct rs (insert a rset)") + apply(subgoal_tac "rsb @ rdistinct rs (insert a rset) \g* rsb @ rdistinct rs (rset \ rset2)") + apply (meson greal_trans) + apply (metis Un_iff Un_insert_left insert_absorb) + by (simp add: gr_in_rstar grewrite_variant1 in_mono) + + + + lemma grewrites_in_distinct0: shows "a \ set rs1 \ rs1 @ (rdistinct (a # rs) rset) \g* rs1 @ (rdistinct rs rset)" @@ -562,13 +598,38 @@ lemma frewrite_rd_grewrites_aux: - shows " rsb @ - rdistinct (RALTS rs # rsa) - (set rsb) \g* rsb @ - rdistinct rs (set rsb) @ rdistinct rsa (insert (RALTS rs) (set rs) \ set rsb)" + shows " RALTS rs \ set rsb \ + rsb @ + RALTS rs # + rdistinct rsa + (insert (RALTS rs) + (set rsb)) \g* rflts rsb @ + rdistinct rs (set rsb) @ rdistinct rsa (set rs \ set rsb \ {RALTS rs})" + apply simp + apply(subgoal_tac "rsb @ + RALTS rs # + rdistinct rsa + (insert (RALTS rs) + (set rsb)) \g* rsb @ + rs @ + rdistinct rsa + (insert (RALTS rs) + (set rsb)) ") + apply(subgoal_tac " rsb @ + rs @ + rdistinct rsa + (insert (RALTS rs) + (set rsb)) \g* + rsb @ + rdistinct rs (set rsb) @ + rdistinct rsa + (insert (RALTS rs) + (set rsb)) ") + apply (smt (verit, ccfv_SIG) Un_insert_left flts_gstar greal_trans grewrite_rdistinct_aux grewritess_concat inf_sup_aci(5) rdistinct_concat_general rdistinct_set_equality set_append) + apply (metis append_assoc grewrites.intros(1) grewritess_concat gstar_rdistinct_general) + by (simp add: gr_in_rstar grewrite.intros(2) grewrites_append) - sorry @@ -698,10 +759,24 @@ apply (simp add: insert_absorb) by auto +lemma middle_grewrites: +"rs1 \g* rs2 \ rsa @ rs1 @ rsb \g* rsa @ rs2 @ rsb " + by (simp add: grewritess_concat) + +lemma rdistinct_removes_all: + shows "set rs \ rset \ rdistinct rs rset = []" + + by (metis append.right_neutral rdistinct.simps(1) rdistinct_concat) lemma ends_removal: shows " rsb @ rdistinct rs (set rsb) @ RALTS rs # rsc \g* rsb @ rdistinct rs (set rsb) @ rsc" - sorry + apply(subgoal_tac "rsb @ rdistinct rs (set rsb) @ RALTS rs # rsc \g* + rsb @ rdistinct rs (set rsb) @ rs @ rsc") + apply(subgoal_tac "rsb @ rdistinct rs (set rsb) @ rs @ rsc \g* +rsb @ rdistinct rs (set rsb) @ rdistinct rs (set (rsb @ rdistinct rs (set rsb))) @ rsc") + apply (metis (full_types) append_Nil2 append_eq_appendI greal_trans list_dlist_union rdistinct_removes_all set_append) + apply (metis append.assoc append_Nil gstar_rdistinct_general middle_grewrites) + using gr_in_rstar grewrite.intros(2) grewrites_append by presburger lemma grewrites_rev_append: shows "rs1 \g* rs2 \ rs1 @ [x] \g* rs2 @ [x]" @@ -717,7 +792,7 @@ shows "\x \ rset; x \ set xs \ \ rdistinct (xs @ [x]) rset = rdistinct xs rset @ [x]" by (simp add: concat_rdistinct_equality1) -lemma grewrites_shape2: +lemma grewrites_shape2_aux: shows " RALTS rs \ set rsb \ rsb @ rdistinct (rs @ rsa) @@ -767,6 +842,16 @@ apply (simp add: distinct_keeps_last)+ done +lemma grewrites_shape2: + shows " RALTS rs \ set rsb \ + rsb @ + rdistinct (rs @ rsa) + (set rsb) \g* rflts rsb @ + rdistinct rs (set rsb) @ + rdistinct rsa (set rs \ set rsb \ {RALTS rs})" + apply (meson flts_gstar greal_trans grewrites.simps grewrites_shape2_aux grewritess_concat) + done + lemma rdistinct_add_acc: shows "rset2 \ set rsb \ rsb @ rdistinct rs rset \g* rsb @ rdistinct rs (rset \ rset2)" apply(induct rs arbitrary: rsb rset rset2) @@ -774,8 +859,8 @@ apply (case_tac "a \ rset") apply simp apply(case_tac "a \ rset2") - apply simp - apply (meson create_nonexistent_distinct_set gr_in_rstar greal_trans grewrite_variant1 in_mono) + apply simp + apply (simp add: more_distinct1) apply simp apply(drule_tac x = "rsb @ [a]" in meta_spec) by (metis Un_insert_left append.assoc append_Cons append_Nil set_append sup.coboundedI1) @@ -823,14 +908,13 @@ apply (metis frewrite_fun1 rdistinct_concat sup_ge2) apply(simp) apply(rule_tac x = - "rsb @ + "rflts rsb @ rdistinct rs (set rsb) @ rdistinct rsa (set rs \ set rsb \ {RALTS rs})" in exI) apply(rule conjI) prefer 2 using grewrites_shape2 apply force - by (metis Un_insert_left frewrite_rd_grewrites_aux inf_sup_aci(5) insert_is_Un rdistinct.simps(2)) - + using frewrite_rd_grewrites_aux by blast @@ -896,13 +980,7 @@ apply(induct rs2 rs3 rule: grewrites.induct) apply simp using grewrite_simpalts by presburger -(* -lemma frewrites_dB_wwo0_simp: - shows "rdistinct rs1 {RZERO} \f* rdistinct rs2 {RZERO} - \ rsimp (RALTS (rdistinct rs1 {})) = rsimp (RALTS (rdistinct rs2 {}))" - sorry -*) @@ -942,12 +1020,9 @@ lemma simp_more_distinct: shows "rsimp (rsimp_ALTs (rsa @ rs)) = rsimp (rsimp_ALTs (rsa @ (rdistinct rs (set rsa)))) " - - + oops - sorry - lemma non_empty_list: shows "a \ set as \ as \ []" by (metis empty_iff empty_set) @@ -1091,89 +1166,136 @@ shows " \a \ set as; rsimp a \ set (map rsimp as); rsimp a = RONE\ \ rsimp a \ set (rflts (map rsimp as))" by (simp add: set_inclusion_with_flts1) -lemma "\x5. \a \ set as; rsimp a \ set (map rsimp as); rsimp a = RALTS x5\ +lemma can_spill_lst:"\x5. \a \ set as; rsimp a \ set (map rsimp as); rsimp a = RALTS x5\ \ rsimp_ALTs (rdistinct (rflts (map rsimp as @ [rsimp a])) {}) = rsimp_ALTs (rdistinct (rflts (map rsimp as @ x5)) {})" + + using flts_append rflts_spills_last rsimp_inner_idem4 by presburger + + + + + +lemma common_rewrites_equal: + shows "(rs1 \g* rs3) \ (rs2 \g* rs3) \ rsimp (rsimp_ALTs rs1 ) = rsimp (rsimp_ALTs rs2)" + using grewrites_simpalts by force + + +lemma basic_regex_property1: + shows "rnullable r \ rsimp r \ RZERO" + sorry + +lemma basic_rsimp_SEQ_property1: + shows "rsimp_SEQ RONE r = r" + by (simp add: idiot) + +lemma basic_rsimp_SEQ_property3: + shows "rsimp_SEQ r RZERO = RZERO" + using rsimp_SEQ.elims by blast + +thm rsimp_SEQ.elims + + +lemma basic_rsimp_SEQ_property2: + shows "\r1 \ RZERO ; r1 \ RONE; r2 \ RZERO\ \rsimp_SEQ r1 r2 = RSEQ r1 r2" + apply(case_tac r1) + apply simp+ + apply (simp add: idiot2) + using idiot2 apply blast + using idiot2 apply auto[1] + using idiot2 by blast + + +(* +lemma rderssimp_same_rewrites_rder_induct1: + shows "\ ([rder x (rsimp r1)] \g* rs1) \ ([rder x r1] \g* rs1) ; + ([rder x (rsimp r2)] \g* rs2) \ ([rder x r2] \g* rs2) \ \ +\rs3. ([rder x (rsimp (RSEQ r1 r2))] \g* rs3) \ ([rder x (RSEQ r1 r2)] \g* rs3) " + sorry + +lemma rderssimp_same_rewrites_rder_induct2: + shows "\ ([rder x (rsimp r1)] \g* rs1) \ ([rder x r1] \g* rs1) \ \ +\rs3. ([rder x (rsimp (RSTAR r1))] \g* rs3) \ ([rder x (RSTAR r1)] \g* rs3) " + sorry + +lemma rderssimp_same_rewrites_rder_induct3: + shows "\ ([rder x (rsimp r1)] \g* rs1) \ ([rder x r1] \g* rs1) ; + ([rder x (rsimp r2)] \g* rs2) \ ([rder x r2] \g* rs2) \ \ +\rs3. ([rder x (rsimp (RALT r1 r2))] \g* rs3) \ ([rder x (RALT r1 r2)] \g* rs3) " + sorry + +lemma rderssimp_same_rewrites_rder_induct4: + shows "\\r \ set rs. \ rsa. ([rder x (rsimp r)] \g* rsa ) \ ([rder x r] \g* rsa) \ \ +\rsb. ([rder x (rsimp (RALTS rs))] \g* rsb) \ ([rder x (RALTS rs)] \g* rsb) " + sorry + +lemma rderssimp_same_rewrites_rder_base1: + shows "([rder x (rsimp RONE)] \g* [] ) \ ([rder x RONE] \g* [])" + by (simp add: gr_in_rstar grewrite.intros(1)) + +lemma rderssimp_same_rewrites_rder_base2: + shows " ([rder x (rsimp RZERO)] \g* [] ) \ ([rder x RZERO] \g* [])" + using rderssimp_same_rewrites_rder_base1 by auto + +lemma rderssimp_same_rewrites_rder_base3: + shows " ([rder x (rsimp (RCHAR c))] \g* [] ) \ ([rder x (RCHAR c)] \g* [])" + sorry +*) + +lemma inside_simp_seq_nullable: + shows +"\r1 r2. + \rsimp (rder x (rsimp r1)) = rsimp (rder x r1); rsimp (rder x (rsimp r2)) = rsimp (rder x r2); + rnullable r1\ + \ rsimp (rder x (rsimp_SEQ (rsimp r1) (rsimp r2))) = + rsimp_ALTs (rdistinct (rflts [rsimp_SEQ (rsimp (rder x r1)) (rsimp r2), rsimp (rder x r2)]) {})" + apply(case_tac "rsimp r1 = RONE") + apply(simp) + apply(subst basic_rsimp_SEQ_property1) + apply (simp add: idem_after_simp1) + apply(case_tac "rsimp r1 = RZERO") + + using basic_regex_property1 apply blast + apply(case_tac "rsimp r2 = RZERO") + + apply (simp add: basic_rsimp_SEQ_property3) + apply(subst basic_rsimp_SEQ_property2) + apply simp+ + apply(subgoal_tac "rnullable (rsimp r1)") + apply simp + using rsimp_idem apply presburger sorry -lemma last_elem_dup1: - shows " a \ set as \ rsimp (RALTS (as @ [a] )) = rsimp (RALTS (as ))" - apply simp - apply(subgoal_tac "rsimp a \ set (map rsimp as)") - prefer 2 - apply simp - apply(case_tac "rsimp a") - apply simp +lemma inside_simp_removal: + shows " rsimp (rder x (rsimp r)) = rsimp (rder x r)" + apply(induct r) + apply simp+ + apply(case_tac "rnullable r1") + apply simp - using flts_identity3 apply presburger - apply(subst flts_identity2) - using rrexp.distinct(1) rrexp.distinct(15) apply presburger - apply(subst distinct_removes_last3[symmetric]) - using set_inclusion_with_flts apply blast - apply simp - apply (metis distinct_removes_last3 flts_identity10 set_inclusion_with_flts10) - apply (metis distinct_removes_last3 flts_identity11 set_inclusion_with_flts11) - sorry - -lemma last_elem_dup: - shows " a \ set as \ rsimp (rsimp_ALTs (as @ [a] )) = rsimp (rsimp_ALTs (as ))" - apply(induct as rule: rev_induct) - apply simp - apply simp - apply(subgoal_tac "xs \ []") - prefer 2 - - - - - sorry - -lemma appeared_before_remove_later: - shows "a \ set as \ rsimp (rsimp_ALTs ( as @ a # rs)) = rsimp (rsimp_ALTs (as @ rs))" -and "a \ set as \ rsimp (rsimp_ALTs as ) = rsimp (rsimp_ALTs (as @ [a]))" - apply(induct rs arbitrary: as) - apply simp - - - sorry - -lemma distinct_remove_later: - shows "\rder x a \ rder x ` set rsa\ - \ rsimp (rsimp_ALTs (map (rder x) rsa @ rder x a # map (rder x) (rdistinct rs (insert a (set rsa))))) = - rsimp (rsimp_ALTs (map (rder x) rsa @ map (rder x) (rdistinct rs (set rsa))))" - + using inside_simp_seq_nullable apply blast sorry -lemma distinct_der_general: - shows "rsimp (rsimp_ALTs (map (rder x) (rsa @ (rdistinct rs (set rsa))))) = - rsimp ( rsimp_ALTs ((map (rder x) rsa)@(rdistinct (map (rder x) rs) (set (map (rder x) rsa)))) )" - apply(induct rs arbitrary: rsa) - apply simp - apply(case_tac "a \ set rsa") - apply(subgoal_tac "rder x a \ set (map (rder x) rsa)") - apply simp +lemma rders_simp_same_simpders: + shows "s \ [] \ rders_simp r s = rsimp (rders r s)" + apply(induct s rule: rev_induct) apply simp - apply(case_tac "rder x a \ set (map (rder x) rsa)") - apply(simp) - apply(subst map_concat_cons)+ - apply(drule_tac x = "rsa @ [a]" in meta_spec) + apply(case_tac "xs = []") apply simp - apply(drule neg_removal_element_of) - apply simp - apply(subst distinct_remove_later) - apply simp - apply(drule_tac x = "rsa" in meta_spec) - by blast + apply(simp add: rders_append rders_simp_append) + using inside_simp_removal by blast - + lemma distinct_der: - shows "rsimp (rsimp_ALTs (map (rder x) (rdistinct rs {}))) = rsimp ( rsimp_ALTs (rdistinct (map (rder x) rs) {}))" - by (metis distinct_der_general list.simps(8) self_append_conv2 set_empty) + shows "rsimp (rsimp_ALTs (map (rder x) (rdistinct rs {}))) = + rsimp (rsimp_ALTs (rdistinct (map (rder x) rs) {}))" + by (metis grewrites_simpalts gstar_rdistinct inside_simp_removal rder_rsimp_ALTs_commute) +