src/FOL/simpdata.ML
author lcp
Thu Mar 30 13:36:00 1995 +0200 (1995-03-30)
changeset 981 864370666a24
parent 942 d9edeb96b51c
child 1088 fc4fb6e8a636
permissions -rw-r--r--
Defined addss to perform simplification in a claset.
Precedence of addcongs is now 4 (to match that of other simplifier infixes)
clasohm@0
     1
(*  Title: 	FOL/simpdata
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
lcp@282
     4
    Copyright   1994  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 = 
lcp@282
    12
 (writeln s;  
lcp@282
    13
  prove_goal IFOL.thy s
lcp@282
    14
   (fn prems => [ (cut_facts_tac prems 1), 
lcp@282
    15
		  (Int.fast_tac 1) ]));
clasohm@0
    16
clasohm@0
    17
val conj_rews = map int_prove_fun
lcp@282
    18
 ["P & True <-> P", 	 "True & P <-> P",
clasohm@0
    19
  "P & False <-> False", "False & P <-> False",
clasohm@0
    20
  "P & P <-> P",
lcp@282
    21
  "P & ~P <-> False", 	 "~P & P <-> False",
clasohm@0
    22
  "(P & Q) & R <-> P & (Q & R)"];
clasohm@0
    23
clasohm@0
    24
val disj_rews = map int_prove_fun
clasohm@0
    25
 ["P | True <-> True", 	"True | P <-> True",
clasohm@0
    26
  "P | False <-> P", 	"False | P <-> P",
clasohm@0
    27
  "P | P <-> P",
clasohm@0
    28
  "(P | Q) | R <-> P | (Q | R)"];
clasohm@0
    29
clasohm@0
    30
val not_rews = map int_prove_fun
lcp@282
    31
 ["~(P|Q)  <-> ~P & ~Q",
lcp@282
    32
  "~ False <-> True",	"~ True <-> False"];
clasohm@0
    33
clasohm@0
    34
val imp_rews = map int_prove_fun
clasohm@0
    35
 ["(P --> False) <-> ~P",	"(P --> True) <-> True",
clasohm@0
    36
  "(False --> P) <-> True",	"(True --> P) <-> P", 
clasohm@0
    37
  "(P --> P) <-> True",		"(P --> ~P) <-> ~P"];
clasohm@0
    38
clasohm@0
    39
val iff_rews = map int_prove_fun
clasohm@0
    40
 ["(True <-> P) <-> P", 	"(P <-> True) <-> P",
clasohm@0
    41
  "(P <-> P) <-> True",
clasohm@0
    42
  "(False <-> P) <-> ~P", 	"(P <-> False) <-> ~P"];
clasohm@0
    43
clasohm@0
    44
val quant_rews = map int_prove_fun
clasohm@0
    45
 ["(ALL x.P) <-> P",	"(EX x.P) <-> P"];
clasohm@0
    46
clasohm@0
    47
(*These are NOT supplied by default!*)
clasohm@0
    48
val distrib_rews  = map int_prove_fun
lcp@282
    49
 ["P & (Q | R) <-> P&Q | P&R", 
lcp@282
    50
  "(Q | R) & P <-> Q&P | R&P",
clasohm@0
    51
  "(P | Q --> R) <-> (P --> R) & (Q --> R)"];
clasohm@0
    52
lcp@784
    53
bind_thm("conj_commute", int_prove_fun "P&Q <-> Q&P");
lcp@784
    54
bind_thm("disj_commute", int_prove_fun "P|Q <-> Q|P");
lcp@784
    55
lcp@282
    56
(** Conversion into rewrite rules **)
clasohm@0
    57
nipkow@53
    58
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th;
nipkow@53
    59
lcp@282
    60
(*Make atomic rewrite rules*)
lcp@429
    61
fun atomize r =
lcp@429
    62
  case concl_of r of
lcp@429
    63
    Const("Trueprop",_) $ p =>
lcp@429
    64
      (case p of
lcp@429
    65
	 Const("op -->",_)$_$_ => atomize(r RS mp)
lcp@429
    66
       | Const("op &",_)$_$_   => atomize(r RS conjunct1) @
lcp@429
    67
	  		          atomize(r RS conjunct2)
lcp@429
    68
       | Const("All",_)$_      => atomize(r RS spec)
lcp@429
    69
       | Const("True",_)       => []	(*True is DELETED*)
lcp@429
    70
       | Const("False",_)      => []	(*should False do something?*)
lcp@429
    71
       | _                     => [r])
lcp@429
    72
  | _ => [r];
lcp@429
    73
lcp@282
    74
lcp@282
    75
val P_iff_F = int_prove_fun "~P ==> (P <-> False)";
lcp@282
    76
val iff_reflection_F = P_iff_F RS iff_reflection;
lcp@282
    77
lcp@282
    78
val P_iff_T = int_prove_fun "P ==> (P <-> True)";
lcp@282
    79
val iff_reflection_T = P_iff_T RS iff_reflection;
lcp@282
    80
lcp@282
    81
(*Make meta-equalities.  The operator below is Trueprop*)
lcp@282
    82
fun mk_meta_eq th = case concl_of th of
nipkow@394
    83
    Const("==",_)$_$_           => th
nipkow@394
    84
  | _ $ (Const("op =",_)$_$_)   => th RS eq_reflection
lcp@282
    85
  | _ $ (Const("op <->",_)$_$_) => th RS iff_reflection
lcp@282
    86
  | _ $ (Const("Not",_)$_)      => th RS iff_reflection_F
lcp@282
    87
  | _                           => th RS iff_reflection_T;
clasohm@0
    88
clasohm@0
    89
structure Induction = InductionFun(struct val spec=IFOL.spec end);
clasohm@0
    90
clasohm@0
    91
open Simplifier Induction;
clasohm@0
    92
lcp@981
    93
(*Add congruence rules for = or <-> (instead of ==) *)
lcp@981
    94
infix 4 addcongs;
nipkow@3
    95
fun ss addcongs congs =
lcp@282
    96
    ss addeqcongs (congs RL [eq_reflection,iff_reflection]);
lcp@282
    97
lcp@981
    98
(*Add a simpset to a classical set!*)
lcp@981
    99
infix 4 addss;
lcp@981
   100
fun cs addss ss = cs addbefore asm_full_simp_tac ss 1;
lcp@981
   101
lcp@981
   102
lcp@282
   103
val IFOL_rews =
lcp@282
   104
   [refl RS P_iff_T] @ conj_rews @ disj_rews @ not_rews @ 
lcp@282
   105
    imp_rews @ iff_rews @ quant_rews;
nipkow@3
   106
lcp@282
   107
val notFalseI = int_prove_fun "~False";
lcp@282
   108
val triv_rls = [TrueI,refl,iff_refl,notFalseI];
lcp@282
   109
lcp@282
   110
val IFOL_ss = 
lcp@282
   111
  empty_ss 
lcp@282
   112
  setmksimps (map mk_meta_eq o atomize o gen_all)
lcp@371
   113
  setsolver  (fn prems => resolve_tac (triv_rls@prems) 
lcp@371
   114
	                  ORELSE' assume_tac
lcp@371
   115
	                  ORELSE' etac FalseE)
lcp@282
   116
  setsubgoaler asm_simp_tac
lcp@282
   117
  addsimps IFOL_rews
lcp@282
   118
  addcongs [imp_cong];
clasohm@0
   119
clasohm@0
   120
(*Classical version...*)
clasohm@0
   121
fun prove_fun s = 
lcp@282
   122
 (writeln s;  
lcp@282
   123
  prove_goal FOL.thy s
lcp@282
   124
   (fn prems => [ (cut_facts_tac prems 1), 
lcp@282
   125
		  (Cla.fast_tac FOL_cs 1) ]));
lcp@745
   126
clasohm@0
   127
val cla_rews = map prove_fun
lcp@282
   128
 ["~(P&Q)  <-> ~P | ~Q",
lcp@282
   129
  "P | ~P", 		"~P | P",
clasohm@0
   130
  "~ ~ P <-> P",	"(~P --> P) <-> P"];
clasohm@0
   131
clasohm@0
   132
val FOL_ss = IFOL_ss addsimps cla_rews;
clasohm@0
   133
clasohm@0
   134
(*** case splitting ***)
clasohm@0
   135
clasohm@756
   136
qed_goal "meta_iffD" FOL.thy "[| P==Q; Q |] ==> P"
clasohm@756
   137
        (fn [prem1,prem2] => [rewtac prem1, rtac prem2 1]);
lcp@282
   138
nipkow@942
   139
local val mktac = mk_case_split_tac meta_iffD
nipkow@942
   140
in
nipkow@942
   141
fun split_tac splits = mktac (map mk_meta_eq splits)
nipkow@942
   142
end;