# HG changeset patch # User prensani # Date 1015348751 -3600 # Node ID b115b305612f53fa8eaefa43618a59912204d0ba # Parent cd0075346431ac83730f8db5a1c7f842d1278c00 New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively) diff -r cd0075346431 -r b115b305612f src/HOL/HoareParallel/Gar_Coll.thy --- a/src/HOL/HoareParallel/Gar_Coll.thy Tue Mar 05 17:14:11 2002 +0100 +++ b/src/HOL/HoareParallel/Gar_Coll.thy Tue Mar 05 18:19:11 2002 +0100 @@ -654,7 +654,7 @@ apply force apply (simp add:BtoW_def) apply force ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply(simp add:abbrev) done @@ -757,7 +757,7 @@ apply(rule conjI) apply(erule disjE, erule disjI1, rule disjI2,erule subset_trans, erule Graph9) apply(simp add:nth_list_update) ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply(clarify, simp add:abbrev Graph7 Graph8 Graph12, erule disjE, erule disjI1, rule disjI2,erule subset_trans, erule Graph9) done diff -r cd0075346431 -r b115b305612f src/HOL/HoareParallel/Graph.thy --- a/src/HOL/HoareParallel/Graph.thy Tue Mar 05 17:14:11 2002 +0100 +++ b/src/HOL/HoareParallel/Graph.thy Tue Mar 05 18:19:11 2002 +0100 @@ -42,7 +42,7 @@ lemmas Graph_defs= Blacks_def Proper_Roots_def Proper_Edges_def BtoW_def declare Graph_defs [simp] -subsubsection{* Graph 1. *} +subsubsection{* Graph 1 *} lemma Graph1_aux [rule_format]: "\ Roots\Blacks M; \iBtoW(E!i,M)\ @@ -89,7 +89,7 @@ apply auto done -subsubsection{* Graph 2. *} +subsubsection{* Graph 2 *} lemma Ex_first_occurrence [rule_format]: "P (n::nat) \ (\m. P m \ (\i. i \ P i))"; @@ -196,7 +196,7 @@ done -subsubsection{* Graph 3. *} +subsubsection{* Graph 3 *} lemma Graph3: "\ T\Reach E; R \ Reach(E[R:=(fst(E!R),T)]) \ Reach E" @@ -281,7 +281,7 @@ apply(force simp add: nth_list_update) done -subsubsection{* Graph 4. *} +subsubsection{* Graph 4 *} lemma Graph4: "\T \ Reach E; Roots\Blacks M; I\length E; T T \ Reach E ; Roots \ Blacks M; \iBtoW(E!i,M); TProper_Edges(M,E); R \ Proper_Edges(M,E[R:=(fst(E!R),T)])" diff -r cd0075346431 -r b115b305612f src/HOL/HoareParallel/Mul_Gar_Coll.thy --- a/src/HOL/HoareParallel/Mul_Gar_Coll.thy Tue Mar 05 17:14:11 2002 +0100 +++ b/src/HOL/HoareParallel/Mul_Gar_Coll.thy Tue Mar 05 18:19:11 2002 +0100 @@ -294,7 +294,7 @@ apply(erule less_SucE) apply force apply (simp add:BtoW_def) ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply clarify apply simp apply(disjE_tac) @@ -388,7 +388,7 @@ apply (force simp add:Blacks_def) --{* 2 subgoals left *} apply force ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply clarify apply(drule le_imp_less_or_eq) apply(disjE_tac) @@ -777,7 +777,7 @@ apply(rule disjI1, erule less_le_trans) apply(force simp add:Queue_def less_Suc_eq_le le_length_filter_update) apply force ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply clarify apply(disjE_tac) apply(simp_all add:Graph6) @@ -908,7 +908,7 @@ apply(rule conjI) apply(rule disjI2,rule disjI1, erule subset_psubset_trans,simp add:Graph11) apply (force simp add:nth_list_update) ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply clarify apply (simp add:mul_collector_defs Mul_PBInv_def Graph7 Graph8 Graph12) apply(case_tac "M x!(T (Muts x!j))=Black") @@ -1023,7 +1023,7 @@ apply(rule impI,rule disjI2,rule disjI2,rule disjI1,erule le_trans,force simp add:Queue_def less_Suc_eq_le le_length_filter_update) apply(rule impI,rule disjI2,rule disjI2,rule disjI1,erule le_trans,force simp add:Queue_def less_Suc_eq_le le_length_filter_update) apply(simp add:Graph6) ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply(simp add:mul_mutator_defs nth_list_update) done @@ -1114,7 +1114,7 @@ apply(rule conjI) apply((rule disjI2)+,erule psubset_subset_trans, simp add: Graph9) apply (simp add: nth_list_update) ---{* 1 subgoals left *} +--{* 1 subgoal left *} apply clarify apply disjE_tac apply (simp add: Graph7 Graph8 Graph12) diff -r cd0075346431 -r b115b305612f src/HOL/HoareParallel/OG_Examples.thy --- a/src/HOL/HoareParallel/OG_Examples.thy Tue Mar 05 17:14:11 2002 +0100 +++ b/src/HOL/HoareParallel/OG_Examples.thy Tue Mar 05 18:19:11 2002 +0100 @@ -461,9 +461,10 @@ subsubsection {* Set Elements of an Array to Zero *} -record scheme1_vars = +record Example1 = a :: "nat \ nat" -lemma scheme1: + +lemma Example1: "\- .{True}. COBEGIN SCHEME [0\ia:=\a (i:=0) .{\a i=0}. COEND .{\i < n. \a i = 0}." @@ -472,14 +473,14 @@ done text {* Same example with lists as auxiliary variables. *} -record scheme1_list_vars = - a :: "nat list" -lemma scheme1_list: - "\- .{n < length \a}. +record Example1_list = + A :: "nat list" +lemma Example1_list: + "\- .{n < length \A}. COBEGIN - SCHEME [0\ia}. \a:=\a[i:=0] .{\a!i=0}. + SCHEME [0\iA}. \A:=\A[i:=0] .{\A!i=0}. COEND - .{\i < n. \a!i = 0}." + .{\i < n. \A!i = 0}." apply oghoare apply simp_all apply force+ @@ -492,13 +493,13 @@ text {* First some lemmas about summation properties. Summation is defined in PreList. *} -lemma scheme2_lemma1: "!!b. j (\i b j = 0 " +lemma Example2_lemma1: "!!b. j (\i b j = 0 " apply(induct n) apply simp_all apply(force simp add: less_Suc_eq) done -lemma scheme2_lemma2_aux: "!!b. j +lemma Example2_lemma2_aux: "!!b. j (\iii s \ (\ii s \ (\iij \ Suc (\i< n. b i)=(\i< n. (b (j := Suc 0)) i)" -apply(frule_tac b="(b (j:=(Suc 0)))" in scheme2_lemma2_aux) +apply(frule_tac b="(b (j:=(Suc 0)))" in Example2_lemma2_aux) apply(erule_tac t="Summation (b(j := (Suc 0))) n" in ssubst) -apply(frule_tac b=b in scheme2_lemma2_aux) +apply(frule_tac b=b in Example2_lemma2_aux) apply(erule_tac t="Summation b n" in ssubst) apply(subgoal_tac "Suc (Summation b j + b j + (\iij") - apply(drule_tac b="b" and t="(Suc 0)" in scheme2_lemma2_aux2) + apply(drule_tac b="b" and t="(Suc 0)" in Example2_lemma2_aux2) apply(rotate_tac -1) apply(erule ssubst) apply simp_all done -lemma scheme2_lemma3: "!!b. \i< n. b i = (Suc 0) \ (\ii< n. b i = (Suc 0) \ (\i nat" x :: nat -lemma scheme_2: "0 + +lemma Example_2: "0 \- .{\x=0 \ (\i< n. \c i)=0}. COBEGIN SCHEME [0\i \ While b P sat [pre, rely, guar, post]" Await: "\ stable pre rely; stable post rely; - \V. \ P sat [pre \ b \ {V}, {(s, t). s = t}, UNIV, {s. (V, s) \ guar} \ post] \ + \V. \ P sat [pre \ b \ {V}, {(s, t). s = t}, + UNIV, {s. (V, s) \ guar} \ post] \ \ \ Await b P sat [pre, rely, guar, post]" Conseq: "\ pre \ pre'; rely \ rely'; guar' \ guar; post' \ post; @@ -59,8 +60,7 @@ consts par_rghoare :: "('a par_rgformula) set" syntax - "_par_rghoare" :: "('a rgformula) list \ 'a set \ ('a \ 'a) set \ ('a \ 'a) set \ 'a set - \ bool" ("\ _ SAT [_, _, _, _]" [60,0,0,0,0] 45) + "_par_rghoare" :: "('a rgformula) list \ 'a set \ ('a \ 'a) set \ ('a \ 'a) set \ 'a set \ bool" ("\ _ SAT [_, _, _, _]" [60,0,0,0,0] 45) translations "\ Ps SAT [pre, rely, guar, post]" \ "(Ps, pre, rely, guar, post) \ par_rghoare" @@ -177,7 +177,8 @@ lemma etran_or_ctran [rule_format]: "\m i. x\cptn \ m \ length x - \ (\i. Suc i < m \ \ x!i -c\ x!Suc i) \ Suc i < m \ x!i -e\ x!Suc i" + \ (\i. Suc i < m \ \ x!i -c\ x!Suc i) \ Suc i < m + \ x!i -e\ x!Suc i" apply(induct x,simp) apply clarify apply(erule cptn.elims,simp) @@ -233,7 +234,8 @@ lemma stability [rule_format]: "\j k. x \ cptn \ stable p rely \ j\k \ k snd(x!j)\p \ - (\i. (Suc i) (x!i -e\ x!(Suc i)) \ (snd(x!i), snd(x!(Suc i))) \ rely) \ + (\i. (Suc i) + (x!i -e\ x!(Suc i)) \ (snd(x!i), snd(x!(Suc i))) \ rely) \ (\i. j\i \ i x!i -e\ x!Suc i) \ snd(x!k)\p \ fst(x!j)=fst(x!k)" apply(induct x) apply clarify @@ -286,7 +288,8 @@ lemma unique_ctran_Basic [rule_format]: "\s i. x \ cptn \ x ! 0 = (Some (Basic f), s) \ - Suc i x!i -c\ x!Suc i \ (\j. Suc j i\j \ x!j -e\ x!Suc j)" + Suc i x!i -c\ x!Suc i \ + (\j. Suc j i\j \ x!j -e\ x!Suc j)" apply(induct x,simp) apply simp apply clarify @@ -383,7 +386,8 @@ lemma unique_ctran_Await [rule_format]: "\s i. x \ cptn \ x ! 0 = (Some (Await b c), s) \ - Suc i x!i -c\ x!Suc i \ (\j. Suc j i\j \ x!j -e\ x!Suc j)" + Suc i x!i -c\ x!Suc i \ + (\j. Suc j i\j \ x!j -e\ x!Suc j)" apply(induct x,simp+) apply clarify apply(erule cptn.elims,simp) @@ -445,8 +449,10 @@ lemma Await_sound: "\stable pre rely; stable post rely; - \V. \ P sat [pre \ b \ {s. s = V}, {(s, t). s = t}, UNIV, {s. (V, s) \ guar} \ post] \ - \ P sat [pre \ b \ {s. s = V}, {(s, t). s = t}, UNIV, {s. (V, s) \ guar} \ post] \ + \V. \ P sat [pre \ b \ {s. s = V}, {(s, t). s = t}, + UNIV, {s. (V, s) \ guar} \ post] \ + \ P sat [pre \ b \ {s. s = V}, {(s, t). s = t}, + UNIV, {s. (V, s) \ guar} \ post] \ \ \ Await b P sat [pre, rely, guar, post]" apply(unfold com_validity_def) apply clarify @@ -683,9 +689,11 @@ done lemma Seq_sound2 [rule_format]: - "x \ cptn \ \s P i. x!0=(Some (Seq P Q), s) \ i fst(x!i)=Some Q \ + "x \ cptn \ \s P i. x!0=(Some (Seq P Q), s) \ i fst(x!i)=Some Q \ (\j(Some Q)) \ - (\xs ys. xs \ cp (Some P) s \ length xs=Suc i \ ys \ cp (Some Q) (snd(xs !i)) \ x=(map (lift Q) xs)@tl ys)" + (\xs ys. xs \ cp (Some P) s \ length xs=Suc i + \ ys \ cp (Some Q) (snd(xs !i)) \ x=(map (lift Q) xs)@tl ys)" apply(erule cptn.induct) apply(unfold cp_def) apply safe @@ -910,9 +918,11 @@ lemma assum_after_body: "\ \ P sat [pre \ b, rely, guar, pre]; - (Some P, s) # xs \ cptn_mod; fst (((Some P, s) # xs)!length xs) = None; s \ b; - (Some (While b P), s) # (Some (Seq P (While b P)), s) # map (lift (While b P)) xs @ ys \ assum (pre, rely)\ - \ (Some (While b P), snd (((Some P, s) # xs)!length xs)) # ys \ assum (pre, rely)" + (Some P, s) # xs \ cptn_mod; fst (((Some P, s) # xs)!length xs) = None; + s \ b; (Some (While b P), s) # (Some (Seq P (While b P)), s) # + map (lift (While b P)) xs @ ys \ assum (pre, rely)\ + \ (Some (While b P), snd (((Some P, s) # xs)!length xs)) # ys + \ assum (pre, rely)" apply(simp add:assum_def com_validity_def cp_def cptn_iff_cptn_mod) apply clarify apply(erule_tac x=s in allE) @@ -948,8 +958,8 @@ lemma assum_after_body: "\ \ P sat [pre \ b, rely, guar, pre]; (Some P, s) # xs \ cptn_mod; fst (last ((Some P, s) # xs)) = None; s \ b; - (Some (While b P), s) # (Some (Seq P (While b P)), s) # map (lift (While b P)) xs @ ys - \ assum (pre, rely)\ + (Some (While b P), s) # (Some (Seq P (While b P)), s) # + map (lift (While b P)) xs @ ys \ assum (pre, rely)\ \ (Some (While b P), snd (last ((Some P, s) # xs))) # ys \ assum (pre, rely)" apply(simp add:assum_def com_validity_def cp_def cptn_iff_cptn_mod) apply clarify @@ -1214,10 +1224,12 @@ "ParallelCom Ps \ map (Some \ fst) Ps" lemma two: - "\ \i (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) \ Rely (xs ! i); - pre \ (\i\{i. i < length xs}. Pre (xs ! i)); - \i Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; - length xs=length clist; x \ par_cp (ParallelCom xs) s; x\par_assum(pre, rely); + "\ \i (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) + \ Rely (xs ! i); + pre \ (\i\{i. i < length xs}. Pre (xs ! i)); + \i Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; + length xs=length clist; x \ par_cp (ParallelCom xs) s; x\par_assum(pre, rely); \icp (Some(Com(xs!i))) s; x \ clist \ \ \j i. i Suc j (clist!i!j) -c\ (clist!i!Suc j) \ (snd(clist!i!j), snd(clist!i!Suc j)) \ Guar(xs!i)" @@ -1291,10 +1303,12 @@ done lemma three [rule_format]: - "\ xs\[]; \i (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) \ Rely (xs ! i); - pre \ (\i\{i. i < length xs}. Pre (xs ! i)); - \i Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; - length xs=length clist; x \ par_cp (ParallelCom xs) s; x\par_assum(pre, rely); + "\ xs\[]; \i (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) + \ Rely (xs ! i); + pre \ (\i\{i. i < length xs}. Pre (xs ! i)); + \i Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; + length xs=length clist; x \ par_cp (ParallelCom xs) s; x \ par_assum(pre, rely); \icp (Some(Com(xs!i))) s; x \ clist \ \ \j i. i Suc j (clist!i!j) -e\ (clist!i!Suc j) \ (snd(clist!i!j), snd(clist!i!Suc j)) \ rely \ (\j\{j. j < length xs \ j \ i}. Guar (xs ! j))" @@ -1325,10 +1339,14 @@ done lemma four: - "\xs\[]; \i < length xs. rely \ (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) \ Rely (xs ! i); - (\j\{j. j < length xs}. Guar (xs ! j)) \ guar; pre \ (\i\{i. i < length xs}. Pre (xs ! i)); - \i < length xs. \ Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; - x \ par_cp (ParallelCom xs) s; x \ par_assum (pre, rely); Suc i < length x; x ! i -pc\ x ! Suc i\ + "\xs\[]; \i < length xs. rely \ (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) + \ Rely (xs ! i); + (\j\{j. j < length xs}. Guar (xs ! j)) \ guar; + pre \ (\i\{i. i < length xs}. Pre (xs ! i)); + \i < length xs. + \ Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; + x \ par_cp (ParallelCom xs) s; x \ par_assum (pre, rely); Suc i < length x; + x ! i -pc\ x ! Suc i\ \ (snd (x ! i), snd (x ! Suc i)) \ guar" apply(simp add: ParallelCom_def) apply(subgoal_tac "(map (Some \ fst) xs)\[]") @@ -1372,11 +1390,14 @@ done lemma five: - "\xs\[]; \i (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) \ Rely (xs ! i); - pre \ (\i\{i. i < length xs}. Pre (xs ! i)); (\i\{i. i < length xs}. Post (xs ! i)) \ post; - \i < length xs. \ Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; - x \ par_cp (ParallelCom xs) s; x \ par_assum (pre, rely); All_None (fst (last x)) \ - \ snd (last x) \ post" + "\xs\[]; \i (\j\{j. j < length xs \ j \ i}. Guar (xs ! j)) + \ Rely (xs ! i); + pre \ (\i\{i. i < length xs}. Pre (xs ! i)); + (\i\{i. i < length xs}. Post (xs ! i)) \ post; + \i < length xs. + \ Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; + x \ par_cp (ParallelCom xs) s; x \ par_assum (pre, rely); + All_None (fst (last x)) \ \ snd (last x) \ post" apply(simp add: ParallelCom_def) apply(subgoal_tac "(map (Some \ fst) xs)\[]") prefer 2 @@ -1459,7 +1480,8 @@ done theorem par_rgsound: - "\ c SAT [pre, rely, guar, post] \ \ (ParallelCom c) SAT [pre, rely, guar, post]" + "\ c SAT [pre, rely, guar, post] \ + \ (ParallelCom c) SAT [pre, rely, guar, post]" apply(erule par_rghoare.induct) apply(case_tac xs,simp) apply(simp add:par_com_validity_def par_comm_def) diff -r cd0075346431 -r b115b305612f src/HOL/HoareParallel/RG_Syntax.thy --- a/src/HOL/HoareParallel/RG_Syntax.thy Tue Mar 05 17:14:11 2002 +0100 +++ b/src/HOL/HoareParallel/RG_Syntax.thy Tue Mar 05 18:19:11 2002 +0100 @@ -1,7 +1,5 @@ -header {* \section{Concrete Syntax} *} - -theory RG_Syntax = Quote_Antiquote + RG_Hoare: +theory RG_Syntax = RG_Hoare + Quote_Antiquote: syntax "_Assign" :: "idt \ 'b \ 'a com" ("(\_ :=/ _)" [70, 65] 61) diff -r cd0075346431 -r b115b305612f src/HOL/HoareParallel/RG_Tran.thy --- a/src/HOL/HoareParallel/RG_Tran.thy Tue Mar 05 17:14:11 2002 +0100 +++ b/src/HOL/HoareParallel/RG_Tran.thy Tue Mar 05 18:19:11 2002 +0100 @@ -407,8 +407,8 @@ c!i -pc\ c!Suc i \ (snd(c!i), snd(c!Suc i)) \ guar) \ (All_None (fst (last c)) \ snd( last c) \ post)}" - par_com_validity :: "'a par_com \ 'a set \ ('a \ 'a) set \ ('a \ 'a) set \ 'a set - \ bool" ("\ _ SAT [_, _, _, _]" [60,0,0,0,0] 45) + par_com_validity :: "'a par_com \ 'a set \ ('a \ 'a) set \ ('a \ 'a) set +\ 'a set \ bool" ("\ _ SAT [_, _, _, _]" [60,0,0,0,0] 45) "\ Ps SAT [pre, rely, guar, post] \ \s. par_cp Ps s \ par_assum(pre, rely) \ par_comm(guar, post)" @@ -429,7 +429,7 @@ compat_label :: "'a par_confs \ ('a confs) list \ bool" "compat_label c clist \ (\j. Suc j (c!j -pc\ c!Suc j \ (\i (clist!i)! Suc j \ - (\li \ (clist!l)!j -e\ (clist!l)! Suc j))) \ + (\li \ (clist!l)!j -e\ (clist!l)! Suc j))) \ (c!j -pe\ c!Suc j \ (\i (clist!i)! Suc j)))" conjoin :: "'a par_confs \ ('a confs) list \ bool" ("_ \ _" [65,65] 64) @@ -437,7 +437,8 @@ subsubsection {* Some previous lemmas *} -lemma list_eq_if [rule_format]: "\ys. xs=ys \ (length xs = length ys) \ (\iys. xs=ys \ (length xs = length ys) \ (\i Suc j ys\[] \ P (tl(ys)!j)" +lemma tl_zero[rule_format]: + "P (ys!Suc j) \ Suc j ys\[] \ P (tl(ys)!j)" apply(induct ys) apply simp_all done