| author | wenzelm | 
| Mon, 09 Jan 2012 18:29:42 +0100 | |
| changeset 46161 | 4ed94d92ae19 | 
| parent 46125 | 00cd193a48dc | 
| child 46190 | a42c5f23109f | 
| permissions | -rw-r--r-- | 
| 923 | 1  | 
(* Title: HOL/HOL.thy  | 
| 11750 | 2  | 
Author: Tobias Nipkow, Markus Wenzel, and Larry Paulson  | 
3  | 
*)  | 
|
| 923 | 4  | 
|
| 11750 | 5  | 
header {* The basis of Higher-Order Logic *}
 | 
| 923 | 6  | 
|
| 15131 | 7  | 
theory HOL  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
8  | 
imports Pure "~~/src/Tools/Code_Generator"  | 
| 23163 | 9  | 
uses  | 
| 
28952
 
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
 
haftmann 
parents: 
28856 
diff
changeset
 | 
10  | 
  ("Tools/hologic.ML")
 | 
| 23171 | 11  | 
"~~/src/Tools/IsaPlanner/zipper.ML"  | 
12  | 
"~~/src/Tools/IsaPlanner/isand.ML"  | 
|
13  | 
"~~/src/Tools/IsaPlanner/rw_tools.ML"  | 
|
14  | 
"~~/src/Tools/IsaPlanner/rw_inst.ML"  | 
|
| 
30165
 
6ee87f67d9cd
moved generic intuitionistic prover to src/Tools/intuitionistic.ML;
 
wenzelm 
parents: 
30160 
diff
changeset
 | 
15  | 
"~~/src/Tools/intuitionistic.ML"  | 
| 
30160
 
5f7b17941730
moved some generic tools to src/Tools/ -- src/Provers is essentially obsolete;
 
wenzelm 
parents: 
30063 
diff
changeset
 | 
16  | 
"~~/src/Tools/project_rule.ML"  | 
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
17  | 
"~~/src/Tools/cong_tac.ML"  | 
| 23263 | 18  | 
"~~/src/Provers/hypsubst.ML"  | 
19  | 
"~~/src/Provers/splitter.ML"  | 
|
| 23163 | 20  | 
"~~/src/Provers/classical.ML"  | 
21  | 
"~~/src/Provers/blast.ML"  | 
|
22  | 
"~~/src/Provers/clasimp.ML"  | 
|
| 
30160
 
5f7b17941730
moved some generic tools to src/Tools/ -- src/Provers is essentially obsolete;
 
wenzelm 
parents: 
30063 
diff
changeset
 | 
23  | 
"~~/src/Tools/coherent.ML"  | 
| 
 
5f7b17941730
moved some generic tools to src/Tools/ -- src/Provers is essentially obsolete;
 
wenzelm 
parents: 
30063 
diff
changeset
 | 
24  | 
"~~/src/Tools/eqsubst.ML"  | 
| 23163 | 25  | 
"~~/src/Provers/quantifier1.ML"  | 
| 
28952
 
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
 
haftmann 
parents: 
28856 
diff
changeset
 | 
26  | 
  ("Tools/simpdata.ML")
 | 
| 
26580
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
27  | 
"~~/src/Tools/atomize_elim.ML"  | 
| 
24901
 
d3cbf79769b9
added first version of user-space type system for class target
 
haftmann 
parents: 
24844 
diff
changeset
 | 
28  | 
"~~/src/Tools/induct.ML"  | 
| 
45014
 
0e847655b2d8
New proof method "induction" that gives induction hypotheses the name IH.
 
nipkow 
parents: 
44921 
diff
changeset
 | 
29  | 
  ("~~/src/Tools/induction.ML")
 | 
| 
27326
 
d3beec370964
moved src/HOL/Tools/induct_tacs.ML to src/Tools/induct_tacs.ML;
 
wenzelm 
parents: 
27212 
diff
changeset
 | 
30  | 
  ("~~/src/Tools/induct_tacs.ML")
 | 
| 
39036
 
dff91b90d74c
use definitional CNFs in Metis rather than plain CNF, following a suggestion by Joe Hurd;
 
blanchet 
parents: 
39014 
diff
changeset
 | 
31  | 
  ("Tools/cnf_funcs.ML")
 | 
| 
40939
 
2c150063cd4d
setup subtyping/coercions once in HOL.thy, but enable it only later via configuration option;
 
wenzelm 
parents: 
40858 
diff
changeset
 | 
32  | 
"~~/src/Tools/subtyping.ML"  | 
| 41827 | 33  | 
"~~/src/Tools/case_product.ML"  | 
| 15131 | 34  | 
begin  | 
| 2260 | 35  | 
|
| 31299 | 36  | 
setup {* Intuitionistic.method_setup @{binding iprover} *}
 | 
| 
40939
 
2c150063cd4d
setup subtyping/coercions once in HOL.thy, but enable it only later via configuration option;
 
wenzelm 
parents: 
40858 
diff
changeset
 | 
37  | 
setup Subtyping.setup  | 
| 41827 | 38  | 
setup Case_Product.setup  | 
| 33316 | 39  | 
|
| 
30165
 
6ee87f67d9cd
moved generic intuitionistic prover to src/Tools/intuitionistic.ML;
 
wenzelm 
parents: 
30160 
diff
changeset
 | 
40  | 
|
| 11750 | 41  | 
subsection {* Primitive logic *}
 | 
42  | 
||
43  | 
subsubsection {* Core syntax *}
 | 
|
| 2260 | 44  | 
|
| 14854 | 45  | 
classes type  | 
| 36452 | 46  | 
default_sort type  | 
| 35625 | 47  | 
setup {* Object_Logic.add_base_sort @{sort type} *}
 | 
| 
25460
 
b80087af2274
interpretation of typedecls: instantiation to class type
 
haftmann 
parents: 
25388 
diff
changeset
 | 
48  | 
|
| 
 
b80087af2274
interpretation of typedecls: instantiation to class type
 
haftmann 
parents: 
25388 
diff
changeset
 | 
49  | 
arities  | 
| 
 
b80087af2274
interpretation of typedecls: instantiation to class type
 
haftmann 
parents: 
25388 
diff
changeset
 | 
50  | 
"fun" :: (type, type) type  | 
| 
 
b80087af2274
interpretation of typedecls: instantiation to class type
 
haftmann 
parents: 
25388 
diff
changeset
 | 
51  | 
itself :: (type) type  | 
| 
 
b80087af2274
interpretation of typedecls: instantiation to class type
 
haftmann 
parents: 
25388 
diff
changeset
 | 
52  | 
|
| 7357 | 53  | 
typedecl bool  | 
| 923 | 54  | 
|
| 11750 | 55  | 
judgment  | 
56  | 
  Trueprop      :: "bool => prop"                   ("(_)" 5)
 | 
|
| 923 | 57  | 
|
| 11750 | 58  | 
consts  | 
| 7357 | 59  | 
True :: bool  | 
60  | 
False :: bool  | 
|
| 38547 | 61  | 
  Not           :: "bool => bool"                   ("~ _" [40] 40)
 | 
| 
38795
 
848be46708dc
formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
 
haftmann 
parents: 
38786 
diff
changeset
 | 
62  | 
|
| 
 
848be46708dc
formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
 
haftmann 
parents: 
38786 
diff
changeset
 | 
63  | 
conj :: "[bool, bool] => bool" (infixr "&" 35)  | 
| 
 
848be46708dc
formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
 
haftmann 
parents: 
38786 
diff
changeset
 | 
64  | 
disj :: "[bool, bool] => bool" (infixr "|" 30)  | 
| 
38786
 
e46e7a9cb622
formerly unnamed infix impliciation now named HOL.implies
 
haftmann 
parents: 
38773 
diff
changeset
 | 
65  | 
implies :: "[bool, bool] => bool" (infixr "-->" 25)  | 
| 38555 | 66  | 
|
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
67  | 
eq :: "['a, 'a] => bool" (infixl "=" 50)  | 
| 
38708
 
8915e3ce8655
discontinued obsolete 'global' and 'local' commands;
 
wenzelm 
parents: 
38669 
diff
changeset
 | 
68  | 
|
| 
11432
 
8a203ae6efe3
added "The" (definite description operator) (by Larry);
 
wenzelm 
parents: 
10489 
diff
changeset
 | 
69  | 
  The           :: "('a => bool) => 'a"
 | 
| 7357 | 70  | 
  All           :: "('a => bool) => bool"           (binder "ALL " 10)
 | 
71  | 
  Ex            :: "('a => bool) => bool"           (binder "EX " 10)
 | 
|
72  | 
  Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
 | 
|
| 923 | 73  | 
|
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
74  | 
|
| 11750 | 75  | 
subsubsection {* Additional concrete syntax *}
 | 
| 2260 | 76  | 
|
| 21210 | 77  | 
notation (output)  | 
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
78  | 
eq (infix "=" 50)  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
79  | 
|
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
80  | 
abbreviation  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21250 
diff
changeset
 | 
81  | 
not_equal :: "['a, 'a] => bool" (infixl "~=" 50) where  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
82  | 
"x ~= y == ~ (x = y)"  | 
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
83  | 
|
| 21210 | 84  | 
notation (output)  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
85  | 
not_equal (infix "~=" 50)  | 
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
86  | 
|
| 21210 | 87  | 
notation (xsymbols)  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21250 
diff
changeset
 | 
88  | 
  Not  ("\<not> _" [40] 40) and
 | 
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
89  | 
conj (infixr "\<and>" 35) and  | 
| 
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
90  | 
disj (infixr "\<or>" 30) and  | 
| 
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
91  | 
implies (infixr "\<longrightarrow>" 25) and  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
92  | 
not_equal (infix "\<noteq>" 50)  | 
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
93  | 
|
| 21210 | 94  | 
notation (HTML output)  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21250 
diff
changeset
 | 
95  | 
  Not  ("\<not> _" [40] 40) and
 | 
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
96  | 
conj (infixr "\<and>" 35) and  | 
| 
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
97  | 
disj (infixr "\<or>" 30) and  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
98  | 
not_equal (infix "\<noteq>" 50)  | 
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
99  | 
|
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
100  | 
abbreviation (iff)  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21250 
diff
changeset
 | 
101  | 
iff :: "[bool, bool] => bool" (infixr "<->" 25) where  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
102  | 
"A <-> B == A = B"  | 
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
103  | 
|
| 21210 | 104  | 
notation (xsymbols)  | 
| 
19656
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
105  | 
iff (infixr "\<longleftrightarrow>" 25)  | 
| 
 
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
 
wenzelm 
parents: 
19607 
diff
changeset
 | 
106  | 
|
| 
46125
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
107  | 
syntax  | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
108  | 
  "_The" :: "[pttrn, bool] => 'a"  ("(3THE _./ _)" [0, 10] 10)
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
109  | 
translations  | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
110  | 
"THE x. P" == "CONST The (%x. P)"  | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
111  | 
print_translation {*
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
112  | 
  [(@{const_syntax The}, fn [Abs abs] =>
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
113  | 
let val (x, t) = Syntax_Trans.atomic_abs_tr' abs  | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
114  | 
      in Syntax.const @{syntax_const "_The"} $ x $ t end)]
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
115  | 
*}  -- {* To avoid eta-contraction of body *}
 | 
| 923 | 116  | 
|
| 
46125
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
117  | 
nonterminal letbinds and letbind  | 
| 923 | 118  | 
syntax  | 
| 7357 | 119  | 
  "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
 | 
120  | 
  ""            :: "letbind => letbinds"                 ("_")
 | 
|
121  | 
  "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
 | 
|
| 36363 | 122  | 
  "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" [0, 10] 10)
 | 
| 923 | 123  | 
|
| 
46125
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
124  | 
nonterminal case_syn and cases_syn  | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
125  | 
syntax  | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
126  | 
  "_case_syntax" :: "['a, cases_syn] => 'b"  ("(case _ of/ _)" 10)
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
127  | 
  "_case1" :: "['a, 'b] => case_syn"  ("(2_ =>/ _)" 10)
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
128  | 
  "" :: "case_syn => cases_syn"  ("_")
 | 
| 
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
129  | 
  "_case2" :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
 | 
| 
42057
 
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
 
wenzelm 
parents: 
41865 
diff
changeset
 | 
130  | 
syntax (xsymbols)  | 
| 
46125
 
00cd193a48dc
improved case syntax: more careful treatment of position constraints, which enables PIDE markup;
 
wenzelm 
parents: 
45654 
diff
changeset
 | 
131  | 
  "_case1" :: "['a, 'b] => case_syn"  ("(2_ \<Rightarrow>/ _)" 10)
 | 
| 
13763
 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
 
nipkow 
parents: 
13723 
diff
changeset
 | 
132  | 
|
| 21524 | 133  | 
notation (xsymbols)  | 
134  | 
All (binder "\<forall>" 10) and  | 
|
135  | 
Ex (binder "\<exists>" 10) and  | 
|
136  | 
Ex1 (binder "\<exists>!" 10)  | 
|
| 2372 | 137  | 
|
| 21524 | 138  | 
notation (HTML output)  | 
139  | 
All (binder "\<forall>" 10) and  | 
|
140  | 
Ex (binder "\<exists>" 10) and  | 
|
141  | 
Ex1 (binder "\<exists>!" 10)  | 
|
| 6340 | 142  | 
|
| 21524 | 143  | 
notation (HOL)  | 
144  | 
All (binder "! " 10) and  | 
|
145  | 
Ex (binder "? " 10) and  | 
|
146  | 
Ex1 (binder "?! " 10)  | 
|
| 
7238
 
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
 
wenzelm 
parents: 
7220 
diff
changeset
 | 
147  | 
|
| 
 
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
 
wenzelm 
parents: 
7220 
diff
changeset
 | 
148  | 
|
| 11750 | 149  | 
subsubsection {* Axioms and basic definitions *}
 | 
| 2260 | 150  | 
|
| 7357 | 151  | 
axioms  | 
| 15380 | 152  | 
refl: "t = (t::'a)"  | 
| 28513 | 153  | 
subst: "s = t \<Longrightarrow> P s \<Longrightarrow> P t"  | 
| 15380 | 154  | 
ext: "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"  | 
155  | 
    -- {*Extensionality is built into the meta-logic, and this rule expresses
 | 
|
156  | 
a related property. It is an eta-expanded version of the traditional  | 
|
157  | 
rule, and similar to the ABS rule of HOL*}  | 
|
| 6289 | 158  | 
|
| 
11432
 
8a203ae6efe3
added "The" (definite description operator) (by Larry);
 
wenzelm 
parents: 
10489 
diff
changeset
 | 
159  | 
the_eq_trivial: "(THE x. x = a) = (a::'a)"  | 
| 923 | 160  | 
|
| 15380 | 161  | 
impI: "(P ==> Q) ==> P-->Q"  | 
162  | 
mp: "[| P-->Q; P |] ==> Q"  | 
|
163  | 
||
164  | 
||
| 923 | 165  | 
defs  | 
| 7357 | 166  | 
True_def: "True == ((%x::bool. x) = (%x. x))"  | 
167  | 
All_def: "All(P) == (P = (%x. True))"  | 
|
| 
11451
 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 
paulson 
parents: 
11438 
diff
changeset
 | 
168  | 
Ex_def: "Ex(P) == !Q. (!x. P x --> Q) --> Q"  | 
| 7357 | 169  | 
False_def: "False == (!P. P)"  | 
170  | 
not_def: "~ P == P-->False"  | 
|
171  | 
and_def: "P & Q == !R. (P-->Q-->R) --> R"  | 
|
172  | 
or_def: "P | Q == !R. (P-->R) --> (Q-->R) --> R"  | 
|
173  | 
Ex1_def: "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)"  | 
|
| 923 | 174  | 
|
| 7357 | 175  | 
axioms  | 
176  | 
iff: "(P-->Q) --> (Q-->P) --> (P=Q)"  | 
|
177  | 
True_or_False: "(P=True) | (P=False)"  | 
|
| 923 | 178  | 
|
| 
14223
 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
 
skalberg 
parents: 
14208 
diff
changeset
 | 
179  | 
finalconsts  | 
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
180  | 
eq  | 
| 
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
181  | 
implies  | 
| 
14223
 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
 
skalberg 
parents: 
14208 
diff
changeset
 | 
182  | 
The  | 
| 
22481
 
79c2724c36b5
added class "default" and expansion axioms for undefined
 
haftmann 
parents: 
22473 
diff
changeset
 | 
183  | 
|
| 38525 | 184  | 
definition If :: "bool \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" ("(if (_)/ then (_)/ else (_))" [0, 0, 10] 10) where
 | 
185  | 
"If P x y \<equiv> (THE z::'a. (P=True --> z=x) & (P=False --> z=y))"  | 
|
186  | 
||
187  | 
definition Let :: "'a \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b" where
 | 
|
188  | 
"Let s f \<equiv> f s"  | 
|
189  | 
||
190  | 
translations  | 
|
191  | 
"_Let (_binds b bs) e" == "_Let b (_Let bs e)"  | 
|
192  | 
"let x = a in e" == "CONST Let a (%x. e)"  | 
|
193  | 
||
| 
22481
 
79c2724c36b5
added class "default" and expansion axioms for undefined
 
haftmann 
parents: 
22473 
diff
changeset
 | 
194  | 
axiomatization  | 
| 
 
79c2724c36b5
added class "default" and expansion axioms for undefined
 
haftmann 
parents: 
22473 
diff
changeset
 | 
195  | 
undefined :: 'a  | 
| 
 
79c2724c36b5
added class "default" and expansion axioms for undefined
 
haftmann 
parents: 
22473 
diff
changeset
 | 
196  | 
|
| 29608 | 197  | 
class default =  | 
| 
24901
 
d3cbf79769b9
added first version of user-space type system for class target
 
haftmann 
parents: 
24844 
diff
changeset
 | 
198  | 
fixes default :: 'a  | 
| 4868 | 199  | 
|
| 11750 | 200  | 
|
| 20944 | 201  | 
subsection {* Fundamental rules *}
 | 
202  | 
||
| 20973 | 203  | 
subsubsection {* Equality *}
 | 
| 20944 | 204  | 
|
| 18457 | 205  | 
lemma sym: "s = t ==> t = s"  | 
206  | 
by (erule subst) (rule refl)  | 
|
| 15411 | 207  | 
|
| 18457 | 208  | 
lemma ssubst: "t = s ==> P s ==> P t"  | 
209  | 
by (drule sym) (erule subst)  | 
|
| 15411 | 210  | 
|
211  | 
lemma trans: "[| r=s; s=t |] ==> r=t"  | 
|
| 18457 | 212  | 
by (erule subst)  | 
| 15411 | 213  | 
|
| 
40715
 
3ba17f07b23c
lemma trans_sym allows single-step "normalization" in Isar, e.g. via moreover/ultimately;
 
wenzelm 
parents: 
40582 
diff
changeset
 | 
214  | 
lemma trans_sym [Pure.elim?]: "r = s ==> t = s ==> r = t"  | 
| 
 
3ba17f07b23c
lemma trans_sym allows single-step "normalization" in Isar, e.g. via moreover/ultimately;
 
wenzelm 
parents: 
40582 
diff
changeset
 | 
215  | 
by (rule trans [OF _ sym])  | 
| 
 
3ba17f07b23c
lemma trans_sym allows single-step "normalization" in Isar, e.g. via moreover/ultimately;
 
wenzelm 
parents: 
40582 
diff
changeset
 | 
216  | 
|
| 20944 | 217  | 
lemma meta_eq_to_obj_eq:  | 
218  | 
assumes meq: "A == B"  | 
|
219  | 
shows "A = B"  | 
|
220  | 
by (unfold meq) (rule refl)  | 
|
| 15411 | 221  | 
|
| 21502 | 222  | 
text {* Useful with @{text erule} for proving equalities from known equalities. *}
 | 
| 20944 | 223  | 
(* a = b  | 
| 15411 | 224  | 
| |  | 
225  | 
c = d *)  | 
|
226  | 
lemma box_equals: "[| a=b; a=c; b=d |] ==> c=d"  | 
|
227  | 
apply (rule trans)  | 
|
228  | 
apply (rule trans)  | 
|
229  | 
apply (rule sym)  | 
|
230  | 
apply assumption+  | 
|
231  | 
done  | 
|
232  | 
||
| 
15524
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
233  | 
text {* For calculational reasoning: *}
 | 
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
234  | 
|
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
235  | 
lemma forw_subst: "a = b ==> P b ==> P a"  | 
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
236  | 
by (rule ssubst)  | 
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
237  | 
|
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
238  | 
lemma back_subst: "P a ==> a = b ==> P b"  | 
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
239  | 
by (rule subst)  | 
| 
 
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
 
nipkow 
parents: 
15481 
diff
changeset
 | 
240  | 
|
| 15411 | 241  | 
|
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
242  | 
subsubsection {* Congruence rules for application *}
 | 
| 15411 | 243  | 
|
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
244  | 
text {* Similar to @{text AP_THM} in Gordon's HOL. *}
 | 
| 15411 | 245  | 
lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)"  | 
246  | 
apply (erule subst)  | 
|
247  | 
apply (rule refl)  | 
|
248  | 
done  | 
|
249  | 
||
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
250  | 
text {* Similar to @{text AP_TERM} in Gordon's HOL and FOL's @{text subst_context}. *}
 | 
| 15411 | 251  | 
lemma arg_cong: "x=y ==> f(x)=f(y)"  | 
252  | 
apply (erule subst)  | 
|
253  | 
apply (rule refl)  | 
|
254  | 
done  | 
|
255  | 
||
| 15655 | 256  | 
lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d"  | 
257  | 
apply (erule ssubst)+  | 
|
258  | 
apply (rule refl)  | 
|
259  | 
done  | 
|
260  | 
||
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
261  | 
lemma cong: "[| f = g; (x::'a) = y |] ==> f x = g y"  | 
| 15411 | 262  | 
apply (erule subst)+  | 
263  | 
apply (rule refl)  | 
|
264  | 
done  | 
|
265  | 
||
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
266  | 
ML {* val cong_tac = Cong_Tac.cong_tac @{thm cong} *}
 | 
| 15411 | 267  | 
|
| 
32733
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
268  | 
|
| 
 
71618deaf777
moved generic cong_tac from HOL/Tools/datatype_aux.ML to Tools/cong_tac.ML, proper subgoal selection (failure, not exception);
 
wenzelm 
parents: 
32668 
diff
changeset
 | 
269  | 
subsubsection {* Equality of booleans -- iff *}
 | 
| 15411 | 270  | 
|
| 21504 | 271  | 
lemma iffI: assumes "P ==> Q" and "Q ==> P" shows "P=Q"  | 
272  | 
by (iprover intro: iff [THEN mp, THEN mp] impI assms)  | 
|
| 15411 | 273  | 
|
274  | 
lemma iffD2: "[| P=Q; Q |] ==> P"  | 
|
| 18457 | 275  | 
by (erule ssubst)  | 
| 15411 | 276  | 
|
277  | 
lemma rev_iffD2: "[| Q; P=Q |] ==> P"  | 
|
| 18457 | 278  | 
by (erule iffD2)  | 
| 15411 | 279  | 
|
| 21504 | 280  | 
lemma iffD1: "Q = P \<Longrightarrow> Q \<Longrightarrow> P"  | 
281  | 
by (drule sym) (rule iffD2)  | 
|
282  | 
||
283  | 
lemma rev_iffD1: "Q \<Longrightarrow> Q = P \<Longrightarrow> P"  | 
|
284  | 
by (drule sym) (rule rev_iffD2)  | 
|
| 15411 | 285  | 
|
286  | 
lemma iffE:  | 
|
287  | 
assumes major: "P=Q"  | 
|
| 21504 | 288  | 
and minor: "[| P --> Q; Q --> P |] ==> R"  | 
| 18457 | 289  | 
shows R  | 
290  | 
by (iprover intro: minor impI major [THEN iffD2] major [THEN iffD1])  | 
|
| 15411 | 291  | 
|
292  | 
||
| 20944 | 293  | 
subsubsection {*True*}
 | 
| 15411 | 294  | 
|
295  | 
lemma TrueI: "True"  | 
|
| 21504 | 296  | 
unfolding True_def by (rule refl)  | 
| 15411 | 297  | 
|
| 21504 | 298  | 
lemma eqTrueI: "P ==> P = True"  | 
| 18457 | 299  | 
by (iprover intro: iffI TrueI)  | 
| 15411 | 300  | 
|
| 21504 | 301  | 
lemma eqTrueE: "P = True ==> P"  | 
302  | 
by (erule iffD2) (rule TrueI)  | 
|
| 15411 | 303  | 
|
304  | 
||
| 20944 | 305  | 
subsubsection {*Universal quantifier*}
 | 
| 15411 | 306  | 
|
| 21504 | 307  | 
lemma allI: assumes "!!x::'a. P(x)" shows "ALL x. P(x)"  | 
308  | 
unfolding All_def by (iprover intro: ext eqTrueI assms)  | 
|
| 15411 | 309  | 
|
310  | 
lemma spec: "ALL x::'a. P(x) ==> P(x)"  | 
|
311  | 
apply (unfold All_def)  | 
|
312  | 
apply (rule eqTrueE)  | 
|
313  | 
apply (erule fun_cong)  | 
|
314  | 
done  | 
|
315  | 
||
316  | 
lemma allE:  | 
|
317  | 
assumes major: "ALL x. P(x)"  | 
|
| 21504 | 318  | 
and minor: "P(x) ==> R"  | 
319  | 
shows R  | 
|
320  | 
by (iprover intro: minor major [THEN spec])  | 
|
| 15411 | 321  | 
|
322  | 
lemma all_dupE:  | 
|
323  | 
assumes major: "ALL x. P(x)"  | 
|
| 21504 | 324  | 
and minor: "[| P(x); ALL x. P(x) |] ==> R"  | 
325  | 
shows R  | 
|
326  | 
by (iprover intro: minor major major [THEN spec])  | 
|
| 15411 | 327  | 
|
328  | 
||
| 21504 | 329  | 
subsubsection {* False *}
 | 
330  | 
||
331  | 
text {*
 | 
|
332  | 
  Depends upon @{text spec}; it is impossible to do propositional
 | 
|
333  | 
logic before quantifiers!  | 
|
334  | 
*}  | 
|
| 15411 | 335  | 
|
336  | 
lemma FalseE: "False ==> P"  | 
|
| 21504 | 337  | 
apply (unfold False_def)  | 
338  | 
apply (erule spec)  | 
|
339  | 
done  | 
|
| 15411 | 340  | 
|
| 21504 | 341  | 
lemma False_neq_True: "False = True ==> P"  | 
342  | 
by (erule eqTrueE [THEN FalseE])  | 
|
| 15411 | 343  | 
|
344  | 
||
| 21504 | 345  | 
subsubsection {* Negation *}
 | 
| 15411 | 346  | 
|
347  | 
lemma notI:  | 
|
| 21504 | 348  | 
assumes "P ==> False"  | 
| 15411 | 349  | 
shows "~P"  | 
| 21504 | 350  | 
apply (unfold not_def)  | 
351  | 
apply (iprover intro: impI assms)  | 
|
352  | 
done  | 
|
| 15411 | 353  | 
|
354  | 
lemma False_not_True: "False ~= True"  | 
|
| 21504 | 355  | 
apply (rule notI)  | 
356  | 
apply (erule False_neq_True)  | 
|
357  | 
done  | 
|
| 15411 | 358  | 
|
359  | 
lemma True_not_False: "True ~= False"  | 
|
| 21504 | 360  | 
apply (rule notI)  | 
361  | 
apply (drule sym)  | 
|
362  | 
apply (erule False_neq_True)  | 
|
363  | 
done  | 
|
| 15411 | 364  | 
|
365  | 
lemma notE: "[| ~P; P |] ==> R"  | 
|
| 21504 | 366  | 
apply (unfold not_def)  | 
367  | 
apply (erule mp [THEN FalseE])  | 
|
368  | 
apply assumption  | 
|
369  | 
done  | 
|
| 15411 | 370  | 
|
| 21504 | 371  | 
lemma notI2: "(P \<Longrightarrow> \<not> Pa) \<Longrightarrow> (P \<Longrightarrow> Pa) \<Longrightarrow> \<not> P"  | 
372  | 
by (erule notE [THEN notI]) (erule meta_mp)  | 
|
| 15411 | 373  | 
|
374  | 
||
| 20944 | 375  | 
subsubsection {*Implication*}
 | 
| 15411 | 376  | 
|
377  | 
lemma impE:  | 
|
378  | 
assumes "P-->Q" "P" "Q ==> R"  | 
|
379  | 
shows "R"  | 
|
| 23553 | 380  | 
by (iprover intro: assms mp)  | 
| 15411 | 381  | 
|
382  | 
(* Reduces Q to P-->Q, allowing substitution in P. *)  | 
|
383  | 
lemma rev_mp: "[| P; P --> Q |] ==> Q"  | 
|
| 17589 | 384  | 
by (iprover intro: mp)  | 
| 15411 | 385  | 
|
386  | 
lemma contrapos_nn:  | 
|
387  | 
assumes major: "~Q"  | 
|
388  | 
and minor: "P==>Q"  | 
|
389  | 
shows "~P"  | 
|
| 17589 | 390  | 
by (iprover intro: notI minor major [THEN notE])  | 
| 15411 | 391  | 
|
392  | 
(*not used at all, but we already have the other 3 combinations *)  | 
|
393  | 
lemma contrapos_pn:  | 
|
394  | 
assumes major: "Q"  | 
|
395  | 
and minor: "P ==> ~Q"  | 
|
396  | 
shows "~P"  | 
|
| 17589 | 397  | 
by (iprover intro: notI minor major notE)  | 
| 15411 | 398  | 
|
399  | 
lemma not_sym: "t ~= s ==> s ~= t"  | 
|
| 21250 | 400  | 
by (erule contrapos_nn) (erule sym)  | 
401  | 
||
402  | 
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"  | 
|
403  | 
by (erule subst, erule ssubst, assumption)  | 
|
| 15411 | 404  | 
|
405  | 
(*still used in HOLCF*)  | 
|
406  | 
lemma rev_contrapos:  | 
|
407  | 
assumes pq: "P ==> Q"  | 
|
408  | 
and nq: "~Q"  | 
|
409  | 
shows "~P"  | 
|
410  | 
apply (rule nq [THEN contrapos_nn])  | 
|
411  | 
apply (erule pq)  | 
|
412  | 
done  | 
|
413  | 
||
| 20944 | 414  | 
subsubsection {*Existential quantifier*}
 | 
| 15411 | 415  | 
|
416  | 
lemma exI: "P x ==> EX x::'a. P x"  | 
|
417  | 
apply (unfold Ex_def)  | 
|
| 17589 | 418  | 
apply (iprover intro: allI allE impI mp)  | 
| 15411 | 419  | 
done  | 
420  | 
||
421  | 
lemma exE:  | 
|
422  | 
assumes major: "EX x::'a. P(x)"  | 
|
423  | 
and minor: "!!x. P(x) ==> Q"  | 
|
424  | 
shows "Q"  | 
|
425  | 
apply (rule major [unfolded Ex_def, THEN spec, THEN mp])  | 
|
| 17589 | 426  | 
apply (iprover intro: impI [THEN allI] minor)  | 
| 15411 | 427  | 
done  | 
428  | 
||
429  | 
||
| 20944 | 430  | 
subsubsection {*Conjunction*}
 | 
| 15411 | 431  | 
|
432  | 
lemma conjI: "[| P; Q |] ==> P&Q"  | 
|
433  | 
apply (unfold and_def)  | 
|
| 17589 | 434  | 
apply (iprover intro: impI [THEN allI] mp)  | 
| 15411 | 435  | 
done  | 
436  | 
||
437  | 
lemma conjunct1: "[| P & Q |] ==> P"  | 
|
438  | 
apply (unfold and_def)  | 
|
| 17589 | 439  | 
apply (iprover intro: impI dest: spec mp)  | 
| 15411 | 440  | 
done  | 
441  | 
||
442  | 
lemma conjunct2: "[| P & Q |] ==> Q"  | 
|
443  | 
apply (unfold and_def)  | 
|
| 17589 | 444  | 
apply (iprover intro: impI dest: spec mp)  | 
| 15411 | 445  | 
done  | 
446  | 
||
447  | 
lemma conjE:  | 
|
448  | 
assumes major: "P&Q"  | 
|
449  | 
and minor: "[| P; Q |] ==> R"  | 
|
450  | 
shows "R"  | 
|
451  | 
apply (rule minor)  | 
|
452  | 
apply (rule major [THEN conjunct1])  | 
|
453  | 
apply (rule major [THEN conjunct2])  | 
|
454  | 
done  | 
|
455  | 
||
456  | 
lemma context_conjI:  | 
|
| 23553 | 457  | 
assumes "P" "P ==> Q" shows "P & Q"  | 
458  | 
by (iprover intro: conjI assms)  | 
|
| 15411 | 459  | 
|
460  | 
||
| 20944 | 461  | 
subsubsection {*Disjunction*}
 | 
| 15411 | 462  | 
|
463  | 
lemma disjI1: "P ==> P|Q"  | 
|
464  | 
apply (unfold or_def)  | 
|
| 17589 | 465  | 
apply (iprover intro: allI impI mp)  | 
| 15411 | 466  | 
done  | 
467  | 
||
468  | 
lemma disjI2: "Q ==> P|Q"  | 
|
469  | 
apply (unfold or_def)  | 
|
| 17589 | 470  | 
apply (iprover intro: allI impI mp)  | 
| 15411 | 471  | 
done  | 
472  | 
||
473  | 
lemma disjE:  | 
|
474  | 
assumes major: "P|Q"  | 
|
475  | 
and minorP: "P ==> R"  | 
|
476  | 
and minorQ: "Q ==> R"  | 
|
477  | 
shows "R"  | 
|
| 17589 | 478  | 
by (iprover intro: minorP minorQ impI  | 
| 15411 | 479  | 
major [unfolded or_def, THEN spec, THEN mp, THEN mp])  | 
480  | 
||
481  | 
||
| 20944 | 482  | 
subsubsection {*Classical logic*}
 | 
| 15411 | 483  | 
|
484  | 
lemma classical:  | 
|
485  | 
assumes prem: "~P ==> P"  | 
|
486  | 
shows "P"  | 
|
487  | 
apply (rule True_or_False [THEN disjE, THEN eqTrueE])  | 
|
488  | 
apply assumption  | 
|
489  | 
apply (rule notI [THEN prem, THEN eqTrueI])  | 
|
490  | 
apply (erule subst)  | 
|
491  | 
apply assumption  | 
|
492  | 
done  | 
|
493  | 
||
| 45607 | 494  | 
lemmas ccontr = FalseE [THEN classical]  | 
| 15411 | 495  | 
|
496  | 
(*notE with premises exchanged; it discharges ~R so that it can be used to  | 
|
497  | 
make elimination rules*)  | 
|
498  | 
lemma rev_notE:  | 
|
499  | 
assumes premp: "P"  | 
|
500  | 
and premnot: "~R ==> ~P"  | 
|
501  | 
shows "R"  | 
|
502  | 
apply (rule ccontr)  | 
|
503  | 
apply (erule notE [OF premnot premp])  | 
|
504  | 
done  | 
|
505  | 
||
506  | 
(*Double negation law*)  | 
|
507  | 
lemma notnotD: "~~P ==> P"  | 
|
508  | 
apply (rule classical)  | 
|
509  | 
apply (erule notE)  | 
|
510  | 
apply assumption  | 
|
511  | 
done  | 
|
512  | 
||
513  | 
lemma contrapos_pp:  | 
|
514  | 
assumes p1: "Q"  | 
|
515  | 
and p2: "~P ==> ~Q"  | 
|
516  | 
shows "P"  | 
|
| 17589 | 517  | 
by (iprover intro: classical p1 p2 notE)  | 
| 15411 | 518  | 
|
519  | 
||
| 20944 | 520  | 
subsubsection {*Unique existence*}
 | 
| 15411 | 521  | 
|
522  | 
lemma ex1I:  | 
|
| 23553 | 523  | 
assumes "P a" "!!x. P(x) ==> x=a"  | 
| 15411 | 524  | 
shows "EX! x. P(x)"  | 
| 23553 | 525  | 
by (unfold Ex1_def, iprover intro: assms exI conjI allI impI)  | 
| 15411 | 526  | 
|
527  | 
text{*Sometimes easier to use: the premises have no shared variables.  Safe!*}
 | 
|
528  | 
lemma ex_ex1I:  | 
|
529  | 
assumes ex_prem: "EX x. P(x)"  | 
|
530  | 
and eq: "!!x y. [| P(x); P(y) |] ==> x=y"  | 
|
531  | 
shows "EX! x. P(x)"  | 
|
| 17589 | 532  | 
by (iprover intro: ex_prem [THEN exE] ex1I eq)  | 
| 15411 | 533  | 
|
534  | 
lemma ex1E:  | 
|
535  | 
assumes major: "EX! x. P(x)"  | 
|
536  | 
and minor: "!!x. [| P(x); ALL y. P(y) --> y=x |] ==> R"  | 
|
537  | 
shows "R"  | 
|
538  | 
apply (rule major [unfolded Ex1_def, THEN exE])  | 
|
539  | 
apply (erule conjE)  | 
|
| 17589 | 540  | 
apply (iprover intro: minor)  | 
| 15411 | 541  | 
done  | 
542  | 
||
543  | 
lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x"  | 
|
544  | 
apply (erule ex1E)  | 
|
545  | 
apply (rule exI)  | 
|
546  | 
apply assumption  | 
|
547  | 
done  | 
|
548  | 
||
549  | 
||
| 20944 | 550  | 
subsubsection {*THE: definite description operator*}
 | 
| 15411 | 551  | 
|
552  | 
lemma the_equality:  | 
|
553  | 
assumes prema: "P a"  | 
|
554  | 
and premx: "!!x. P x ==> x=a"  | 
|
555  | 
shows "(THE x. P x) = a"  | 
|
556  | 
apply (rule trans [OF _ the_eq_trivial])  | 
|
557  | 
apply (rule_tac f = "The" in arg_cong)  | 
|
558  | 
apply (rule ext)  | 
|
559  | 
apply (rule iffI)  | 
|
560  | 
apply (erule premx)  | 
|
561  | 
apply (erule ssubst, rule prema)  | 
|
562  | 
done  | 
|
563  | 
||
564  | 
lemma theI:  | 
|
565  | 
assumes "P a" and "!!x. P x ==> x=a"  | 
|
566  | 
shows "P (THE x. P x)"  | 
|
| 23553 | 567  | 
by (iprover intro: assms the_equality [THEN ssubst])  | 
| 15411 | 568  | 
|
569  | 
lemma theI': "EX! x. P x ==> P (THE x. P x)"  | 
|
570  | 
apply (erule ex1E)  | 
|
571  | 
apply (erule theI)  | 
|
572  | 
apply (erule allE)  | 
|
573  | 
apply (erule mp)  | 
|
574  | 
apply assumption  | 
|
575  | 
done  | 
|
576  | 
||
577  | 
(*Easier to apply than theI: only one occurrence of P*)  | 
|
578  | 
lemma theI2:  | 
|
579  | 
assumes "P a" "!!x. P x ==> x=a" "!!x. P x ==> Q x"  | 
|
580  | 
shows "Q (THE x. P x)"  | 
|
| 23553 | 581  | 
by (iprover intro: assms theI)  | 
| 15411 | 582  | 
|
| 24553 | 583  | 
lemma the1I2: assumes "EX! x. P x" "\<And>x. P x \<Longrightarrow> Q x" shows "Q (THE x. P x)"  | 
584  | 
by(iprover intro:assms(2) theI2[where P=P and Q=Q] ex1E[OF assms(1)]  | 
|
585  | 
elim:allE impE)  | 
|
586  | 
||
| 18697 | 587  | 
lemma the1_equality [elim?]: "[| EX!x. P x; P a |] ==> (THE x. P x) = a"  | 
| 15411 | 588  | 
apply (rule the_equality)  | 
589  | 
apply assumption  | 
|
590  | 
apply (erule ex1E)  | 
|
591  | 
apply (erule all_dupE)  | 
|
592  | 
apply (drule mp)  | 
|
593  | 
apply assumption  | 
|
594  | 
apply (erule ssubst)  | 
|
595  | 
apply (erule allE)  | 
|
596  | 
apply (erule mp)  | 
|
597  | 
apply assumption  | 
|
598  | 
done  | 
|
599  | 
||
600  | 
lemma the_sym_eq_trivial: "(THE y. x=y) = x"  | 
|
601  | 
apply (rule the_equality)  | 
|
602  | 
apply (rule refl)  | 
|
603  | 
apply (erule sym)  | 
|
604  | 
done  | 
|
605  | 
||
606  | 
||
| 20944 | 607  | 
subsubsection {*Classical intro rules for disjunction and existential quantifiers*}
 | 
| 15411 | 608  | 
|
609  | 
lemma disjCI:  | 
|
610  | 
assumes "~Q ==> P" shows "P|Q"  | 
|
611  | 
apply (rule classical)  | 
|
| 23553 | 612  | 
apply (iprover intro: assms disjI1 disjI2 notI elim: notE)  | 
| 15411 | 613  | 
done  | 
614  | 
||
615  | 
lemma excluded_middle: "~P | P"  | 
|
| 17589 | 616  | 
by (iprover intro: disjCI)  | 
| 15411 | 617  | 
|
| 20944 | 618  | 
text {*
 | 
619  | 
case distinction as a natural deduction rule.  | 
|
620  | 
  Note that @{term "~P"} is the second case, not the first
 | 
|
621  | 
*}  | 
|
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
622  | 
lemma case_split [case_names True False]:  | 
| 15411 | 623  | 
assumes prem1: "P ==> Q"  | 
624  | 
and prem2: "~P ==> Q"  | 
|
625  | 
shows "Q"  | 
|
626  | 
apply (rule excluded_middle [THEN disjE])  | 
|
627  | 
apply (erule prem2)  | 
|
628  | 
apply (erule prem1)  | 
|
629  | 
done  | 
|
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
630  | 
|
| 15411 | 631  | 
(*Classical implies (-->) elimination. *)  | 
632  | 
lemma impCE:  | 
|
633  | 
assumes major: "P-->Q"  | 
|
634  | 
and minor: "~P ==> R" "Q ==> R"  | 
|
635  | 
shows "R"  | 
|
636  | 
apply (rule excluded_middle [of P, THEN disjE])  | 
|
| 17589 | 637  | 
apply (iprover intro: minor major [THEN mp])+  | 
| 15411 | 638  | 
done  | 
639  | 
||
640  | 
(*This version of --> elimination works on Q before P. It works best for  | 
|
641  | 
those cases in which P holds "almost everywhere". Can't install as  | 
|
642  | 
default: would break old proofs.*)  | 
|
643  | 
lemma impCE':  | 
|
644  | 
assumes major: "P-->Q"  | 
|
645  | 
and minor: "Q ==> R" "~P ==> R"  | 
|
646  | 
shows "R"  | 
|
647  | 
apply (rule excluded_middle [of P, THEN disjE])  | 
|
| 17589 | 648  | 
apply (iprover intro: minor major [THEN mp])+  | 
| 15411 | 649  | 
done  | 
650  | 
||
651  | 
(*Classical <-> elimination. *)  | 
|
652  | 
lemma iffCE:  | 
|
653  | 
assumes major: "P=Q"  | 
|
654  | 
and minor: "[| P; Q |] ==> R" "[| ~P; ~Q |] ==> R"  | 
|
655  | 
shows "R"  | 
|
656  | 
apply (rule major [THEN iffE])  | 
|
| 17589 | 657  | 
apply (iprover intro: minor elim: impCE notE)  | 
| 15411 | 658  | 
done  | 
659  | 
||
660  | 
lemma exCI:  | 
|
661  | 
assumes "ALL x. ~P(x) ==> P(a)"  | 
|
662  | 
shows "EX x. P(x)"  | 
|
663  | 
apply (rule ccontr)  | 
|
| 23553 | 664  | 
apply (iprover intro: assms exI allI notI notE [of "\<exists>x. P x"])  | 
| 15411 | 665  | 
done  | 
666  | 
||
667  | 
||
| 12386 | 668  | 
subsubsection {* Intuitionistic Reasoning *}
 | 
669  | 
||
670  | 
lemma impE':  | 
|
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
671  | 
assumes 1: "P --> Q"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
672  | 
and 2: "Q ==> R"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
673  | 
and 3: "P --> Q ==> P"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
674  | 
shows R  | 
| 12386 | 675  | 
proof -  | 
676  | 
from 3 and 1 have P .  | 
|
677  | 
with 1 have Q by (rule impE)  | 
|
678  | 
with 2 show R .  | 
|
679  | 
qed  | 
|
680  | 
||
681  | 
lemma allE':  | 
|
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
682  | 
assumes 1: "ALL x. P x"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
683  | 
and 2: "P x ==> ALL x. P x ==> Q"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
684  | 
shows Q  | 
| 12386 | 685  | 
proof -  | 
686  | 
from 1 have "P x" by (rule spec)  | 
|
687  | 
from this and 1 show Q by (rule 2)  | 
|
688  | 
qed  | 
|
689  | 
||
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
690  | 
lemma notE':  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
691  | 
assumes 1: "~ P"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
692  | 
and 2: "~ P ==> P"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
693  | 
shows R  | 
| 12386 | 694  | 
proof -  | 
695  | 
from 2 and 1 have P .  | 
|
696  | 
with 1 show R by (rule notE)  | 
|
697  | 
qed  | 
|
698  | 
||
| 
22444
 
fb80fedd192d
added safe intro rules for removing "True" subgoals as well as "~ False" ones.
 
dixon 
parents: 
22377 
diff
changeset
 | 
699  | 
lemma TrueE: "True ==> P ==> P" .  | 
| 
 
fb80fedd192d
added safe intro rules for removing "True" subgoals as well as "~ False" ones.
 
dixon 
parents: 
22377 
diff
changeset
 | 
700  | 
lemma notFalseE: "~ False ==> P ==> P" .  | 
| 
 
fb80fedd192d
added safe intro rules for removing "True" subgoals as well as "~ False" ones.
 
dixon 
parents: 
22377 
diff
changeset
 | 
701  | 
|
| 
22467
 
c9357ef01168
TrueElim and notTrueElim tested and added as safe elim rules.
 
dixon 
parents: 
22445 
diff
changeset
 | 
702  | 
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE TrueE notFalseE  | 
| 15801 | 703  | 
and [Pure.intro!] = iffI conjI impI TrueI notI allI refl  | 
704  | 
and [Pure.elim 2] = allE notE' impE'  | 
|
705  | 
and [Pure.intro] = exI disjI2 disjI1  | 
|
| 12386 | 706  | 
|
707  | 
lemmas [trans] = trans  | 
|
708  | 
and [sym] = sym not_sym  | 
|
| 15801 | 709  | 
and [Pure.elim?] = iffD1 iffD2 impE  | 
| 11750 | 710  | 
|
| 
28952
 
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
 
haftmann 
parents: 
28856 
diff
changeset
 | 
711  | 
use "Tools/hologic.ML"  | 
| 23553 | 712  | 
|
| 
11438
 
3d9222b80989
declare trans [trans]  (*overridden in theory Calculation*);
 
wenzelm 
parents: 
11432 
diff
changeset
 | 
713  | 
|
| 11750 | 714  | 
subsubsection {* Atomizing meta-level connectives *}
 | 
715  | 
||
| 28513 | 716  | 
axiomatization where  | 
717  | 
eq_reflection: "x = y \<Longrightarrow> x \<equiv> y" (*admissible axiom*)  | 
|
718  | 
||
| 11750 | 719  | 
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"  | 
| 12003 | 720  | 
proof  | 
| 9488 | 721  | 
assume "!!x. P x"  | 
| 23389 | 722  | 
then show "ALL x. P x" ..  | 
| 9488 | 723  | 
next  | 
724  | 
assume "ALL x. P x"  | 
|
| 23553 | 725  | 
then show "!!x. P x" by (rule allE)  | 
| 9488 | 726  | 
qed  | 
727  | 
||
| 11750 | 728  | 
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"  | 
| 12003 | 729  | 
proof  | 
| 9488 | 730  | 
assume r: "A ==> B"  | 
| 10383 | 731  | 
show "A --> B" by (rule impI) (rule r)  | 
| 9488 | 732  | 
next  | 
733  | 
assume "A --> B" and A  | 
|
| 23553 | 734  | 
then show B by (rule mp)  | 
| 9488 | 735  | 
qed  | 
736  | 
||
| 14749 | 737  | 
lemma atomize_not: "(A ==> False) == Trueprop (~A)"  | 
738  | 
proof  | 
|
739  | 
assume r: "A ==> False"  | 
|
740  | 
show "~A" by (rule notI) (rule r)  | 
|
741  | 
next  | 
|
742  | 
assume "~A" and A  | 
|
| 23553 | 743  | 
then show False by (rule notE)  | 
| 14749 | 744  | 
qed  | 
745  | 
||
| 39566 | 746  | 
lemma atomize_eq [atomize, code]: "(x == y) == Trueprop (x = y)"  | 
| 12003 | 747  | 
proof  | 
| 
10432
 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
 
wenzelm 
parents: 
10383 
diff
changeset
 | 
748  | 
assume "x == y"  | 
| 23553 | 749  | 
show "x = y" by (unfold `x == y`) (rule refl)  | 
| 
10432
 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
 
wenzelm 
parents: 
10383 
diff
changeset
 | 
750  | 
next  | 
| 
 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
 
wenzelm 
parents: 
10383 
diff
changeset
 | 
751  | 
assume "x = y"  | 
| 23553 | 752  | 
then show "x == y" by (rule eq_reflection)  | 
| 
10432
 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
 
wenzelm 
parents: 
10383 
diff
changeset
 | 
753  | 
qed  | 
| 
 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
 
wenzelm 
parents: 
10383 
diff
changeset
 | 
754  | 
|
| 
28856
 
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
 
wenzelm 
parents: 
28741 
diff
changeset
 | 
755  | 
lemma atomize_conj [atomize]: "(A &&& B) == Trueprop (A & B)"  | 
| 12003 | 756  | 
proof  | 
| 
28856
 
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
 
wenzelm 
parents: 
28741 
diff
changeset
 | 
757  | 
assume conj: "A &&& B"  | 
| 19121 | 758  | 
show "A & B"  | 
759  | 
proof (rule conjI)  | 
|
760  | 
from conj show A by (rule conjunctionD1)  | 
|
761  | 
from conj show B by (rule conjunctionD2)  | 
|
762  | 
qed  | 
|
| 11953 | 763  | 
next  | 
| 19121 | 764  | 
assume conj: "A & B"  | 
| 
28856
 
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
 
wenzelm 
parents: 
28741 
diff
changeset
 | 
765  | 
show "A &&& B"  | 
| 19121 | 766  | 
proof -  | 
767  | 
from conj show A ..  | 
|
768  | 
from conj show B ..  | 
|
| 11953 | 769  | 
qed  | 
770  | 
qed  | 
|
771  | 
||
| 12386 | 772  | 
lemmas [symmetric, rulify] = atomize_all atomize_imp  | 
| 18832 | 773  | 
and [symmetric, defn] = atomize_all atomize_imp atomize_eq  | 
| 12386 | 774  | 
|
| 11750 | 775  | 
|
| 
26580
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
776  | 
subsubsection {* Atomizing elimination rules *}
 | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
777  | 
|
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
778  | 
setup AtomizeElim.setup  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
779  | 
|
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
780  | 
lemma atomize_exL[atomize_elim]: "(!!x. P x ==> Q) == ((EX x. P x) ==> Q)"  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
781  | 
by rule iprover+  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
782  | 
|
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
783  | 
lemma atomize_conjL[atomize_elim]: "(A ==> B ==> C) == (A & B ==> C)"  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
784  | 
by rule iprover+  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
785  | 
|
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
786  | 
lemma atomize_disjL[atomize_elim]: "((A ==> C) ==> (B ==> C) ==> C) == ((A | B ==> C) ==> C)"  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
787  | 
by rule iprover+  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
788  | 
|
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
789  | 
lemma atomize_elimL[atomize_elim]: "(!!B. (A ==> B) ==> B) == Trueprop A" ..  | 
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
790  | 
|
| 
 
c3e597a476fd
Generic conversion and tactic "atomize_elim" to convert elimination rules
 
krauss 
parents: 
26555 
diff
changeset
 | 
791  | 
|
| 20944 | 792  | 
subsection {* Package setup *}
 | 
793  | 
||
| 
35828
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
794  | 
subsubsection {* Sledgehammer setup *}
 | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
795  | 
|
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
796  | 
text {*
 | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
797  | 
Theorems blacklisted to Sledgehammer. These theorems typically produce clauses  | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
798  | 
that are prolific (match too many equality or membership literals) and relate to  | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
799  | 
seldom-used facts. Some duplicate other rules.  | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
800  | 
*}  | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
801  | 
|
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
802  | 
ML {*
 | 
| 
36297
 
6b2b9516a3cd
removed obsolete Named_Thm_Set -- Named_Thms provides efficient member operation;
 
wenzelm 
parents: 
36246 
diff
changeset
 | 
803  | 
structure No_ATPs = Named_Thms  | 
| 
35828
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
804  | 
(  | 
| 45294 | 805  | 
  val name = @{binding no_atp}
 | 
| 
36060
 
4d27652ffb40
reintroduce efficient set structure to collect "no_atp" theorems
 
blanchet 
parents: 
35828 
diff
changeset
 | 
806  | 
val description = "theorems that should be filtered out by Sledgehammer"  | 
| 
35828
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
807  | 
)  | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
808  | 
*}  | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
809  | 
|
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
810  | 
setup {* No_ATPs.setup *}
 | 
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
811  | 
|
| 
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
812  | 
|
| 11750 | 813  | 
subsubsection {* Classical Reasoner setup *}
 | 
| 9529 | 814  | 
|
| 26411 | 815  | 
lemma imp_elim: "P --> Q ==> (~ R ==> P) ==> (Q ==> R) ==> R"  | 
816  | 
by (rule classical) iprover  | 
|
817  | 
||
818  | 
lemma swap: "~ P ==> (~ R ==> P) ==> R"  | 
|
819  | 
by (rule classical) iprover  | 
|
820  | 
||
| 20944 | 821  | 
lemma thin_refl:  | 
822  | 
"\<And>X. \<lbrakk> x=x; PROP W \<rbrakk> \<Longrightarrow> PROP W" .  | 
|
823  | 
||
| 21151 | 824  | 
ML {*
 | 
| 42799 | 825  | 
structure Hypsubst = Hypsubst  | 
826  | 
(  | 
|
| 21218 | 827  | 
val dest_eq = HOLogic.dest_eq  | 
| 21151 | 828  | 
val dest_Trueprop = HOLogic.dest_Trueprop  | 
829  | 
val dest_imp = HOLogic.dest_imp  | 
|
| 26411 | 830  | 
  val eq_reflection = @{thm eq_reflection}
 | 
831  | 
  val rev_eq_reflection = @{thm meta_eq_to_obj_eq}
 | 
|
832  | 
  val imp_intr = @{thm impI}
 | 
|
833  | 
  val rev_mp = @{thm rev_mp}
 | 
|
834  | 
  val subst = @{thm subst}
 | 
|
835  | 
  val sym = @{thm sym}
 | 
|
| 22129 | 836  | 
  val thin_refl = @{thm thin_refl};
 | 
| 42799 | 837  | 
);  | 
| 21671 | 838  | 
open Hypsubst;  | 
| 21151 | 839  | 
|
| 42799 | 840  | 
structure Classical = Classical  | 
841  | 
(  | 
|
| 26411 | 842  | 
  val imp_elim = @{thm imp_elim}
 | 
843  | 
  val not_elim = @{thm notE}
 | 
|
844  | 
  val swap = @{thm swap}
 | 
|
845  | 
  val classical = @{thm classical}
 | 
|
| 21151 | 846  | 
val sizef = Drule.size_of_thm  | 
847  | 
val hyp_subst_tacs = [Hypsubst.hyp_subst_tac]  | 
|
| 42799 | 848  | 
);  | 
| 21151 | 849  | 
|
| 
33308
 
cf62d1690d04
separate ResBlacklist, based on scalable persistent data -- avoids inefficient hashing later on;
 
wenzelm 
parents: 
33185 
diff
changeset
 | 
850  | 
structure Basic_Classical: BASIC_CLASSICAL = Classical;  | 
| 
 
cf62d1690d04
separate ResBlacklist, based on scalable persistent data -- avoids inefficient hashing later on;
 
wenzelm 
parents: 
33185 
diff
changeset
 | 
851  | 
open Basic_Classical;  | 
| 
43560
 
d1650e3720fd
ML antiquotations are managed as theory data, with proper name space and entity markup;
 
wenzelm 
parents: 
42802 
diff
changeset
 | 
852  | 
*}  | 
| 22129 | 853  | 
|
| 
43560
 
d1650e3720fd
ML antiquotations are managed as theory data, with proper name space and entity markup;
 
wenzelm 
parents: 
42802 
diff
changeset
 | 
854  | 
setup {*
 | 
| 
 
d1650e3720fd
ML antiquotations are managed as theory data, with proper name space and entity markup;
 
wenzelm 
parents: 
42802 
diff
changeset
 | 
855  | 
  ML_Antiquote.value @{binding claset}
 | 
| 
 
d1650e3720fd
ML antiquotations are managed as theory data, with proper name space and entity markup;
 
wenzelm 
parents: 
42802 
diff
changeset
 | 
856  | 
(Scan.succeed "Classical.claset_of (ML_Context.the_local_context ())")  | 
| 21151 | 857  | 
*}  | 
858  | 
||
| 
33308
 
cf62d1690d04
separate ResBlacklist, based on scalable persistent data -- avoids inefficient hashing later on;
 
wenzelm 
parents: 
33185 
diff
changeset
 | 
859  | 
setup Classical.setup  | 
| 
24286
 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 
paulson 
parents: 
24280 
diff
changeset
 | 
860  | 
|
| 21009 | 861  | 
setup {*
 | 
862  | 
let  | 
|
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
863  | 
  fun non_bool_eq (@{const_name HOL.eq}, Type (_, [T, _])) = T <> @{typ bool}
 | 
| 35389 | 864  | 
| non_bool_eq _ = false;  | 
865  | 
val hyp_subst_tac' =  | 
|
866  | 
SUBGOAL (fn (goal, i) =>  | 
|
867  | 
if Term.exists_Const non_bool_eq goal  | 
|
868  | 
then Hypsubst.hyp_subst_tac i  | 
|
869  | 
else no_tac);  | 
|
| 21009 | 870  | 
in  | 
| 21151 | 871  | 
Hypsubst.hypsubst_setup  | 
| 35389 | 872  | 
(*prevent substitution on bool*)  | 
| 33369 | 873  | 
#> Context_Rules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)  | 
| 21009 | 874  | 
end  | 
875  | 
*}  | 
|
876  | 
||
877  | 
declare iffI [intro!]  | 
|
878  | 
and notI [intro!]  | 
|
879  | 
and impI [intro!]  | 
|
880  | 
and disjCI [intro!]  | 
|
881  | 
and conjI [intro!]  | 
|
882  | 
and TrueI [intro!]  | 
|
883  | 
and refl [intro!]  | 
|
884  | 
||
885  | 
declare iffCE [elim!]  | 
|
886  | 
and FalseE [elim!]  | 
|
887  | 
and impCE [elim!]  | 
|
888  | 
and disjE [elim!]  | 
|
889  | 
and conjE [elim!]  | 
|
890  | 
||
891  | 
declare ex_ex1I [intro!]  | 
|
892  | 
and allI [intro!]  | 
|
893  | 
and the_equality [intro]  | 
|
894  | 
and exI [intro]  | 
|
895  | 
||
896  | 
declare exE [elim!]  | 
|
897  | 
allE [elim]  | 
|
898  | 
||
| 22377 | 899  | 
ML {* val HOL_cs = @{claset} *}
 | 
| 19162 | 900  | 
|
| 20223 | 901  | 
lemma contrapos_np: "~ Q ==> (~ P ==> Q) ==> P"  | 
902  | 
apply (erule swap)  | 
|
903  | 
apply (erule (1) meta_mp)  | 
|
904  | 
done  | 
|
| 10383 | 905  | 
|
| 
18689
 
a50587cd8414
prefer ex1I over ex_ex1I in single-step reasoning;
 
wenzelm 
parents: 
18595 
diff
changeset
 | 
906  | 
declare ex_ex1I [rule del, intro! 2]  | 
| 
 
a50587cd8414
prefer ex1I over ex_ex1I in single-step reasoning;
 
wenzelm 
parents: 
18595 
diff
changeset
 | 
907  | 
and ex1I [intro]  | 
| 
 
a50587cd8414
prefer ex1I over ex_ex1I in single-step reasoning;
 
wenzelm 
parents: 
18595 
diff
changeset
 | 
908  | 
|
| 
41865
 
4e8483cc2cc5
declare ext [intro]: Extensionality now available by default
 
paulson 
parents: 
41827 
diff
changeset
 | 
909  | 
declare ext [intro]  | 
| 
 
4e8483cc2cc5
declare ext [intro]: Extensionality now available by default
 
paulson 
parents: 
41827 
diff
changeset
 | 
910  | 
|
| 12386 | 911  | 
lemmas [intro?] = ext  | 
912  | 
and [elim?] = ex1_implies_ex  | 
|
| 11977 | 913  | 
|
| 20944 | 914  | 
(*Better then ex1E for classical reasoner: needs no quantifier duplication!*)  | 
| 20973 | 915  | 
lemma alt_ex1E [elim!]:  | 
| 20944 | 916  | 
assumes major: "\<exists>!x. P x"  | 
917  | 
and prem: "\<And>x. \<lbrakk> P x; \<forall>y y'. P y \<and> P y' \<longrightarrow> y = y' \<rbrakk> \<Longrightarrow> R"  | 
|
918  | 
shows R  | 
|
919  | 
apply (rule ex1E [OF major])  | 
|
920  | 
apply (rule prem)  | 
|
| 22129 | 921  | 
apply (tactic {* ares_tac @{thms allI} 1 *})+
 | 
922  | 
apply (tactic {* etac (Classical.dup_elim @{thm allE}) 1 *})
 | 
|
923  | 
apply iprover  | 
|
924  | 
done  | 
|
| 20944 | 925  | 
|
| 21151 | 926  | 
ML {*
 | 
| 42477 | 927  | 
structure Blast = Blast  | 
928  | 
(  | 
|
929  | 
structure Classical = Classical  | 
|
| 42802 | 930  | 
    val Trueprop_const = dest_Const @{const Trueprop}
 | 
| 42477 | 931  | 
    val equality_name = @{const_name HOL.eq}
 | 
932  | 
    val not_name = @{const_name Not}
 | 
|
933  | 
    val notE = @{thm notE}
 | 
|
934  | 
    val ccontr = @{thm ccontr}
 | 
|
935  | 
val hyp_subst_tac = Hypsubst.blast_hyp_subst_tac  | 
|
936  | 
);  | 
|
937  | 
val blast_tac = Blast.blast_tac;  | 
|
| 20944 | 938  | 
*}  | 
939  | 
||
| 21151 | 940  | 
setup Blast.setup  | 
941  | 
||
| 20944 | 942  | 
|
943  | 
subsubsection {* Simplifier *}
 | 
|
| 12281 | 944  | 
|
945  | 
lemma eta_contract_eq: "(%s. f s) = f" ..  | 
|
946  | 
||
947  | 
lemma simp_thms:  | 
|
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
948  | 
shows not_not: "(~ ~ P) = P"  | 
| 15354 | 949  | 
and Not_eq_iff: "((~P) = (~Q)) = (P = Q)"  | 
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
950  | 
and  | 
| 
12436
 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
 
berghofe 
parents: 
12386 
diff
changeset
 | 
951  | 
"(P ~= Q) = (P = (~Q))"  | 
| 
 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
 
berghofe 
parents: 
12386 
diff
changeset
 | 
952  | 
"(P | ~P) = True" "(~P | P) = True"  | 
| 12281 | 953  | 
"(x = x) = True"  | 
| 32068 | 954  | 
and not_True_eq_False [code]: "(\<not> True) = False"  | 
955  | 
and not_False_eq_True [code]: "(\<not> False) = True"  | 
|
| 20944 | 956  | 
and  | 
| 
12436
 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
 
berghofe 
parents: 
12386 
diff
changeset
 | 
957  | 
"(~P) ~= P" "P ~= (~P)"  | 
| 20944 | 958  | 
"(True=P) = P"  | 
959  | 
and eq_True: "(P = True) = P"  | 
|
960  | 
and "(False=P) = (~P)"  | 
|
961  | 
and eq_False: "(P = False) = (\<not> P)"  | 
|
962  | 
and  | 
|
| 12281 | 963  | 
"(True --> P) = P" "(False --> P) = True"  | 
964  | 
"(P --> True) = True" "(P --> P) = True"  | 
|
965  | 
"(P --> False) = (~P)" "(P --> ~P) = (~P)"  | 
|
966  | 
"(P & True) = P" "(True & P) = P"  | 
|
967  | 
"(P & False) = False" "(False & P) = False"  | 
|
968  | 
"(P & P) = P" "(P & (P & Q)) = (P & Q)"  | 
|
969  | 
"(P & ~P) = False" "(~P & P) = False"  | 
|
970  | 
"(P | True) = True" "(True | P) = True"  | 
|
971  | 
"(P | False) = P" "(False | P) = P"  | 
|
| 
12436
 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
 
berghofe 
parents: 
12386 
diff
changeset
 | 
972  | 
"(P | P) = P" "(P | (P | Q)) = (P | Q)" and  | 
| 12281 | 973  | 
"(ALL x. P) = P" "(EX x. P) = P" "EX x. x=t" "EX x. t=x"  | 
| 
31166
 
a90fe83f58ea
"{x. P x & x=t & Q x}" is now rewritten to "if P t & Q t then {t} else {}"
 
nipkow 
parents: 
31156 
diff
changeset
 | 
974  | 
and  | 
| 12281 | 975  | 
"!!P. (EX x. x=t & P(x)) = P(t)"  | 
976  | 
"!!P. (EX x. t=x & P(x)) = P(t)"  | 
|
977  | 
"!!P. (ALL x. x=t --> P(x)) = P(t)"  | 
|
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
978  | 
"!!P. (ALL x. t=x --> P(x)) = P(t)"  | 
| 17589 | 979  | 
by (blast, blast, blast, blast, blast, iprover+)  | 
| 13421 | 980  | 
|
| 14201 | 981  | 
lemma disj_absorb: "(A | A) = A"  | 
982  | 
by blast  | 
|
983  | 
||
984  | 
lemma disj_left_absorb: "(A | (A | B)) = (A | B)"  | 
|
985  | 
by blast  | 
|
986  | 
||
987  | 
lemma conj_absorb: "(A & A) = A"  | 
|
988  | 
by blast  | 
|
989  | 
||
990  | 
lemma conj_left_absorb: "(A & (A & B)) = (A & B)"  | 
|
991  | 
by blast  | 
|
992  | 
||
| 12281 | 993  | 
lemma eq_ac:  | 
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
994  | 
shows eq_commute: "(a=b) = (b=a)"  | 
| 
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
995  | 
and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))"  | 
| 17589 | 996  | 
and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (iprover, blast+)  | 
997  | 
lemma neq_commute: "(a~=b) = (b~=a)" by iprover  | 
|
| 12281 | 998  | 
|
999  | 
lemma conj_comms:  | 
|
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
1000  | 
shows conj_commute: "(P&Q) = (Q&P)"  | 
| 17589 | 1001  | 
and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by iprover+  | 
1002  | 
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by iprover  | 
|
| 12281 | 1003  | 
|
| 19174 | 1004  | 
lemmas conj_ac = conj_commute conj_left_commute conj_assoc  | 
1005  | 
||
| 12281 | 1006  | 
lemma disj_comms:  | 
| 
12937
 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 
wenzelm 
parents: 
12892 
diff
changeset
 | 
1007  | 
shows disj_commute: "(P|Q) = (Q|P)"  | 
| 17589 | 1008  | 
and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by iprover+  | 
1009  | 
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by iprover  | 
|
| 12281 | 1010  | 
|
| 19174 | 1011  | 
lemmas disj_ac = disj_commute disj_left_commute disj_assoc  | 
1012  | 
||
| 17589 | 1013  | 
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by iprover  | 
1014  | 
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by iprover  | 
|
| 12281 | 1015  | 
|
| 17589 | 1016  | 
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by iprover  | 
1017  | 
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by iprover  | 
|
| 12281 | 1018  | 
|
| 17589 | 1019  | 
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by iprover  | 
1020  | 
lemma imp_conjL: "((P&Q) -->R) = (P --> (Q --> R))" by iprover  | 
|
1021  | 
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by iprover  | 
|
| 12281 | 1022  | 
|
1023  | 
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
 | 
|
1024  | 
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast  | 
|
1025  | 
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast  | 
|
1026  | 
||
1027  | 
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast  | 
|
1028  | 
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast  | 
|
1029  | 
||
| 21151 | 1030  | 
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"  | 
1031  | 
by iprover  | 
|
1032  | 
||
| 17589 | 1033  | 
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by iprover  | 
| 12281 | 1034  | 
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast  | 
1035  | 
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast  | 
|
1036  | 
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast  | 
|
1037  | 
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast  | 
|
1038  | 
lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
 | 
|
1039  | 
by blast  | 
|
1040  | 
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast  | 
|
1041  | 
||
| 17589 | 1042  | 
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by iprover  | 
| 12281 | 1043  | 
|
1044  | 
||
1045  | 
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"  | 
|
1046  | 
  -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
 | 
|
1047  | 
  -- {* cases boil down to the same thing. *}
 | 
|
1048  | 
by blast  | 
|
1049  | 
||
1050  | 
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast  | 
|
1051  | 
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast  | 
|
| 17589 | 1052  | 
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by iprover  | 
1053  | 
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by iprover  | 
|
| 23403 | 1054  | 
lemma all_not_ex: "(ALL x. P x) = (~ (EX x. ~ P x ))" by blast  | 
| 12281 | 1055  | 
|
| 
35828
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
1056  | 
declare All_def [no_atp]  | 
| 
24286
 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 
paulson 
parents: 
24280 
diff
changeset
 | 
1057  | 
|
| 17589 | 1058  | 
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by iprover  | 
1059  | 
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by iprover  | 
|
| 12281 | 1060  | 
|
1061  | 
text {*
 | 
|
1062  | 
  \medskip The @{text "&"} congruence rule: not included by default!
 | 
|
1063  | 
May slow rewrite proofs down by as much as 50\% *}  | 
|
1064  | 
||
1065  | 
lemma conj_cong:  | 
|
1066  | 
"(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"  | 
|
| 17589 | 1067  | 
by iprover  | 
| 12281 | 1068  | 
|
1069  | 
lemma rev_conj_cong:  | 
|
1070  | 
"(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"  | 
|
| 17589 | 1071  | 
by iprover  | 
| 12281 | 1072  | 
|
1073  | 
text {* The @{text "|"} congruence rule: not included by default! *}
 | 
|
1074  | 
||
1075  | 
lemma disj_cong:  | 
|
1076  | 
"(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"  | 
|
1077  | 
by blast  | 
|
1078  | 
||
1079  | 
||
1080  | 
text {* \medskip if-then-else rules *}
 | 
|
1081  | 
||
| 32068 | 1082  | 
lemma if_True [code]: "(if True then x else y) = x"  | 
| 38525 | 1083  | 
by (unfold If_def) blast  | 
| 12281 | 1084  | 
|
| 32068 | 1085  | 
lemma if_False [code]: "(if False then x else y) = y"  | 
| 38525 | 1086  | 
by (unfold If_def) blast  | 
| 12281 | 1087  | 
|
1088  | 
lemma if_P: "P ==> (if P then x else y) = x"  | 
|
| 38525 | 1089  | 
by (unfold If_def) blast  | 
| 12281 | 1090  | 
|
1091  | 
lemma if_not_P: "~P ==> (if P then x else y) = y"  | 
|
| 38525 | 1092  | 
by (unfold If_def) blast  | 
| 12281 | 1093  | 
|
1094  | 
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"  | 
|
1095  | 
apply (rule case_split [of Q])  | 
|
| 15481 | 1096  | 
apply (simplesubst if_P)  | 
1097  | 
prefer 3 apply (simplesubst if_not_P, blast+)  | 
|
| 12281 | 1098  | 
done  | 
1099  | 
||
1100  | 
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"  | 
|
| 15481 | 1101  | 
by (simplesubst split_if, blast)  | 
| 12281 | 1102  | 
|
| 
35828
 
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
 
blanchet 
parents: 
35808 
diff
changeset
 | 
1103  | 
lemmas if_splits [no_atp] = split_if split_if_asm  | 
| 12281 | 1104  | 
|
1105  | 
lemma if_cancel: "(if c then x else x) = x"  | 
|
| 15481 | 1106  | 
by (simplesubst split_if, blast)  | 
| 12281 | 1107  | 
|
1108  | 
lemma if_eq_cancel: "(if x = y then y else x) = x"  | 
|
| 15481 | 1109  | 
by (simplesubst split_if, blast)  | 
| 12281 | 1110  | 
|
| 
41792
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1111  | 
lemma if_bool_eq_conj:  | 
| 
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1112  | 
"(if P then Q else R) = ((P-->Q) & (~P-->R))"  | 
| 19796 | 1113  | 
  -- {* This form is useful for expanding @{text "if"}s on the RIGHT of the @{text "==>"} symbol. *}
 | 
| 12281 | 1114  | 
by (rule split_if)  | 
1115  | 
||
1116  | 
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"  | 
|
| 19796 | 1117  | 
  -- {* And this form is useful for expanding @{text "if"}s on the LEFT. *}
 | 
| 15481 | 1118  | 
apply (simplesubst split_if, blast)  | 
| 12281 | 1119  | 
done  | 
1120  | 
||
| 17589 | 1121  | 
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) iprover  | 
1122  | 
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) iprover  | 
|
| 12281 | 1123  | 
|
| 15423 | 1124  | 
text {* \medskip let rules for simproc *}
 | 
1125  | 
||
1126  | 
lemma Let_folded: "f x \<equiv> g x \<Longrightarrow> Let x f \<equiv> Let x g"  | 
|
1127  | 
by (unfold Let_def)  | 
|
1128  | 
||
1129  | 
lemma Let_unfold: "f x \<equiv> g \<Longrightarrow> Let x f \<equiv> g"  | 
|
1130  | 
by (unfold Let_def)  | 
|
1131  | 
||
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1132  | 
text {*
 | 
| 16999 | 1133  | 
The following copy of the implication operator is useful for  | 
1134  | 
fine-tuning congruence rules. It instructs the simplifier to simplify  | 
|
1135  | 
its premise.  | 
|
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1136  | 
*}  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1137  | 
|
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1138  | 
definition simp_implies :: "[prop, prop] => prop" (infixr "=simp=>" 1) where  | 
| 37767 | 1139  | 
"simp_implies \<equiv> op ==>"  | 
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1140  | 
|
| 18457 | 1141  | 
lemma simp_impliesI:  | 
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1142  | 
assumes PQ: "(PROP P \<Longrightarrow> PROP Q)"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1143  | 
shows "PROP P =simp=> PROP Q"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1144  | 
apply (unfold simp_implies_def)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1145  | 
apply (rule PQ)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1146  | 
apply assumption  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1147  | 
done  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1148  | 
|
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1149  | 
lemma simp_impliesE:  | 
| 25388 | 1150  | 
assumes PQ: "PROP P =simp=> PROP Q"  | 
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1151  | 
and P: "PROP P"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1152  | 
and QR: "PROP Q \<Longrightarrow> PROP R"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1153  | 
shows "PROP R"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1154  | 
apply (rule QR)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1155  | 
apply (rule PQ [unfolded simp_implies_def])  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1156  | 
apply (rule P)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1157  | 
done  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1158  | 
|
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1159  | 
lemma simp_implies_cong:  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1160  | 
assumes PP' :"PROP P == PROP P'"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1161  | 
and P'QQ': "PROP P' ==> (PROP Q == PROP Q')"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1162  | 
shows "(PROP P =simp=> PROP Q) == (PROP P' =simp=> PROP Q')"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1163  | 
proof (unfold simp_implies_def, rule equal_intr_rule)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1164  | 
assume PQ: "PROP P \<Longrightarrow> PROP Q"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1165  | 
and P': "PROP P'"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1166  | 
from PP' [symmetric] and P' have "PROP P"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1167  | 
by (rule equal_elim_rule1)  | 
| 23553 | 1168  | 
then have "PROP Q" by (rule PQ)  | 
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1169  | 
with P'QQ' [OF P'] show "PROP Q'" by (rule equal_elim_rule1)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1170  | 
next  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1171  | 
assume P'Q': "PROP P' \<Longrightarrow> PROP Q'"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1172  | 
and P: "PROP P"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1173  | 
from PP' and P have P': "PROP P'" by (rule equal_elim_rule1)  | 
| 23553 | 1174  | 
then have "PROP Q'" by (rule P'Q')  | 
| 
16633
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1175  | 
with P'QQ' [OF P', symmetric] show "PROP Q"  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1176  | 
by (rule equal_elim_rule1)  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1177  | 
qed  | 
| 
 
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
 
berghofe 
parents: 
16587 
diff
changeset
 | 
1178  | 
|
| 20944 | 1179  | 
lemma uncurry:  | 
1180  | 
assumes "P \<longrightarrow> Q \<longrightarrow> R"  | 
|
1181  | 
shows "P \<and> Q \<longrightarrow> R"  | 
|
| 23553 | 1182  | 
using assms by blast  | 
| 20944 | 1183  | 
|
1184  | 
lemma iff_allI:  | 
|
1185  | 
assumes "\<And>x. P x = Q x"  | 
|
1186  | 
shows "(\<forall>x. P x) = (\<forall>x. Q x)"  | 
|
| 23553 | 1187  | 
using assms by blast  | 
| 20944 | 1188  | 
|
1189  | 
lemma iff_exI:  | 
|
1190  | 
assumes "\<And>x. P x = Q x"  | 
|
1191  | 
shows "(\<exists>x. P x) = (\<exists>x. Q x)"  | 
|
| 23553 | 1192  | 
using assms by blast  | 
| 20944 | 1193  | 
|
1194  | 
lemma all_comm:  | 
|
1195  | 
"(\<forall>x y. P x y) = (\<forall>y x. P x y)"  | 
|
1196  | 
by blast  | 
|
1197  | 
||
1198  | 
lemma ex_comm:  | 
|
1199  | 
"(\<exists>x y. P x y) = (\<exists>y x. P x y)"  | 
|
1200  | 
by blast  | 
|
1201  | 
||
| 
28952
 
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
 
haftmann 
parents: 
28856 
diff
changeset
 | 
1202  | 
use "Tools/simpdata.ML"  | 
| 21671 | 1203  | 
ML {* open Simpdata *}
 | 
| 42455 | 1204  | 
|
| 
42795
 
66fcc9882784
clarified map_simpset versus Simplifier.map_simpset_global;
 
wenzelm 
parents: 
42477 
diff
changeset
 | 
1205  | 
setup {* Simplifier.map_simpset_global (K HOL_basic_ss) *}
 | 
| 42455 | 1206  | 
|
| 42459 | 1207  | 
simproc_setup defined_Ex ("EX x. P x") = {* fn _ => Quantifier1.rearrange_ex *}
 | 
1208  | 
simproc_setup defined_All ("ALL x. P x") = {* fn _ => Quantifier1.rearrange_all *}
 | 
|
| 21671 | 1209  | 
|
| 21151 | 1210  | 
setup {*
 | 
1211  | 
Simplifier.method_setup Splitter.split_modifiers  | 
|
1212  | 
#> Splitter.setup  | 
|
| 
26496
 
49ae9456eba9
purely functional setup of claset/simpset/clasimpset;
 
wenzelm 
parents: 
26411 
diff
changeset
 | 
1213  | 
#> clasimp_setup  | 
| 21151 | 1214  | 
#> EqSubst.setup  | 
1215  | 
*}  | 
|
1216  | 
||
| 24035 | 1217  | 
text {* Simproc for proving @{text "(y = x) == False"} from premise @{text "~(x = y)"}: *}
 | 
1218  | 
||
1219  | 
simproc_setup neq ("x = y") = {* fn _ =>
 | 
|
1220  | 
let  | 
|
1221  | 
  val neq_to_EQ_False = @{thm not_sym} RS @{thm Eq_FalseI};
 | 
|
1222  | 
fun is_neq eq lhs rhs thm =  | 
|
1223  | 
(case Thm.prop_of thm of  | 
|
1224  | 
_ $ (Not $ (eq' $ l' $ r')) =>  | 
|
1225  | 
Not = HOLogic.Not andalso eq' = eq andalso  | 
|
1226  | 
r' aconv lhs andalso l' aconv rhs  | 
|
1227  | 
| _ => false);  | 
|
1228  | 
fun proc ss ct =  | 
|
1229  | 
(case Thm.term_of ct of  | 
|
1230  | 
eq $ lhs $ rhs =>  | 
|
| 43597 | 1231  | 
(case find_first (is_neq eq lhs rhs) (Simplifier.prems_of ss) of  | 
| 24035 | 1232  | 
SOME thm => SOME (thm RS neq_to_EQ_False)  | 
1233  | 
| NONE => NONE)  | 
|
1234  | 
| _ => NONE);  | 
|
1235  | 
in proc end;  | 
|
1236  | 
*}  | 
|
1237  | 
||
1238  | 
simproc_setup let_simp ("Let x f") = {*
 | 
|
1239  | 
let  | 
|
1240  | 
val (f_Let_unfold, x_Let_unfold) =  | 
|
| 28741 | 1241  | 
    let val [(_ $ (f $ x) $ _)] = prems_of @{thm Let_unfold}
 | 
| 24035 | 1242  | 
    in (cterm_of @{theory} f, cterm_of @{theory} x) end
 | 
1243  | 
val (f_Let_folded, x_Let_folded) =  | 
|
| 28741 | 1244  | 
    let val [(_ $ (f $ x) $ _)] = prems_of @{thm Let_folded}
 | 
| 24035 | 1245  | 
    in (cterm_of @{theory} f, cterm_of @{theory} x) end;
 | 
1246  | 
val g_Let_folded =  | 
|
| 28741 | 1247  | 
    let val [(_ $ _ $ (g $ _))] = prems_of @{thm Let_folded}
 | 
1248  | 
    in cterm_of @{theory} g end;
 | 
|
1249  | 
fun count_loose (Bound i) k = if i >= k then 1 else 0  | 
|
1250  | 
| count_loose (s $ t) k = count_loose s k + count_loose t k  | 
|
1251  | 
| count_loose (Abs (_, _, t)) k = count_loose t (k + 1)  | 
|
1252  | 
| count_loose _ _ = 0;  | 
|
1253  | 
  fun is_trivial_let (Const (@{const_name Let}, _) $ x $ t) =
 | 
|
1254  | 
case t  | 
|
1255  | 
of Abs (_, _, t') => count_loose t' 0 <= 1  | 
|
1256  | 
| _ => true;  | 
|
1257  | 
in fn _ => fn ss => fn ct => if is_trivial_let (Thm.term_of ct)  | 
|
| 31151 | 1258  | 
  then SOME @{thm Let_def} (*no or one ocurrence of bound variable*)
 | 
| 28741 | 1259  | 
else let (*Norbert Schirmer's case*)  | 
1260  | 
val ctxt = Simplifier.the_context ss;  | 
|
| 42361 | 1261  | 
val thy = Proof_Context.theory_of ctxt;  | 
| 28741 | 1262  | 
val t = Thm.term_of ct;  | 
1263  | 
val ([t'], ctxt') = Variable.import_terms false [t] ctxt;  | 
|
1264  | 
in Option.map (hd o Variable.export ctxt' ctxt o single)  | 
|
1265  | 
    (case t' of Const (@{const_name Let},_) $ x $ f => (* x and f are already in normal form *)
 | 
|
1266  | 
if is_Free x orelse is_Bound x orelse is_Const x  | 
|
1267  | 
      then SOME @{thm Let_def}
 | 
|
1268  | 
else  | 
|
1269  | 
let  | 
|
1270  | 
val n = case f of (Abs (x, _, _)) => x | _ => "x";  | 
|
1271  | 
val cx = cterm_of thy x;  | 
|
1272  | 
          val {T = xT, ...} = rep_cterm cx;
 | 
|
1273  | 
val cf = cterm_of thy f;  | 
|
1274  | 
val fx_g = Simplifier.rewrite ss (Thm.capply cf cx);  | 
|
1275  | 
val (_ $ _ $ g) = prop_of fx_g;  | 
|
1276  | 
val g' = abstract_over (x,g);  | 
|
1277  | 
in (if (g aconv g')  | 
|
1278  | 
then  | 
|
1279  | 
let  | 
|
1280  | 
val rl =  | 
|
1281  | 
                    cterm_instantiate [(f_Let_unfold, cf), (x_Let_unfold, cx)] @{thm Let_unfold};
 | 
|
1282  | 
in SOME (rl OF [fx_g]) end  | 
|
1283  | 
else if Term.betapply (f, x) aconv g then NONE (*avoid identity conversion*)  | 
|
1284  | 
else let  | 
|
1285  | 
val abs_g'= Abs (n,xT,g');  | 
|
1286  | 
val g'x = abs_g'$x;  | 
|
| 36945 | 1287  | 
val g_g'x = Thm.symmetric (Thm.beta_conversion false (cterm_of thy g'x));  | 
| 28741 | 1288  | 
val rl = cterm_instantiate  | 
1289  | 
[(f_Let_folded, cterm_of thy f), (x_Let_folded, cx),  | 
|
1290  | 
(g_Let_folded, cterm_of thy abs_g')]  | 
|
1291  | 
                             @{thm Let_folded};
 | 
|
| 36945 | 1292  | 
in SOME (rl OF [Thm.transitive fx_g g_g'x])  | 
| 28741 | 1293  | 
end)  | 
1294  | 
end  | 
|
1295  | 
| _ => NONE)  | 
|
1296  | 
end  | 
|
1297  | 
end *}  | 
|
| 24035 | 1298  | 
|
| 21151 | 1299  | 
lemma True_implies_equals: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"  | 
1300  | 
proof  | 
|
| 23389 | 1301  | 
assume "True \<Longrightarrow> PROP P"  | 
1302  | 
from this [OF TrueI] show "PROP P" .  | 
|
| 21151 | 1303  | 
next  | 
1304  | 
assume "PROP P"  | 
|
| 23389 | 1305  | 
then show "PROP P" .  | 
| 21151 | 1306  | 
qed  | 
1307  | 
||
1308  | 
lemma ex_simps:  | 
|
1309  | 
"!!P Q. (EX x. P x & Q) = ((EX x. P x) & Q)"  | 
|
1310  | 
"!!P Q. (EX x. P & Q x) = (P & (EX x. Q x))"  | 
|
1311  | 
"!!P Q. (EX x. P x | Q) = ((EX x. P x) | Q)"  | 
|
1312  | 
"!!P Q. (EX x. P | Q x) = (P | (EX x. Q x))"  | 
|
1313  | 
"!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"  | 
|
1314  | 
"!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"  | 
|
1315  | 
  -- {* Miniscoping: pushing in existential quantifiers. *}
 | 
|
1316  | 
by (iprover | blast)+  | 
|
1317  | 
||
1318  | 
lemma all_simps:  | 
|
1319  | 
"!!P Q. (ALL x. P x & Q) = ((ALL x. P x) & Q)"  | 
|
1320  | 
"!!P Q. (ALL x. P & Q x) = (P & (ALL x. Q x))"  | 
|
1321  | 
"!!P Q. (ALL x. P x | Q) = ((ALL x. P x) | Q)"  | 
|
1322  | 
"!!P Q. (ALL x. P | Q x) = (P | (ALL x. Q x))"  | 
|
1323  | 
"!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"  | 
|
1324  | 
"!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"  | 
|
1325  | 
  -- {* Miniscoping: pushing in universal quantifiers. *}
 | 
|
1326  | 
by (iprover | blast)+  | 
|
| 15481 | 1327  | 
|
| 21671 | 1328  | 
lemmas [simp] =  | 
1329  | 
triv_forall_equality (*prunes params*)  | 
|
1330  | 
True_implies_equals (*prune asms `True'*)  | 
|
1331  | 
if_True  | 
|
1332  | 
if_False  | 
|
1333  | 
if_cancel  | 
|
1334  | 
if_eq_cancel  | 
|
1335  | 
imp_disjL  | 
|
| 20973 | 1336  | 
(*In general it seems wrong to add distributive laws by default: they  | 
1337  | 
might cause exponential blow-up. But imp_disjL has been in for a while  | 
|
1338  | 
and cannot be removed without affecting existing proofs. Moreover,  | 
|
1339  | 
rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the  | 
|
1340  | 
grounds that it allows simplification of R in the two cases.*)  | 
|
| 21671 | 1341  | 
conj_assoc  | 
1342  | 
disj_assoc  | 
|
1343  | 
de_Morgan_conj  | 
|
1344  | 
de_Morgan_disj  | 
|
1345  | 
imp_disj1  | 
|
1346  | 
imp_disj2  | 
|
1347  | 
not_imp  | 
|
1348  | 
disj_not1  | 
|
1349  | 
not_all  | 
|
1350  | 
not_ex  | 
|
1351  | 
cases_simp  | 
|
1352  | 
the_eq_trivial  | 
|
1353  | 
the_sym_eq_trivial  | 
|
1354  | 
ex_simps  | 
|
1355  | 
all_simps  | 
|
1356  | 
simp_thms  | 
|
1357  | 
||
1358  | 
lemmas [cong] = imp_cong simp_implies_cong  | 
|
1359  | 
lemmas [split] = split_if  | 
|
| 20973 | 1360  | 
|
| 22377 | 1361  | 
ML {* val HOL_ss = @{simpset} *}
 | 
| 20973 | 1362  | 
|
| 20944 | 1363  | 
text {* Simplifies x assuming c and y assuming ~c *}
 | 
1364  | 
lemma if_cong:  | 
|
1365  | 
assumes "b = c"  | 
|
1366  | 
and "c \<Longrightarrow> x = u"  | 
|
1367  | 
and "\<not> c \<Longrightarrow> y = v"  | 
|
1368  | 
shows "(if b then x else y) = (if c then u else v)"  | 
|
| 38525 | 1369  | 
using assms by simp  | 
| 20944 | 1370  | 
|
1371  | 
text {* Prevents simplification of x and y:
 | 
|
1372  | 
faster and allows the execution of functional programs. *}  | 
|
1373  | 
lemma if_weak_cong [cong]:  | 
|
1374  | 
assumes "b = c"  | 
|
1375  | 
shows "(if b then x else y) = (if c then x else y)"  | 
|
| 23553 | 1376  | 
using assms by (rule arg_cong)  | 
| 20944 | 1377  | 
|
1378  | 
text {* Prevents simplification of t: much faster *}
 | 
|
1379  | 
lemma let_weak_cong:  | 
|
1380  | 
assumes "a = b"  | 
|
1381  | 
shows "(let x = a in t x) = (let x = b in t x)"  | 
|
| 23553 | 1382  | 
using assms by (rule arg_cong)  | 
| 20944 | 1383  | 
|
1384  | 
text {* To tidy up the result of a simproc.  Only the RHS will be simplified. *}
 | 
|
1385  | 
lemma eq_cong2:  | 
|
1386  | 
assumes "u = u'"  | 
|
1387  | 
shows "(t \<equiv> u) \<equiv> (t \<equiv> u')"  | 
|
| 23553 | 1388  | 
using assms by simp  | 
| 20944 | 1389  | 
|
1390  | 
lemma if_distrib:  | 
|
1391  | 
"f (if c then x else y) = (if c then f x else f y)"  | 
|
1392  | 
by simp  | 
|
1393  | 
||
| 
44277
 
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
 
haftmann 
parents: 
44121 
diff
changeset
 | 
1394  | 
text{*As a simplification rule, it replaces all function equalities by
 | 
| 
 
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
 
haftmann 
parents: 
44121 
diff
changeset
 | 
1395  | 
first-order equalities.*}  | 
| 
 
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
 
haftmann 
parents: 
44121 
diff
changeset
 | 
1396  | 
lemma fun_eq_iff: "f = g \<longleftrightarrow> (\<forall>x. f x = g x)"  | 
| 
 
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
 
haftmann 
parents: 
44121 
diff
changeset
 | 
1397  | 
by auto  | 
| 
 
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
 
haftmann 
parents: 
44121 
diff
changeset
 | 
1398  | 
|
| 17459 | 1399  | 
|
| 20944 | 1400  | 
subsubsection {* Generic cases and induction *}
 | 
| 17459 | 1401  | 
|
| 20944 | 1402  | 
text {* Rule projections: *}
 | 
| 18887 | 1403  | 
|
| 20944 | 1404  | 
ML {*
 | 
| 32172 | 1405  | 
structure Project_Rule = Project_Rule  | 
| 25388 | 1406  | 
(  | 
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1407  | 
  val conjunct1 = @{thm conjunct1}
 | 
| 
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1408  | 
  val conjunct2 = @{thm conjunct2}
 | 
| 
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1409  | 
  val mp = @{thm mp}
 | 
| 25388 | 1410  | 
)  | 
| 17459 | 1411  | 
*}  | 
1412  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1413  | 
definition induct_forall where  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1414  | 
"induct_forall P == \<forall>x. P x"  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1415  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1416  | 
definition induct_implies where  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1417  | 
"induct_implies A B == A \<longrightarrow> B"  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1418  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1419  | 
definition induct_equal where  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1420  | 
"induct_equal x y == x = y"  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1421  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1422  | 
definition induct_conj where  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1423  | 
"induct_conj A B == A \<and> B"  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1424  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1425  | 
definition induct_true where  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1426  | 
"induct_true == True"  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1427  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1428  | 
definition induct_false where  | 
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35115 
diff
changeset
 | 
1429  | 
"induct_false == False"  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1430  | 
|
| 11989 | 1431  | 
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"  | 
| 18457 | 1432  | 
by (unfold atomize_all induct_forall_def)  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1433  | 
|
| 11989 | 1434  | 
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"  | 
| 18457 | 1435  | 
by (unfold atomize_imp induct_implies_def)  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1436  | 
|
| 11989 | 1437  | 
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"  | 
| 18457 | 1438  | 
by (unfold atomize_eq induct_equal_def)  | 
1439  | 
||
| 
28856
 
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
 
wenzelm 
parents: 
28741 
diff
changeset
 | 
1440  | 
lemma induct_conj_eq: "(A &&& B) == Trueprop (induct_conj A B)"  | 
| 18457 | 1441  | 
by (unfold atomize_conj induct_conj_def)  | 
1442  | 
||
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1443  | 
lemmas induct_atomize' = induct_forall_eq induct_implies_eq induct_conj_eq  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1444  | 
lemmas induct_atomize = induct_atomize' induct_equal_eq  | 
| 45607 | 1445  | 
lemmas induct_rulify' [symmetric] = induct_atomize'  | 
1446  | 
lemmas induct_rulify [symmetric] = induct_atomize  | 
|
| 18457 | 1447  | 
lemmas induct_rulify_fallback =  | 
1448  | 
induct_forall_def induct_implies_def induct_equal_def induct_conj_def  | 
|
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1449  | 
induct_true_def induct_false_def  | 
| 18457 | 1450  | 
|
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1451  | 
|
| 11989 | 1452  | 
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =  | 
1453  | 
induct_conj (induct_forall A) (induct_forall B)"  | 
|
| 17589 | 1454  | 
by (unfold induct_forall_def induct_conj_def) iprover  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1455  | 
|
| 11989 | 1456  | 
lemma induct_implies_conj: "induct_implies C (induct_conj A B) =  | 
1457  | 
induct_conj (induct_implies C A) (induct_implies C B)"  | 
|
| 17589 | 1458  | 
by (unfold induct_implies_def induct_conj_def) iprover  | 
| 11989 | 1459  | 
|
| 
13598
 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
 
berghofe 
parents: 
13596 
diff
changeset
 | 
1460  | 
lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)"  | 
| 
 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
 
berghofe 
parents: 
13596 
diff
changeset
 | 
1461  | 
proof  | 
| 
 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
 
berghofe 
parents: 
13596 
diff
changeset
 | 
1462  | 
assume r: "induct_conj A B ==> PROP C" and A B  | 
| 18457 | 1463  | 
show "PROP C" by (rule r) (simp add: induct_conj_def `A` `B`)  | 
| 
13598
 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
 
berghofe 
parents: 
13596 
diff
changeset
 | 
1464  | 
next  | 
| 
 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
 
berghofe 
parents: 
13596 
diff
changeset
 | 
1465  | 
assume r: "A ==> B ==> PROP C" and "induct_conj A B"  | 
| 18457 | 1466  | 
show "PROP C" by (rule r) (simp_all add: `induct_conj A B` [unfolded induct_conj_def])  | 
| 
13598
 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
 
berghofe 
parents: 
13596 
diff
changeset
 | 
1467  | 
qed  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1468  | 
|
| 11989 | 1469  | 
lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1470  | 
|
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1471  | 
lemma induct_trueI: "induct_true"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1472  | 
by (simp add: induct_true_def)  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1473  | 
|
| 
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1474  | 
text {* Method setup. *}
 | 
| 
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1475  | 
|
| 
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1476  | 
ML {*
 | 
| 32171 | 1477  | 
structure Induct = Induct  | 
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1478  | 
(  | 
| 
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1479  | 
  val cases_default = @{thm case_split}
 | 
| 
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1480  | 
  val atomize = @{thms induct_atomize}
 | 
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1481  | 
  val rulify = @{thms induct_rulify'}
 | 
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1482  | 
  val rulify_fallback = @{thms induct_rulify_fallback}
 | 
| 
34988
 
cca208c8d619
Added setup for simplification of equality constraints in cases rules.
 
berghofe 
parents: 
34917 
diff
changeset
 | 
1483  | 
  val equal_def = @{thm induct_equal_def}
 | 
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1484  | 
  fun dest_def (Const (@{const_name induct_equal}, _) $ t $ u) = SOME (t, u)
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1485  | 
| dest_def _ = NONE  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1486  | 
  val trivial_tac = match_tac @{thms induct_trueI}
 | 
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1487  | 
)  | 
| 
11824
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1488  | 
*}  | 
| 
 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
 
wenzelm 
parents: 
11770 
diff
changeset
 | 
1489  | 
|
| 
45014
 
0e847655b2d8
New proof method "induction" that gives induction hypotheses the name IH.
 
nipkow 
parents: 
44921 
diff
changeset
 | 
1490  | 
use "~~/src/Tools/induction.ML"  | 
| 
 
0e847655b2d8
New proof method "induction" that gives induction hypotheses the name IH.
 
nipkow 
parents: 
44921 
diff
changeset
 | 
1491  | 
|
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1492  | 
setup {*
 | 
| 
45014
 
0e847655b2d8
New proof method "induction" that gives induction hypotheses the name IH.
 
nipkow 
parents: 
44921 
diff
changeset
 | 
1493  | 
Induct.setup #> Induction.setup #>  | 
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1494  | 
Context.theory_map (Induct.map_simpset (fn ss => ss  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1495  | 
addsimprocs  | 
| 
38715
 
6513ea67d95d
renamed Simplifier.simproc(_i) to Simplifier.simproc_global(_i) to emphasize that this is not the real thing;
 
wenzelm 
parents: 
38708 
diff
changeset
 | 
1496  | 
      [Simplifier.simproc_global @{theory} "swap_induct_false"
 | 
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1497  | 
["induct_false ==> PROP P ==> PROP Q"]  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1498  | 
(fn _ => fn _ =>  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1499  | 
            (fn _ $ (P as _ $ @{const induct_false}) $ (_ $ Q $ _) =>
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1500  | 
if P <> Q then SOME Drule.swap_prems_eq else NONE  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1501  | 
| _ => NONE)),  | 
| 
38715
 
6513ea67d95d
renamed Simplifier.simproc(_i) to Simplifier.simproc_global(_i) to emphasize that this is not the real thing;
 
wenzelm 
parents: 
38708 
diff
changeset
 | 
1502  | 
       Simplifier.simproc_global @{theory} "induct_equal_conj_curry"
 | 
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1503  | 
["induct_conj P Q ==> PROP R"]  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1504  | 
(fn _ => fn _ =>  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1505  | 
(fn _ $ (_ $ P) $ _ =>  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1506  | 
let  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1507  | 
                  fun is_conj (@{const induct_conj} $ P $ Q) =
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1508  | 
is_conj P andalso is_conj Q  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1509  | 
                    | is_conj (Const (@{const_name induct_equal}, _) $ _ $ _) = true
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1510  | 
                    | is_conj @{const induct_true} = true
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1511  | 
                    | is_conj @{const induct_false} = true
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1512  | 
| is_conj _ = false  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1513  | 
                in if is_conj P then SOME @{thm induct_conj_curry} else NONE end
 | 
| 
45625
 
750c5a47400b
modernized some old-style infix operations, which were left over from the time of ML proof scripts;
 
wenzelm 
parents: 
45607 
diff
changeset
 | 
1514  | 
| _ => NONE))]  | 
| 
 
750c5a47400b
modernized some old-style infix operations, which were left over from the time of ML proof scripts;
 
wenzelm 
parents: 
45607 
diff
changeset
 | 
1515  | 
|> Simplifier.set_mksimps (fn ss => Simpdata.mksimps Simpdata.mksimps_pairs ss #>  | 
| 
 
750c5a47400b
modernized some old-style infix operations, which were left over from the time of ML proof scripts;
 
wenzelm 
parents: 
45607 
diff
changeset
 | 
1516  | 
map (Simplifier.rewrite_rule (map Thm.symmetric  | 
| 
 
750c5a47400b
modernized some old-style infix operations, which were left over from the time of ML proof scripts;
 
wenzelm 
parents: 
45607 
diff
changeset
 | 
1517  | 
        @{thms induct_rulify_fallback})))))
 | 
| 
34908
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1518  | 
*}  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1519  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1520  | 
text {* Pre-simplification of induction and cases rules *}
 | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1521  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1522  | 
lemma [induct_simp]: "(!!x. induct_equal x t ==> PROP P x) == PROP P t"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1523  | 
unfolding induct_equal_def  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1524  | 
proof  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1525  | 
assume R: "!!x. x = t ==> PROP P x"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1526  | 
show "PROP P t" by (rule R [OF refl])  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1527  | 
next  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1528  | 
fix x assume "PROP P t" "x = t"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1529  | 
then show "PROP P x" by simp  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1530  | 
qed  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1531  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1532  | 
lemma [induct_simp]: "(!!x. induct_equal t x ==> PROP P x) == PROP P t"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1533  | 
unfolding induct_equal_def  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1534  | 
proof  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1535  | 
assume R: "!!x. t = x ==> PROP P x"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1536  | 
show "PROP P t" by (rule R [OF refl])  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1537  | 
next  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1538  | 
fix x assume "PROP P t" "t = x"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1539  | 
then show "PROP P x" by simp  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1540  | 
qed  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1541  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1542  | 
lemma [induct_simp]: "(induct_false ==> P) == Trueprop induct_true"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1543  | 
unfolding induct_false_def induct_true_def  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1544  | 
by (iprover intro: equal_intr_rule)  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1545  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1546  | 
lemma [induct_simp]: "(induct_true ==> PROP P) == PROP P"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1547  | 
unfolding induct_true_def  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1548  | 
proof  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1549  | 
assume R: "True \<Longrightarrow> PROP P"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1550  | 
from TrueI show "PROP P" by (rule R)  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1551  | 
next  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1552  | 
assume "PROP P"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1553  | 
then show "PROP P" .  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1554  | 
qed  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1555  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1556  | 
lemma [induct_simp]: "(PROP P ==> induct_true) == Trueprop induct_true"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1557  | 
unfolding induct_true_def  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1558  | 
by (iprover intro: equal_intr_rule)  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1559  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1560  | 
lemma [induct_simp]: "(!!x. induct_true) == Trueprop induct_true"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1561  | 
unfolding induct_true_def  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1562  | 
by (iprover intro: equal_intr_rule)  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1563  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1564  | 
lemma [induct_simp]: "induct_implies induct_true P == P"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1565  | 
by (simp add: induct_implies_def induct_true_def)  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1566  | 
|
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1567  | 
lemma [induct_simp]: "(x = x) = True"  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1568  | 
by (rule simp_thms)  | 
| 
 
d546e75631bb
Added setup for simplification of equality constraints in induction rules.
 
berghofe 
parents: 
34294 
diff
changeset
 | 
1569  | 
|
| 
36176
 
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
 
wenzelm 
parents: 
36060 
diff
changeset
 | 
1570  | 
hide_const induct_forall induct_implies induct_equal induct_conj induct_true induct_false  | 
| 18457 | 1571  | 
|
| 
27326
 
d3beec370964
moved src/HOL/Tools/induct_tacs.ML to src/Tools/induct_tacs.ML;
 
wenzelm 
parents: 
27212 
diff
changeset
 | 
1572  | 
use "~~/src/Tools/induct_tacs.ML"  | 
| 45133 | 1573  | 
setup Induct_Tacs.setup  | 
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1574  | 
|
| 20944 | 1575  | 
|
| 28325 | 1576  | 
subsubsection {* Coherent logic *}
 | 
1577  | 
||
1578  | 
ML {*
 | 
|
| 32734 | 1579  | 
structure Coherent = Coherent  | 
| 28325 | 1580  | 
(  | 
1581  | 
  val atomize_elimL = @{thm atomize_elimL}
 | 
|
1582  | 
  val atomize_exL = @{thm atomize_exL}
 | 
|
1583  | 
  val atomize_conjL = @{thm atomize_conjL}
 | 
|
1584  | 
  val atomize_disjL = @{thm atomize_disjL}
 | 
|
1585  | 
val operator_names =  | 
|
| 
38795
 
848be46708dc
formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
 
haftmann 
parents: 
38786 
diff
changeset
 | 
1586  | 
    [@{const_name HOL.disj}, @{const_name HOL.conj}, @{const_name Ex}]
 | 
| 28325 | 1587  | 
);  | 
1588  | 
*}  | 
|
1589  | 
||
1590  | 
setup Coherent.setup  | 
|
1591  | 
||
1592  | 
||
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1593  | 
subsubsection {* Reorienting equalities *}
 | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1594  | 
|
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1595  | 
ML {*
 | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1596  | 
signature REORIENT_PROC =  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1597  | 
sig  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1598  | 
val add : (term -> bool) -> theory -> theory  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1599  | 
val proc : morphism -> simpset -> cterm -> thm option  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1600  | 
end;  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1601  | 
|
| 33523 | 1602  | 
structure Reorient_Proc : REORIENT_PROC =  | 
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1603  | 
struct  | 
| 33523 | 1604  | 
structure Data = Theory_Data  | 
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1605  | 
(  | 
| 33523 | 1606  | 
type T = ((term -> bool) * stamp) list;  | 
1607  | 
val empty = [];  | 
|
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1608  | 
val extend = I;  | 
| 33523 | 1609  | 
fun merge data : T = Library.merge (eq_snd op =) data;  | 
1610  | 
);  | 
|
1611  | 
fun add m = Data.map (cons (m, stamp ()));  | 
|
1612  | 
fun matches thy t = exists (fn (m, _) => m t) (Data.get thy);  | 
|
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1613  | 
|
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1614  | 
  val meta_reorient = @{thm eq_commute [THEN eq_reflection]};
 | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1615  | 
fun proc phi ss ct =  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1616  | 
let  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1617  | 
val ctxt = Simplifier.the_context ss;  | 
| 42361 | 1618  | 
val thy = Proof_Context.theory_of ctxt;  | 
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1619  | 
in  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1620  | 
case Thm.term_of ct of  | 
| 33523 | 1621  | 
(_ $ t $ u) => if matches thy u then NONE else SOME meta_reorient  | 
| 
31024
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1622  | 
| _ => NONE  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1623  | 
end;  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1624  | 
end;  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1625  | 
*}  | 
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1626  | 
|
| 
 
0fdf666e08bf
reimplement reorientation simproc using theory data
 
huffman 
parents: 
30980 
diff
changeset
 | 
1627  | 
|
| 20944 | 1628  | 
subsection {* Other simple lemmas and lemma duplicates *}
 | 
1629  | 
||
1630  | 
lemma ex1_eq [iff]: "EX! x. x = t" "EX! x. t = x"  | 
|
1631  | 
by blast+  | 
|
1632  | 
||
1633  | 
lemma choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))"  | 
|
1634  | 
apply (rule iffI)  | 
|
1635  | 
apply (rule_tac a = "%x. THE y. P x y" in ex1I)  | 
|
1636  | 
apply (fast dest!: theI')  | 
|
| 44921 | 1637  | 
apply (fast intro: the1_equality [symmetric])  | 
| 20944 | 1638  | 
apply (erule ex1E)  | 
1639  | 
apply (rule allI)  | 
|
1640  | 
apply (rule ex1I)  | 
|
1641  | 
apply (erule spec)  | 
|
1642  | 
apply (erule_tac x = "%z. if z = x then y else f z" in allE)  | 
|
1643  | 
apply (erule impE)  | 
|
1644  | 
apply (rule allI)  | 
|
| 
27126
 
3ede9103de8e
eliminated obsolete case_split_thm -- use case_split;
 
wenzelm 
parents: 
27107 
diff
changeset
 | 
1645  | 
apply (case_tac "xa = x")  | 
| 20944 | 1646  | 
apply (drule_tac [3] x = x in fun_cong, simp_all)  | 
1647  | 
done  | 
|
1648  | 
||
| 22218 | 1649  | 
lemmas eq_sym_conv = eq_commute  | 
1650  | 
||
| 
23037
 
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
 
chaieb 
parents: 
22993 
diff
changeset
 | 
1651  | 
lemma nnf_simps:  | 
| 
 
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
 
chaieb 
parents: 
22993 
diff
changeset
 | 
1652  | 
"(\<not>(P \<and> Q)) = (\<not> P \<or> \<not> Q)" "(\<not> (P \<or> Q)) = (\<not> P \<and> \<not>Q)" "(P \<longrightarrow> Q) = (\<not>P \<or> Q)"  | 
| 
 
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
 
chaieb 
parents: 
22993 
diff
changeset
 | 
1653  | 
"(P = Q) = ((P \<and> Q) \<or> (\<not>P \<and> \<not> Q))" "(\<not>(P = Q)) = ((P \<and> \<not> Q) \<or> (\<not>P \<and> Q))"  | 
| 
 
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
 
chaieb 
parents: 
22993 
diff
changeset
 | 
1654  | 
"(\<not> \<not>(P)) = P"  | 
| 
 
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
 
chaieb 
parents: 
22993 
diff
changeset
 | 
1655  | 
by blast+  | 
| 
 
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
 
chaieb 
parents: 
22993 
diff
changeset
 | 
1656  | 
|
| 21671 | 1657  | 
subsection {* Basic ML bindings *}
 | 
1658  | 
||
1659  | 
ML {*
 | 
|
| 22129 | 1660  | 
val FalseE = @{thm FalseE}
 | 
1661  | 
val Let_def = @{thm Let_def}
 | 
|
1662  | 
val TrueI = @{thm TrueI}
 | 
|
1663  | 
val allE = @{thm allE}
 | 
|
1664  | 
val allI = @{thm allI}
 | 
|
1665  | 
val all_dupE = @{thm all_dupE}
 | 
|
1666  | 
val arg_cong = @{thm arg_cong}
 | 
|
1667  | 
val box_equals = @{thm box_equals}
 | 
|
1668  | 
val ccontr = @{thm ccontr}
 | 
|
1669  | 
val classical = @{thm classical}
 | 
|
1670  | 
val conjE = @{thm conjE}
 | 
|
1671  | 
val conjI = @{thm conjI}
 | 
|
1672  | 
val conjunct1 = @{thm conjunct1}
 | 
|
1673  | 
val conjunct2 = @{thm conjunct2}
 | 
|
1674  | 
val disjCI = @{thm disjCI}
 | 
|
1675  | 
val disjE = @{thm disjE}
 | 
|
1676  | 
val disjI1 = @{thm disjI1}
 | 
|
1677  | 
val disjI2 = @{thm disjI2}
 | 
|
1678  | 
val eq_reflection = @{thm eq_reflection}
 | 
|
1679  | 
val ex1E = @{thm ex1E}
 | 
|
1680  | 
val ex1I = @{thm ex1I}
 | 
|
1681  | 
val ex1_implies_ex = @{thm ex1_implies_ex}
 | 
|
1682  | 
val exE = @{thm exE}
 | 
|
1683  | 
val exI = @{thm exI}
 | 
|
1684  | 
val excluded_middle = @{thm excluded_middle}
 | 
|
1685  | 
val ext = @{thm ext}
 | 
|
1686  | 
val fun_cong = @{thm fun_cong}
 | 
|
1687  | 
val iffD1 = @{thm iffD1}
 | 
|
1688  | 
val iffD2 = @{thm iffD2}
 | 
|
1689  | 
val iffI = @{thm iffI}
 | 
|
1690  | 
val impE = @{thm impE}
 | 
|
1691  | 
val impI = @{thm impI}
 | 
|
1692  | 
val meta_eq_to_obj_eq = @{thm meta_eq_to_obj_eq}
 | 
|
1693  | 
val mp = @{thm mp}
 | 
|
1694  | 
val notE = @{thm notE}
 | 
|
1695  | 
val notI = @{thm notI}
 | 
|
1696  | 
val not_all = @{thm not_all}
 | 
|
1697  | 
val not_ex = @{thm not_ex}
 | 
|
1698  | 
val not_iff = @{thm not_iff}
 | 
|
1699  | 
val not_not = @{thm not_not}
 | 
|
1700  | 
val not_sym = @{thm not_sym}
 | 
|
1701  | 
val refl = @{thm refl}
 | 
|
1702  | 
val rev_mp = @{thm rev_mp}
 | 
|
1703  | 
val spec = @{thm spec}
 | 
|
1704  | 
val ssubst = @{thm ssubst}
 | 
|
1705  | 
val subst = @{thm subst}
 | 
|
1706  | 
val sym = @{thm sym}
 | 
|
1707  | 
val trans = @{thm trans}
 | 
|
| 21671 | 1708  | 
*}  | 
1709  | 
||
| 
39036
 
dff91b90d74c
use definitional CNFs in Metis rather than plain CNF, following a suggestion by Joe Hurd;
 
blanchet 
parents: 
39014 
diff
changeset
 | 
1710  | 
use "Tools/cnf_funcs.ML"  | 
| 21671 | 1711  | 
|
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1712  | 
subsection {* Code generator setup *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1713  | 
|
| 31151 | 1714  | 
subsubsection {* Generic code generator preprocessor setup *}
 | 
1715  | 
||
1716  | 
setup {*
 | 
|
1717  | 
Code_Preproc.map_pre (K HOL_basic_ss)  | 
|
1718  | 
#> Code_Preproc.map_post (K HOL_basic_ss)  | 
|
| 37442 | 1719  | 
#> Code_Simp.map_ss (K HOL_basic_ss)  | 
| 31151 | 1720  | 
*}  | 
1721  | 
||
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1722  | 
subsubsection {* Equality *}
 | 
| 
24844
 
98c006a30218
certificates for code generator case expressions
 
haftmann 
parents: 
24842 
diff
changeset
 | 
1723  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1724  | 
class equal =  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1725  | 
fixes equal :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1726  | 
assumes equal_eq: "equal x y \<longleftrightarrow> x = y"  | 
| 26513 | 1727  | 
begin  | 
1728  | 
||
| 
45231
 
d85a2fdc586c
replacing code_inline by code_unfold, removing obsolete code_unfold, code_inline del now that the ancient code generator is removed
 
bulwahn 
parents: 
45171 
diff
changeset
 | 
1729  | 
lemma equal: "equal = (op =)"  | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1730  | 
by (rule ext equal_eq)+  | 
| 
28346
 
b8390cd56b8f
discontinued special treatment of op = vs. eq_class.eq
 
haftmann 
parents: 
28325 
diff
changeset
 | 
1731  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1732  | 
lemma equal_refl: "equal x x \<longleftrightarrow> True"  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1733  | 
unfolding equal by rule+  | 
| 
28346
 
b8390cd56b8f
discontinued special treatment of op = vs. eq_class.eq
 
haftmann 
parents: 
28325 
diff
changeset
 | 
1734  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1735  | 
lemma eq_equal: "(op =) \<equiv> equal"  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1736  | 
by (rule eq_reflection) (rule ext, rule ext, rule sym, rule equal_eq)  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1737  | 
|
| 26513 | 1738  | 
end  | 
1739  | 
||
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1740  | 
declare eq_equal [symmetric, code_post]  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1741  | 
declare eq_equal [code]  | 
| 30966 | 1742  | 
|
| 31151 | 1743  | 
setup {*
 | 
1744  | 
Code_Preproc.map_pre (fn simpset =>  | 
|
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
1745  | 
    simpset addsimprocs [Simplifier.simproc_global_i @{theory} "equal" [@{term HOL.eq}]
 | 
| 40842 | 1746  | 
(fn thy => fn _ =>  | 
1747  | 
        fn Const (_, Type ("fun", [Type _, _])) => SOME @{thm eq_equal} | _ => NONE)])
 | 
|
| 31151 | 1748  | 
*}  | 
1749  | 
||
| 30966 | 1750  | 
|
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1751  | 
subsubsection {* Generic code generator foundation *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1752  | 
|
| 
39421
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1753  | 
text {* Datatype @{typ bool} *}
 | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1754  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1755  | 
code_datatype True False  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1756  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1757  | 
lemma [code]:  | 
| 
33185
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1758  | 
shows "False \<and> P \<longleftrightarrow> False"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1759  | 
and "True \<and> P \<longleftrightarrow> P"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1760  | 
and "P \<and> False \<longleftrightarrow> False"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1761  | 
and "P \<and> True \<longleftrightarrow> P" by simp_all  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1762  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1763  | 
lemma [code]:  | 
| 
33185
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1764  | 
shows "False \<or> P \<longleftrightarrow> P"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1765  | 
and "True \<or> P \<longleftrightarrow> True"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1766  | 
and "P \<or> False \<longleftrightarrow> P"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1767  | 
and "P \<or> True \<longleftrightarrow> True" by simp_all  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1768  | 
|
| 
33185
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1769  | 
lemma [code]:  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1770  | 
shows "(False \<longrightarrow> P) \<longleftrightarrow> True"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1771  | 
and "(True \<longrightarrow> P) \<longleftrightarrow> P"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1772  | 
and "(P \<longrightarrow> False) \<longleftrightarrow> \<not> P"  | 
| 
 
247f6c6969d9
tuned code setup for primitive boolean connectors
 
haftmann 
parents: 
33084 
diff
changeset
 | 
1773  | 
and "(P \<longrightarrow> True) \<longleftrightarrow> True" by simp_all  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1774  | 
|
| 
39421
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1775  | 
text {* More about @{typ prop} *}
 | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1776  | 
|
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1777  | 
lemma [code nbe]:  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1778  | 
shows "(True \<Longrightarrow> PROP Q) \<equiv> PROP Q"  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1779  | 
and "(PROP Q \<Longrightarrow> True) \<equiv> Trueprop True"  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1780  | 
and "(P \<Longrightarrow> R) \<equiv> Trueprop (P \<longrightarrow> R)" by (auto intro!: equal_intr_rule)  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1781  | 
|
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1782  | 
lemma Trueprop_code [code]:  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1783  | 
"Trueprop True \<equiv> Code_Generator.holds"  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1784  | 
by (auto intro!: equal_intr_rule holds)  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1785  | 
|
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1786  | 
declare Trueprop_code [symmetric, code_post]  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1787  | 
|
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1788  | 
text {* Equality *}
 | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1789  | 
|
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1790  | 
declare simp_thms(6) [code nbe]  | 
| 
 
b6a77cffc231
introduced "holds" as synthetic datatype constructor for "prop"; moved Pure code generator setup to Code_Generator.thy
 
haftmann 
parents: 
39403 
diff
changeset
 | 
1791  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1792  | 
instantiation itself :: (type) equal  | 
| 31132 | 1793  | 
begin  | 
1794  | 
||
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1795  | 
definition equal_itself :: "'a itself \<Rightarrow> 'a itself \<Rightarrow> bool" where  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1796  | 
"equal_itself x y \<longleftrightarrow> x = y"  | 
| 31132 | 1797  | 
|
1798  | 
instance proof  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1799  | 
qed (fact equal_itself_def)  | 
| 31132 | 1800  | 
|
1801  | 
end  | 
|
1802  | 
||
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1803  | 
lemma equal_itself_code [code]:  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1804  | 
  "equal TYPE('a) TYPE('a) \<longleftrightarrow> True"
 | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1805  | 
by (simp add: equal)  | 
| 31132 | 1806  | 
|
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1807  | 
setup {*
 | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1808  | 
  Sign.add_const_constraint (@{const_name equal}, SOME @{typ "'a\<Colon>type \<Rightarrow> 'a \<Rightarrow> bool"})
 | 
| 
31956
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1809  | 
*}  | 
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1810  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1811  | 
lemma equal_alias_cert: "OFCLASS('a, equal_class) \<equiv> ((op = :: 'a \<Rightarrow> 'a \<Rightarrow> bool) \<equiv> equal)" (is "?ofclass \<equiv> ?equal")
 | 
| 
31956
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1812  | 
proof  | 
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1813  | 
assume "PROP ?ofclass"  | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1814  | 
show "PROP ?equal"  | 
| 
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1815  | 
    by (tactic {* ALLGOALS (rtac (Thm.unconstrainT @{thm eq_equal})) *})
 | 
| 
31956
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1816  | 
(fact `PROP ?ofclass`)  | 
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1817  | 
next  | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1818  | 
assume "PROP ?equal"  | 
| 
31956
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1819  | 
show "PROP ?ofclass" proof  | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1820  | 
qed (simp add: `PROP ?equal`)  | 
| 
31956
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1821  | 
qed  | 
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1822  | 
|
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1823  | 
setup {*
 | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1824  | 
  Sign.add_const_constraint (@{const_name equal}, SOME @{typ "'a\<Colon>equal \<Rightarrow> 'a \<Rightarrow> bool"})
 | 
| 
31956
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1825  | 
*}  | 
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1826  | 
|
| 
 
c3844c4d0c2c
more accurate certificates for constant aliasses
 
haftmann 
parents: 
31902 
diff
changeset
 | 
1827  | 
setup {*
 | 
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1828  | 
  Nbe.add_const_alias @{thm equal_alias_cert}
 | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1829  | 
*}  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1830  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1831  | 
text {* Cases *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1832  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1833  | 
lemma Let_case_cert:  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1834  | 
assumes "CASE \<equiv> (\<lambda>x. Let x f)"  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1835  | 
shows "CASE x \<equiv> f x"  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1836  | 
using assms by simp_all  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1837  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1838  | 
setup {*
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1839  | 
  Code.add_case @{thm Let_case_cert}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1840  | 
  #> Code.add_undefined @{const_name undefined}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1841  | 
*}  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1842  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1843  | 
code_abort undefined  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1844  | 
|
| 38972 | 1845  | 
|
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1846  | 
subsubsection {* Generic code generator target languages *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1847  | 
|
| 38972 | 1848  | 
text {* type @{typ bool} *}
 | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1849  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1850  | 
code_type bool  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1851  | 
(SML "bool")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1852  | 
(OCaml "bool")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1853  | 
(Haskell "Bool")  | 
| 34294 | 1854  | 
(Scala "Boolean")  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1855  | 
|
| 
42420
 
8a09dfeb2cec
making the evaluation of HOL.implies lazy even in strict languages by mapping it to an if statement
 
bulwahn 
parents: 
42361 
diff
changeset
 | 
1856  | 
code_const True and False and Not and HOL.conj and HOL.disj and HOL.implies and If  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1857  | 
(SML "true" and "false" and "not"  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1858  | 
and infixl 1 "andalso" and infixl 0 "orelse"  | 
| 
42420
 
8a09dfeb2cec
making the evaluation of HOL.implies lazy even in strict languages by mapping it to an if statement
 
bulwahn 
parents: 
42361 
diff
changeset
 | 
1859  | 
and "!(if (_)/ then (_)/ else true)"  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1860  | 
and "!(if (_)/ then (_)/ else (_))")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1861  | 
(OCaml "true" and "false" and "not"  | 
| 39715 | 1862  | 
and infixl 3 "&&" and infixl 2 "||"  | 
| 
42420
 
8a09dfeb2cec
making the evaluation of HOL.implies lazy even in strict languages by mapping it to an if statement
 
bulwahn 
parents: 
42361 
diff
changeset
 | 
1863  | 
and "!(if (_)/ then (_)/ else true)"  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1864  | 
and "!(if (_)/ then (_)/ else (_))")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1865  | 
(Haskell "True" and "False" and "not"  | 
| 
42178
 
b992c8e6394b
corrected infix precedence for boolean operators in Haskell
 
haftmann 
parents: 
42057 
diff
changeset
 | 
1866  | 
and infixr 3 "&&" and infixr 2 "||"  | 
| 
42420
 
8a09dfeb2cec
making the evaluation of HOL.implies lazy even in strict languages by mapping it to an if statement
 
bulwahn 
parents: 
42361 
diff
changeset
 | 
1867  | 
and "!(if (_)/ then (_)/ else True)"  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1868  | 
and "!(if (_)/ then (_)/ else (_))")  | 
| 
38773
 
f9837065b5e8
prevent line breaks after Scala symbolic operators
 
haftmann 
parents: 
38715 
diff
changeset
 | 
1869  | 
(Scala "true" and "false" and "'! _"  | 
| 34305 | 1870  | 
and infixl 3 "&&" and infixl 1 "||"  | 
| 
42420
 
8a09dfeb2cec
making the evaluation of HOL.implies lazy even in strict languages by mapping it to an if statement
 
bulwahn 
parents: 
42361 
diff
changeset
 | 
1871  | 
and "!(if ((_))/ (_)/ else true)"  | 
| 34305 | 1872  | 
and "!(if ((_))/ (_)/ else (_))")  | 
| 34294 | 1873  | 
|
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1874  | 
code_reserved SML  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1875  | 
bool true false not  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1876  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1877  | 
code_reserved OCaml  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1878  | 
bool not  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1879  | 
|
| 34294 | 1880  | 
code_reserved Scala  | 
1881  | 
Boolean  | 
|
1882  | 
||
| 39026 | 1883  | 
code_modulename SML Pure HOL  | 
1884  | 
code_modulename OCaml Pure HOL  | 
|
1885  | 
code_modulename Haskell Pure HOL  | 
|
1886  | 
||
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1887  | 
text {* using built-in Haskell equality *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1888  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1889  | 
code_class equal  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1890  | 
(Haskell "Eq")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1891  | 
|
| 
38857
 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 
haftmann 
parents: 
38795 
diff
changeset
 | 
1892  | 
code_const "HOL.equal"  | 
| 39272 | 1893  | 
(Haskell infix 4 "==")  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1894  | 
|
| 
38864
 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 
haftmann 
parents: 
38857 
diff
changeset
 | 
1895  | 
code_const HOL.eq  | 
| 39272 | 1896  | 
(Haskell infix 4 "==")  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1897  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1898  | 
text {* undefined *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1899  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1900  | 
code_const undefined  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1901  | 
(SML "!(raise/ Fail/ \"undefined\")")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1902  | 
(OCaml "failwith/ \"undefined\"")  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1903  | 
(Haskell "error/ \"undefined\"")  | 
| 34886 | 1904  | 
(Scala "!error(\"undefined\")")  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1905  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1906  | 
subsubsection {* Evaluation and normalization by evaluation *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1907  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1908  | 
ML {*
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1909  | 
fun gen_eval_method conv ctxt = SIMPLE_METHOD'  | 
| 42426 | 1910  | 
(CONVERSION (Conv.params_conv ~1 (K (Conv.concl_conv ~1 (conv ctxt))) ctxt)  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1911  | 
THEN' rtac TrueI)  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1912  | 
*}  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1913  | 
|
| 42426 | 1914  | 
method_setup eval = {*
 | 
1915  | 
Scan.succeed (gen_eval_method (Code_Runtime.dynamic_holds_conv o Proof_Context.theory_of))  | 
|
1916  | 
*} "solve goal by evaluation"  | 
|
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1917  | 
|
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1918  | 
method_setup normalization = {*
 | 
| 41247 | 1919  | 
Scan.succeed (fn ctxt => SIMPLE_METHOD'  | 
| 42361 | 1920  | 
(CHANGED_PROP o (CONVERSION (Nbe.dynamic_conv (Proof_Context.theory_of ctxt))  | 
| 41247 | 1921  | 
THEN' (fn k => TRY (rtac TrueI k)))))  | 
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1922  | 
*} "solve goal by normalization"  | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1923  | 
|
| 31902 | 1924  | 
|
| 33084 | 1925  | 
subsection {* Counterexample Search Units *}
 | 
1926  | 
||
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1927  | 
subsubsection {* Quickcheck *}
 | 
| 
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1928  | 
|
| 33084 | 1929  | 
quickcheck_params [size = 5, iterations = 50]  | 
1930  | 
||
| 
30929
 
d9343c0aac11
code generator bootstrap theory src/Tools/Code_Generator.thy
 
haftmann 
parents: 
30927 
diff
changeset
 | 
1931  | 
|
| 33084 | 1932  | 
subsubsection {* Nitpick setup *}
 | 
| 
30309
 
188f0658af9f
Added a "nitpick_maybe" symbol, which is used by Nitpick. This will go away once Nitpick is part of HOL.
 
blanchet 
parents: 
30254 
diff
changeset
 | 
1933  | 
|
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1934  | 
ML {*
 | 
| 
41792
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1935  | 
structure Nitpick_Unfolds = Named_Thms  | 
| 
30254
 
7b8afdfa2f83
Second try at adding "nitpick_const_def" attribute.
 
blanchet 
parents: 
30242 
diff
changeset
 | 
1936  | 
(  | 
| 45294 | 1937  | 
  val name = @{binding nitpick_unfold}
 | 
| 
30254
 
7b8afdfa2f83
Second try at adding "nitpick_const_def" attribute.
 
blanchet 
parents: 
30242 
diff
changeset
 | 
1938  | 
val description = "alternative definitions of constants as needed by Nitpick"  | 
| 
 
7b8afdfa2f83
Second try at adding "nitpick_const_def" attribute.
 
blanchet 
parents: 
30242 
diff
changeset
 | 
1939  | 
)  | 
| 
33056
 
791a4655cae3
renamed "nitpick_const_xxx" attributes to "nitpick_xxx" and "nitpick_ind_intros" to "nitpick_intros"
 
blanchet 
parents: 
33022 
diff
changeset
 | 
1940  | 
structure Nitpick_Simps = Named_Thms  | 
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1941  | 
(  | 
| 45294 | 1942  | 
  val name = @{binding nitpick_simp}
 | 
| 
29869
 
a7a8b90cd882
Renamed descriptions of Nitpick (and ATP) attributes, so that they fit well with the rest of the sentence in ProofGeneral.
 
blanchet 
parents: 
29868 
diff
changeset
 | 
1943  | 
val description = "equational specification of constants as needed by Nitpick"  | 
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1944  | 
)  | 
| 
33056
 
791a4655cae3
renamed "nitpick_const_xxx" attributes to "nitpick_xxx" and "nitpick_ind_intros" to "nitpick_intros"
 
blanchet 
parents: 
33022 
diff
changeset
 | 
1945  | 
structure Nitpick_Psimps = Named_Thms  | 
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1946  | 
(  | 
| 45294 | 1947  | 
  val name = @{binding nitpick_psimp}
 | 
| 
29869
 
a7a8b90cd882
Renamed descriptions of Nitpick (and ATP) attributes, so that they fit well with the rest of the sentence in ProofGeneral.
 
blanchet 
parents: 
29868 
diff
changeset
 | 
1948  | 
val description = "partial equational specification of constants as needed by Nitpick"  | 
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1949  | 
)  | 
| 
35807
 
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
 
blanchet 
parents: 
35625 
diff
changeset
 | 
1950  | 
structure Nitpick_Choice_Specs = Named_Thms  | 
| 
 
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
 
blanchet 
parents: 
35625 
diff
changeset
 | 
1951  | 
(  | 
| 45294 | 1952  | 
  val name = @{binding nitpick_choice_spec}
 | 
| 
35807
 
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
 
blanchet 
parents: 
35625 
diff
changeset
 | 
1953  | 
val description = "choice specification of constants as needed by Nitpick"  | 
| 
 
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
 
blanchet 
parents: 
35625 
diff
changeset
 | 
1954  | 
)  | 
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1955  | 
*}  | 
| 30980 | 1956  | 
|
1957  | 
setup {*
 | 
|
| 
41792
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1958  | 
Nitpick_Unfolds.setup  | 
| 
33056
 
791a4655cae3
renamed "nitpick_const_xxx" attributes to "nitpick_xxx" and "nitpick_ind_intros" to "nitpick_intros"
 
blanchet 
parents: 
33022 
diff
changeset
 | 
1959  | 
#> Nitpick_Simps.setup  | 
| 
 
791a4655cae3
renamed "nitpick_const_xxx" attributes to "nitpick_xxx" and "nitpick_ind_intros" to "nitpick_intros"
 
blanchet 
parents: 
33022 
diff
changeset
 | 
1960  | 
#> Nitpick_Psimps.setup  | 
| 
35807
 
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
 
blanchet 
parents: 
35625 
diff
changeset
 | 
1961  | 
#> Nitpick_Choice_Specs.setup  | 
| 30980 | 1962  | 
*}  | 
1963  | 
||
| 
41792
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1964  | 
declare if_bool_eq_conj [nitpick_unfold, no_atp]  | 
| 
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1965  | 
if_bool_eq_disj [no_atp]  | 
| 
 
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
 
blanchet 
parents: 
41636 
diff
changeset
 | 
1966  | 
|
| 
29863
 
dadad1831e9d
Added "nitpick_const_simps" and "nitpick_ind_intros" attributes for theorems;
 
blanchet 
parents: 
29608 
diff
changeset
 | 
1967  | 
|
| 33084 | 1968  | 
subsection {* Preprocessing for the predicate compiler *}
 | 
1969  | 
||
1970  | 
ML {*
 | 
|
1971  | 
structure Predicate_Compile_Alternative_Defs = Named_Thms  | 
|
1972  | 
(  | 
|
| 45294 | 1973  | 
  val name = @{binding code_pred_def}
 | 
| 33084 | 1974  | 
val description = "alternative definitions of constants for the Predicate Compiler"  | 
1975  | 
)  | 
|
1976  | 
structure Predicate_Compile_Inline_Defs = Named_Thms  | 
|
1977  | 
(  | 
|
| 45294 | 1978  | 
  val name = @{binding code_pred_inline}
 | 
| 33084 | 1979  | 
val description = "inlining definitions for the Predicate Compiler"  | 
1980  | 
)  | 
|
| 
36246
 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 
bulwahn 
parents: 
36176 
diff
changeset
 | 
1981  | 
structure Predicate_Compile_Simps = Named_Thms  | 
| 
 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 
bulwahn 
parents: 
36176 
diff
changeset
 | 
1982  | 
(  | 
| 45294 | 1983  | 
  val name = @{binding code_pred_simp}
 | 
| 
36246
 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 
bulwahn 
parents: 
36176 
diff
changeset
 | 
1984  | 
val description = "simplification rules for the optimisations in the Predicate Compiler"  | 
| 
 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 
bulwahn 
parents: 
36176 
diff
changeset
 | 
1985  | 
)  | 
| 33084 | 1986  | 
*}  | 
1987  | 
||
1988  | 
setup {*
 | 
|
1989  | 
Predicate_Compile_Alternative_Defs.setup  | 
|
1990  | 
#> Predicate_Compile_Inline_Defs.setup  | 
|
| 
36246
 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 
bulwahn 
parents: 
36176 
diff
changeset
 | 
1991  | 
#> Predicate_Compile_Simps.setup  | 
| 33084 | 1992  | 
*}  | 
1993  | 
||
1994  | 
||
| 22839 | 1995  | 
subsection {* Legacy tactics and ML bindings *}
 | 
| 21671 | 1996  | 
|
1997  | 
ML {*
 | 
|
1998  | 
fun strip_tac i = REPEAT (resolve_tac [impI, allI] i);  | 
|
1999  | 
||
2000  | 
(* combination of (spec RS spec RS ...(j times) ... spec RS mp) *)  | 
|
2001  | 
local  | 
|
| 35364 | 2002  | 
  fun wrong_prem (Const (@{const_name All}, _) $ Abs (_, _, t)) = wrong_prem t
 | 
| 21671 | 2003  | 
| wrong_prem (Bound _) = true  | 
2004  | 
| wrong_prem _ = false;  | 
|
2005  | 
val filter_right = filter (not o wrong_prem o HOLogic.dest_Trueprop o hd o Thm.prems_of);  | 
|
2006  | 
in  | 
|
2007  | 
fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp]);  | 
|
2008  | 
fun smp_tac j = EVERY'[dresolve_tac (smp j), atac];  | 
|
2009  | 
end;  | 
|
| 22839 | 2010  | 
|
| 45654 | 2011  | 
val nnf_conv = Simplifier.rewrite (HOL_basic_ss addsimps @{thms simp_thms nnf_simps});
 | 
| 21671 | 2012  | 
*}  | 
2013  | 
||
| 38866 | 2014  | 
hide_const (open) eq equal  | 
2015  | 
||
| 14357 | 2016  | 
end  |