src/HOLCF/IOA/meta_theory/Traces.ML
author nipkow
Tue Jan 09 15:36:30 2001 +0100 (2001-01-09)
changeset 10835 f4745d77e620
parent 7229 6773ba0c36d5
child 12218 6597093b77e7
permissions -rw-r--r--
` -> $
     1 (*  Title:      HOLCF/IOA/meta_theory/Traces.ML
     2     ID:         $Id$
     3     Author:     Olaf M"uller
     4     Copyright   1996  TU Muenchen
     5 
     6 Theorems about Executions and Traces of I/O automata in HOLCF.
     7 *)   
     8 
     9 (* global changes to simpset() and claset(), see also TLS.ML *)
    10 Delsimps (ex_simps @ all_simps);
    11 Delsimps [split_paired_Ex];
    12 Addsimps [Let_def];
    13 claset_ref() := claset() delSWrapper "split_all_tac";
    14 
    15 val exec_rws = [executions_def,is_exec_frag_def];
    16 
    17 
    18 
    19 (* ----------------------------------------------------------------------------------- *)
    20 
    21 section "recursive equations of operators";
    22 
    23 
    24 (* ---------------------------------------------------------------- *)
    25 (*                               filter_act                         *)
    26 (* ---------------------------------------------------------------- *)
    27 
    28 
    29 Goal  "filter_act$UU = UU";
    30 by (simp_tac (simpset() addsimps [filter_act_def]) 1);
    31 qed"filter_act_UU";
    32 
    33 Goal  "filter_act$nil = nil";
    34 by (simp_tac (simpset() addsimps [filter_act_def]) 1);
    35 qed"filter_act_nil";
    36 
    37 Goal "filter_act$(x>>xs) = (fst x) >> filter_act$xs";
    38 by (simp_tac (simpset() addsimps [filter_act_def]) 1);
    39 qed"filter_act_cons";
    40 
    41 Addsimps [filter_act_UU,filter_act_nil,filter_act_cons];
    42 
    43 
    44 (* ---------------------------------------------------------------- *)
    45 (*                             mk_trace                             *)
    46 (* ---------------------------------------------------------------- *)
    47 
    48 Goal "mk_trace A$UU=UU";
    49 by (simp_tac (simpset() addsimps [mk_trace_def]) 1);
    50 qed"mk_trace_UU";
    51 
    52 Goal "mk_trace A$nil=nil";
    53 by (simp_tac (simpset() addsimps [mk_trace_def]) 1);
    54 qed"mk_trace_nil";
    55 
    56 Goal "mk_trace A$(at >> xs) =    \
    57 \            (if ((fst at):ext A)    \       
    58 \                 then (fst at) >> (mk_trace A$xs) \   
    59 \                 else mk_trace A$xs)";
    60 
    61 by (asm_full_simp_tac (simpset() addsimps [mk_trace_def]) 1);
    62 qed"mk_trace_cons";
    63 
    64 Addsimps [mk_trace_UU,mk_trace_nil,mk_trace_cons];
    65 
    66 (* ---------------------------------------------------------------- *)
    67 (*                             is_exec_fragC                             *)
    68 (* ---------------------------------------------------------------- *)
    69 
    70 
    71 Goal "is_exec_fragC A = (LAM ex. (%s. case ex of \
    72 \      nil => TT \
    73 \    | x##xs => (flift1 \ 
    74 \            (%p. Def ((s,p):trans_of A) andalso (is_exec_fragC A$xs) (snd p)) \
    75 \             $x) \
    76 \   ))";
    77 by (rtac trans 1);
    78 by (rtac fix_eq2 1);
    79 by (rtac is_exec_fragC_def 1);
    80 by (rtac beta_cfun 1);
    81 by (simp_tac (simpset() addsimps [flift1_def]) 1);
    82 qed"is_exec_fragC_unfold";
    83 
    84 Goal "(is_exec_fragC A$UU) s=UU";
    85 by (stac is_exec_fragC_unfold 1);
    86 by (Simp_tac 1);
    87 qed"is_exec_fragC_UU";
    88 
    89 Goal "(is_exec_fragC A$nil) s = TT";
    90 by (stac is_exec_fragC_unfold 1);
    91 by (Simp_tac 1);
    92 qed"is_exec_fragC_nil";
    93 
    94 Goal "(is_exec_fragC A$(pr>>xs)) s = \
    95 \                        (Def ((s,pr):trans_of A) \
    96 \                andalso (is_exec_fragC A$xs)(snd pr))";
    97 by (rtac trans 1);
    98 by (stac is_exec_fragC_unfold 1);
    99 by (asm_full_simp_tac (simpset() addsimps [Consq_def,flift1_def]) 1);
   100 by (Simp_tac 1);
   101 qed"is_exec_fragC_cons";
   102 
   103 
   104 Addsimps [is_exec_fragC_UU,is_exec_fragC_nil,is_exec_fragC_cons];
   105 
   106 
   107 (* ---------------------------------------------------------------- *)
   108 (*                        is_exec_frag                              *)
   109 (* ---------------------------------------------------------------- *)
   110 
   111 Goal "is_exec_frag A (s, UU)";
   112 by (simp_tac (simpset() addsimps [is_exec_frag_def]) 1);
   113 qed"is_exec_frag_UU";
   114 
   115 Goal "is_exec_frag A (s, nil)";
   116 by (simp_tac (simpset() addsimps [is_exec_frag_def]) 1);
   117 qed"is_exec_frag_nil";
   118 
   119 Goal "is_exec_frag A (s, (a,t)>>ex) = \
   120 \                               (((s,a,t):trans_of A) & \
   121 \                               is_exec_frag A (t, ex))";
   122 by (simp_tac (simpset() addsimps [is_exec_frag_def]) 1);
   123 qed"is_exec_frag_cons";
   124 
   125 
   126 (* Delsimps [is_exec_fragC_UU,is_exec_fragC_nil,is_exec_fragC_cons]; *)
   127 Addsimps [is_exec_frag_UU,is_exec_frag_nil, is_exec_frag_cons];  
   128 
   129 (* ---------------------------------------------------------------------------- *)
   130                            section "laststate";
   131 (* ---------------------------------------------------------------------------- *)
   132 
   133 Goal "laststate (s,UU) = s";
   134 by (simp_tac (simpset() addsimps [laststate_def]) 1); 
   135 qed"laststate_UU";
   136 
   137 Goal "laststate (s,nil) = s";
   138 by (simp_tac (simpset() addsimps [laststate_def]) 1);
   139 qed"laststate_nil";
   140 
   141 Goal "!! ex. Finite ex ==> laststate (s,at>>ex) = laststate (snd at,ex)";
   142 by (simp_tac (simpset() addsimps [laststate_def]) 1);
   143 by (case_tac "ex=nil" 1);
   144 by (Asm_simp_tac 1);
   145 by (Asm_simp_tac 1);
   146 by (dtac (Finite_Last1 RS mp) 1);
   147 by (assume_tac 1);
   148 by (def_tac 1);
   149 qed"laststate_cons";
   150 
   151 Addsimps [laststate_UU,laststate_nil,laststate_cons];
   152 
   153 Goal "!!ex. Finite ex ==> (! s. ? u. laststate (s,ex)=u)";
   154 by (Seq_Finite_induct_tac 1);
   155 qed"exists_laststate";
   156 
   157 
   158 (* -------------------------------------------------------------------------------- *)
   159 
   160 section "has_trace, mk_trace";
   161 
   162 (* alternative definition of has_trace tailored for the refinement proof, as it does not 
   163    take the detour of schedules *)
   164 
   165 Goalw  [executions_def,mk_trace_def,has_trace_def,schedules_def,has_schedule_def] 
   166 "has_trace A b = (? ex:executions A. b = mk_trace A$(snd ex))";
   167 
   168 by (safe_tac set_cs);
   169 (* 1 *)
   170 by (res_inst_tac[("x","ex")] bexI 1);
   171 by (stac beta_cfun 1);
   172 by (cont_tacR 1);
   173 by (Simp_tac 1);
   174 by (Asm_simp_tac 1);
   175 (* 2 *)
   176 by (res_inst_tac[("x","filter_act$(snd ex)")] bexI 1);
   177 by (stac beta_cfun 1);
   178 by (cont_tacR 1);
   179 by (Simp_tac 1);
   180 by (safe_tac set_cs);
   181 by (res_inst_tac[("x","ex")] bexI 1);
   182 by (REPEAT (Asm_simp_tac 1));
   183 qed"has_trace_def2";
   184 
   185 
   186 (* -------------------------------------------------------------------------------- *)
   187 
   188 section "signatures and executions, schedules";
   189 
   190 
   191 (* All executions of A have only actions of A. This is only true because of the 
   192    predicate state_trans (part of the predicate IOA): We have no dependent types.
   193    For executions of parallel automata this assumption is not needed, as in par_def
   194    this condition is included once more. (see Lemmas 1.1.1c in CompoExecs for example) *)
   195 
   196 Goal 
   197   "!! A. is_trans_of A ==> \
   198 \ ! s. is_exec_frag A (s,xs) --> Forall (%a. a:act A) (filter_act$xs)";
   199 
   200 by (pair_induct_tac "xs" [is_exec_frag_def,Forall_def,sforall_def] 1);
   201 (* main case *)
   202 ren "ss a t" 1;
   203 by (safe_tac set_cs);
   204 by (REPEAT (asm_full_simp_tac (simpset() addsimps [is_trans_of_def]) 1));
   205 qed"execfrag_in_sig";
   206 
   207 Goal 
   208   "!! A.[|  is_trans_of A; x:executions A |] ==> \
   209 \ Forall (%a. a:act A) (filter_act$(snd x))";
   210 
   211 by (asm_full_simp_tac (simpset() addsimps [executions_def]) 1);
   212 by (pair_tac "x" 1);
   213 by (rtac (execfrag_in_sig RS spec RS mp) 1);
   214 by Auto_tac;
   215 qed"exec_in_sig";
   216 
   217 Goalw [schedules_def,has_schedule_def]
   218   "!! A.[|  is_trans_of A; x:schedules A |] ==> \
   219 \   Forall (%a. a:act A) x";
   220 
   221 by (fast_tac (claset() addSIs [exec_in_sig]) 1);
   222 qed"scheds_in_sig";
   223 
   224 (*
   225 
   226 is ok but needs ForallQFilterP which has to been proven first (is trivial also)
   227 
   228 Goalw [traces_def,has_trace_def]
   229   "!! A.[| x:traces A |] ==> \
   230 \   Forall (%a. a:act A) x";
   231  by (safe_tac set_cs );
   232 by (rtac ForallQFilterP 1);
   233 by (fast_tac (!claset addSIs [ext_is_act]) 1);
   234 qed"traces_in_sig";
   235 *)
   236 
   237 
   238 (* -------------------------------------------------------------------------------- *)
   239 
   240 section "executions are prefix closed";
   241 
   242 (* only admissible in y, not if done in x !! *)
   243 Goal "!x s. is_exec_frag A (s,x) & y<<x  --> is_exec_frag A (s,y)";
   244 by (pair_induct_tac "y" [is_exec_frag_def] 1);
   245 by (strip_tac 1);
   246 by (Seq_case_simp_tac "xa" 1);
   247 by (pair_tac "a" 1);
   248 by Auto_tac;
   249 qed"execfrag_prefixclosed";
   250 
   251 bind_thm ("exec_prefixclosed",conjI RS (execfrag_prefixclosed RS spec RS spec RS mp));
   252 
   253 
   254 (* second prefix notion for Finite x *)
   255 
   256 Goal "! y s. is_exec_frag A (s,x@@y) --> is_exec_frag A (s,x)";
   257 by (pair_induct_tac "x" [is_exec_frag_def] 1);
   258 by (strip_tac 1);
   259 by (Seq_case_simp_tac "s" 1);
   260 by (pair_tac "a" 1);
   261 by Auto_tac;
   262 qed_spec_mp"exec_prefix2closed";
   263