diff -r 5f764272183e -r b2af2549efd1 src/HOL/IOA/IOA.thy --- a/src/HOL/IOA/IOA.thy Tue Jun 06 20:47:12 2006 +0200 +++ b/src/HOL/IOA/IOA.thy Wed Jun 07 00:57:14 2006 +0200 @@ -195,6 +195,167 @@ in ? x. Some(x) = ren(a) & (s,x,t):trans_of(ioa)})" -ML {* use_legacy_bindings (the_context ()) *} + +declare Let_def [simp] + +lemmas ioa_projections = asig_of_def starts_of_def trans_of_def + and exec_rws = executions_def is_execution_fragment_def + +lemma ioa_triple_proj: + "asig_of(x,y,z) = x & starts_of(x,y,z) = y & trans_of(x,y,z) = z" + apply (simp add: ioa_projections) + done + +lemma trans_in_actions: + "[| IOA(A); (s1,a,s2):trans_of(A) |] ==> a:actions(asig_of(A))" + apply (unfold ioa_def state_trans_def actions_def is_asig_def) + apply (erule conjE)+ + apply (erule allE, erule impE, assumption) + apply simp + done + + +lemma filter_oseq_idemp: "filter_oseq p (filter_oseq p s) = filter_oseq p s" + apply (simp add: filter_oseq_def) + apply (rule ext) + apply (case_tac "s i") + apply simp_all + done + +lemma mk_trace_thm: +"(mk_trace A s n = None) = + (s(n)=None | (? a. s(n)=Some(a) & a ~: externals(asig_of(A)))) + & + (mk_trace A s n = Some(a)) = + (s(n)=Some(a) & a : externals(asig_of(A)))" + apply (unfold mk_trace_def filter_oseq_def) + apply (case_tac "s n") + apply auto + done + +lemma reachable_0: "s:starts_of(A) ==> reachable A s" + apply (unfold reachable_def) + apply (rule_tac x = "(%i. None, %i. s)" in bexI) + apply simp + apply (simp add: exec_rws) + done + +lemma reachable_n: + "!!A. [| reachable A s; (s,a,t) : trans_of(A) |] ==> reachable A t" + apply (unfold reachable_def exec_rws) + apply (simp del: bex_simps) + apply (simp (no_asm_simp) only: split_tupled_all) + apply safe + apply (rename_tac ex1 ex2 n) + apply (rule_tac x = "(%i. if i P(s)" + and p2: "!!s t a. [|reachable A s; P(s)|] ==> (s,a,t): trans_of(A) --> P(t)" + shows "invariant A P" + apply (unfold invariant_def reachable_def Let_def exec_rws) + apply safe + apply (rename_tac ex1 ex2 n) + apply (rule_tac Q = "reachable A (ex2 n) " in conjunct1) + apply simp + apply (induct_tac n) + apply (fast intro: p1 reachable_0) + apply (erule_tac x = na in allE) + apply (case_tac "ex1 na", simp_all) + apply safe + apply (erule p2 [THEN mp]) + apply (fast dest: reachable_n)+ + done + +lemma invariantI1: + "[| !!s. s : starts_of(A) ==> P(s); + !!s t a. reachable A s ==> P(s) --> (s,a,t):trans_of(A) --> P(t) + |] ==> invariant A P" + apply (blast intro!: invariantI) + done + +lemma invariantE: + "[| invariant A P; reachable A s |] ==> P(s)" + apply (unfold invariant_def) + apply blast + done + +lemma actions_asig_comp: + "actions(asig_comp a b) = actions(a) Un actions(b)" + apply (auto simp add: actions_def asig_comp_def asig_projections) + done + +lemma starts_of_par: + "starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}" + apply (simp add: par_def ioa_projections) + done + +(* Every state in an execution is reachable *) +lemma states_of_exec_reachable: + "ex:executions(A) ==> !n. reachable A (snd ex n)" + apply (unfold reachable_def) + apply fast + done + + +lemma trans_of_par4: +"(s,a,t) : trans_of(A || B || C || D) = + ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) | + a:actions(asig_of(D))) & + (if a:actions(asig_of(A)) then (fst(s),a,fst(t)):trans_of(A) + else fst t=fst s) & + (if a:actions(asig_of(B)) then (fst(snd(s)),a,fst(snd(t))):trans_of(B) + else fst(snd(t))=fst(snd(s))) & + (if a:actions(asig_of(C)) then + (fst(snd(snd(s))),a,fst(snd(snd(t)))):trans_of(C) + else fst(snd(snd(t)))=fst(snd(snd(s)))) & + (if a:actions(asig_of(D)) then + (snd(snd(snd(s))),a,snd(snd(snd(t)))):trans_of(D) + else snd(snd(snd(t)))=snd(snd(snd(s)))))" + (*SLOW*) + apply (simp (no_asm) add: par_def actions_asig_comp Pair_fst_snd_eq ioa_projections) + done + +lemma cancel_restrict: "starts_of(restrict ioa acts) = starts_of(ioa) & + trans_of(restrict ioa acts) = trans_of(ioa) & + reachable (restrict ioa acts) s = reachable ioa s" + apply (simp add: is_execution_fragment_def executions_def + reachable_def restrict_def ioa_projections) + done + +lemma asig_of_par: "asig_of(A || B) = asig_comp (asig_of A) (asig_of B)" + apply (simp add: par_def ioa_projections) + done + + +lemma externals_of_par: "externals(asig_of(A1||A2)) = + (externals(asig_of(A1)) Un externals(asig_of(A2)))" + apply (simp add: externals_def asig_of_par asig_comp_def + asig_inputs_def asig_outputs_def Un_def set_diff_def) + apply blast + done + +lemma ext1_is_not_int2: + "[| compat_ioas A1 A2; a:externals(asig_of(A1))|] ==> a~:internals(asig_of(A2))" + apply (unfold externals_def actions_def compat_ioas_def compat_asigs_def) + apply auto + done + +lemma ext2_is_not_int1: + "[| compat_ioas A2 A1 ; a:externals(asig_of(A1))|] ==> a~:internals(asig_of(A2))" + apply (unfold externals_def actions_def compat_ioas_def compat_asigs_def) + apply auto + done + +lemmas ext1_ext2_is_not_act2 = ext1_is_not_int2 [THEN int_and_ext_is_act] + and ext1_ext2_is_not_act1 = ext2_is_not_int1 [THEN int_and_ext_is_act] end