12369
|
1 |
(* Title: FOL/ex/First_Order_Logic.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Markus Wenzel, TU Munich
|
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
|
5 |
*)
|
|
6 |
|
|
7 |
header {* A simple formulation of First-Order Logic *}
|
|
8 |
|
|
9 |
theory First_Order_Logic = Pure:
|
|
10 |
|
|
11 |
text {*
|
|
12 |
The subsequent theory development illustrates single-sorted
|
|
13 |
intuitionistic first-order logic with equality, formulated within
|
|
14 |
the Pure framework. Actually this is not an example of
|
|
15 |
Isabelle/FOL, but of Isabelle/Pure.
|
|
16 |
*}
|
|
17 |
|
|
18 |
subsection {* Syntax *}
|
|
19 |
|
|
20 |
typedecl i
|
|
21 |
typedecl o
|
|
22 |
|
|
23 |
judgment
|
|
24 |
Trueprop :: "o \<Rightarrow> prop" ("_" 5)
|
|
25 |
|
|
26 |
|
|
27 |
subsection {* Propositional logic *}
|
|
28 |
|
|
29 |
consts
|
|
30 |
false :: o ("\<bottom>")
|
|
31 |
imp :: "o \<Rightarrow> o \<Rightarrow> o" (infixr "\<longrightarrow>" 25)
|
|
32 |
conj :: "o \<Rightarrow> o \<Rightarrow> o" (infixr "\<and>" 35)
|
|
33 |
disj :: "o \<Rightarrow> o \<Rightarrow> o" (infixr "\<or>" 30)
|
|
34 |
|
|
35 |
axioms
|
|
36 |
falseE [elim]: "\<bottom> \<Longrightarrow> A"
|
|
37 |
|
|
38 |
impI [intro]: "(A \<Longrightarrow> B) \<Longrightarrow> A \<longrightarrow> B"
|
|
39 |
mp [dest]: "A \<longrightarrow> B \<Longrightarrow> A \<Longrightarrow> B"
|
|
40 |
|
|
41 |
conjI [intro]: "A \<Longrightarrow> B \<Longrightarrow> A \<and> B"
|
|
42 |
conjD1: "A \<and> B \<Longrightarrow> A"
|
|
43 |
conjD2: "A \<and> B \<Longrightarrow> B"
|
|
44 |
|
|
45 |
disjE [elim]: "A \<or> B \<Longrightarrow> (A \<Longrightarrow> C) \<Longrightarrow> (B \<Longrightarrow> C) \<Longrightarrow> C"
|
|
46 |
disjI1 [intro]: "A \<Longrightarrow> A \<or> B"
|
|
47 |
disjI2 [intro]: "B \<Longrightarrow> A \<or> B"
|
|
48 |
|
|
49 |
theorem conjE [elim]: "A \<and> B \<Longrightarrow> (A \<Longrightarrow> B \<Longrightarrow> C) \<Longrightarrow> C"
|
|
50 |
proof -
|
|
51 |
assume ab: "A \<and> B"
|
|
52 |
assume r: "A \<Longrightarrow> B \<Longrightarrow> C"
|
|
53 |
show C
|
|
54 |
proof (rule r)
|
|
55 |
from ab show A by (rule conjD1)
|
|
56 |
from ab show B by (rule conjD2)
|
|
57 |
qed
|
|
58 |
qed
|
|
59 |
|
|
60 |
constdefs
|
|
61 |
true :: o ("\<top>")
|
|
62 |
"\<top> \<equiv> \<bottom> \<longrightarrow> \<bottom>"
|
|
63 |
not :: "o \<Rightarrow> o" ("\<not> _" [40] 40)
|
|
64 |
"\<not> A \<equiv> A \<longrightarrow> \<bottom>"
|
|
65 |
|
|
66 |
theorem trueI [intro]: \<top>
|
|
67 |
proof (unfold true_def)
|
|
68 |
show "\<bottom> \<longrightarrow> \<bottom>" ..
|
|
69 |
qed
|
|
70 |
|
|
71 |
theorem notI [intro]: "(A \<Longrightarrow> \<bottom>) \<Longrightarrow> \<not> A"
|
|
72 |
proof (unfold not_def)
|
|
73 |
assume "A \<Longrightarrow> \<bottom>"
|
|
74 |
thus "A \<longrightarrow> \<bottom>" ..
|
|
75 |
qed
|
|
76 |
|
|
77 |
theorem notE [elim]: "\<not> A \<Longrightarrow> A \<Longrightarrow> B"
|
|
78 |
proof (unfold not_def)
|
|
79 |
assume "A \<longrightarrow> \<bottom>" and A
|
|
80 |
hence \<bottom> .. thus B ..
|
|
81 |
qed
|
|
82 |
|
|
83 |
|
|
84 |
subsection {* Equality *}
|
|
85 |
|
|
86 |
consts
|
|
87 |
equal :: "i \<Rightarrow> i \<Rightarrow> o" (infixl "=" 50)
|
|
88 |
|
|
89 |
axioms
|
|
90 |
refl [intro]: "x = x"
|
|
91 |
subst: "x = y \<Longrightarrow> P(x) \<Longrightarrow> P(y)"
|
|
92 |
|
|
93 |
theorem trans [trans]: "x = y \<Longrightarrow> y = z \<Longrightarrow> x = z"
|
|
94 |
by (rule subst)
|
|
95 |
|
|
96 |
theorem sym [sym]: "x = y \<Longrightarrow> y = x"
|
|
97 |
proof -
|
|
98 |
assume "x = y"
|
|
99 |
from this and refl show "y = x" by (rule subst)
|
|
100 |
qed
|
|
101 |
|
|
102 |
|
|
103 |
subsection {* Quantifiers *}
|
|
104 |
|
|
105 |
consts
|
|
106 |
All :: "(i \<Rightarrow> o) \<Rightarrow> o" (binder "\<forall>" 10)
|
|
107 |
Ex :: "(i \<Rightarrow> o) \<Rightarrow> o" (binder "\<exists>" 10)
|
|
108 |
|
|
109 |
axioms
|
|
110 |
allI [intro]: "(\<And>x. P(x)) \<Longrightarrow> \<forall>x. P(x)"
|
|
111 |
allD [dest]: "\<forall>x. P(x) \<Longrightarrow> P(a)"
|
|
112 |
|
|
113 |
exI [intro]: "P(a) \<Longrightarrow> \<exists>x. P(x)"
|
|
114 |
exE [elim]: "\<exists>x. P(x) \<Longrightarrow> (\<And>x. P(x) \<Longrightarrow> C) \<Longrightarrow> C"
|
|
115 |
|
|
116 |
|
|
117 |
lemma "(\<exists>x. P(f(x))) \<longrightarrow> (\<exists>y. P(y))"
|
|
118 |
proof
|
|
119 |
assume "\<exists>x. P(f(x))"
|
|
120 |
thus "\<exists>y. P(y)"
|
|
121 |
proof
|
|
122 |
fix x assume "P(f(x))"
|
|
123 |
thus ?thesis ..
|
|
124 |
qed
|
|
125 |
qed
|
|
126 |
|
|
127 |
lemma "(\<exists>x. \<forall>y. R(x, y)) \<longrightarrow> (\<forall>y. \<exists>x. R(x, y))"
|
|
128 |
proof
|
|
129 |
assume "\<exists>x. \<forall>y. R(x, y)"
|
|
130 |
thus "\<forall>y. \<exists>x. R(x, y)"
|
|
131 |
proof
|
|
132 |
fix x assume a: "\<forall>y. R(x, y)"
|
|
133 |
show ?thesis
|
|
134 |
proof
|
|
135 |
fix y from a have "R(x, y)" ..
|
|
136 |
thus "\<exists>x. R(x, y)" ..
|
|
137 |
qed
|
|
138 |
qed
|
|
139 |
qed
|
|
140 |
|
|
141 |
end
|