src/ZF/ex/parcontract.ML
author lcp
Tue Aug 16 18:58:42 1994 +0200 (1994-08-16)
changeset 532 851df239ac8b
parent 0 a5a9c433f639
permissions -rw-r--r--
ZF/Makefile,ROOT.ML, ZF/ex/Integ.thy: updated for EquivClass
clasohm@0
     1
(*  Title: 	ZF/ex/parcontract.ML
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson
clasohm@0
     4
    Copyright   1993  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Parallel contraction
clasohm@0
     7
clasohm@0
     8
HOL system proofs may be found in
clasohm@0
     9
/usr/groups/theory/hvg-aftp/contrib/rule-induction/cl.ml
clasohm@0
    10
*)
clasohm@0
    11
clasohm@0
    12
structure ParContract = Inductive_Fun
clasohm@0
    13
 (val thy = Contract.thy;
clasohm@0
    14
  val rec_doms = [("parcontract","comb*comb")];
clasohm@0
    15
  val sintrs = 
clasohm@0
    16
      ["[| p:comb |] ==> p =1=> p",
clasohm@0
    17
       "[| p:comb;  q:comb |] ==> K#p#q =1=> p",
clasohm@0
    18
       "[| p:comb;  q:comb;  r:comb |] ==> S#p#q#r =1=> (p#r)#(q#r)",
clasohm@0
    19
       "[| p=1=>q;  r=1=>s |] ==> p#r =1=> q#s"];
clasohm@0
    20
  val monos = [];
clasohm@0
    21
  val con_defs = [];
clasohm@0
    22
  val type_intrs = Comb.intrs@[SigmaI];
clasohm@0
    23
  val type_elims = [SigmaE2]);
clasohm@0
    24
clasohm@0
    25
val [parcontract_refl,K_parcontract,S_parcontract,Ap_parcontract] = ParContract.intrs;
clasohm@0
    26
clasohm@0
    27
val parcontract_induct = standard
clasohm@0
    28
    (ParContract.mutual_induct RS spec RS spec RSN (2,rev_mp));
clasohm@0
    29
clasohm@0
    30
(*For type checking: replaces a=1=>b by a,b:comb *)
clasohm@0
    31
val parcontract_combE2 = ParContract.dom_subset RS subsetD RS SigmaE2;
clasohm@0
    32
val parcontract_combD1 = ParContract.dom_subset RS subsetD RS SigmaD1;
clasohm@0
    33
val parcontract_combD2 = ParContract.dom_subset RS subsetD RS SigmaD2;
clasohm@0
    34
clasohm@0
    35
goal ParContract.thy "field(parcontract) = comb";
clasohm@0
    36
by (fast_tac (ZF_cs addIs [equalityI,K_parcontract] 
clasohm@0
    37
	            addSEs [parcontract_combE2]) 1);
clasohm@0
    38
val field_parcontract_eq = result();
clasohm@0
    39
clasohm@0
    40
val parcontract_caseE = standard
clasohm@0
    41
     (ParContract.unfold RS equalityD1 RS subsetD RS CollectE);
clasohm@0
    42
clasohm@0
    43
(*Derive a case for each combinator constructor*)
clasohm@0
    44
val K_parcontract_case = ParContract.mk_cases Comb.con_defs "K =1=> r";
clasohm@0
    45
val S_parcontract_case = ParContract.mk_cases Comb.con_defs "S =1=> r";
clasohm@0
    46
val Ap_parcontract_case = ParContract.mk_cases Comb.con_defs "p#q =1=> r";
clasohm@0
    47
clasohm@0
    48
val parcontract_cs =
clasohm@0
    49
    ZF_cs addSIs Comb.intrs
clasohm@0
    50
	  addIs  ParContract.intrs
clasohm@0
    51
	  addSEs [Ap_E, K_parcontract_case, S_parcontract_case, 
clasohm@0
    52
		  Ap_parcontract_case]
clasohm@0
    53
	  addSEs [parcontract_combD1, parcontract_combD2]     (*type checking*)
clasohm@0
    54
          addSEs Comb.free_SEs;
clasohm@0
    55
clasohm@0
    56
(*** Basic properties of parallel contraction ***)
clasohm@0
    57
clasohm@0
    58
goal ParContract.thy "!!p r. K#p =1=> r ==> (EX p'. r = K#p' & p =1=> p')";
clasohm@0
    59
by (fast_tac parcontract_cs 1);
clasohm@0
    60
val K1_parcontractD = result();
clasohm@0
    61
clasohm@0
    62
goal ParContract.thy "!!p r. S#p =1=> r ==> (EX p'. r = S#p' & p =1=> p')";
clasohm@0
    63
by (fast_tac parcontract_cs 1);
clasohm@0
    64
val S1_parcontractD = result();
clasohm@0
    65
clasohm@0
    66
goal ParContract.thy
clasohm@0
    67
 "!!p q r. S#p#q =1=> r ==> (EX p' q'. r = S#p'#q' & p =1=> p' & q =1=> q')";
clasohm@0
    68
by (fast_tac (parcontract_cs addSDs [S1_parcontractD]) 1);
clasohm@0
    69
val S2_parcontractD = result();
clasohm@0
    70
clasohm@0
    71
(*Church-Rosser property for parallel contraction*)
clasohm@0
    72
goalw ParContract.thy [diamond_def] "diamond(parcontract)";
clasohm@0
    73
by (rtac (impI RS allI RS allI) 1);
clasohm@0
    74
by (etac parcontract_induct 1);
clasohm@0
    75
by (ALLGOALS 
clasohm@0
    76
    (fast_tac (parcontract_cs addSDs [K1_parcontractD,S2_parcontractD])));
clasohm@0
    77
val diamond_parcontract = result();
clasohm@0
    78
clasohm@0
    79
(*** Transitive closure preserves the Church-Rosser property ***)
clasohm@0
    80
clasohm@0
    81
goalw ParContract.thy [diamond_def]
clasohm@0
    82
    "!!x y r. [| diamond(r);  <x,y>:r^+ |] ==> \
clasohm@0
    83
\    ALL y'. <x,y'>:r --> (EX z. <y',z>: r^+ & <y,z>: r)";
clasohm@0
    84
by (etac trancl_induct 1);
clasohm@0
    85
by (fast_tac (ZF_cs addIs [r_into_trancl]) 1);
clasohm@0
    86
by (slow_best_tac (ZF_cs addSDs [spec RS mp]
clasohm@0
    87
		         addIs  [r_into_trancl, trans_trancl RS transD]) 1);
clasohm@0
    88
val diamond_trancl_lemma = result();
clasohm@0
    89
clasohm@0
    90
val diamond_lemmaE = diamond_trancl_lemma RS spec RS mp RS exE;
clasohm@0
    91
clasohm@0
    92
val [major] = goal ParContract.thy "diamond(r) ==> diamond(r^+)";
clasohm@0
    93
bw diamond_def;  (*unfold only in goal, not in premise!*)
clasohm@0
    94
by (rtac (impI RS allI RS allI) 1);
clasohm@0
    95
by (etac trancl_induct 1);
clasohm@0
    96
by (ALLGOALS
clasohm@0
    97
    (slow_best_tac (ZF_cs addIs [r_into_trancl, trans_trancl RS transD]
clasohm@0
    98
		          addEs [major RS diamond_lemmaE])));
clasohm@0
    99
val diamond_trancl = result();
clasohm@0
   100
clasohm@0
   101
clasohm@0
   102
(*** Equivalence of p--->q and p===>q ***)
clasohm@0
   103
clasohm@0
   104
goal ParContract.thy "!!p q. p-1->q ==> p=1=>q";
clasohm@0
   105
by (etac contract_induct 1);
clasohm@0
   106
by (ALLGOALS (fast_tac (parcontract_cs)));
clasohm@0
   107
val contract_imp_parcontract = result();
clasohm@0
   108
clasohm@0
   109
goal ParContract.thy "!!p q. p--->q ==> p===>q";
clasohm@0
   110
by (forward_tac [rtrancl_type RS subsetD RS SigmaD1] 1);
clasohm@0
   111
by (dtac (field_contract_eq RS equalityD1 RS subsetD) 1);
clasohm@0
   112
by (etac rtrancl_induct 1);
clasohm@0
   113
by (fast_tac (parcontract_cs addIs [r_into_trancl]) 1);
clasohm@0
   114
by (fast_tac (ZF_cs addIs [contract_imp_parcontract, 
clasohm@0
   115
			   r_into_trancl, trans_trancl RS transD]) 1);
clasohm@0
   116
val reduce_imp_parreduce = result();
clasohm@0
   117
clasohm@0
   118
clasohm@0
   119
goal ParContract.thy "!!p q. p=1=>q ==> p--->q";
clasohm@0
   120
by (etac parcontract_induct 1);
clasohm@0
   121
by (fast_tac (contract_cs addIs reduction_rls) 1);
clasohm@0
   122
by (fast_tac (contract_cs addIs reduction_rls) 1);
clasohm@0
   123
by (fast_tac (contract_cs addIs reduction_rls) 1);
clasohm@0
   124
by (rtac (trans_rtrancl RS transD) 1);
clasohm@0
   125
by (ALLGOALS 
clasohm@0
   126
    (fast_tac 
clasohm@0
   127
     (contract_cs addIs [Ap_reduce1, Ap_reduce2]
clasohm@0
   128
                  addSEs [parcontract_combD1,parcontract_combD2])));
clasohm@0
   129
val parcontract_imp_reduce = result();
clasohm@0
   130
clasohm@0
   131
goal ParContract.thy "!!p q. p===>q ==> p--->q";
clasohm@0
   132
by (forward_tac [trancl_type RS subsetD RS SigmaD1] 1);
clasohm@0
   133
by (dtac (field_parcontract_eq RS equalityD1 RS subsetD) 1);
clasohm@0
   134
by (etac trancl_induct 1);
clasohm@0
   135
by (etac parcontract_imp_reduce 1);
clasohm@0
   136
by (etac (trans_rtrancl RS transD) 1);
clasohm@0
   137
by (etac parcontract_imp_reduce 1);
clasohm@0
   138
val parreduce_imp_reduce = result();
clasohm@0
   139
clasohm@0
   140
goal ParContract.thy "p===>q <-> p--->q";
clasohm@0
   141
by (REPEAT (ares_tac [iffI, parreduce_imp_reduce, reduce_imp_parreduce] 1));
clasohm@0
   142
val parreduce_iff_reduce = result();
clasohm@0
   143
clasohm@0
   144
writeln"Reached end of file.";