src/HOL/IMP/Equiv.ML
changeset 924 806721cfbf46
child 972 e61b058d58d2
equal deleted inserted replaced
923:ff1574a81019 924:806721cfbf46
       
     1 (*  Title: 	HOL/IMP/Equiv.ML
       
     2     ID:         $Id$
       
     3     Author: 	Heiko Loetzbeyer & Robert Sandner, TUM
       
     4     Copyright   1994 TUM
       
     5 *)
       
     6 
       
     7 goal Equiv.thy "!n. (<a,s> -a-> n) = (n = A a s)";
       
     8 by (aexp.induct_tac "a" 1);                		  (* struct. ind. *)
       
     9 by (ALLGOALS(simp_tac (HOL_ss addsimps A_simps)));	  (* rewr. Den.   *)
       
    10 by (TRYALL (fast_tac (set_cs addSIs (evala.intrs@prems)
       
    11                              addSEs evala_elim_cases)));
       
    12 bind_thm("aexp_iff", result() RS spec);
       
    13 
       
    14 goal Equiv.thy "!w. (<b,s> -b-> w) = (w = B b s)";
       
    15 by (bexp.induct_tac "b" 1);
       
    16 by (ALLGOALS(asm_simp_tac (HOL_ss addcongs [conj_cong]
       
    17               addsimps (aexp_iff::B_simps@evalb_simps))));
       
    18 bind_thm("bexp_iff", result() RS spec);
       
    19 
       
    20 val bexp1 = bexp_iff RS iffD1;
       
    21 val bexp2 = bexp_iff RS iffD2;
       
    22 
       
    23 val BfstI = read_instantiate_sg (sign_of Equiv.thy)
       
    24               [("P","%x.B ?b x")] (fst_conv RS ssubst);
       
    25 val BfstD = read_instantiate_sg (sign_of Equiv.thy)
       
    26               [("P","%x.B ?b x")] (fst_conv RS subst);
       
    27 
       
    28 goal Equiv.thy "!!c. <c,s> -c-> t ==> <s,t> : C(c)";
       
    29 
       
    30 (* start with rule induction *)
       
    31 be (evalc.mutual_induct RS spec RS spec RS spec RSN (2,rev_mp)) 1;
       
    32 by (rewrite_tac (Gamma_def::C_simps));
       
    33   (* simplification with HOL_ss again too agressive *)
       
    34 (* skip *)
       
    35 by (fast_tac comp_cs 1);
       
    36 (* assign *)
       
    37 by (asm_full_simp_tac (prod_ss addsimps [aexp_iff]) 1);
       
    38 (* comp *)
       
    39 by (fast_tac comp_cs 1);
       
    40 (* if *)
       
    41 by(fast_tac (set_cs addSIs [BfstI] addSDs [BfstD,bexp1]) 1);
       
    42 by(fast_tac (set_cs addSIs [BfstI] addSDs [BfstD,bexp1]) 1);
       
    43 (* while *)
       
    44 by (rtac (rewrite_rule [Gamma_def] (Gamma_mono RS lfp_Tarski RS ssubst)) 1);
       
    45 by (fast_tac (comp_cs addSIs [bexp1,BfstI] addSDs [BfstD,bexp1]) 1);
       
    46 by (rtac (rewrite_rule [Gamma_def] (Gamma_mono RS lfp_Tarski RS ssubst)) 1);
       
    47 by (fast_tac (comp_cs addSIs [bexp1,BfstI] addSDs [BfstD,bexp1]) 1);
       
    48 
       
    49 qed "com1";
       
    50 
       
    51 
       
    52 val com_ss = prod_ss addsimps (aexp_iff::bexp_iff::evalc.intrs);
       
    53 
       
    54 goal Equiv.thy "!io:C(c). <c,fst(io)> -c-> snd(io)";
       
    55 by (com.induct_tac "c" 1);
       
    56 by (rewrite_tac C_simps);
       
    57 by (safe_tac comp_cs);
       
    58 by (ALLGOALS (asm_full_simp_tac com_ss));
       
    59 
       
    60 (* comp *)
       
    61 by (REPEAT (EVERY [(dtac bspec 1),(atac 1)]));
       
    62 by (asm_full_simp_tac com_ss 1);
       
    63 
       
    64 (* while *)
       
    65 by (etac (Gamma_mono RSN (2,induct)) 1);
       
    66 by (rewrite_goals_tac [Gamma_def]);  
       
    67 by (safe_tac comp_cs);
       
    68 by (EVERY1 [dtac bspec, atac]);
       
    69 by (ALLGOALS (asm_full_simp_tac com_ss));
       
    70 
       
    71 qed "com2";
       
    72 
       
    73 
       
    74 (**** Proof of Equivalence ****)
       
    75 
       
    76 val com_iff_cs = set_cs addEs [com2 RS bspec] addDs [com1];
       
    77 
       
    78 goal Equiv.thy "C(c) = {io . <c,fst(io)> -c-> snd(io)}";
       
    79 by (rtac equalityI 1);
       
    80 (* => *)
       
    81 by (fast_tac com_iff_cs 1);
       
    82 (* <= *)
       
    83 by (REPEAT (step_tac com_iff_cs 1));
       
    84 by (asm_full_simp_tac (prod_ss addsimps [surjective_pairing RS sym])1);
       
    85 qed "com_equivalence";