src/HOL/HOL.ML
author clasohm
Fri Apr 19 11:33:24 1996 +0200 (1996-04-19)
changeset 1668 8ead1fe65aad
parent 1660 8cb42cd97579
child 1672 2c109cd2fdd0
permissions -rw-r--r--
added Konrad's code for the datatype package
clasohm@1465
     1
(*  Title:      HOL/HOL.ML
clasohm@923
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Tobias Nipkow
clasohm@923
     4
    Copyright   1991  University of Cambridge
clasohm@923
     5
clasohm@1465
     6
For HOL.thy
clasohm@923
     7
Derived rules from Appendix of Mike Gordons HOL Report, Cambridge TR 68 
clasohm@923
     8
*)
clasohm@923
     9
clasohm@923
    10
open HOL;
clasohm@923
    11
clasohm@923
    12
clasohm@923
    13
(** Equality **)
oheimb@1660
    14
section "=";
clasohm@923
    15
clasohm@923
    16
qed_goal "sym" HOL.thy "s=t ==> t=s"
clasohm@923
    17
 (fn prems => [cut_facts_tac prems 1, etac subst 1, rtac refl 1]);
clasohm@923
    18
clasohm@923
    19
(*calling "standard" reduces maxidx to 0*)
clasohm@923
    20
bind_thm ("ssubst", (sym RS subst));
clasohm@923
    21
clasohm@923
    22
qed_goal "trans" HOL.thy "[| r=s; s=t |] ==> r=t"
clasohm@923
    23
 (fn prems =>
clasohm@1465
    24
        [rtac subst 1, resolve_tac prems 1, resolve_tac prems 1]);
clasohm@923
    25
clasohm@923
    26
(*Useful with eresolve_tac for proving equalties from known equalities.
clasohm@1465
    27
        a = b
clasohm@1465
    28
        |   |
clasohm@1465
    29
        c = d   *)
clasohm@923
    30
qed_goal "box_equals" HOL.thy
clasohm@923
    31
    "[| a=b;  a=c;  b=d |] ==> c=d"  
clasohm@923
    32
 (fn prems=>
clasohm@923
    33
  [ (rtac trans 1),
clasohm@923
    34
    (rtac trans 1),
clasohm@923
    35
    (rtac sym 1),
clasohm@923
    36
    (REPEAT (resolve_tac prems 1)) ]);
clasohm@923
    37
oheimb@1660
    38
clasohm@923
    39
(** Congruence rules for meta-application **)
oheimb@1660
    40
section "Congruence";
clasohm@923
    41
clasohm@923
    42
(*similar to AP_THM in Gordon's HOL*)
clasohm@923
    43
qed_goal "fun_cong" HOL.thy "(f::'a=>'b) = g ==> f(x)=g(x)"
clasohm@923
    44
  (fn [prem] => [rtac (prem RS subst) 1, rtac refl 1]);
clasohm@923
    45
clasohm@923
    46
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
clasohm@923
    47
qed_goal "arg_cong" HOL.thy "x=y ==> f(x)=f(y)"
clasohm@923
    48
 (fn [prem] => [rtac (prem RS subst) 1, rtac refl 1]);
clasohm@923
    49
clasohm@923
    50
qed_goal "cong" HOL.thy
clasohm@923
    51
   "[| f = g; (x::'a) = y |] ==> f(x) = g(y)"
clasohm@923
    52
 (fn [prem1,prem2] =>
clasohm@923
    53
   [rtac (prem1 RS subst) 1, rtac (prem2 RS subst) 1, rtac refl 1]);
clasohm@923
    54
oheimb@1660
    55
clasohm@923
    56
(** Equality of booleans -- iff **)
oheimb@1660
    57
section "iff";
clasohm@923
    58
clasohm@923
    59
qed_goal "iffI" HOL.thy
clasohm@923
    60
   "[| P ==> Q;  Q ==> P |] ==> P=Q"
clasohm@923
    61
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI, iff RS mp RS mp]) 1)) ]);
clasohm@923
    62
clasohm@923
    63
qed_goal "iffD2" HOL.thy "[| P=Q; Q |] ==> P"
clasohm@923
    64
 (fn prems =>
clasohm@1465
    65
        [rtac ssubst 1, resolve_tac prems 1, resolve_tac prems 1]);
clasohm@923
    66
clasohm@923
    67
val iffD1 = sym RS iffD2;
clasohm@923
    68
clasohm@923
    69
qed_goal "iffE" HOL.thy
clasohm@923
    70
    "[| P=Q; [| P --> Q; Q --> P |] ==> R |] ==> R"
clasohm@923
    71
 (fn [p1,p2] => [REPEAT(ares_tac([p1 RS iffD2, p1 RS iffD1, p2, impI])1)]);
clasohm@923
    72
oheimb@1660
    73
clasohm@923
    74
(** True **)
oheimb@1660
    75
section "True";
clasohm@923
    76
clasohm@923
    77
qed_goalw "TrueI" HOL.thy [True_def] "True"
clasohm@923
    78
  (fn _ => [rtac refl 1]);
clasohm@923
    79
clasohm@923
    80
qed_goal "eqTrueI " HOL.thy "P ==> P=True" 
clasohm@923
    81
 (fn prems => [REPEAT(resolve_tac ([iffI,TrueI]@prems) 1)]);
clasohm@923
    82
clasohm@923
    83
qed_goal "eqTrueE" HOL.thy "P=True ==> P" 
clasohm@923
    84
 (fn prems => [REPEAT(resolve_tac (prems@[TrueI,iffD2]) 1)]);
clasohm@923
    85
oheimb@1660
    86
clasohm@923
    87
(** Universal quantifier **)
oheimb@1660
    88
section "!";
clasohm@923
    89
clasohm@923
    90
qed_goalw "allI" HOL.thy [All_def] "(!!x::'a. P(x)) ==> !x. P(x)"
clasohm@923
    91
 (fn prems => [resolve_tac (prems RL [eqTrueI RS ext]) 1]);
clasohm@923
    92
clasohm@923
    93
qed_goalw "spec" HOL.thy [All_def] "! x::'a.P(x) ==> P(x)"
clasohm@923
    94
 (fn prems => [rtac eqTrueE 1, resolve_tac (prems RL [fun_cong]) 1]);
clasohm@923
    95
clasohm@923
    96
qed_goal "allE" HOL.thy "[| !x.P(x);  P(x) ==> R |] ==> R"
clasohm@923
    97
 (fn major::prems=>
clasohm@923
    98
  [ (REPEAT (resolve_tac (prems @ [major RS spec]) 1)) ]);
clasohm@923
    99
clasohm@923
   100
qed_goal "all_dupE" HOL.thy 
clasohm@923
   101
    "[| ! x.P(x);  [| P(x); ! x.P(x) |] ==> R |] ==> R"
clasohm@923
   102
 (fn prems =>
clasohm@923
   103
  [ (REPEAT (resolve_tac (prems @ (prems RL [spec])) 1)) ]);
clasohm@923
   104
clasohm@923
   105
clasohm@923
   106
(** False ** Depends upon spec; it is impossible to do propositional logic
clasohm@923
   107
             before quantifiers! **)
oheimb@1660
   108
section "False";
clasohm@923
   109
clasohm@923
   110
qed_goalw "FalseE" HOL.thy [False_def] "False ==> P"
clasohm@923
   111
 (fn [major] => [rtac (major RS spec) 1]);
clasohm@923
   112
clasohm@923
   113
qed_goal "False_neq_True" HOL.thy "False=True ==> P"
clasohm@923
   114
 (fn [prem] => [rtac (prem RS eqTrueE RS FalseE) 1]);
clasohm@923
   115
clasohm@923
   116
clasohm@923
   117
(** Negation **)
oheimb@1660
   118
section "~";
clasohm@923
   119
clasohm@923
   120
qed_goalw "notI" HOL.thy [not_def] "(P ==> False) ==> ~P"
clasohm@923
   121
 (fn prems=> [rtac impI 1, eresolve_tac prems 1]);
clasohm@923
   122
clasohm@923
   123
qed_goalw "notE" HOL.thy [not_def] "[| ~P;  P |] ==> R"
clasohm@923
   124
 (fn prems => [rtac (prems MRS mp RS FalseE) 1]);
clasohm@923
   125
oheimb@1660
   126
clasohm@923
   127
(** Implication **)
oheimb@1660
   128
section "-->";
clasohm@923
   129
clasohm@923
   130
qed_goal "impE" HOL.thy "[| P-->Q;  P;  Q ==> R |] ==> R"
clasohm@923
   131
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
clasohm@923
   132
clasohm@923
   133
(* Reduces Q to P-->Q, allowing substitution in P. *)
clasohm@923
   134
qed_goal "rev_mp" HOL.thy "[| P;  P --> Q |] ==> Q"
clasohm@923
   135
 (fn prems=>  [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
clasohm@923
   136
clasohm@923
   137
qed_goal "contrapos" HOL.thy "[| ~Q;  P==>Q |] ==> ~P"
clasohm@923
   138
 (fn [major,minor]=> 
clasohm@923
   139
  [ (rtac (major RS notE RS notI) 1), 
clasohm@923
   140
    (etac minor 1) ]);
clasohm@923
   141
nipkow@1334
   142
qed_goal "rev_contrapos" HOL.thy "[| P==>Q; ~Q |] ==> ~P"
nipkow@1334
   143
 (fn [major,minor]=> 
nipkow@1334
   144
  [ (rtac (minor RS contrapos) 1), (etac major 1) ]);
nipkow@1334
   145
clasohm@923
   146
(* ~(?t = ?s) ==> ~(?s = ?t) *)
nipkow@1334
   147
bind_thm("not_sym", sym COMP rev_contrapos);
clasohm@923
   148
clasohm@923
   149
clasohm@923
   150
(** Existential quantifier **)
oheimb@1660
   151
section "?";
clasohm@923
   152
clasohm@923
   153
qed_goalw "exI" HOL.thy [Ex_def] "P(x) ==> ? x::'a.P(x)"
clasohm@923
   154
 (fn prems => [rtac selectI 1, resolve_tac prems 1]);
clasohm@923
   155
clasohm@923
   156
qed_goalw "exE" HOL.thy [Ex_def]
clasohm@923
   157
  "[| ? x::'a.P(x); !!x. P(x) ==> Q |] ==> Q"
clasohm@923
   158
  (fn prems => [REPEAT(resolve_tac prems 1)]);
clasohm@923
   159
clasohm@923
   160
clasohm@923
   161
(** Conjunction **)
oheimb@1660
   162
section "&";
clasohm@923
   163
clasohm@923
   164
qed_goalw "conjI" HOL.thy [and_def] "[| P; Q |] ==> P&Q"
clasohm@923
   165
 (fn prems =>
clasohm@923
   166
  [REPEAT (resolve_tac (prems@[allI,impI]) 1 ORELSE etac (mp RS mp) 1)]);
clasohm@923
   167
clasohm@923
   168
qed_goalw "conjunct1" HOL.thy [and_def] "[| P & Q |] ==> P"
clasohm@923
   169
 (fn prems =>
clasohm@923
   170
   [resolve_tac (prems RL [spec] RL [mp]) 1, REPEAT(ares_tac [impI] 1)]);
clasohm@923
   171
clasohm@923
   172
qed_goalw "conjunct2" HOL.thy [and_def] "[| P & Q |] ==> Q"
clasohm@923
   173
 (fn prems =>
clasohm@923
   174
   [resolve_tac (prems RL [spec] RL [mp]) 1, REPEAT(ares_tac [impI] 1)]);
clasohm@923
   175
clasohm@923
   176
qed_goal "conjE" HOL.thy "[| P&Q;  [| P; Q |] ==> R |] ==> R"
clasohm@923
   177
 (fn prems =>
clasohm@1465
   178
         [cut_facts_tac prems 1, resolve_tac prems 1,
clasohm@1465
   179
          etac conjunct1 1, etac conjunct2 1]);
clasohm@923
   180
oheimb@1660
   181
clasohm@923
   182
(** Disjunction *)
oheimb@1660
   183
section "|";
clasohm@923
   184
clasohm@923
   185
qed_goalw "disjI1" HOL.thy [or_def] "P ==> P|Q"
clasohm@923
   186
 (fn [prem] => [REPEAT(ares_tac [allI,impI, prem RSN (2,mp)] 1)]);
clasohm@923
   187
clasohm@923
   188
qed_goalw "disjI2" HOL.thy [or_def] "Q ==> P|Q"
clasohm@923
   189
 (fn [prem] => [REPEAT(ares_tac [allI,impI, prem RSN (2,mp)] 1)]);
clasohm@923
   190
clasohm@923
   191
qed_goalw "disjE" HOL.thy [or_def] "[| P | Q; P ==> R; Q ==> R |] ==> R"
clasohm@923
   192
 (fn [a1,a2,a3] =>
clasohm@1465
   193
        [rtac (mp RS mp) 1, rtac spec 1, rtac a1 1,
clasohm@1465
   194
         rtac (a2 RS impI) 1, assume_tac 1, rtac (a3 RS impI) 1, assume_tac 1]);
clasohm@923
   195
oheimb@1660
   196
clasohm@923
   197
(** CCONTR -- classical logic **)
oheimb@1660
   198
section "classical logic";
clasohm@923
   199
clasohm@923
   200
qed_goalw "classical" HOL.thy [not_def]  "(~P ==> P) ==> P"
clasohm@923
   201
 (fn [prem] =>
clasohm@923
   202
   [rtac (True_or_False RS (disjE RS eqTrueE)) 1,  assume_tac 1,
clasohm@923
   203
    rtac (impI RS prem RS eqTrueI) 1,
clasohm@923
   204
    etac subst 1,  assume_tac 1]);
clasohm@923
   205
clasohm@923
   206
val ccontr = FalseE RS classical;
clasohm@923
   207
clasohm@923
   208
(*Double negation law*)
clasohm@923
   209
qed_goal "notnotD" HOL.thy "~~P ==> P"
clasohm@923
   210
 (fn [major]=>
clasohm@923
   211
  [ (rtac classical 1), (eresolve_tac [major RS notE] 1) ]);
clasohm@923
   212
oheimb@1660
   213
qed_goal "contrapos2" HOL.thy "[| Q; ~ P ==> ~ Q |] ==> P" (fn [p1,p2] => [
oheimb@1660
   214
	rtac classical 1,
oheimb@1660
   215
	dtac p2 1,
oheimb@1660
   216
	etac notE 1,
oheimb@1660
   217
	rtac p1 1]);
oheimb@1660
   218
oheimb@1660
   219
qed_goal "swap2" HOL.thy "[| P;  Q ==> ~ P |] ==> ~ Q" (fn [p1,p2] => [
oheimb@1660
   220
	rtac notI 1,
oheimb@1660
   221
	dtac p2 1,
oheimb@1660
   222
	etac notE 1,
oheimb@1660
   223
	rtac p1 1]);
clasohm@923
   224
clasohm@923
   225
(** Unique existence **)
oheimb@1660
   226
section "?!";
clasohm@923
   227
clasohm@923
   228
qed_goalw "ex1I" HOL.thy [Ex1_def]
oheimb@1660
   229
	    "[| P(a);  !!x. P(x) ==> x=a |] ==> ?! x. P(x)"
clasohm@923
   230
 (fn prems =>
clasohm@923
   231
  [REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)]);
clasohm@923
   232
clasohm@923
   233
qed_goalw "ex1E" HOL.thy [Ex1_def]
clasohm@923
   234
    "[| ?! x.P(x);  !!x. [| P(x);  ! y. P(y) --> y=x |] ==> R |] ==> R"
clasohm@923
   235
 (fn major::prems =>
clasohm@923
   236
  [rtac (major RS exE) 1, REPEAT (etac conjE 1 ORELSE ares_tac prems 1)]);
clasohm@923
   237
clasohm@923
   238
clasohm@923
   239
(** Select: Hilbert's Epsilon-operator **)
oheimb@1660
   240
section "@";
clasohm@923
   241
clasohm@923
   242
(*Easier to apply than selectI: conclusion has only one occurrence of P*)
clasohm@923
   243
qed_goal "selectI2" HOL.thy
clasohm@923
   244
    "[| P(a);  !!x. P(x) ==> Q(x) |] ==> Q(@x.P(x))"
clasohm@923
   245
 (fn prems => [ resolve_tac prems 1, 
clasohm@1465
   246
                rtac selectI 1, 
clasohm@1465
   247
                resolve_tac prems 1 ]);
clasohm@923
   248
clasohm@923
   249
qed_goal "select_equality" HOL.thy
clasohm@923
   250
    "[| P(a);  !!x. P(x) ==> x=a |] ==> (@x.P(x)) = a"
clasohm@923
   251
 (fn prems => [ rtac selectI2 1, 
clasohm@1465
   252
                REPEAT (ares_tac prems 1) ]);
clasohm@923
   253
oheimb@1660
   254
qed_goal "select_eq_Ex" HOL.thy "P (@ x. P x) =  (? x. P x)" (fn prems => [
oheimb@1660
   255
        rtac iffI 1,
oheimb@1660
   256
        etac exI 1,
oheimb@1660
   257
        etac exE 1,
oheimb@1660
   258
        etac selectI 1]);
oheimb@1660
   259
clasohm@923
   260
clasohm@923
   261
(** Classical intro rules for disjunction and existential quantifiers *)
oheimb@1660
   262
section "classical intro rules";
clasohm@923
   263
clasohm@923
   264
qed_goal "disjCI" HOL.thy "(~Q ==> P) ==> P|Q"
clasohm@923
   265
 (fn prems=>
clasohm@923
   266
  [ (rtac classical 1),
clasohm@923
   267
    (REPEAT (ares_tac (prems@[disjI1,notI]) 1)),
clasohm@923
   268
    (REPEAT (ares_tac (prems@[disjI2,notE]) 1)) ]);
clasohm@923
   269
clasohm@923
   270
qed_goal "excluded_middle" HOL.thy "~P | P"
clasohm@923
   271
 (fn _ => [ (REPEAT (ares_tac [disjCI] 1)) ]);
clasohm@923
   272
clasohm@923
   273
(*For disjunctive case analysis*)
clasohm@923
   274
fun excluded_middle_tac sP =
clasohm@923
   275
    res_inst_tac [("Q",sP)] (excluded_middle RS disjE);
clasohm@923
   276
clasohm@923
   277
(*Classical implies (-->) elimination. *)
clasohm@923
   278
qed_goal "impCE" HOL.thy "[| P-->Q; ~P ==> R; Q ==> R |] ==> R" 
clasohm@923
   279
 (fn major::prems=>
clasohm@923
   280
  [ rtac (excluded_middle RS disjE) 1,
clasohm@923
   281
    REPEAT (DEPTH_SOLVE_1 (ares_tac (prems @ [major RS mp]) 1))]);
clasohm@923
   282
clasohm@923
   283
(*Classical <-> elimination. *)
clasohm@923
   284
qed_goal "iffCE" HOL.thy
clasohm@923
   285
    "[| P=Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R"
clasohm@923
   286
 (fn major::prems =>
clasohm@923
   287
  [ (rtac (major RS iffE) 1),
clasohm@923
   288
    (REPEAT (DEPTH_SOLVE_1 
clasohm@1465
   289
        (eresolve_tac ([asm_rl,impCE,notE]@prems) 1))) ]);
clasohm@923
   290
clasohm@923
   291
qed_goal "exCI" HOL.thy "(! x. ~P(x) ==> P(a)) ==> ? x.P(x)"
clasohm@923
   292
 (fn prems=>
clasohm@923
   293
  [ (rtac ccontr 1),
clasohm@923
   294
    (REPEAT (ares_tac (prems@[exI,allI,notI,notE]) 1))  ]);
clasohm@923
   295
clasohm@923
   296
clasohm@923
   297
(* case distinction *)
clasohm@923
   298
clasohm@923
   299
qed_goal "case_split_thm" HOL.thy "[| P ==> Q; ~P ==> Q |] ==> Q"
clasohm@923
   300
  (fn [p1,p2] => [cut_facts_tac [excluded_middle] 1, etac disjE 1,
clasohm@923
   301
                  etac p2 1, etac p1 1]);
clasohm@923
   302
clasohm@923
   303
fun case_tac a = res_inst_tac [("P",a)] case_split_thm;
clasohm@923
   304
oheimb@1660
   305
clasohm@923
   306
(** Standard abbreviations **)
clasohm@923
   307
clasohm@923
   308
fun stac th = rtac(th RS ssubst);
clasohm@923
   309
fun strip_tac i = REPEAT(resolve_tac [impI,allI] i); 
clasohm@1338
   310
nipkow@1485
   311
(** strip proved goal while preserving !-bound var names **)
nipkow@1485
   312
nipkow@1485
   313
local
nipkow@1485
   314
nipkow@1515
   315
(* Use XXX to avoid forall_intr failing because of duplicate variable name *)
nipkow@1485
   316
val myspec = read_instantiate [("P","?XXX")] spec;
nipkow@1485
   317
val _ $ (_ $ (vx as Var(_,vxT))) = concl_of myspec;
nipkow@1485
   318
val cvx = cterm_of (#sign(rep_thm myspec)) vx;
nipkow@1485
   319
val aspec = forall_intr cvx myspec;
nipkow@1485
   320
nipkow@1485
   321
in
nipkow@1485
   322
nipkow@1515
   323
fun RSspec th =
nipkow@1515
   324
  (case concl_of th of
nipkow@1515
   325
     _ $ (Const("All",_) $ Abs(a,_,_)) =>
nipkow@1515
   326
         let val ca = cterm_of (#sign(rep_thm th)) (Var((a,0),vxT))
nipkow@1515
   327
         in th RS forall_elim ca aspec end
nipkow@1515
   328
  | _ => raise THM("RSspec",0,[th]));
nipkow@1515
   329
nipkow@1515
   330
fun RSmp th =
nipkow@1515
   331
  (case concl_of th of
nipkow@1515
   332
     _ $ (Const("op -->",_)$_$_) => th RS mp
nipkow@1515
   333
  | _ => raise THM("RSmp",0,[th]));
nipkow@1515
   334
nipkow@1515
   335
fun normalize_thm funs =
nipkow@1515
   336
let fun trans [] th = th
nipkow@1515
   337
      | trans (f::fs) th = (trans funs (f th)) handle THM _ => trans fs th
nipkow@1515
   338
in trans funs end;
nipkow@1515
   339
nipkow@1515
   340
fun qed_spec_mp name =
nipkow@1515
   341
  let val thm = normalize_thm [RSspec,RSmp] (result())
nipkow@1515
   342
  in bind_thm(name, thm) end;
nipkow@1485
   343
nipkow@1485
   344
end;
clasohm@1338
   345
oheimb@1660
   346
oheimb@1660
   347
clasohm@1338
   348
(*** Load simpdata.ML to be able to initialize HOL's simpset ***)
clasohm@1338
   349
oheimb@1660
   350
clasohm@1338
   351
(** Applying HypsubstFun to generate hyp_subst_tac **)
oheimb@1660
   352
section "Classical Reasoner";
clasohm@1338
   353
clasohm@1338
   354
structure Hypsubst_Data =
clasohm@1338
   355
  struct
clasohm@1338
   356
  structure Simplifier = Simplifier
clasohm@1338
   357
  (*Take apart an equality judgement; otherwise raise Match!*)
clasohm@1338
   358
  fun dest_eq (Const("Trueprop",_) $ (Const("op =",_)  $ t $ u)) = (t,u);
clasohm@1338
   359
  val eq_reflection = eq_reflection
clasohm@1338
   360
  val imp_intr = impI
clasohm@1338
   361
  val rev_mp = rev_mp
clasohm@1338
   362
  val subst = subst
clasohm@1338
   363
  val sym = sym
clasohm@1338
   364
  end;
clasohm@1338
   365
clasohm@1338
   366
structure Hypsubst = HypsubstFun(Hypsubst_Data);
clasohm@1338
   367
open Hypsubst;
clasohm@1338
   368
clasohm@1338
   369
(*** Applying ClassicalFun to create a classical prover ***)
clasohm@1338
   370
structure Classical_Data = 
clasohm@1338
   371
  struct
clasohm@1465
   372
  val sizef     = size_of_thm
clasohm@1465
   373
  val mp        = mp
clasohm@1465
   374
  val not_elim  = notE
clasohm@1465
   375
  val classical = classical
clasohm@1338
   376
  val hyp_subst_tacs=[hyp_subst_tac]
clasohm@1338
   377
  end;
clasohm@1338
   378
clasohm@1338
   379
structure Classical = ClassicalFun(Classical_Data);
clasohm@1338
   380
open Classical;
clasohm@1338
   381
clasohm@1338
   382
(*Propositional rules*)
clasohm@1338
   383
val prop_cs = empty_cs addSIs [refl,TrueI,conjI,disjCI,impI,notI,iffI]
clasohm@1338
   384
                       addSEs [conjE,disjE,impCE,FalseE,iffE];
clasohm@1338
   385
clasohm@1338
   386
(*Quantifier rules*)
clasohm@1338
   387
val HOL_cs = prop_cs addSIs [allI] addIs [exI,ex1I]
clasohm@1338
   388
                     addSEs [exE,ex1E] addEs [allE];
clasohm@1338
   389
oheimb@1660
   390
oheimb@1660
   391
section "Simplifier";
oheimb@1660
   392
clasohm@1338
   393
use     "simpdata.ML";
clasohm@1338
   394
simpset := HOL_ss;
clasohm@1455
   395
clasohm@1455
   396
clasohm@1455
   397
(** Install simpsets and datatypes in theory structure **)
clasohm@1455
   398
exception SS_DATA of simpset;
clasohm@1455
   399
clasohm@1455
   400
let fun merge [] = SS_DATA empty_ss
clasohm@1455
   401
      | merge ss = let val ss = map (fn SS_DATA x => x) ss;
clasohm@1455
   402
                   in SS_DATA (foldl merge_ss (hd ss, tl ss)) end;
clasohm@1455
   403
clasohm@1455
   404
    fun put (SS_DATA ss) = simpset := ss;
clasohm@1455
   405
clasohm@1455
   406
    fun get () = SS_DATA (!simpset);
clasohm@1657
   407
in add_thydata "HOL"
clasohm@1455
   408
     ("simpset", ThyMethods {merge = merge, put = put, get = get})
clasohm@1455
   409
end;
clasohm@1455
   410
clasohm@1668
   411
clasohm@1668
   412
type dtype_info = {case_const:term, case_rewrites:thm list,
clasohm@1668
   413
                   constructors:term list, nchotomy:thm, case_cong:thm};
clasohm@1668
   414
clasohm@1668
   415
exception DT_DATA of (string * dtype_info) list;
clasohm@1668
   416
val datatypes = ref [] : (string * dtype_info) list ref;
clasohm@1455
   417
clasohm@1455
   418
let fun merge [] = DT_DATA []
clasohm@1668
   419
      | merge ds =
clasohm@1668
   420
          let val ds = map (fn DT_DATA x => x) ds;
clasohm@1668
   421
          in DT_DATA (foldl (gen_union eq_fst) (hd ds, tl ds)) end;
clasohm@1455
   422
clasohm@1455
   423
    fun put (DT_DATA ds) = datatypes := ds;
clasohm@1455
   424
clasohm@1455
   425
    fun get () = DT_DATA (!datatypes);
clasohm@1657
   426
in add_thydata "HOL"
clasohm@1455
   427
     ("datatypes", ThyMethods {merge = merge, put = put, get = get})
clasohm@1455
   428
end;
clasohm@1455
   429
clasohm@1455
   430
clasohm@1455
   431
add_thy_reader_file "thy_data.ML";