src/ZF/IMP/Equiv.ML
author paulson
Wed, 26 Nov 1997 16:48:11 +0100
changeset 4298 b69eedd3aa6c
parent 4152 451104c223e2
child 5068 fb28eaa07e01
permissions -rw-r--r--
Tidying and modification to cope with iffCE
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 808
diff changeset
     1
(*  Title:      ZF/IMP/Equiv.ML
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 808
diff changeset
     3
    Author:     Heiko Loetzbeyer & Robert Sandner, TUM
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
     4
    Copyright   1994 TUM
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
     5
*)
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
     6
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
     7
val prems = goal Equiv.thy
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
     8
   "!!a. [| a: aexp; sigma: loc -> nat |] ==> \
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
     9
\        <a,sigma> -a-> n <-> A(a,sigma) = n";
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    10
by (res_inst_tac [("x","n")] spec 1);                       (* quantify n *)
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    11
by (etac aexp.induct 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    12
by (ALLGOALS (fast_tac (claset() addSIs evala.intrs
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    13
                                 addSEs aexp_elim_cases 
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    14
                                 addss (simpset()))));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 672
diff changeset
    15
qed "aexp_iff";
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    16
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    17
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    18
val aexp1 = aexp_iff RS iffD1;
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    19
val aexp2 = aexp_iff RS iffD2;
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    20
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    21
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    22
val bexp_elim_cases = 
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    23
   [
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    24
    evalb.mk_cases bexp.con_defs "<true,sigma> -b-> x",
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    25
    evalb.mk_cases bexp.con_defs "<false,sigma> -b-> x",
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    26
    evalb.mk_cases bexp.con_defs "<ROp(f,a0,a1),sigma> -b-> x",
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    27
    evalb.mk_cases bexp.con_defs "<noti(b),sigma> -b-> x",
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    28
    evalb.mk_cases bexp.con_defs "<b0 andi b1,sigma> -b-> x",
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    29
    evalb.mk_cases bexp.con_defs "<b0 ori b1,sigma> -b-> x"
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    30
   ];
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    31
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    32
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    33
val prems = goal Equiv.thy
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    34
   "!!b. [| b: bexp; sigma: loc -> nat |] ==> \
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    35
\        <b,sigma> -b-> w <-> B(b,sigma) = w";
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    36
by (res_inst_tac [("x","w")] spec 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    37
by (etac bexp.induct 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    38
by (ALLGOALS (fast_tac (claset() addSIs evalb.intrs
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    39
                                 addSEs bexp_elim_cases 
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    40
                                 addss (simpset() addsimps [aexp_iff]))));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 672
diff changeset
    41
qed "bexp_iff";
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    42
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    43
val bexp1 = bexp_iff RS iffD1;
518
4530c45370b4 Proof beautification
nipkow
parents: 511
diff changeset
    44
val bexp2 = bexp_iff RS iffD2;
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    45
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    46
518
4530c45370b4 Proof beautification
nipkow
parents: 511
diff changeset
    47
goal Equiv.thy "!!c. <c,sigma> -c-> sigma' ==> <sigma,sigma'> : C(c)";
1742
328fb06a1648 Updated for new form of induction rules
paulson
parents: 1461
diff changeset
    48
by (etac evalc.induct 1);
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    49
by (ALLGOALS (asm_simp_tac (simpset() addsimps [bexp1])));
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    50
(* skip *)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1742
diff changeset
    51
by (Fast_tac 1);
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    52
(* assign *)
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    53
by (asm_full_simp_tac (simpset() addsimps 
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    54
		       [aexp1, assign_type] @ op_type_intrs) 1);
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    55
(* comp *)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1742
diff changeset
    56
by (Fast_tac 1);
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    57
(* while *)
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    58
by (etac (Gamma_bnd_mono RS lfp_Tarski RS ssubst) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    59
by (asm_simp_tac (simpset() addsimps [Gamma_def, bexp1]) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    60
by (blast_tac (claset() addSIs [bexp1]@evalb_type_intrs) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    61
(* recursive case of while *)
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    62
by (etac (Gamma_bnd_mono RS lfp_Tarski RS ssubst) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    63
by (asm_full_simp_tac (simpset() addsimps [Gamma_def, bexp1]) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    64
by (blast_tac (claset() addSIs [bexp1]@evalb_type_intrs) 1);
500
0842a38074e7 some small simplifications
nipkow
parents: 482
diff changeset
    65
val com1 = result();
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    66
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    67
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1742
diff changeset
    68
AddSIs [aexp2,bexp2,B_type,A_type];
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    69
AddIs  evalc.intrs;
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    70
AddEs  [C_type,C_type_fst];
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    71
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    72
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    73
goal Equiv.thy "!!c. c : com ==> ALL x:C(c). <c,fst(x)> -c-> snd(x)";
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    74
by (etac com.induct 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    75
(* skip *)
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    76
by (fast_tac (claset() addss (simpset())) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    77
(* assign *)
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    78
by (fast_tac (claset() addss (simpset())) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    79
(* comp *)
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    80
by (best_tac (claset() addss (simpset())) 1);
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    81
(* while *)
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
    82
by Safe_tac;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1742
diff changeset
    83
by (ALLGOALS Asm_full_simp_tac);
518
4530c45370b4 Proof beautification
nipkow
parents: 511
diff changeset
    84
by (EVERY1 [forward_tac [Gamma_bnd_mono], etac induct, atac]);
808
c51c1f59e59e ran expandshort script
lcp
parents: 760
diff changeset
    85
by (rewtac Gamma_def);  
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
    86
by Safe_tac;
518
4530c45370b4 Proof beautification
nipkow
parents: 511
diff changeset
    87
by (EVERY1 [dtac bspec, atac]);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1742
diff changeset
    88
by (ALLGOALS Asm_full_simp_tac);
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    89
(* while, if *)
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    90
by (ALLGOALS Blast_tac);
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    91
val com2 = result();
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    92
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    93
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    94
(**** Proof of Equivalence ****)
482
3a4e092ba69c Initial revision
nipkow
parents:
diff changeset
    95
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    96
goal Equiv.thy
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
    97
    "ALL c:com. C(c) = {io:(loc->nat)*(loc->nat). <c,fst(io)> -c-> snd(io)}";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2496
diff changeset
    98
by (fast_tac (claset() addIs [C_subset RS subsetD]
4298
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
    99
		       addEs [com2 RS bspec]
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
   100
		       addDs [com1]
b69eedd3aa6c Tidying and modification to cope with iffCE
paulson
parents: 4152
diff changeset
   101
		       addss (simpset())) 1);
511
b2be4790da7a re-organized using new theory sections
lcp
parents: 510
diff changeset
   102
val com_equivalence = result();