src/HOL/IOA/meta_theory/IOA.ML
author clasohm
Mon, 20 Mar 1995 15:37:03 +0100
changeset 966 3fd66f245ad7
child 972 e61b058d58d2
permissions -rw-r--r--
converted IOA with curried function application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
966
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/IOA/meta_theory/IOA.ML
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     3
    Author:     Tobias Nipkow & Konrad Slind
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1994  TU Muenchen
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     5
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     6
The I/O automata of Lynch and Tuttle.
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     7
*)
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     8
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
     9
open IOA Asig;
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    10
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    11
val ioa_projections = [asig_of_def, starts_of_def, trans_of_def];
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    12
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    13
val exec_rws = [executions_def,is_execution_fragment_def];
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    14
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    15
goal IOA.thy
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    16
"asig_of(<x,y,z>) = x & starts_of(<x,y,z>) = y & trans_of(<x,y,z>) = z";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    17
  by (simp_tac (SS addsimps ioa_projections) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    18
  qed "ioa_triple_proj";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    19
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    20
goalw IOA.thy [ioa_def,state_trans_def,actions_def, is_asig_def]
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    21
  "!!A. [| IOA(A); <s1,a,s2>:trans_of(A) |] ==> a:actions(asig_of(A))";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    22
  by (REPEAT(etac conjE 1));
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    23
  by (EVERY1[etac allE, etac impE, atac]);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    24
  by (asm_full_simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    25
qed "trans_in_actions";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    26
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    27
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    28
goal IOA.thy "filter_oseq p (filter_oseq p s) = filter_oseq p s";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    29
  by (simp_tac (SS addsimps [filter_oseq_def]) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    30
  by (rtac ext 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    31
  by (Option.option.induct_tac "s(i)" 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    32
  by (simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    33
  by (simp_tac (SS setloop (split_tac [expand_if])) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    34
qed "filter_oseq_idemp";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    35
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    36
goalw IOA.thy [mk_behaviour_def,filter_oseq_def]
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    37
"(mk_behaviour A s n = None) =                                        \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    38
\  (s(n)=None | (? a. s(n)=Some(a) & a ~: externals(asig_of(A))))     \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    39
\  &                                                                  \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    40
\  (mk_behaviour A s n = Some(a)) =                                   \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    41
\   (s(n)=Some(a) & a : externals(asig_of(A)))";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    42
  by (Option.option.induct_tac "s(n)" 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    43
  by (ALLGOALS (simp_tac (SS setloop (split_tac [expand_if]))));
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    44
  by (fast_tac HOL_cs 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    45
qed "mk_behaviour_thm";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    46
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    47
goalw IOA.thy [reachable_def] "!!A. s:starts_of(A) ==> reachable A s";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    48
  by (res_inst_tac [("x","<%i.None,%i.s>")] bexI 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    49
  by (simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    50
  by (asm_simp_tac (SS addsimps exec_rws) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    51
qed "reachable_0";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    52
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    53
goalw IOA.thy (reachable_def::exec_rws)
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    54
"!!A. [| reachable A s; <s,a,t> : trans_of(A) |] ==> reachable A t";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    55
  by(asm_full_simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    56
  by(safe_tac set_cs);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    57
  by(res_inst_tac [("x","<%i.if i<n then fst ex i                    \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    58
\                            else (if i=n then Some a else None),    \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    59
\                         %i.if i<Suc n then snd ex i else t>")] bexI 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    60
  by(res_inst_tac [("x","Suc(n)")] exI 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    61
  by(simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    62
  by(asm_simp_tac (SS delsimps [less_Suc_eq]) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    63
  by(REPEAT(rtac allI 1));
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    64
  by(res_inst_tac [("m","na"),("n","n")] (make_elim less_linear) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    65
  be disjE 1;
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    66
  by(asm_simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    67
  be disjE 1;
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    68
  by(asm_simp_tac SS 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    69
  by(fast_tac HOL_cs 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    70
  by(forward_tac [less_not_sym] 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    71
  by(asm_simp_tac (SS addsimps [less_not_refl2]) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    72
qed "reachable_n";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    73
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    74
val [p1,p2] = goalw IOA.thy [invariant_def]
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    75
  "[| !!s. s:starts_of(A) ==> P(s);                                          \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    76
\     !!s t a. [|reachable A s; P(s)|] ==> <s,a,t>: trans_of(A) --> P(t) |] \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    77
\  ==> invariant A P";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    78
  by (rewrite_goals_tac(reachable_def::Let_def::exec_rws));
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    79
  by (safe_tac set_cs);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    80
  by (res_inst_tac [("Q","reachable A (snd ex n)")] conjunct1 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    81
  by (nat_ind_tac "n" 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    82
  by (fast_tac (set_cs addIs [p1,reachable_0]) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    83
  by (eres_inst_tac[("x","n1")]allE 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    84
  by (eres_inst_tac[("P","%x.!a.?Q x a"), ("opt","fst ex n1")] optE 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    85
  by (asm_simp_tac HOL_ss 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    86
  by (safe_tac HOL_cs);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    87
  by (etac (p2 RS mp) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    88
  by (ALLGOALS(fast_tac(set_cs addDs [hd Option.option.inject RS iffD1,
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    89
                                      reachable_n])));
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    90
qed "invariantI";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    91
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    92
val [p1,p2] = goal IOA.thy
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    93
 "[| !!s. s : starts_of(A) ==> P(s); \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    94
\   !!s t a. reachable A s ==> P(s) --> <s,a,t>:trans_of(A) --> P(t) \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    95
\ |] ==> invariant A P";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    96
  by (fast_tac (HOL_cs addSIs [invariantI] addSDs [p1,p2]) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    97
qed "invariantI1";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    98
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
    99
val [p1,p2] = goalw IOA.thy [invariant_def]
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   100
"[| invariant A P; reachable A s |] ==> P(s)";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   101
   br(p2 RS (p1 RS spec RS mp))1;
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   102
qed "invariantE";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   103
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   104
goal IOA.thy 
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   105
"actions(asig_comp a b) = actions(a) Un actions(b)";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   106
  by(simp_tac (prod_ss addsimps
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   107
               ([actions_def,asig_comp_def]@asig_projections)) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   108
  by(fast_tac eq_cs 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   109
qed "actions_asig_comp";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   110
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   111
goal IOA.thy
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   112
"starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   113
  by(simp_tac (SS addsimps (par_def::ioa_projections)) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   114
qed "starts_of_par";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   115
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   116
(* Every state in an execution is reachable *)
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   117
goalw IOA.thy [reachable_def] 
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   118
"!!A. ex:executions(A) ==> !n. reachable A (snd ex n)";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   119
  by (fast_tac set_cs 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   120
qed "states_of_exec_reachable";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   121
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   122
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   123
goal IOA.thy 
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   124
"<s,a,t> : trans_of(A || B || C || D) =                                      \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   125
\ ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) |  \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   126
\   a:actions(asig_of(D))) &                                                 \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   127
\  (if a:actions(asig_of(A)) then <fst(s),a,fst(t)>:trans_of(A)              \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   128
\   else fst t=fst s) &                                                      \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   129
\  (if a:actions(asig_of(B)) then <fst(snd(s)),a,fst(snd(t))>:trans_of(B)    \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   130
\   else fst(snd(t))=fst(snd(s))) &                                          \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   131
\  (if a:actions(asig_of(C)) then                                            \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   132
\     <fst(snd(snd(s))),a,fst(snd(snd(t)))>:trans_of(C)                      \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   133
\   else fst(snd(snd(t)))=fst(snd(snd(s)))) &                                \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   134
\  (if a:actions(asig_of(D)) then                                            \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   135
\     <snd(snd(snd(s))),a,snd(snd(snd(t)))>:trans_of(D)                      \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   136
\   else snd(snd(snd(t)))=snd(snd(snd(s)))))";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   137
  by(simp_tac (SS addsimps ([par_def,actions_asig_comp,Pair_fst_snd_eq]@
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   138
                            ioa_projections)
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   139
                  setloop (split_tac [expand_if])) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   140
qed "trans_of_par4";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   141
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   142
goal IOA.thy "starts_of(restrict ioa acts) = starts_of(ioa) &     \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   143
\             trans_of(restrict ioa acts) = trans_of(ioa) &       \
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   144
\             reachable (restrict ioa acts) s = reachable ioa s";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   145
by(simp_tac (SS addsimps ([is_execution_fragment_def,executions_def,
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   146
                           reachable_def,restrict_def]@ioa_projections)) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   147
qed "cancel_restrict";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   148
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   149
goal IOA.thy "asig_of(A || B) = asig_comp (asig_of A) (asig_of B)";
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   150
  by(simp_tac (SS addsimps (par_def::ioa_projections)) 1);
3fd66f245ad7 converted IOA with curried function application
clasohm
parents:
diff changeset
   151
qed "asig_of_par";