src/FOLP/simpdata.ML
author clasohm
Tue, 30 Jan 1996 15:12:53 +0100
changeset 1463 49ca5e875691
parent 1459 d12da312eff4
child 2603 4988dda71c0b
permissions -rw-r--r--
expanded tabs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1463
49ca5e875691 expanded tabs
clasohm
parents: 1459
diff changeset
     1
(*  Title:      FOLP/simpdata.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
1463
49ca5e875691 expanded tabs
clasohm
parents: 1459
diff changeset
     6
Simplification data for FOLP
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
(*** Rewrite rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
fun int_prove_fun_raw s = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
    (writeln s;  prove_goal IFOLP.thy s
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
       (fn prems => [ (cut_facts_tac prems 1), (Int.fast_tac 1) ]));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
fun int_prove_fun s = int_prove_fun_raw ("?p : "^s);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
val conj_rews = map int_prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    18
 ["P & True <-> P",     "True & P <-> P",
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
  "P & False <-> False", "False & P <-> False",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  "P & P <-> P",
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    21
  "P & ~P <-> False",   "~P & P <-> False",
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  "(P & Q) & R <-> P & (Q & R)"];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
val disj_rews = map int_prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    25
 ["P | True <-> True",  "True | P <-> True",
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    26
  "P | False <-> P",    "False | P <-> P",
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  "P | P <-> P",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
  "(P | Q) | R <-> P | (Q | R)"];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
val not_rews = map int_prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    31
 ["~ False <-> True",   "~ True <-> False"];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
val imp_rews = map int_prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    34
 ["(P --> False) <-> ~P",       "(P --> True) <-> True",
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    35
  "(False --> P) <-> True",     "(True --> P) <-> P", 
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    36
  "(P --> P) <-> True",         "(P --> ~P) <-> ~P"];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
val iff_rews = map int_prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    39
 ["(True <-> P) <-> P",         "(P <-> True) <-> P",
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  "(P <-> P) <-> True",
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    41
  "(False <-> P) <-> ~P",       "(P <-> False) <-> ~P"];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
val quant_rews = map int_prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    44
 ["(ALL x.P) <-> P",    "(EX x.P) <-> P"];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
(*These are NOT supplied by default!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
val distrib_rews  = map int_prove_fun
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
 ["~(P|Q) <-> ~P & ~Q",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
  "P & (Q | R) <-> P&Q | P&R", "(Q | R) & P <-> Q&P | R&P",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  "(P | Q --> R) <-> (P --> R) & (Q --> R)",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
  "~(EX x.NORM(P(x))) <-> (ALL x. ~NORM(P(x)))",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
  "((EX x.NORM(P(x))) --> Q) <-> (ALL x. NORM(P(x)) --> Q)",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
  "(EX x.NORM(P(x))) & NORM(Q) <-> (EX x. NORM(P(x)) & NORM(Q))",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
  "NORM(Q) & (EX x.NORM(P(x))) <-> (EX x. NORM(Q) & NORM(P(x)))"];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
val P_Imp_P_iff_T = int_prove_fun_raw "p:P ==> ?p:(P <-> True)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
fun make_iff_T th = th RS P_Imp_P_iff_T;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
val refl_iff_T = make_iff_T refl;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
val norm_thms = [(norm_eq RS sym, norm_eq),
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    63
                 (NORM_iff RS iff_sym, NORM_iff)];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
(* Conversion into rewrite rules *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
val not_P_imp_P_iff_F = int_prove_fun_raw "p:~P ==> ?p:(P <-> False)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
fun mk_eq th = case concl_of th of
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
      _ $ (Const("op <->",_)$_$_) $ _ => th
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
    | _ $ (Const("op =",_)$_$_) $ _ => th
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
    | _ $ (Const("Not",_)$_) $ _ => th RS not_P_imp_P_iff_F 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
    | _ => make_iff_T th;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
fun atomize th = case concl_of th of (*The operator below is "Proof $ P $ p"*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
      _ $ (Const("op -->",_) $ _ $ _) $ _ => atomize(th RS mp)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
    | _ $ (Const("op &",_) $ _ $ _) $ _ => atomize(th RS conjunct1) @
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    79
                                       atomize(th RS conjunct2)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
    | _ $ (Const("All",_) $ _) $ _ => atomize(th RS spec)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
    | _ $ (Const("True",_)) $ _ => []
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
    | _ $ (Const("False",_)) $ _ => []
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
    | _ => [th];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
fun mk_rew_rules th = map mk_eq (atomize th);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
(*destruct function for analysing equations*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
fun dest_red(_ $ (red $ lhs $ rhs) $ _) = (red,lhs,rhs)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
  | dest_red t = raise TERM("FOL/dest_red", [t]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
structure FOLP_SimpData : SIMP_DATA =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
  struct
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    93
  val refl_thms         = [refl, iff_refl]
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    94
  val trans_thms        = [trans, iff_trans]
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    95
  val red1              = iffD1
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    96
  val red2              = iffD2
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    97
  val mk_rew_rules      = mk_rew_rules
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    98
  val case_splits       = []         (*NO IF'S!*)
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
    99
  val norm_thms         = norm_thms
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
   100
  val subst_thms        = [subst];
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
   101
  val dest_red          = dest_red
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
structure FOLP_Simp = SimpFun(FOLP_SimpData);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
(*not a component of SIMP_DATA, but an argument of SIMP_TAC *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
val FOLP_congs = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
   [all_cong,ex_cong,eq_cong,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
    conj_cong,disj_cong,imp_cong,iff_cong,not_cong] @ pred_congs;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
val IFOLP_rews =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
   [refl_iff_T] @ conj_rews @ disj_rews @ not_rews @ 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
    imp_rews @ iff_rews @ quant_rews;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
1009
eb7c50688405 No longer builds the induction structure (from ../Provers/ind.ML)
lcp
parents: 0
diff changeset
   115
open FOLP_Simp;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
val auto_ss = empty_ss setauto ares_tac [TrueI];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
val IFOLP_ss = auto_ss addcongs FOLP_congs addrews IFOLP_rews;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
(*Classical version...*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
fun prove_fun s = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
    (writeln s;  prove_goal FOLP.thy s
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
       (fn prems => [ (cut_facts_tac prems 1), (Cla.fast_tac FOLP_cs 1) ]));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
val cla_rews = map prove_fun
1459
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
   127
 ["?p:P | ~P",          "?p:~P | P",
d12da312eff4 expanded tabs
clasohm
parents: 1009
diff changeset
   128
  "?p:~ ~ P <-> P",     "?p:(~P --> P) <-> P"];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
val FOLP_rews = IFOLP_rews@cla_rews;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
val FOLP_ss = auto_ss addcongs FOLP_congs addrews FOLP_rews;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134