# HG changeset patch # User Christian Urban # Date 1395925587 0 # Node ID 457240e429724fbc82c38f1668a15e7ad6ba3eb1 # Parent f8b2bf858caf4fc5a5b18e6169ee876ada13547a some minor changes diff -r f8b2bf858caf -r 457240e42972 thys/Hoare_gen.thy --- a/thys/Hoare_gen.thy Thu Mar 27 11:50:37 2014 +0000 +++ b/thys/Hoare_gen.thy Thu Mar 27 13:06:27 2014 +0000 @@ -30,20 +30,26 @@ lemmas sep_conj_cond = sep_conj_cond1 sep_conj_cond2 sep_conj_cond3 -lemma cond_true_eq[simp]: " = \" +lemma cond_true_eq [simp]: + " = \" by(unfold sep_empty_def pasrt_def, auto) -lemma cond_true_eq1: "( \* p) = p" - by(simp) +lemma cond_true_eq1: + "( \* p) = p" + by (simp) -lemma false_simp [simp]: " = sep_false" (* move *) +lemma cond_true_eq2: + "(p \* ) = p" + by simp + +lemma false_simp [simp]: + " = sep_false" (* move *) by (simp add:pasrt_def) -lemma cond_true_eq2: "(p \* ) = p" - by simp - -lemma condD: "( \* r) s \ b \ r s" -by (unfold sep_conj_def pasrt_def, auto) +lemma condD: + "( \* r) s \ b \ r s" +unfolding sep_conj_def pasrt_def +by auto locale sep_exec = fixes step :: "'conf \ 'conf" @@ -189,8 +195,8 @@ lemma hoare_sep_false: "\sep_false\ c \q\" - by(unfold Hoare_gen_def, clarify, simp) - +unfolding Hoare_gen_def +by auto lemma pred_exI: assumes "(P(x) \* r) s" diff -r f8b2bf858caf -r 457240e42972 thys/Hoare_tm.thy --- a/thys/Hoare_tm.thy Thu Mar 27 11:50:37 2014 +0000 +++ b/thys/Hoare_tm.thy Thu Mar 27 13:06:27 2014 +0000 @@ -25,7 +25,6 @@ *} setup {* StepRules.setup *} - setup {* FwdRules.setup *} method_setup prune = @@ -128,18 +127,22 @@ notation TLocal (binder "TL " 10) -abbreviation tprog_instr :: "tm_inst \ tpg" ("\ _" [61] 61) +abbreviation + tprog_instr :: "tm_inst \ tpg" ("\ _" [61] 61) where "\ i \ TInstr i" -abbreviation tprog_seq :: "tpg \ tpg \ tpg" (infixr ";" 52) +abbreviation tprog_seq :: + "tpg \ tpg \ tpg" (infixr ";" 52) where "c1 ; c2 \ TSeq c1 c2" -definition "sg e = (\ s. s = e)" +definition "sg e = (\s. s = e)" type_synonym tassert = "tresource set \ bool" -abbreviation t_hoare :: "tassert \ tassert \ tassert \ bool" ("(\(1_)\/ (_)/ \(1_)\)" 50) - where "\p\ c \q\ == sep_exec.Hoare_gen tstep trset_of p c q" +abbreviation + t_hoare :: "tassert \ tassert \ tassert \ bool" ("(\(1_)\/ (_)/ \(1_)\)" 50) +where + "\p\ c \q\ == sep_exec.Hoare_gen tstep trset_of p c q" abbreviation it_hoare :: "('a::sep_algebra \ tresource set \ bool) \ ('a \ bool) \ (tresource set \ bool) \ ('a \ bool) \ bool" @@ -165,8 +168,10 @@ lemmas tasmp = tassemble_to.simps (2, 3, 4) -abbreviation tasmb_to :: "nat \ tpg \ nat \ tassert" ("_ :[ _ ]: _" [60, 60, 60] 60) - where "i :[ tpg ]: j \ tassemble_to tpg i j" +abbreviation + tasmb_to :: "nat \ tpg \ nat \ tassert" ("_ :[ _ ]: _" [60, 60, 60] 60) + where + "i :[ tpg ]: j \ tassemble_to tpg i j" lemma EXS_intro: assumes h: "(P x) s" @@ -202,7 +207,8 @@ definition "tpg_fold tpgs = foldr TSeq (butlast tpgs) (last tpgs)" -lemma tpg_fold_sg: "tpg_fold [tpg] = tpg" +lemma tpg_fold_sg: + "tpg_fold [tpg] = tpg" by (simp add:tpg_fold_def) lemma tpg_fold_cons: @@ -352,24 +358,23 @@ definition "st l = sg (tpc_set l)" definition "ps p = sg (tpos_set p)" -definition "tm a v =sg ({TM a v})" +definition "tm a v = sg ({TM a v})" definition "one i = tm i Oc" definition "zero i= tm i Bk" definition "any i = (EXS v. tm i v)" declare trset_of.simps[simp del] -lemma stimes_sgD: "(sg x ** q) s \ q (s - x) \ x \ s" +lemma stimes_sgD: + "(sg x \* q) s \ q (s - x) \ x \ s" apply(erule_tac sep_conjE) apply(unfold set_ins_def sg_def) - by (metis Diff_Int2 Diff_Int_distrib2 Diff_Un Diff_cancel - Diff_empty Diff_idemp Diff_triv Int_Diff Un_Diff - Un_Diff_cancel inf_commute inf_idem sup_bot_right sup_commute sup_ge2) - -lemma stD: "(st i ** r) (trset_of (ft, prog, i', pos, mem)) - \ i' = i" + by (metis Diff_Int Diff_cancel Diff_empty Un_Diff sup.cobounded1 sup_bot.left_neutral sup_commute) + +lemma stD: + "(st i \* r) (trset_of (ft, prog, i', pos, mem)) \ i' = i" proof - - assume "(st i ** r) (trset_of (ft, prog, i', pos, mem))" + assume "(st i \* r) (trset_of (ft, prog, i', pos, mem))" from stimes_sgD [OF this[unfolded st_def], unfolded trset_of.simps] have "tpc_set i \ tprog_set prog \ tpc_set i' \ tpos_set pos \ tmem_set mem \ tfaults_set ft" by auto @@ -377,8 +382,8 @@ by (unfold tpn_set_def, auto) qed -lemma psD: "(ps p ** r) (trset_of (ft, prog, i', pos, mem)) - \ pos = p" +lemma psD: + "(ps p \* r) (trset_of (ft, prog, i', pos, mem)) \ pos = p" proof - assume "(ps p ** r) (trset_of (ft, prog, i', pos, mem))" from stimes_sgD [OF this[unfolded ps_def], unfolded trset_of.simps] @@ -408,45 +413,37 @@ qed lemma t_hoare_seq: - "\\ i j. \st i ** p\ i:[c1]:j \st j ** q\; - \ j k. \st j ** q\ j:[c2]:k \st k ** r\\ \ \st i ** p\ i:[(c1 ; c2)]:k \st k ** r\" -proof - - assume h: "\ i j. \st i ** p\ i:[c1]:j \st j ** q\" - "\ j k. \st j ** q\ j:[c2]:k \st k ** r\" - show "\st i ** p\ i:[(c1 ; c2)]:k \st k ** r\" - proof(subst tassemble_to.simps, rule tm.code_exI) - fix j' - show "\st i \* p\ i :[ c1 ]: j' \* j' :[ c2 ]: k \st k \* r\" - proof(rule tm.composition) - from h(1) show "\st i \* p\ i :[ c1 ]: j' \ st j' \* q \" by auto - next - from h(2) show "\st j' \* q\ j' :[ c2 ]: k \st k \* r\" by auto - qed + assumes a1: "\ i j. \st i \* p\ i:[c1]:j \st j \* q\" + and a2: "\ j k. \st j ** q\ j:[c2]:k \st k ** r\" + shows "\st i \* p\ i:[(c1 ; c2)]:k \st k \* r\" +proof(subst tassemble_to.simps, rule tm.code_exI) + fix j' + show "\st i \* p\ i:[ c1 ]:j' \* j':[ c2 ]:k \st k \* r\" + proof(rule tm.composition) + from a1 show "\st i \* p\ i:[ c1 ]:j' \st j' \* q\" by auto + next + from a2 show "\st j' \* q\ j':[ c2 ]:k \st k \* r\" by auto qed qed + lemma t_hoare_seq1: - "\\j'. \st i ** p\ i:[c1]:j' \st j' ** q\; - \j'. \st j' ** q\ j':[c2]:k \st k' ** r\\ \ - \st i ** p\ i:[(c1 ; c2)]:k \st k' ** r\" -proof - - assume h: "\j'. \st i \* p\ i :[ c1 ]: j' \st j' \* q\" - "\j'. \st j' \* q\ j' :[ c2 ]: k \st k' \* r\" - show "\st i \* p\ i :[ (c1 ; c2) ]: k \st k' \* r\" - proof(subst tassemble_to.simps, rule tm.code_exI) - fix j' - show "\st i \* p\ i :[ c1 ]: j' \* j' :[ c2 ]: k \st k' \* r\" - proof(rule tm.composition) - from h(1) show "\st i \* p\ i :[ c1 ]: j' \ st j' \* q \" by auto - next - from h(2) show " \st j' \* q\ j' :[ c2 ]: k \st k' \* r\" by auto - qed + assumes a1: "\j'. \st i \* p\ i:[c1]:j' \st j' \* q\" + assumes a2: "\j'. \st j' \* q\ j':[c2]:k \st k' \* r\" + shows "\st i \* p\ i:[(c1 ; c2)]:k \st k' \* r\" +proof(subst tassemble_to.simps, rule tm.code_exI) + fix j' + show "\st i \* p\ i:[ c1 ]:j' \* j':[ c2 ]:k \st k' \* r\" + proof(rule tm.composition) + from a1 show "\st i \* p\ i:[ c1 ]:j' \st j' \* q\" by auto + next + from a2 show " \st j' \* q\ j':[ c2 ]:k \st k' \* r\" by auto qed qed lemma t_hoare_seq2: - assumes h: "\j. \st i ** p\ i:[c1]:j \st k' \* r\" - shows "\st i ** p\ i:[(c1 ; c2)]:j \st k' ** r\" + assumes h: "\j. \st i ** p\ i:[c1]:j \st k' \* r\" + shows "\st i ** p\ i:[(c1 ; c2)]:j \st k' ** r\" apply (unfold tassemble_to.simps, rule tm.code_exI) by (rule tm.code_extension, rule h) @@ -456,10 +453,9 @@ by (unfold tassemble_to.simps, intro tm.code_exI, simp) lemma t_hoare_label: - "(\l. l = i \ \st l \* p\ l :[ c l ]: j \st k \* q\) \ - \st i \* p \ - i:[(TLabel l; c l)]:j - \st k \* q\" + assumes "\l. l = i \ \st l \* p\ l:[ c l ]:j \st k \* q\" + shows "\st i \* p\ i:[(TLabel l; c l)]:j \st k \* q\" +using assms by (unfold tassemble_to.simps, intro tm.code_exI tm.code_condI, clarify, auto) primrec t_split_cmd :: "tpg \ (tpg \ tpg option)" @@ -470,15 +466,15 @@ (c21, None) \ (c1, Some c21))" | "t_split_cmd (TLocal c) = (TLocal c, None)" -definition "t_last_cmd tpg = (snd (t_split_cmd tpg))" +definition "t_last_cmd tpg = snd (t_split_cmd tpg)" declare t_last_cmd_def [simp] -definition "t_blast_cmd tpg = (fst (t_split_cmd tpg))" +definition "t_blast_cmd tpg = fst (t_split_cmd tpg)" declare t_blast_cmd_def [simp] -lemma "t_last_cmd (c1; c2; (TLabel l)) = (Some (TLabel l))" +lemma "t_last_cmd (c1; c2; TLabel l) = Some (TLabel l)" by simp lemma "t_blast_cmd (c1; c2; TLabel l) = (c1; c2)" @@ -486,7 +482,7 @@ lemma t_split_cmd_eq: assumes "t_split_cmd c = (c1, Some c2)" - shows "(i:[c]:j) = (i:[(c1; c2)]:j)" + shows "i:[c]:j = i:[(c1; c2)]:j" using assms proof(induct c arbitrary: c1 c2 i j) case (TSeq cx cy) @@ -505,7 +501,6 @@ qed auto lemma t_hoare_label_last_pre: - fixes l assumes h1: "t_split_cmd c = (c', Some (TLabel l))" and h2: "l = j \ \p\ i:[c']:j \q\" shows "\p\ i:[c]:j \q\" @@ -514,7 +509,6 @@ intro tm.code_exI tm.code_condI, insert h2, auto) lemma t_hoare_label_last: - fixes l assumes h1: "t_last_cmd c = Some (TLabel l)" and h2: "l = j \ \p\ i:[t_blast_cmd c]:j \q\" shows "\p\ i:[c]:j \q\"