src/FOL/simpdata.ML
author nipkow
Tue Oct 12 13:39:35 1993 +0100 (1993-10-12)
changeset 53 f8f37a9a31dc
parent 3 5f77582e3a89
child 215 bc439e9ce958
permissions -rw-r--r--
Added gen_all to simpdata.ML.
clasohm@0
     1
(*  Title: 	FOL/simpdata
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1991  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Simplification data for FOL
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
(*** Rewrite rules ***)
clasohm@0
    10
clasohm@0
    11
fun int_prove_fun s = 
clasohm@0
    12
    (writeln s;  prove_goal IFOL.thy s
clasohm@0
    13
       (fn prems => [ (cut_facts_tac prems 1), (Int.fast_tac 1) ]));
clasohm@0
    14
clasohm@0
    15
val conj_rews = map int_prove_fun
clasohm@0
    16
 ["P & True <-> P", 	"True & P <-> P",
clasohm@0
    17
  "P & False <-> False", "False & P <-> False",
clasohm@0
    18
  "P & P <-> P",
clasohm@0
    19
  "P & ~P <-> False", 	"~P & P <-> False",
clasohm@0
    20
  "(P & Q) & R <-> P & (Q & R)"];
clasohm@0
    21
clasohm@0
    22
val disj_rews = map int_prove_fun
clasohm@0
    23
 ["P | True <-> True", 	"True | P <-> True",
clasohm@0
    24
  "P | False <-> P", 	"False | P <-> P",
clasohm@0
    25
  "P | P <-> P",
clasohm@0
    26
  "(P | Q) | R <-> P | (Q | R)"];
clasohm@0
    27
clasohm@0
    28
val not_rews = map int_prove_fun
clasohm@0
    29
 ["~ False <-> True",	"~ True <-> False"];
clasohm@0
    30
clasohm@0
    31
val imp_rews = map int_prove_fun
clasohm@0
    32
 ["(P --> False) <-> ~P",	"(P --> True) <-> True",
clasohm@0
    33
  "(False --> P) <-> True",	"(True --> P) <-> P", 
clasohm@0
    34
  "(P --> P) <-> True",		"(P --> ~P) <-> ~P"];
clasohm@0
    35
clasohm@0
    36
val iff_rews = map int_prove_fun
clasohm@0
    37
 ["(True <-> P) <-> P", 	"(P <-> True) <-> P",
clasohm@0
    38
  "(P <-> P) <-> True",
clasohm@0
    39
  "(False <-> P) <-> ~P", 	"(P <-> False) <-> ~P"];
clasohm@0
    40
clasohm@0
    41
val quant_rews = map int_prove_fun
clasohm@0
    42
 ["(ALL x.P) <-> P",	"(EX x.P) <-> P"];
clasohm@0
    43
clasohm@0
    44
(*These are NOT supplied by default!*)
clasohm@0
    45
val distrib_rews  = map int_prove_fun
clasohm@0
    46
 ["~(P|Q) <-> ~P & ~Q",
clasohm@0
    47
  "P & (Q | R) <-> P&Q | P&R", "(Q | R) & P <-> Q&P | R&P",
clasohm@0
    48
  "(P | Q --> R) <-> (P --> R) & (Q --> R)"];
clasohm@0
    49
clasohm@0
    50
val P_Imp_P_iff_T = int_prove_fun "P ==> (P <-> True)";
clasohm@0
    51
clasohm@0
    52
fun make_iff_T th = th RS P_Imp_P_iff_T;
clasohm@0
    53
clasohm@0
    54
val refl_iff_T = make_iff_T refl;
clasohm@0
    55
clasohm@0
    56
val notFalseI = int_prove_fun "~False";
clasohm@0
    57
clasohm@0
    58
(* Conversion into rewrite rules *)
clasohm@0
    59
clasohm@0
    60
val not_P_imp_P_iff_F = int_prove_fun "~P ==> (P <-> False)";
clasohm@0
    61
clasohm@0
    62
fun mk_meta_eq th = case concl_of th of
clasohm@0
    63
      _ $ (Const("op <->",_)$_$_) => th RS iff_reflection
clasohm@0
    64
    | _ $ (Const("op =",_)$_$_) => th RS eq_reflection
clasohm@0
    65
    | _ $ (Const("Not",_)$_) => (th RS not_P_imp_P_iff_F) RS iff_reflection
clasohm@0
    66
    | _ => (make_iff_T th) RS iff_reflection;
clasohm@0
    67
clasohm@0
    68
fun atomize th = case concl_of th of (*The operator below is Trueprop*)
clasohm@0
    69
      _ $ (Const("op -->",_) $ _ $ _) => atomize(th RS mp)
clasohm@0
    70
    | _ $ (Const("op &",_) $ _ $ _) => atomize(th RS conjunct1) @
clasohm@0
    71
				       atomize(th RS conjunct2)
clasohm@0
    72
    | _ $ (Const("All",_) $ _) => atomize(th RS spec)
clasohm@0
    73
    | _ $ (Const("True",_)) => []
clasohm@0
    74
    | _ $ (Const("False",_)) => []
clasohm@0
    75
    | _ => [th];
clasohm@0
    76
nipkow@53
    77
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th;
nipkow@53
    78
nipkow@53
    79
fun mk_rew_rules th = map mk_meta_eq (atomize(gen_all th));
clasohm@0
    80
clasohm@0
    81
structure Induction = InductionFun(struct val spec=IFOL.spec end);
clasohm@0
    82
clasohm@0
    83
val IFOL_rews =
clasohm@0
    84
   [refl_iff_T] @ conj_rews @ disj_rews @ not_rews @ 
clasohm@0
    85
    imp_rews @ iff_rews @ quant_rews;
clasohm@0
    86
clasohm@0
    87
open Simplifier Induction;
clasohm@0
    88
nipkow@3
    89
infix addcongs;
nipkow@3
    90
fun ss addcongs congs =
nipkow@3
    91
  ss addeqcongs (congs RL [eq_reflection,iff_reflection]);
nipkow@3
    92
clasohm@0
    93
val IFOL_ss = empty_ss
clasohm@0
    94
      setmksimps mk_rew_rules
clasohm@0
    95
      setsolver
clasohm@0
    96
        (fn prems => resolve_tac (TrueI::refl::iff_refl::notFalseI::prems))
clasohm@0
    97
      setsubgoaler asm_simp_tac
clasohm@0
    98
      addsimps IFOL_rews
nipkow@3
    99
      addcongs [imp_cong];
clasohm@0
   100
clasohm@0
   101
(*Classical version...*)
clasohm@0
   102
fun prove_fun s = 
clasohm@0
   103
    (writeln s;  prove_goal FOL.thy s
clasohm@0
   104
       (fn prems => [ (cut_facts_tac prems 1), (Cla.fast_tac FOL_cs 1) ]));
clasohm@0
   105
clasohm@0
   106
val cla_rews = map prove_fun
clasohm@0
   107
 ["P | ~P", 		"~P | P",
clasohm@0
   108
  "~ ~ P <-> P",	"(~P --> P) <-> P"];
clasohm@0
   109
clasohm@0
   110
val FOL_ss = IFOL_ss addsimps cla_rews;
clasohm@0
   111
clasohm@0
   112
(*** case splitting ***)
clasohm@0
   113
clasohm@0
   114
val split_tac =
clasohm@0
   115
  let val eq_reflection2 = prove_goal FOL.thy "x==y ==> x=y"
clasohm@0
   116
                             (fn [prem] => [rewtac prem, rtac refl 1])
clasohm@0
   117
      val iff_reflection2 = prove_goal FOL.thy "x==y ==> x<->y"
clasohm@0
   118
                              (fn [prem] => [rewtac prem, rtac iff_refl 1])
clasohm@0
   119
      val [iffD] = [eq_reflection2,iff_reflection2] RL [iffD2]
clasohm@0
   120
  in fn splits => mk_case_split_tac iffD (map mk_meta_eq splits) end;