IOA/meta_theory/IOA.ML
author clasohm
Wed, 02 Nov 1994 11:50:09 +0100
changeset 156 fd1be45b64bf
child 168 44ff2275d44f
permissions -rw-r--r--
added IOA to isabelle/HOL

open IOA Asig;

val exec_rws = [executions_def,is_execution_fragment_def];

goal IOA.thy
"asig_of(<x,y,z>) = x & starts_of(<x,y,z>) = y & trans_of(<x,y,z>) = z";
  by (simp_tac (SS addsimps [ioa_projections_def]) 1);
  val ioa_triple_proj = result();

goalw IOA.thy [ioa_def,state_trans_def,actions_def, is_asig_def]
  "!!A. [| IOA(A); <s1,a,s2>:trans_of(A) |] ==> a:actions(asig_of(A))";
  by (REPEAT(etac conjE 1));
  by (EVERY1[etac allE, etac impE, atac]);
  by (asm_full_simp_tac SS 1);
val trans_in_actions = result();


goal IOA.thy "filter_oseq(p,filter_oseq(p,s)) = filter_oseq(p,s)";
  by (simp_tac (SS addsimps [filter_oseq_def]) 1);
  by (rtac ext 1);
  by (Option.option.induct_tac "s(i)" 1);
  by (simp_tac SS 1);
  by (simp_tac (SS setloop (split_tac [expand_if])) 1);
val filter_oseq_idemp = result();

goalw IOA.thy [mk_behaviour_def,filter_oseq_def]
"(mk_behaviour(A, s, n) = None) =                                     \
\  (s(n)=None | (? a. s(n)=Some(a) & a ~: externals(asig_of(A))))     \
\  &                                                                  \
\  (mk_behaviour(A, s, n) = Some(a)) =                                \
\   (s(n)=Some(a) & a : externals(asig_of(A)))";
  by (Option.option.induct_tac "s(n)" 1);
  by (ALLGOALS (simp_tac (SS setloop (split_tac [expand_if]))));
  by (fast_tac HOL_cs 1);
val mk_behaviour_thm = result();

goalw IOA.thy [reachable_def] "!!A. s:starts_of(A) ==> reachable(A,s)";
  by (res_inst_tac [("x","<(%i.None),(%i.s)>::('action,'a)execution")] bexI 1);
  by (simp_tac SS 1);
  by (asm_simp_tac (SS addsimps exec_rws) 1);
val reachable_0 = result();

goalw IOA.thy (reachable_def::exec_rws)
"!!A. [| reachable(A,s); <s,a,t> : trans_of(A) |] ==> reachable(A,t)";
  by(asm_full_simp_tac SS 1);
  by(safe_tac set_cs);
  by(res_inst_tac [("x","<%i.if(i<n,fst(ex,i),if(i=n,Some(a),None)), \
                        \ %i.if(i<Suc(n),snd(ex,i),t)>")] bexI 1);
  by(res_inst_tac [("x","Suc(n)")] exI 1);
  by(simp_tac SS 1);
  by(asm_simp_tac (SS delsimps [less_Suc_eq]) 1);
  by(REPEAT(rtac allI 1));
  by(res_inst_tac [("m","na"),("n","n")] (make_elim less_linear) 1);
  be disjE 1;
  by(asm_simp_tac SS 1);
  be disjE 1;
  by(asm_simp_tac SS 1);
  by(fast_tac HOL_cs 1);
  by(forward_tac [less_not_sym] 1);
  by(asm_simp_tac (SS addsimps [less_not_refl2]) 1);
val reachable_n = result();

val [p1,p2] = goalw IOA.thy [invariant_def]
  "[| !!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)";
  by (rewrite_goals_tac(reachable_def::Let_def::exec_rws));
  by (safe_tac set_cs);
  by (res_inst_tac [("Q","reachable(A,snd(ex,n))")] conjunct1 1);
  by (nat_ind_tac "n" 1);
  by (fast_tac (set_cs addIs [p1,reachable_0]) 1);
  by (eres_inst_tac[("x","n1")]allE 1);
  by (eres_inst_tac[("P","%x.!a::'action.?Q(x,a)"),
                    ("opt","fst(ex,n1)")] optE 1);
  by (asm_simp_tac HOL_ss 1);
  by (safe_tac HOL_cs);
  by (etac (p2 RS mp) 1);
  by (ALLGOALS(fast_tac(set_cs addDs [hd Option.option.inject RS iffD1,
                                      reachable_n])));
val invariantI = result();

val [p1,p2] = goal IOA.thy
 "[| !!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)";
  by (fast_tac (HOL_cs addSIs [invariantI] addSDs [p1,p2]) 1);
val invariantI1 = result();

val [p1,p2] = goalw IOA.thy [invariant_def]
"[| invariant(A,P); reachable(A,s) |] ==> P(s)";
   br(p2 RS (p1 RS spec RS mp))1;
val invariantE = result();

goal IOA.thy 
"actions(asig_comp(a,b)) = actions(a) Un actions(b)";
  by(simp_tac (pair_ss addsimps
               [actions_def,asig_projections_def,asig_comp_def]) 1);
  by(fast_tac eq_cs 1);
val actions_asig_comp = result();

goal IOA.thy
"starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}";
  by(simp_tac (SS addsimps [par_def,ioa_projections_def]) 1);
val starts_of_par = result();

(* Every state in an execution is reachable *)
goalw IOA.thy [reachable_def] 
"!!A. ex:executions(A) ==> !n. reachable(A, snd(ex,n))";
  by (fast_tac set_cs 1);
val states_of_exec_reachable = result();


goal IOA.thy 
"<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)), <fst(s),a,fst(t)>:trans_of(A), fst(t)=fst(s)) & \
\  if(a:actions(asig_of(B)), <fst(snd(s)),a,fst(snd(t))>:trans_of(B),        \
\     fst(snd(t))=fst(snd(s))) &                                             \
\  if(a:actions(asig_of(C)),                                                 \
\     <fst(snd(snd(s))),a,fst(snd(snd(t)))>:trans_of(C),                     \
\     fst(snd(snd(t)))=fst(snd(snd(s)))) &                                   \
\  if(a:actions(asig_of(D)),                                                 \
\     <snd(snd(snd(s))),a,snd(snd(snd(t)))>:trans_of(D),                     \
\     snd(snd(snd(t)))=snd(snd(snd(s)))))";
  by(simp_tac (SS addsimps [par_def,ioa_projections_def,actions_asig_comp,
                            Pair_fst_snd_eq (* old pair_eq *)]
                  setloop (split_tac [expand_if])) 1);
val trans_of_par4 = result();

goal IOA.thy "starts_of(restrict(ioa,acts)) = starts_of(ioa) &     \
\             trans_of(restrict(ioa,acts)) = trans_of(ioa) &       \
\             reachable(restrict(ioa,acts),s) = reachable(ioa,s)";
  by (simp_tac (SS addsimps [ioa_projections_def,is_execution_fragment_def,
                             executions_def,reachable_def,restrict_def]) 1);
val cancel_restrict = result();

goal IOA.thy "asig_of(A || B) = asig_comp(asig_of(A),asig_of(B))";
  by(simp_tac (SS addsimps [ioa_projections_def,par_def]) 1);
val asig_of_par = result();