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