author | wenzelm |
Sat, 20 May 2006 23:36:49 +0200 | |
changeset 19683 | 3620e494cef2 |
parent 19656 | 09be06943252 |
child 19756 | 61c4117345c6 |
permissions | -rw-r--r-- |
1268 | 1 |
(* Title: FOL/IFOL.thy |
35 | 2 |
ID: $Id$ |
11677 | 3 |
Author: Lawrence C Paulson and Markus Wenzel |
4 |
*) |
|
35 | 5 |
|
11677 | 6 |
header {* Intuitionistic first-order logic *} |
35 | 7 |
|
15481 | 8 |
theory IFOL |
9 |
imports Pure |
|
16417 | 10 |
uses ("IFOL_lemmas.ML") ("fologic.ML") ("hypsubstdata.ML") ("intprover.ML") |
15481 | 11 |
begin |
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
12 |
|
0 | 13 |
|
11677 | 14 |
subsection {* Syntax and axiomatic basis *} |
15 |
||
3906 | 16 |
global |
17 |
||
14854 | 18 |
classes "term" |
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
19 |
defaultsort "term" |
0 | 20 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
21 |
typedecl o |
79 | 22 |
|
11747 | 23 |
judgment |
24 |
Trueprop :: "o => prop" ("(_)" 5) |
|
0 | 25 |
|
11747 | 26 |
consts |
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
27 |
True :: o |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
28 |
False :: o |
79 | 29 |
|
30 |
(* Connectives *) |
|
31 |
||
17276 | 32 |
"op =" :: "['a, 'a] => o" (infixl "=" 50) |
35 | 33 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
34 |
Not :: "o => o" ("~ _" [40] 40) |
17276 | 35 |
"op &" :: "[o, o] => o" (infixr "&" 35) |
36 |
"op |" :: "[o, o] => o" (infixr "|" 30) |
|
37 |
"op -->" :: "[o, o] => o" (infixr "-->" 25) |
|
38 |
"op <->" :: "[o, o] => o" (infixr "<->" 25) |
|
79 | 39 |
|
40 |
(* Quantifiers *) |
|
41 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
42 |
All :: "('a => o) => o" (binder "ALL " 10) |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
43 |
Ex :: "('a => o) => o" (binder "EX " 10) |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
44 |
Ex1 :: "('a => o) => o" (binder "EX! " 10) |
79 | 45 |
|
0 | 46 |
|
19363 | 47 |
abbreviation |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
48 |
not_equal :: "['a, 'a] => o" (infixl "~=" 50) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
49 |
"x ~= y == ~ (x = y)" |
79 | 50 |
|
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19380
diff
changeset
|
51 |
const_syntax (xsymbols) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19380
diff
changeset
|
52 |
not_equal (infixl "\<noteq>" 50) |
19363 | 53 |
|
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19380
diff
changeset
|
54 |
const_syntax (HTML output) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19380
diff
changeset
|
55 |
not_equal (infixl "\<noteq>" 50) |
19363 | 56 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12019
diff
changeset
|
57 |
syntax (xsymbols) |
11677 | 58 |
Not :: "o => o" ("\<not> _" [40] 40) |
59 |
"op &" :: "[o, o] => o" (infixr "\<and>" 35) |
|
60 |
"op |" :: "[o, o] => o" (infixr "\<or>" 30) |
|
61 |
"ALL " :: "[idts, o] => o" ("(3\<forall>_./ _)" [0, 10] 10) |
|
62 |
"EX " :: "[idts, o] => o" ("(3\<exists>_./ _)" [0, 10] 10) |
|
63 |
"EX! " :: "[idts, o] => o" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
64 |
"op -->" :: "[o, o] => o" (infixr "\<longrightarrow>" 25) |
|
65 |
"op <->" :: "[o, o] => o" (infixr "\<longleftrightarrow>" 25) |
|
35 | 66 |
|
6340 | 67 |
syntax (HTML output) |
11677 | 68 |
Not :: "o => o" ("\<not> _" [40] 40) |
14565 | 69 |
"op &" :: "[o, o] => o" (infixr "\<and>" 35) |
70 |
"op |" :: "[o, o] => o" (infixr "\<or>" 30) |
|
71 |
"ALL " :: "[idts, o] => o" ("(3\<forall>_./ _)" [0, 10] 10) |
|
72 |
"EX " :: "[idts, o] => o" ("(3\<exists>_./ _)" [0, 10] 10) |
|
73 |
"EX! " :: "[idts, o] => o" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
6340 | 74 |
|
75 |
||
3932 | 76 |
local |
3906 | 77 |
|
14236 | 78 |
finalconsts |
79 |
False All Ex |
|
80 |
"op =" |
|
81 |
"op &" |
|
82 |
"op |" |
|
83 |
"op -->" |
|
84 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
85 |
axioms |
0 | 86 |
|
79 | 87 |
(* Equality *) |
0 | 88 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
89 |
refl: "a=a" |
0 | 90 |
|
79 | 91 |
(* Propositional logic *) |
0 | 92 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
93 |
conjI: "[| P; Q |] ==> P&Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
94 |
conjunct1: "P&Q ==> P" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
95 |
conjunct2: "P&Q ==> Q" |
0 | 96 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
97 |
disjI1: "P ==> P|Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
98 |
disjI2: "Q ==> P|Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
99 |
disjE: "[| P|Q; P ==> R; Q ==> R |] ==> R" |
0 | 100 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
101 |
impI: "(P ==> Q) ==> P-->Q" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
102 |
mp: "[| P-->Q; P |] ==> Q" |
0 | 103 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
104 |
FalseE: "False ==> P" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
105 |
|
79 | 106 |
(* Quantifiers *) |
0 | 107 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
108 |
allI: "(!!x. P(x)) ==> (ALL x. P(x))" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
109 |
spec: "(ALL x. P(x)) ==> P(x)" |
0 | 110 |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
111 |
exI: "P(x) ==> (EX x. P(x))" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
112 |
exE: "[| EX x. P(x); !!x. P(x) ==> R |] ==> R" |
0 | 113 |
|
114 |
(* Reflection *) |
|
115 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
116 |
eq_reflection: "(x=y) ==> (x==y)" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
117 |
iff_reflection: "(P<->Q) ==> (P==Q)" |
0 | 118 |
|
4092 | 119 |
|
15377 | 120 |
text{*Thanks to Stephan Merz*} |
121 |
theorem subst: |
|
122 |
assumes eq: "a = b" and p: "P(a)" |
|
123 |
shows "P(b)" |
|
124 |
proof - |
|
125 |
from eq have meta: "a \<equiv> b" |
|
126 |
by (rule eq_reflection) |
|
127 |
from p show ?thesis |
|
128 |
by (unfold meta) |
|
129 |
qed |
|
130 |
||
131 |
||
14236 | 132 |
defs |
133 |
(* Definitions *) |
|
134 |
||
135 |
True_def: "True == False-->False" |
|
136 |
not_def: "~P == P-->False" |
|
137 |
iff_def: "P<->Q == (P-->Q) & (Q-->P)" |
|
138 |
||
139 |
(* Unique existence *) |
|
140 |
||
141 |
ex1_def: "Ex1(P) == EX x. P(x) & (ALL y. P(y) --> y=x)" |
|
142 |
||
13779 | 143 |
|
11677 | 144 |
subsection {* Lemmas and proof tools *} |
145 |
||
9886 | 146 |
use "IFOL_lemmas.ML" |
11734 | 147 |
|
18481 | 148 |
ML {* |
149 |
structure ProjectRule = ProjectRuleFun |
|
150 |
(struct |
|
151 |
val conjunct1 = thm "conjunct1"; |
|
152 |
val conjunct2 = thm "conjunct2"; |
|
153 |
val mp = thm "mp"; |
|
154 |
end) |
|
155 |
*} |
|
156 |
||
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
157 |
use "fologic.ML" |
9886 | 158 |
use "hypsubstdata.ML" |
159 |
setup hypsubst_setup |
|
7355
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
160 |
use "intprover.ML" |
4c43090659ca
proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
6340
diff
changeset
|
161 |
|
4092 | 162 |
|
12875 | 163 |
subsection {* Intuitionistic Reasoning *} |
12368 | 164 |
|
12349 | 165 |
lemma impE': |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
166 |
assumes 1: "P --> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
167 |
and 2: "Q ==> R" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
168 |
and 3: "P --> Q ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
169 |
shows R |
12349 | 170 |
proof - |
171 |
from 3 and 1 have P . |
|
12368 | 172 |
with 1 have Q by (rule impE) |
12349 | 173 |
with 2 show R . |
174 |
qed |
|
175 |
||
176 |
lemma allE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
177 |
assumes 1: "ALL x. P(x)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
178 |
and 2: "P(x) ==> ALL x. P(x) ==> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
179 |
shows Q |
12349 | 180 |
proof - |
181 |
from 1 have "P(x)" by (rule spec) |
|
182 |
from this and 1 show Q by (rule 2) |
|
183 |
qed |
|
184 |
||
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
185 |
lemma notE': |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
186 |
assumes 1: "~ P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
187 |
and 2: "~ P ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12875
diff
changeset
|
188 |
shows R |
12349 | 189 |
proof - |
190 |
from 2 and 1 have P . |
|
191 |
with 1 show R by (rule notE) |
|
192 |
qed |
|
193 |
||
194 |
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE |
|
195 |
and [Pure.intro!] = iffI conjI impI TrueI notI allI refl |
|
196 |
and [Pure.elim 2] = allE notE' impE' |
|
197 |
and [Pure.intro] = exI disjI2 disjI1 |
|
198 |
||
18708 | 199 |
setup {* ContextRules.addSWrapper (fn tac => hyp_subst_tac ORELSE' tac) *} |
12349 | 200 |
|
201 |
||
12368 | 202 |
lemma iff_not_sym: "~ (Q <-> P) ==> ~ (P <-> Q)" |
17591 | 203 |
by iprover |
12368 | 204 |
|
205 |
lemmas [sym] = sym iff_sym not_sym iff_not_sym |
|
206 |
and [Pure.elim?] = iffD1 iffD2 impE |
|
207 |
||
208 |
||
13435 | 209 |
lemma eq_commute: "a=b <-> b=a" |
210 |
apply (rule iffI) |
|
211 |
apply (erule sym)+ |
|
212 |
done |
|
213 |
||
214 |
||
11677 | 215 |
subsection {* Atomizing meta-level rules *} |
216 |
||
11747 | 217 |
lemma atomize_all [atomize]: "(!!x. P(x)) == Trueprop (ALL x. P(x))" |
11976 | 218 |
proof |
11677 | 219 |
assume "!!x. P(x)" |
12368 | 220 |
show "ALL x. P(x)" .. |
11677 | 221 |
next |
222 |
assume "ALL x. P(x)" |
|
12368 | 223 |
thus "!!x. P(x)" .. |
11677 | 224 |
qed |
225 |
||
11747 | 226 |
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)" |
11976 | 227 |
proof |
12368 | 228 |
assume "A ==> B" |
229 |
thus "A --> B" .. |
|
11677 | 230 |
next |
231 |
assume "A --> B" and A |
|
232 |
thus B by (rule mp) |
|
233 |
qed |
|
234 |
||
11747 | 235 |
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" |
11976 | 236 |
proof |
11677 | 237 |
assume "x == y" |
238 |
show "x = y" by (unfold prems) (rule refl) |
|
239 |
next |
|
240 |
assume "x = y" |
|
241 |
thus "x == y" by (rule eq_reflection) |
|
242 |
qed |
|
243 |
||
18813 | 244 |
lemma atomize_iff [atomize]: "(A == B) == Trueprop (A <-> B)" |
245 |
proof |
|
246 |
assume "A == B" |
|
247 |
show "A <-> B" by (unfold prems) (rule iff_refl) |
|
248 |
next |
|
249 |
assume "A <-> B" |
|
250 |
thus "A == B" by (rule iff_reflection) |
|
251 |
qed |
|
252 |
||
12875 | 253 |
lemma atomize_conj [atomize]: |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
254 |
includes meta_conjunction_syntax |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
255 |
shows "(A && B) == Trueprop (A & B)" |
11976 | 256 |
proof |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
257 |
assume conj: "A && B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
258 |
show "A & B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
259 |
proof (rule conjI) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
260 |
from conj show A by (rule conjunctionD1) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
261 |
from conj show B by (rule conjunctionD2) |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
262 |
qed |
11953 | 263 |
next |
19120
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
264 |
assume conj: "A & B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
265 |
show "A && B" |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
266 |
proof - |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
267 |
from conj show A .. |
353d349740de
not_equal: replaced syntax translation by abbreviation;
wenzelm
parents:
18861
diff
changeset
|
268 |
from conj show B .. |
11953 | 269 |
qed |
270 |
qed |
|
271 |
||
12368 | 272 |
lemmas [symmetric, rulify] = atomize_all atomize_imp |
18861 | 273 |
and [symmetric, defn] = atomize_all atomize_imp atomize_eq atomize_iff |
11771 | 274 |
|
11848 | 275 |
|
276 |
subsection {* Calculational rules *} |
|
277 |
||
278 |
lemma forw_subst: "a = b ==> P(b) ==> P(a)" |
|
279 |
by (rule ssubst) |
|
280 |
||
281 |
lemma back_subst: "P(a) ==> a = b ==> P(b)" |
|
282 |
by (rule subst) |
|
283 |
||
284 |
text {* |
|
285 |
Note that this list of rules is in reverse order of priorities. |
|
286 |
*} |
|
287 |
||
12019 | 288 |
lemmas basic_trans_rules [trans] = |
11848 | 289 |
forw_subst |
290 |
back_subst |
|
291 |
rev_mp |
|
292 |
mp |
|
293 |
trans |
|
294 |
||
13779 | 295 |
subsection {* ``Let'' declarations *} |
296 |
||
297 |
nonterminals letbinds letbind |
|
298 |
||
299 |
constdefs |
|
14854 | 300 |
Let :: "['a::{}, 'a => 'b] => ('b::{})" |
13779 | 301 |
"Let(s, f) == f(s)" |
302 |
||
303 |
syntax |
|
304 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
|
305 |
"" :: "letbind => letbinds" ("_") |
|
306 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
307 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
308 |
||
309 |
translations |
|
310 |
"_Let(_binds(b, bs), e)" == "_Let(b, _Let(bs, e))" |
|
311 |
"let x = a in e" == "Let(a, %x. e)" |
|
312 |
||
313 |
||
314 |
lemma LetI: |
|
315 |
assumes prem: "(!!x. x=t ==> P(u(x)))" |
|
316 |
shows "P(let x=t in u(x))" |
|
317 |
apply (unfold Let_def) |
|
318 |
apply (rule refl [THEN prem]) |
|
319 |
done |
|
320 |
||
321 |
ML |
|
322 |
{* |
|
323 |
val Let_def = thm "Let_def"; |
|
324 |
val LetI = thm "LetI"; |
|
325 |
*} |
|
326 |
||
4854 | 327 |
end |