src/HOL/IOA/ABP/Correctness.ML
changeset 1138 82fd99d5a6ff
parent 1050 0c36c6a52a1d
child 1252 27130da22f52
equal deleted inserted replaced
1137:1a768988f8e3 1138:82fd99d5a6ff
     1  (*  Title:      HOL/IOA/ABP/Correctness.ML
     1  (*  Title:      HOL/IOA/example/Correctness.ML
     2     ID:         $Id$
     2     ID:         $Id$
     3     Author:     Tobias Nipkow & Olaf Mueller
     3     Author:     Tobias Nipkow & Konrad Slind
     4     Copyright   1995  TU Muenchen
     4     Copyright   1994  TU Muenchen
     5 
     5 
     6 *)
     6 *)
     7 
     7 
     8 open Correctness; open Abschannel; open Abschannel_finite;
     8 open Correctness; open Abschannel; open Abschannel_finite;
       
     9 open Impl; open Impl_finite;
     9 
    10 
    10 goal Abschannel.thy "(? x.x=P & Q(x)) = Q(P)";
    11 goal Abschannel.thy "(? x.x=P & Q(x)) = Q(P)";
    11 by (fast_tac HOL_cs 1);
    12 by (fast_tac HOL_cs 1);
    12 qed"exis_elim";
    13 qed"exis_elim";
    13 
    14 
    35                asig_projections @ set_lemmas;
    36                asig_projections @ set_lemmas;
    36 val hom_ss = (impl_ss addsimps hom_ioas);
    37 val hom_ss = (impl_ss addsimps hom_ioas);
    37 
    38 
    38 val red_ss = impl_ss addsimps [reduce_Nil,reduce_Cons];
    39 val red_ss = impl_ss addsimps [reduce_Nil,reduce_Cons];
    39 val red_ss_ch = merge_ss(abschannel_fin_ss,red_ss);
    40 val red_ss_ch = merge_ss(abschannel_fin_ss,red_ss);
       
    41 
       
    42 
    40 
    43 
    41 
    44 
    42 (* auxiliary function *)
    45 (* auxiliary function *)
    43 fun rotate n i = EVERY(replicate n (etac revcut_rl i));
    46 fun rotate n i = EVERY(replicate n (etac revcut_rl i));
    44 
    47 
   166 by (rtac conjI 1);
   169 by (rtac conjI 1);
   167 by (simp_tac (red_ss addsimps [and_de_morgan_and_absorbe]) 2);
   170 by (simp_tac (red_ss addsimps [and_de_morgan_and_absorbe]) 2);
   168 by (ALLGOALS (EVERY'[rtac impI,etac conjE,cut_inst_tac [("l","xs")] cons_not_nil,asm_full_simp_tac red_ss]));
   171 by (ALLGOALS (EVERY'[rtac impI,etac conjE,cut_inst_tac [("l","xs")] cons_not_nil,asm_full_simp_tac red_ss]));
   169 by (REPEAT (etac exE 1));
   172 by (REPEAT (etac exE 1));
   170 by (REPEAT (etac exE 2));
   173 by (REPEAT (etac exE 2));
   171 by (hyp_subst_tac 2);
   174 by (REPEAT(hyp_subst_tac 2));
   172 by (ALLGOALS (asm_full_simp_tac red_ss));
   175 by (ALLGOALS (asm_full_simp_tac red_ss));
   173 val reduce_tl =result();
   176 val reduce_tl =result();
   174 
   177 
   175 
   178 
       
   179 (*******************************************************************
       
   180           C h a n n e l   A b s t r a c t i o n
       
   181  *******************************************************************)
   176 
   182 
   177 goal Correctness.thy 
   183 goal Correctness.thy 
   178       "is_weak_pmap reduce ch_ioa ch_fin_ioa";
   184       "is_weak_pmap reduce ch_ioa ch_fin_ioa";
   179 by (simp_tac (red_ss addsimps [Solve.is_weak_pmap_def]) 1);
   185 by (simp_tac (red_ss addsimps [Solve.is_weak_pmap_def]) 1);
   180 by (rtac conjI 1);
   186 by (rtac conjI 1);
   181 (* start states *)
   187 (* --------------  start states ----------------- *)
   182 by (simp_tac red_ss_ch 1);
   188 by (simp_tac red_ss_ch 1);
   183 br ballI 1;
   189 br ballI 1;
   184 by (asm_full_simp_tac red_ss_ch 1);
   190 by (asm_full_simp_tac red_ss_ch 1);
   185 (* main-part *)
   191 (* ---------------- main-part ------------------- *)
   186 by (REPEAT (rtac allI 1));
   192 by (REPEAT (rtac allI 1));
   187 by (rtac imp_conj_lemma 1);
   193 by (rtac imp_conj_lemma 1);
   188 by (act.induct_tac "a" 1);
   194 by (act.induct_tac "a" 1);
   189 (* 2 cases *)
   195 (* ----------------- 2 cases ---------------------*)
   190 by (ALLGOALS (simp_tac (red_ss_ch addsimps [externals_def])));
   196 by (ALLGOALS (simp_tac (red_ss_ch addsimps [externals_def])));
   191 (* fst case *)
   197 (* fst case --------------------------------------*)
   192  by (rtac impI 1);
   198  by (rtac impI 1);
   193  by (rtac disjI2 1);
   199  by (rtac disjI2 1);
   194 by (rtac reduce_hd 1);
   200 by (rtac reduce_hd 1);
   195 (* snd case *)
   201 (* snd case --------------------------------------*)
   196  by (rtac impI 1);
   202  by (rtac impI 1);
   197  by (REPEAT (etac conjE 1));
   203  by (REPEAT (etac conjE 1));
   198  by (etac disjE 1);
   204  by (etac disjE 1);
   199 by (asm_full_simp_tac (red_ss addsimps [l_iff_red_nil]) 1);
   205 by (asm_full_simp_tac (red_ss addsimps [l_iff_red_nil]) 1);
   200 by (etac (hd_is_reduce_hd RS mp) 1); 
   206 by (etac (hd_is_reduce_hd RS mp) 1); 
   238 (* 2 copies of before *)
   244 (* 2 copies of before *)
   239 goal Correctness.thy 
   245 goal Correctness.thy 
   240       "is_weak_pmap (%id.id) receiver_ioa receiver_ioa";
   246       "is_weak_pmap (%id.id) receiver_ioa receiver_ioa";
   241 by (simp_tac (red_ss addsimps [Solve.is_weak_pmap_def]) 1);
   247 by (simp_tac (red_ss addsimps [Solve.is_weak_pmap_def]) 1);
   242 by (rtac conjI 1);
   248 by (rtac conjI 1);
   243 (* start states *)
   249  (* start states *)
   244 br ballI 1;
   250 br ballI 1;
   245 by (simp_tac red_ss_ch 1);
   251 by (simp_tac red_ss_ch 1);
   246 (* main-part *)
   252 (* main-part *)
   247 by (REPEAT (rtac allI 1));
   253 by (REPEAT (rtac allI 1));
   248 by (rtac imp_conj_lemma 1);
   254 by (rtac imp_conj_lemma 1);
   353  "externals(asig_of(srch_fin_ioa)) = externals(asig_of(srch_ioa)) &  \
   359  "externals(asig_of(srch_fin_ioa)) = externals(asig_of(srch_ioa)) &  \
   354 \ externals(asig_of(rsch_fin_ioa)) = externals(asig_of(rsch_ioa))";
   360 \ externals(asig_of(rsch_fin_ioa)) = externals(asig_of(rsch_ioa))";
   355 by (simp_tac (red_ss_ch addsimps [externals_def]) 1);
   361 by (simp_tac (red_ss_ch addsimps [externals_def]) 1);
   356 val ext_single_ch = result();
   362 val ext_single_ch = result();
   357 
   363 
   358 goal Correctness.thy "is_weak_pmap                                       \
   364 
   359 \   (%p.(fst(p),(fst(snd(p)),(fst(snd(snd(p))),                          \
   365 
   360 \      (reduce(fst(snd(snd(snd(p))))),reduce(snd(snd(snd(snd(p)))))))))) \
   366 
   361 \    (env_ioa || impl_ioa) (env_ioa || impl_fin_ioa)";
   367 
   362 by (simp_tac (impl_ss addsimps [Impl.impl_def,Impl_finite.impl_fin_def]) 1);
   368 val ext_ss = [externals_of_par,ext_single_ch];
   363 by(REPEAT(EVERY[rtac fxg_is_weak_pmap_of_product_IOA 1, 
   369 val compat_ss = [compat_single_ch,compat_single_fin_ch,compat_rec,
   364                 simp_tac (red_ss addsimps [env_unchanged,sender_unchanged,
   370          compat_rec_fin,compat_sen,compat_sen_fin,compat_env,compat_env_fin];
   365           receiver_unchanged,sender_abstraction,receiver_abstraction]) 1,
   371 val abstractions = [env_unchanged,sender_unchanged,
   366                 rtac conjI 1]));
   372           receiver_unchanged,sender_abstraction,receiver_abstraction];
   367 by (ALLGOALS(simp_tac (list_ss addsimps [externals_of_par,ext_single_ch,
   373 val impl_ss = impl_ss addsimps [impl_def,impl_fin_def,sys_IOA, sys_fin_IOA];
   368              compat_single_ch,compat_single_fin_ch,compat_rec,compat_rec_fin,
   374 val sys_ss = impl_ss addsimps [system_def, system_fin_def, abs_def];
   369              compat_sen,compat_sen_fin,compat_env,compat_env_fin]))); 
   375 
       
   376 
       
   377 
       
   378 (************************************************************************
       
   379             S o u n d n e s s   o f   A b s t r a c t i o n        
       
   380 *************************************************************************)
       
   381 
       
   382 
       
   383 goal Correctness.thy 
       
   384      "is_weak_pmap  abs  system_ioa  system_fin_ioa";
       
   385 
       
   386 by (simp_tac sys_ss 1);
       
   387 
       
   388 by (REPEAT (EVERY[rtac fxg_is_weak_pmap_of_product_IOA 1, 
       
   389                   simp_tac (red_ss addsimps abstractions) 1,
       
   390                   rtac conjI 1]));
       
   391 
       
   392 by (ALLGOALS (simp_tac (red_ss addsimps ext_ss @ compat_ss))); 
       
   393 
   370 qed "system_refinement";
   394 qed "system_refinement";
   371 
   395 
       
   396 
       
   397 
       
   398 (************************************************************************
       
   399               I n t e r a c t i v e   A b s t r a c t i o n 
       
   400 *************************************************************************)
       
   401 
       
   402 goal Correctness.thy
       
   403    "ioa_implements system_ioa system_fin_ioa"; 
       
   404 
       
   405 (* ------------------- Rewriting ----------------------------*)
       
   406 by (simp_tac (impl_ss addsimps [ioa_implements_def]) 1);
       
   407 by (rtac conjI 1);
       
   408 by (simp_tac (sys_ss addsimps ext_ss) 1);
       
   409 
       
   410 (* ------------------- Lemmata ------------------------------*)
       
   411 by (rtac trace_inclusion 1); 
       
   412 by (rtac system_refinement 4);
       
   413 
       
   414 (* -------------------- Rewriting ---------------------------*)
       
   415 by (ALLGOALS (simp_tac impl_ss));
       
   416 by (simp_tac (sys_ss addsimps ext_ss) 1);
       
   417 
       
   418 qed"interactive_abstraction";
       
   419 
       
   420 
       
   421 
       
   422 
       
   423 
       
   424 (***********************************************************************
       
   425                    Illustrative ISABELLE Examples
       
   426 ************************************************************************)
       
   427  
       
   428 (*** Cantor's Theorem: There is no surjection from a set to its powerset. ***)
       
   429 
       
   430 goal Set.thy 
       
   431           "~ (? f:: 'a=>'a set. ! S. ? x. f(x) = S)";
       
   432 
       
   433 by (best_tac (set_cs addSEs [equalityCE]) 1);
       
   434 qed "cantor1";
       
   435 
       
   436 (***** Theorem 2   *)
       
   437 val prems = goalw Lfp.thy [image_def] "inj(f) ==> Inv(f)``(f``X) = X";
       
   438 by (cut_facts_tac prems 1);
       
   439 by (rtac equalityI 1);
       
   440 by (fast_tac (set_cs addEs [Inv_f_f RS ssubst]) 1);
       
   441 by (fast_tac (set_cs addEs [Inv_f_f RS ssubst]) 1);
       
   442 qed "inv_image_comp";