author | wenzelm |
Sun, 18 Oct 2015 22:57:09 +0200 | |
changeset 61477 | e467ae7aa808 |
parent 61458 | 987533262fc2 |
child 61493 | 0debd22f0c0e |
permissions | -rw-r--r-- |
29755 | 1 |
theory Logic |
2 |
imports Base |
|
3 |
begin |
|
18537 | 4 |
|
58618 | 5 |
chapter \<open>Primitive logic \label{ch:logic}\<close> |
18537 | 6 |
|
58618 | 7 |
text \<open> |
20480 | 8 |
The logical foundations of Isabelle/Isar are that of the Pure logic, |
29774 | 9 |
which has been introduced as a Natural Deduction framework in |
58555 | 10 |
@{cite paulson700}. This is essentially the same logic as ``@{text |
20493 | 11 |
"\<lambda>HOL"}'' in the more abstract setting of Pure Type Systems (PTS) |
58555 | 12 |
@{cite "Barendregt-Geuvers:2001"}, although there are some key |
20491 | 13 |
differences in the specific treatment of simple types in |
14 |
Isabelle/Pure. |
|
20480 | 15 |
|
16 |
Following type-theoretic parlance, the Pure logic consists of three |
|
20543 | 17 |
levels of @{text "\<lambda>"}-calculus with corresponding arrows, @{text |
20480 | 18 |
"\<Rightarrow>"} for syntactic function space (terms depending on terms), @{text |
19 |
"\<And>"} for universal quantification (proofs depending on terms), and |
|
20 |
@{text "\<Longrightarrow>"} for implication (proofs depending on proofs). |
|
21 |
||
20537 | 22 |
Derivations are relative to a logical theory, which declares type |
23 |
constructors, constants, and axioms. Theory declarations support |
|
24 |
schematic polymorphism, which is strictly speaking outside the |
|
25 |
logic.\footnote{This is the deeper logical reason, why the theory |
|
26 |
context @{text "\<Theta>"} is separate from the proof context @{text "\<Gamma>"} |
|
34929 | 27 |
of the core calculus: type constructors, term constants, and facts |
28 |
(proof constants) may involve arbitrary type schemes, but the type |
|
29 |
of a locally fixed term parameter is also fixed!} |
|
58618 | 30 |
\<close> |
20480 | 31 |
|
32 |
||
58618 | 33 |
section \<open>Types \label{sec:types}\<close> |
20437 | 34 |
|
58618 | 35 |
text \<open> |
20480 | 36 |
The language of types is an uninterpreted order-sorted first-order |
37 |
algebra; types are qualified by ordered type classes. |
|
38 |
||
61416 | 39 |
\<^medskip> |
61477 | 40 |
A \<^emph>\<open>type class\<close> is an abstract syntactic entity |
41 |
declared in the theory context. The \<^emph>\<open>subclass relation\<close> @{text |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
42 |
"c\<^sub>1 \<subseteq> c\<^sub>2"} is specified by stating an acyclic |
20491 | 43 |
generating relation; the transitive closure is maintained |
44 |
internally. The resulting relation is an ordering: reflexive, |
|
45 |
transitive, and antisymmetric. |
|
20451 | 46 |
|
61477 | 47 |
A \<^emph>\<open>sort\<close> is a list of type classes written as @{text "s = {c\<^sub>1, |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
48 |
\<dots>, c\<^sub>m}"}, it represents symbolic intersection. Notationally, the |
34929 | 49 |
curly braces are omitted for singleton intersections, i.e.\ any |
50 |
class @{text "c"} may be read as a sort @{text "{c}"}. The ordering |
|
51 |
on type classes is extended to sorts according to the meaning of |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
52 |
intersections: @{text "{c\<^sub>1, \<dots> c\<^sub>m} \<subseteq> {d\<^sub>1, \<dots>, d\<^sub>n}"} iff @{text |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
53 |
"\<forall>j. \<exists>i. c\<^sub>i \<subseteq> d\<^sub>j"}. The empty intersection @{text "{}"} refers to |
34929 | 54 |
the universal sort, which is the largest element wrt.\ the sort |
55 |
order. Thus @{text "{}"} represents the ``full sort'', not the |
|
56 |
empty one! The intersection of all (finitely many) classes declared |
|
57 |
in the current theory is the least element wrt.\ the sort ordering. |
|
20480 | 58 |
|
61416 | 59 |
\<^medskip> |
61477 | 60 |
A \<^emph>\<open>fixed type variable\<close> is a pair of a basic name |
20537 | 61 |
(starting with a @{text "'"} character) and a sort constraint, e.g.\ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
62 |
@{text "('a, s)"} which is usually printed as @{text "\<alpha>\<^sub>s"}. |
61477 | 63 |
A \<^emph>\<open>schematic type variable\<close> is a pair of an indexname and a |
20537 | 64 |
sort constraint, e.g.\ @{text "(('a, 0), s)"} which is usually |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
65 |
printed as @{text "?\<alpha>\<^sub>s"}. |
20451 | 66 |
|
61477 | 67 |
Note that \<^emph>\<open>all\<close> syntactic components contribute to the identity |
34929 | 68 |
of type variables: basic name, index, and sort constraint. The core |
69 |
logic handles type variables with the same name but different sorts |
|
70 |
as different, although the type-inference layer (which is outside |
|
71 |
the core) rejects anything like that. |
|
20451 | 72 |
|
61477 | 73 |
A \<^emph>\<open>type constructor\<close> @{text "\<kappa>"} is a @{text "k"}-ary operator |
20493 | 74 |
on types declared in the theory. Type constructor application is |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
75 |
written postfix as @{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>k)\<kappa>"}. For |
20537 | 76 |
@{text "k = 0"} the argument tuple is omitted, e.g.\ @{text "prop"} |
77 |
instead of @{text "()prop"}. For @{text "k = 1"} the parentheses |
|
78 |
are omitted, e.g.\ @{text "\<alpha> list"} instead of @{text "(\<alpha>)list"}. |
|
79 |
Further notation is provided for specific constructors, notably the |
|
80 |
right-associative infix @{text "\<alpha> \<Rightarrow> \<beta>"} instead of @{text "(\<alpha>, |
|
81 |
\<beta>)fun"}. |
|
20480 | 82 |
|
61477 | 83 |
The logical category \<^emph>\<open>type\<close> is defined inductively over type |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
84 |
variables and type constructors as follows: @{text "\<tau> = \<alpha>\<^sub>s | ?\<alpha>\<^sub>s | |
20543 | 85 |
(\<tau>\<^sub>1, \<dots>, \<tau>\<^sub>k)\<kappa>"}. |
20451 | 86 |
|
61477 | 87 |
A \<^emph>\<open>type abbreviation\<close> is a syntactic definition @{text |
20494 | 88 |
"(\<^vec>\<alpha>)\<kappa> = \<tau>"} of an arbitrary type expression @{text "\<tau>"} over |
20537 | 89 |
variables @{text "\<^vec>\<alpha>"}. Type abbreviations appear as type |
90 |
constructors in the syntax, but are expanded before entering the |
|
91 |
logical core. |
|
20480 | 92 |
|
61477 | 93 |
A \<^emph>\<open>type arity\<close> declares the image behavior of a type |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
94 |
constructor wrt.\ the algebra of sorts: @{text "\<kappa> :: (s\<^sub>1, \<dots>, |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
95 |
s\<^sub>k)s"} means that @{text "(\<tau>\<^sub>1, \<dots>, \<tau>\<^sub>k)\<kappa>"} is |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
96 |
of sort @{text "s"} if every argument type @{text "\<tau>\<^sub>i"} is |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
97 |
of sort @{text "s\<^sub>i"}. Arity declarations are implicitly |
20494 | 98 |
completed, i.e.\ @{text "\<kappa> :: (\<^vec>s)c"} entails @{text "\<kappa> :: |
20491 | 99 |
(\<^vec>s)c'"} for any @{text "c' \<supseteq> c"}. |
100 |
||
61416 | 101 |
\<^medskip> |
61477 | 102 |
The sort algebra is always maintained as \<^emph>\<open>coregular\<close>, |
20491 | 103 |
which means that type arities are consistent with the subclass |
20537 | 104 |
relation: for any type constructor @{text "\<kappa>"}, and classes @{text |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
105 |
"c\<^sub>1 \<subseteq> c\<^sub>2"}, and arities @{text "\<kappa> :: |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
106 |
(\<^vec>s\<^sub>1)c\<^sub>1"} and @{text "\<kappa> :: |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
107 |
(\<^vec>s\<^sub>2)c\<^sub>2"} holds @{text "\<^vec>s\<^sub>1 \<subseteq> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
108 |
\<^vec>s\<^sub>2"} component-wise. |
20451 | 109 |
|
20491 | 110 |
The key property of a coregular order-sorted algebra is that sort |
20537 | 111 |
constraints can be solved in a most general fashion: for each type |
112 |
constructor @{text "\<kappa>"} and sort @{text "s"} there is a most general |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
113 |
vector of argument sorts @{text "(s\<^sub>1, \<dots>, s\<^sub>k)"} such |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
114 |
that a type scheme @{text "(\<alpha>\<^bsub>s\<^sub>1\<^esub>, \<dots>, |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
115 |
\<alpha>\<^bsub>s\<^sub>k\<^esub>)\<kappa>"} is of sort @{text "s"}. |
20543 | 116 |
Consequently, type unification has most general solutions (modulo |
117 |
equivalence of sorts), so type-inference produces primary types as |
|
58555 | 118 |
expected @{cite "nipkow-prehofer"}. |
58618 | 119 |
\<close> |
20451 | 120 |
|
58618 | 121 |
text %mlref \<open> |
20480 | 122 |
\begin{mldecls} |
34921 | 123 |
@{index_ML_type class: string} \\ |
124 |
@{index_ML_type sort: "class list"} \\ |
|
125 |
@{index_ML_type arity: "string * sort list * sort"} \\ |
|
20480 | 126 |
@{index_ML_type typ} \\ |
39846 | 127 |
@{index_ML Term.map_atyps: "(typ -> typ) -> typ -> typ"} \\ |
128 |
@{index_ML Term.fold_atyps: "(typ -> 'a -> 'a) -> typ -> 'a -> 'a"} \\ |
|
20547 | 129 |
\end{mldecls} |
130 |
\begin{mldecls} |
|
20480 | 131 |
@{index_ML Sign.subsort: "theory -> sort * sort -> bool"} \\ |
132 |
@{index_ML Sign.of_sort: "theory -> typ * sort -> bool"} \\ |
|
47174 | 133 |
@{index_ML Sign.add_type: "Proof.context -> binding * int * mixfix -> theory -> theory"} \\ |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
134 |
@{index_ML Sign.add_type_abbrev: "Proof.context -> |
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
135 |
binding * string list * typ -> theory -> theory"} \\ |
30355 | 136 |
@{index_ML Sign.primitive_class: "binding * class list -> theory -> theory"} \\ |
20480 | 137 |
@{index_ML Sign.primitive_classrel: "class * class -> theory -> theory"} \\ |
138 |
@{index_ML Sign.primitive_arity: "arity -> theory -> theory"} \\ |
|
139 |
\end{mldecls} |
|
140 |
||
61439 | 141 |
\<^descr> Type @{ML_type class} represents type classes. |
20480 | 142 |
|
61439 | 143 |
\<^descr> Type @{ML_type sort} represents sorts, i.e.\ finite |
39864 | 144 |
intersections of classes. The empty list @{ML "[]: sort"} refers to |
145 |
the empty class intersection, i.e.\ the ``full sort''. |
|
20451 | 146 |
|
61439 | 147 |
\<^descr> Type @{ML_type arity} represents type arities. A triple |
39864 | 148 |
@{text "(\<kappa>, \<^vec>s, s) : arity"} represents @{text "\<kappa> :: |
149 |
(\<^vec>s)s"} as described above. |
|
20480 | 150 |
|
61439 | 151 |
\<^descr> Type @{ML_type typ} represents types; this is a datatype with |
20480 | 152 |
constructors @{ML TFree}, @{ML TVar}, @{ML Type}. |
153 |
||
61439 | 154 |
\<^descr> @{ML Term.map_atyps}~@{text "f \<tau>"} applies the mapping @{text |
39846 | 155 |
"f"} to all atomic types (@{ML TFree}, @{ML TVar}) occurring in |
156 |
@{text "\<tau>"}. |
|
20519 | 157 |
|
61439 | 158 |
\<^descr> @{ML Term.fold_atyps}~@{text "f \<tau>"} iterates the operation |
39846 | 159 |
@{text "f"} over all occurrences of atomic types (@{ML TFree}, @{ML |
160 |
TVar}) in @{text "\<tau>"}; the type structure is traversed from left to |
|
161 |
right. |
|
20494 | 162 |
|
61439 | 163 |
\<^descr> @{ML Sign.subsort}~@{text "thy (s\<^sub>1, s\<^sub>2)"} |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
164 |
tests the subsort relation @{text "s\<^sub>1 \<subseteq> s\<^sub>2"}. |
20480 | 165 |
|
61439 | 166 |
\<^descr> @{ML Sign.of_sort}~@{text "thy (\<tau>, s)"} tests whether type |
20537 | 167 |
@{text "\<tau>"} is of sort @{text "s"}. |
20480 | 168 |
|
61439 | 169 |
\<^descr> @{ML Sign.add_type}~@{text "ctxt (\<kappa>, k, mx)"} declares a |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
170 |
new type constructors @{text "\<kappa>"} with @{text "k"} arguments and |
20480 | 171 |
optional mixfix syntax. |
20451 | 172 |
|
61439 | 173 |
\<^descr> @{ML Sign.add_type_abbrev}~@{text "ctxt (\<kappa>, \<^vec>\<alpha>, \<tau>)"} |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
174 |
defines a new type abbreviation @{text "(\<^vec>\<alpha>)\<kappa> = \<tau>"}. |
20480 | 175 |
|
61439 | 176 |
\<^descr> @{ML Sign.primitive_class}~@{text "(c, [c\<^sub>1, \<dots>, |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
177 |
c\<^sub>n])"} declares a new class @{text "c"}, together with class |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
178 |
relations @{text "c \<subseteq> c\<^sub>i"}, for @{text "i = 1, \<dots>, n"}. |
20480 | 179 |
|
61439 | 180 |
\<^descr> @{ML Sign.primitive_classrel}~@{text "(c\<^sub>1, |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
181 |
c\<^sub>2)"} declares the class relation @{text "c\<^sub>1 \<subseteq> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
182 |
c\<^sub>2"}. |
20480 | 183 |
|
61439 | 184 |
\<^descr> @{ML Sign.primitive_arity}~@{text "(\<kappa>, \<^vec>s, s)"} declares |
20537 | 185 |
the arity @{text "\<kappa> :: (\<^vec>s)s"}. |
58618 | 186 |
\<close> |
20437 | 187 |
|
58618 | 188 |
text %mlantiq \<open> |
39832 | 189 |
\begin{matharray}{rcl} |
190 |
@{ML_antiquotation_def "class"} & : & @{text ML_antiquotation} \\ |
|
191 |
@{ML_antiquotation_def "sort"} & : & @{text ML_antiquotation} \\ |
|
192 |
@{ML_antiquotation_def "type_name"} & : & @{text ML_antiquotation} \\ |
|
193 |
@{ML_antiquotation_def "type_abbrev"} & : & @{text ML_antiquotation} \\ |
|
194 |
@{ML_antiquotation_def "nonterminal"} & : & @{text ML_antiquotation} \\ |
|
195 |
@{ML_antiquotation_def "typ"} & : & @{text ML_antiquotation} \\ |
|
196 |
\end{matharray} |
|
197 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55029
diff
changeset
|
198 |
@{rail \<open> |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
199 |
@@{ML_antiquotation class} nameref |
39832 | 200 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
201 |
@@{ML_antiquotation sort} sort |
39832 | 202 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
203 |
(@@{ML_antiquotation type_name} | |
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
204 |
@@{ML_antiquotation type_abbrev} | |
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
205 |
@@{ML_antiquotation nonterminal}) nameref |
39832 | 206 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
207 |
@@{ML_antiquotation typ} type |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55029
diff
changeset
|
208 |
\<close>} |
39832 | 209 |
|
61439 | 210 |
\<^descr> @{text "@{class c}"} inlines the internalized class @{text |
39832 | 211 |
"c"} --- as @{ML_type string} literal. |
212 |
||
61439 | 213 |
\<^descr> @{text "@{sort s}"} inlines the internalized sort @{text "s"} |
39832 | 214 |
--- as @{ML_type "string list"} literal. |
215 |
||
61439 | 216 |
\<^descr> @{text "@{type_name c}"} inlines the internalized type |
39832 | 217 |
constructor @{text "c"} --- as @{ML_type string} literal. |
218 |
||
61439 | 219 |
\<^descr> @{text "@{type_abbrev c}"} inlines the internalized type |
39832 | 220 |
abbreviation @{text "c"} --- as @{ML_type string} literal. |
221 |
||
61439 | 222 |
\<^descr> @{text "@{nonterminal c}"} inlines the internalized syntactic |
39832 | 223 |
type~/ grammar nonterminal @{text "c"} --- as @{ML_type string} |
224 |
literal. |
|
225 |
||
61439 | 226 |
\<^descr> @{text "@{typ \<tau>}"} inlines the internalized type @{text "\<tau>"} |
39832 | 227 |
--- as constructor term for datatype @{ML_type typ}. |
58618 | 228 |
\<close> |
39832 | 229 |
|
20437 | 230 |
|
58618 | 231 |
section \<open>Terms \label{sec:terms}\<close> |
18537 | 232 |
|
58618 | 233 |
text \<open> |
20491 | 234 |
The language of terms is that of simply-typed @{text "\<lambda>"}-calculus |
58555 | 235 |
with de-Bruijn indices for bound variables (cf.\ @{cite debruijn72} |
236 |
or @{cite "paulson-ml2"}), with the types being determined by the |
|
29761 | 237 |
corresponding binders. In contrast, free variables and constants |
34929 | 238 |
have an explicit name and type in each occurrence. |
20514 | 239 |
|
61416 | 240 |
\<^medskip> |
61477 | 241 |
A \<^emph>\<open>bound variable\<close> is a natural number @{text "b"}, |
20537 | 242 |
which accounts for the number of intermediate binders between the |
243 |
variable occurrence in the body and its binding position. For |
|
34929 | 244 |
example, the de-Bruijn term @{text "\<lambda>\<^bsub>bool\<^esub>. \<lambda>\<^bsub>bool\<^esub>. 1 \<and> 0"} would |
245 |
correspond to @{text "\<lambda>x\<^bsub>bool\<^esub>. \<lambda>y\<^bsub>bool\<^esub>. x \<and> y"} in a named |
|
20543 | 246 |
representation. Note that a bound variable may be represented by |
247 |
different de-Bruijn indices at different occurrences, depending on |
|
248 |
the nesting of abstractions. |
|
20537 | 249 |
|
61477 | 250 |
A \<^emph>\<open>loose variable\<close> is a bound variable that is outside the |
20537 | 251 |
scope of local binders. The types (and names) for loose variables |
20543 | 252 |
can be managed as a separate context, that is maintained as a stack |
253 |
of hypothetical binders. The core logic operates on closed terms, |
|
254 |
without any loose variables. |
|
20514 | 255 |
|
61477 | 256 |
A \<^emph>\<open>fixed variable\<close> is a pair of a basic name and a type, e.g.\ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
257 |
@{text "(x, \<tau>)"} which is usually printed @{text "x\<^sub>\<tau>"} here. A |
61477 | 258 |
\<^emph>\<open>schematic variable\<close> is a pair of an indexname and a type, |
34929 | 259 |
e.g.\ @{text "((x, 0), \<tau>)"} which is likewise printed as @{text |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
260 |
"?x\<^sub>\<tau>"}. |
20491 | 261 |
|
61416 | 262 |
\<^medskip> |
61477 | 263 |
A \<^emph>\<open>constant\<close> is a pair of a basic name and a type, |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
264 |
e.g.\ @{text "(c, \<tau>)"} which is usually printed as @{text "c\<^sub>\<tau>"} |
34929 | 265 |
here. Constants are declared in the context as polymorphic families |
266 |
@{text "c :: \<sigma>"}, meaning that all substitution instances @{text |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
267 |
"c\<^sub>\<tau>"} for @{text "\<tau> = \<sigma>\<vartheta>"} are valid. |
20514 | 268 |
|
61477 | 269 |
The vector of \<^emph>\<open>type arguments\<close> of constant @{text "c\<^sub>\<tau>"} wrt.\ |
34929 | 270 |
the declaration @{text "c :: \<sigma>"} is defined as the codomain of the |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
271 |
matcher @{text "\<vartheta> = {?\<alpha>\<^sub>1 \<mapsto> \<tau>\<^sub>1, \<dots>, ?\<alpha>\<^sub>n \<mapsto> \<tau>\<^sub>n}"} presented in |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
272 |
canonical order @{text "(\<tau>\<^sub>1, \<dots>, \<tau>\<^sub>n)"}, corresponding to the |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
273 |
left-to-right occurrences of the @{text "\<alpha>\<^sub>i"} in @{text "\<sigma>"}. |
34929 | 274 |
Within a given theory context, there is a one-to-one correspondence |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
275 |
between any constant @{text "c\<^sub>\<tau>"} and the application @{text "c(\<tau>\<^sub>1, |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
276 |
\<dots>, \<tau>\<^sub>n)"} of its type arguments. For example, with @{text "plus :: \<alpha> |
34929 | 277 |
\<Rightarrow> \<alpha> \<Rightarrow> \<alpha>"}, the instance @{text "plus\<^bsub>nat \<Rightarrow> nat \<Rightarrow> nat\<^esub>"} corresponds to |
278 |
@{text "plus(nat)"}. |
|
20480 | 279 |
|
20514 | 280 |
Constant declarations @{text "c :: \<sigma>"} may contain sort constraints |
281 |
for type variables in @{text "\<sigma>"}. These are observed by |
|
61477 | 282 |
type-inference as expected, but \<^emph>\<open>ignored\<close> by the core logic. |
20514 | 283 |
This means the primitive logic is able to reason with instances of |
20537 | 284 |
polymorphic constants that the user-level type-checker would reject |
285 |
due to violation of type class restrictions. |
|
20480 | 286 |
|
61416 | 287 |
\<^medskip> |
61477 | 288 |
An \<^emph>\<open>atomic term\<close> is either a variable or constant. |
289 |
The logical category \<^emph>\<open>term\<close> is defined inductively over atomic |
|
34929 | 290 |
terms, with abstraction and application as follows: @{text "t = b | |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
291 |
x\<^sub>\<tau> | ?x\<^sub>\<tau> | c\<^sub>\<tau> | \<lambda>\<^sub>\<tau>. t | t\<^sub>1 t\<^sub>2"}. Parsing and printing takes care of |
34929 | 292 |
converting between an external representation with named bound |
293 |
variables. Subsequently, we shall use the latter notation instead |
|
294 |
of internal de-Bruijn representation. |
|
20498 | 295 |
|
20537 | 296 |
The inductive relation @{text "t :: \<tau>"} assigns a (unique) type to a |
297 |
term according to the structure of atomic terms, abstractions, and |
|
56579 | 298 |
applications: |
20498 | 299 |
\[ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
300 |
\infer{@{text "a\<^sub>\<tau> :: \<tau>"}}{} |
20498 | 301 |
\qquad |
20501 | 302 |
\infer{@{text "(\<lambda>x\<^sub>\<tau>. t) :: \<tau> \<Rightarrow> \<sigma>"}}{@{text "t :: \<sigma>"}} |
303 |
\qquad |
|
304 |
\infer{@{text "t u :: \<sigma>"}}{@{text "t :: \<tau> \<Rightarrow> \<sigma>"} & @{text "u :: \<tau>"}} |
|
20498 | 305 |
\] |
61477 | 306 |
A \<^emph>\<open>well-typed term\<close> is a term that can be typed according to these rules. |
20498 | 307 |
|
20514 | 308 |
Typing information can be omitted: type-inference is able to |
309 |
reconstruct the most general type of a raw term, while assigning |
|
310 |
most general types to all of its variables and constants. |
|
311 |
Type-inference depends on a context of type constraints for fixed |
|
312 |
variables, and declarations for polymorphic constants. |
|
313 |
||
20537 | 314 |
The identity of atomic terms consists both of the name and the type |
315 |
component. This means that different variables @{text |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
316 |
"x\<^bsub>\<tau>\<^sub>1\<^esub>"} and @{text "x\<^bsub>\<tau>\<^sub>2\<^esub>"} may become the same after |
34929 | 317 |
type instantiation. Type-inference rejects variables of the same |
318 |
name, but different types. In contrast, mixed instances of |
|
319 |
polymorphic constants occur routinely. |
|
20514 | 320 |
|
61416 | 321 |
\<^medskip> |
61477 | 322 |
The \<^emph>\<open>hidden polymorphism\<close> of a term @{text "t :: \<sigma>"} |
20514 | 323 |
is the set of type variables occurring in @{text "t"}, but not in |
34929 | 324 |
its type @{text "\<sigma>"}. This means that the term implicitly depends |
325 |
on type arguments that are not accounted in the result type, i.e.\ |
|
326 |
there are different type instances @{text "t\<vartheta> :: \<sigma>"} and |
|
327 |
@{text "t\<vartheta>' :: \<sigma>"} with the same type. This slightly |
|
20543 | 328 |
pathological situation notoriously demands additional care. |
20514 | 329 |
|
61416 | 330 |
\<^medskip> |
61477 | 331 |
A \<^emph>\<open>term abbreviation\<close> is a syntactic definition @{text |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
332 |
"c\<^sub>\<sigma> \<equiv> t"} of a closed term @{text "t"} of type @{text "\<sigma>"}, |
20537 | 333 |
without any hidden polymorphism. A term abbreviation looks like a |
20543 | 334 |
constant in the syntax, but is expanded before entering the logical |
335 |
core. Abbreviations are usually reverted when printing terms, using |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
336 |
@{text "t \<rightarrow> c\<^sub>\<sigma>"} as rules for higher-order rewriting. |
20519 | 337 |
|
61416 | 338 |
\<^medskip> |
339 |
Canonical operations on @{text "\<lambda>"}-terms include @{text |
|
20537 | 340 |
"\<alpha>\<beta>\<eta>"}-conversion: @{text "\<alpha>"}-conversion refers to capture-free |
20519 | 341 |
renaming of bound variables; @{text "\<beta>"}-conversion contracts an |
20537 | 342 |
abstraction applied to an argument term, substituting the argument |
20519 | 343 |
in the body: @{text "(\<lambda>x. b)a"} becomes @{text "b[a/x]"}; @{text |
344 |
"\<eta>"}-conversion contracts vacuous application-abstraction: @{text |
|
345 |
"\<lambda>x. f x"} becomes @{text "f"}, provided that the bound variable |
|
20537 | 346 |
does not occur in @{text "f"}. |
20519 | 347 |
|
20537 | 348 |
Terms are normally treated modulo @{text "\<alpha>"}-conversion, which is |
349 |
implicit in the de-Bruijn representation. Names for bound variables |
|
350 |
in abstractions are maintained separately as (meaningless) comments, |
|
351 |
mostly for parsing and printing. Full @{text "\<alpha>\<beta>\<eta>"}-conversion is |
|
28784 | 352 |
commonplace in various standard operations (\secref{sec:obj-rules}) |
353 |
that are based on higher-order unification and matching. |
|
58618 | 354 |
\<close> |
18537 | 355 |
|
58618 | 356 |
text %mlref \<open> |
20514 | 357 |
\begin{mldecls} |
358 |
@{index_ML_type term} \\ |
|
46262 | 359 |
@{index_ML_op "aconv": "term * term -> bool"} \\ |
39846 | 360 |
@{index_ML Term.map_types: "(typ -> typ) -> term -> term"} \\ |
361 |
@{index_ML Term.fold_types: "(typ -> 'a -> 'a) -> term -> 'a -> 'a"} \\ |
|
362 |
@{index_ML Term.map_aterms: "(term -> term) -> term -> term"} \\ |
|
363 |
@{index_ML Term.fold_aterms: "(term -> 'a -> 'a) -> term -> 'a -> 'a"} \\ |
|
20547 | 364 |
\end{mldecls} |
365 |
\begin{mldecls} |
|
20514 | 366 |
@{index_ML fastype_of: "term -> typ"} \\ |
20519 | 367 |
@{index_ML lambda: "term -> term -> term"} \\ |
368 |
@{index_ML betapply: "term * term -> term"} \\ |
|
42934 | 369 |
@{index_ML incr_boundvars: "int -> term -> term"} \\ |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
370 |
@{index_ML Sign.declare_const: "Proof.context -> |
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
371 |
(binding * typ) * mixfix -> theory -> term * theory"} \\ |
33174 | 372 |
@{index_ML Sign.add_abbrev: "string -> binding * term -> |
24972
acafb18a47dc
replaced Sign.add_consts_i by Sign.declare_const;
wenzelm
parents:
24828
diff
changeset
|
373 |
theory -> (term * term) * theory"} \\ |
20519 | 374 |
@{index_ML Sign.const_typargs: "theory -> string * typ -> typ list"} \\ |
375 |
@{index_ML Sign.const_instance: "theory -> string * typ list -> typ"} \\ |
|
20514 | 376 |
\end{mldecls} |
18537 | 377 |
|
61439 | 378 |
\<^descr> Type @{ML_type term} represents de-Bruijn terms, with comments |
39864 | 379 |
in abstractions, and explicitly named free variables and constants; |
52408 | 380 |
this is a datatype with constructors @{index_ML Bound}, @{index_ML |
381 |
Free}, @{index_ML Var}, @{index_ML Const}, @{index_ML Abs}, |
|
382 |
@{index_ML_op "$"}. |
|
20519 | 383 |
|
61439 | 384 |
\<^descr> @{text "t"}~@{ML_text aconv}~@{text "u"} checks @{text |
20519 | 385 |
"\<alpha>"}-equivalence of two terms. This is the basic equality relation |
386 |
on type @{ML_type term}; raw datatype equality should only be used |
|
387 |
for operations related to parsing or printing! |
|
388 |
||
61439 | 389 |
\<^descr> @{ML Term.map_types}~@{text "f t"} applies the mapping @{text |
20537 | 390 |
"f"} to all types occurring in @{text "t"}. |
391 |
||
61439 | 392 |
\<^descr> @{ML Term.fold_types}~@{text "f t"} iterates the operation |
39846 | 393 |
@{text "f"} over all occurrences of types in @{text "t"}; the term |
20537 | 394 |
structure is traversed from left to right. |
20519 | 395 |
|
61439 | 396 |
\<^descr> @{ML Term.map_aterms}~@{text "f t"} applies the mapping @{text |
39846 | 397 |
"f"} to all atomic terms (@{ML Bound}, @{ML Free}, @{ML Var}, @{ML |
20537 | 398 |
Const}) occurring in @{text "t"}. |
399 |
||
61439 | 400 |
\<^descr> @{ML Term.fold_aterms}~@{text "f t"} iterates the operation |
39846 | 401 |
@{text "f"} over all occurrences of atomic terms (@{ML Bound}, @{ML |
402 |
Free}, @{ML Var}, @{ML Const}) in @{text "t"}; the term structure is |
|
20519 | 403 |
traversed from left to right. |
404 |
||
61439 | 405 |
\<^descr> @{ML fastype_of}~@{text "t"} determines the type of a |
20537 | 406 |
well-typed term. This operation is relatively slow, despite the |
407 |
omission of any sanity checks. |
|
20519 | 408 |
|
61439 | 409 |
\<^descr> @{ML lambda}~@{text "a b"} produces an abstraction @{text |
20537 | 410 |
"\<lambda>a. b"}, where occurrences of the atomic term @{text "a"} in the |
411 |
body @{text "b"} are replaced by bound variables. |
|
20519 | 412 |
|
61439 | 413 |
\<^descr> @{ML betapply}~@{text "(t, u)"} produces an application @{text |
20537 | 414 |
"t u"}, with topmost @{text "\<beta>"}-conversion if @{text "t"} is an |
415 |
abstraction. |
|
20519 | 416 |
|
61439 | 417 |
\<^descr> @{ML incr_boundvars}~@{text "j"} increments a term's dangling |
42934 | 418 |
bound variables by the offset @{text "j"}. This is required when |
419 |
moving a subterm into a context where it is enclosed by a different |
|
420 |
number of abstractions. Bound variables with a matching abstraction |
|
421 |
are unaffected. |
|
422 |
||
61439 | 423 |
\<^descr> @{ML Sign.declare_const}~@{text "ctxt ((c, \<sigma>), mx)"} declares |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
424 |
a new constant @{text "c :: \<sigma>"} with optional mixfix syntax. |
20519 | 425 |
|
61439 | 426 |
\<^descr> @{ML Sign.add_abbrev}~@{text "print_mode (c, t)"} |
21827 | 427 |
introduces a new term abbreviation @{text "c \<equiv> t"}. |
20519 | 428 |
|
61439 | 429 |
\<^descr> @{ML Sign.const_typargs}~@{text "thy (c, \<tau>)"} and @{ML |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
430 |
Sign.const_instance}~@{text "thy (c, [\<tau>\<^sub>1, \<dots>, \<tau>\<^sub>n])"} |
20543 | 431 |
convert between two representations of polymorphic constants: full |
432 |
type instance vs.\ compact type arguments form. |
|
58618 | 433 |
\<close> |
18537 | 434 |
|
58618 | 435 |
text %mlantiq \<open> |
39832 | 436 |
\begin{matharray}{rcl} |
437 |
@{ML_antiquotation_def "const_name"} & : & @{text ML_antiquotation} \\ |
|
438 |
@{ML_antiquotation_def "const_abbrev"} & : & @{text ML_antiquotation} \\ |
|
439 |
@{ML_antiquotation_def "const"} & : & @{text ML_antiquotation} \\ |
|
440 |
@{ML_antiquotation_def "term"} & : & @{text ML_antiquotation} \\ |
|
441 |
@{ML_antiquotation_def "prop"} & : & @{text ML_antiquotation} \\ |
|
442 |
\end{matharray} |
|
443 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55029
diff
changeset
|
444 |
@{rail \<open> |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
445 |
(@@{ML_antiquotation const_name} | |
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
446 |
@@{ML_antiquotation const_abbrev}) nameref |
39832 | 447 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
448 |
@@{ML_antiquotation const} ('(' (type + ',') ')')? |
39832 | 449 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
450 |
@@{ML_antiquotation term} term |
39832 | 451 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
452 |
@@{ML_antiquotation prop} prop |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55029
diff
changeset
|
453 |
\<close>} |
39832 | 454 |
|
61439 | 455 |
\<^descr> @{text "@{const_name c}"} inlines the internalized logical |
39832 | 456 |
constant name @{text "c"} --- as @{ML_type string} literal. |
457 |
||
61439 | 458 |
\<^descr> @{text "@{const_abbrev c}"} inlines the internalized |
39832 | 459 |
abbreviated constant name @{text "c"} --- as @{ML_type string} |
460 |
literal. |
|
461 |
||
61439 | 462 |
\<^descr> @{text "@{const c(\<^vec>\<tau>)}"} inlines the internalized |
39832 | 463 |
constant @{text "c"} with precise type instantiation in the sense of |
464 |
@{ML Sign.const_instance} --- as @{ML Const} constructor term for |
|
465 |
datatype @{ML_type term}. |
|
466 |
||
61439 | 467 |
\<^descr> @{text "@{term t}"} inlines the internalized term @{text "t"} |
39832 | 468 |
--- as constructor term for datatype @{ML_type term}. |
469 |
||
61439 | 470 |
\<^descr> @{text "@{prop \<phi>}"} inlines the internalized proposition |
39832 | 471 |
@{text "\<phi>"} --- as constructor term for datatype @{ML_type term}. |
58618 | 472 |
\<close> |
39832 | 473 |
|
18537 | 474 |
|
58618 | 475 |
section \<open>Theorems \label{sec:thms}\<close> |
18537 | 476 |
|
58618 | 477 |
text \<open> |
61477 | 478 |
A \<^emph>\<open>proposition\<close> is a well-typed term of type @{text "prop"}, a |
479 |
\<^emph>\<open>theorem\<close> is a proven proposition (depending on a context of |
|
20521 | 480 |
hypotheses and the background theory). Primitive inferences include |
29774 | 481 |
plain Natural Deduction rules for the primary connectives @{text |
20537 | 482 |
"\<And>"} and @{text "\<Longrightarrow>"} of the framework. There is also a builtin |
483 |
notion of equality/equivalence @{text "\<equiv>"}. |
|
58618 | 484 |
\<close> |
20521 | 485 |
|
29758 | 486 |
|
58618 | 487 |
subsection \<open>Primitive connectives and rules \label{sec:prim-rules}\<close> |
18537 | 488 |
|
58618 | 489 |
text \<open> |
20543 | 490 |
The theory @{text "Pure"} contains constant declarations for the |
491 |
primitive connectives @{text "\<And>"}, @{text "\<Longrightarrow>"}, and @{text "\<equiv>"} of |
|
492 |
the logical framework, see \figref{fig:pure-connectives}. The |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
493 |
derivability judgment @{text "A\<^sub>1, \<dots>, A\<^sub>n \<turnstile> B"} is |
20543 | 494 |
defined inductively by the primitive inferences given in |
495 |
\figref{fig:prim-rules}, with the global restriction that the |
|
61477 | 496 |
hypotheses must \<^emph>\<open>not\<close> contain any schematic variables. The |
20543 | 497 |
builtin equality is conceptually axiomatized as shown in |
20521 | 498 |
\figref{fig:pure-equality}, although the implementation works |
20543 | 499 |
directly with derived inferences. |
20521 | 500 |
|
501 |
\begin{figure}[htb] |
|
502 |
\begin{center} |
|
20501 | 503 |
\begin{tabular}{ll} |
504 |
@{text "all :: (\<alpha> \<Rightarrow> prop) \<Rightarrow> prop"} & universal quantification (binder @{text "\<And>"}) \\ |
|
505 |
@{text "\<Longrightarrow> :: prop \<Rightarrow> prop \<Rightarrow> prop"} & implication (right associative infix) \\ |
|
20521 | 506 |
@{text "\<equiv> :: \<alpha> \<Rightarrow> \<alpha> \<Rightarrow> prop"} & equality relation (infix) \\ |
20501 | 507 |
\end{tabular} |
20537 | 508 |
\caption{Primitive connectives of Pure}\label{fig:pure-connectives} |
20521 | 509 |
\end{center} |
510 |
\end{figure} |
|
18537 | 511 |
|
20501 | 512 |
\begin{figure}[htb] |
513 |
\begin{center} |
|
20498 | 514 |
\[ |
515 |
\infer[@{text "(axiom)"}]{@{text "\<turnstile> A"}}{@{text "A \<in> \<Theta>"}} |
|
516 |
\qquad |
|
517 |
\infer[@{text "(assume)"}]{@{text "A \<turnstile> A"}}{} |
|
518 |
\] |
|
519 |
\[ |
|
52407 | 520 |
\infer[@{text "(\<And>\<hyphen>intro)"}]{@{text "\<Gamma> \<turnstile> \<And>x. B[x]"}}{@{text "\<Gamma> \<turnstile> B[x]"} & @{text "x \<notin> \<Gamma>"}} |
20498 | 521 |
\qquad |
52407 | 522 |
\infer[@{text "(\<And>\<hyphen>elim)"}]{@{text "\<Gamma> \<turnstile> B[a]"}}{@{text "\<Gamma> \<turnstile> \<And>x. B[x]"}} |
20498 | 523 |
\] |
524 |
\[ |
|
42666 | 525 |
\infer[@{text "(\<Longrightarrow>\<hyphen>intro)"}]{@{text "\<Gamma> - A \<turnstile> A \<Longrightarrow> B"}}{@{text "\<Gamma> \<turnstile> B"}} |
20498 | 526 |
\qquad |
42666 | 527 |
\infer[@{text "(\<Longrightarrow>\<hyphen>elim)"}]{@{text "\<Gamma>\<^sub>1 \<union> \<Gamma>\<^sub>2 \<turnstile> B"}}{@{text "\<Gamma>\<^sub>1 \<turnstile> A \<Longrightarrow> B"} & @{text "\<Gamma>\<^sub>2 \<turnstile> A"}} |
20498 | 528 |
\] |
20521 | 529 |
\caption{Primitive inferences of Pure}\label{fig:prim-rules} |
530 |
\end{center} |
|
531 |
\end{figure} |
|
532 |
||
533 |
\begin{figure}[htb] |
|
534 |
\begin{center} |
|
535 |
\begin{tabular}{ll} |
|
20537 | 536 |
@{text "\<turnstile> (\<lambda>x. b[x]) a \<equiv> b[a]"} & @{text "\<beta>"}-conversion \\ |
20521 | 537 |
@{text "\<turnstile> x \<equiv> x"} & reflexivity \\ |
538 |
@{text "\<turnstile> x \<equiv> y \<Longrightarrow> P x \<Longrightarrow> P y"} & substitution \\ |
|
539 |
@{text "\<turnstile> (\<And>x. f x \<equiv> g x) \<Longrightarrow> f \<equiv> g"} & extensionality \\ |
|
20537 | 540 |
@{text "\<turnstile> (A \<Longrightarrow> B) \<Longrightarrow> (B \<Longrightarrow> A) \<Longrightarrow> A \<equiv> B"} & logical equivalence \\ |
20521 | 541 |
\end{tabular} |
20542 | 542 |
\caption{Conceptual axiomatization of Pure equality}\label{fig:pure-equality} |
20501 | 543 |
\end{center} |
544 |
\end{figure} |
|
18537 | 545 |
|
20501 | 546 |
The introduction and elimination rules for @{text "\<And>"} and @{text |
20537 | 547 |
"\<Longrightarrow>"} are analogous to formation of dependently typed @{text |
20501 | 548 |
"\<lambda>"}-terms representing the underlying proof objects. Proof terms |
20543 | 549 |
are irrelevant in the Pure logic, though; they cannot occur within |
550 |
propositions. The system provides a runtime option to record |
|
52408 | 551 |
explicit proof terms for primitive inferences, see also |
552 |
\secref{sec:proof-terms}. Thus all three levels of @{text |
|
553 |
"\<lambda>"}-calculus become explicit: @{text "\<Rightarrow>"} for terms, and @{text |
|
58555 | 554 |
"\<And>/\<Longrightarrow>"} for proofs (cf.\ @{cite "Berghofer-Nipkow:2000:TPHOL"}). |
20491 | 555 |
|
34929 | 556 |
Observe that locally fixed parameters (as in @{text |
42666 | 557 |
"\<And>\<hyphen>intro"}) need not be recorded in the hypotheses, because |
34929 | 558 |
the simple syntactic types of Pure are always inhabitable. |
559 |
``Assumptions'' @{text "x :: \<tau>"} for type-membership are only |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
560 |
present as long as some @{text "x\<^sub>\<tau>"} occurs in the statement |
34929 | 561 |
body.\footnote{This is the key difference to ``@{text "\<lambda>HOL"}'' in |
58555 | 562 |
the PTS framework @{cite "Barendregt-Geuvers:2001"}, where hypotheses |
34929 | 563 |
@{text "x : A"} are treated uniformly for propositions and types.} |
20501 | 564 |
|
61416 | 565 |
\<^medskip> |
566 |
The axiomatization of a theory is implicitly closed by |
|
20537 | 567 |
forming all instances of type and term variables: @{text "\<turnstile> |
568 |
A\<vartheta>"} holds for any substitution instance of an axiom |
|
20543 | 569 |
@{text "\<turnstile> A"}. By pushing substitutions through derivations |
570 |
inductively, we also get admissible @{text "generalize"} and @{text |
|
34929 | 571 |
"instantiate"} rules as shown in \figref{fig:subst-rules}. |
20501 | 572 |
|
573 |
\begin{figure}[htb] |
|
574 |
\begin{center} |
|
20498 | 575 |
\[ |
20501 | 576 |
\infer{@{text "\<Gamma> \<turnstile> B[?\<alpha>]"}}{@{text "\<Gamma> \<turnstile> B[\<alpha>]"} & @{text "\<alpha> \<notin> \<Gamma>"}} |
577 |
\quad |
|
578 |
\infer[\quad@{text "(generalize)"}]{@{text "\<Gamma> \<turnstile> B[?x]"}}{@{text "\<Gamma> \<turnstile> B[x]"} & @{text "x \<notin> \<Gamma>"}} |
|
20498 | 579 |
\] |
580 |
\[ |
|
20501 | 581 |
\infer{@{text "\<Gamma> \<turnstile> B[\<tau>]"}}{@{text "\<Gamma> \<turnstile> B[?\<alpha>]"}} |
582 |
\quad |
|
583 |
\infer[\quad@{text "(instantiate)"}]{@{text "\<Gamma> \<turnstile> B[t]"}}{@{text "\<Gamma> \<turnstile> B[?x]"}} |
|
20498 | 584 |
\] |
20501 | 585 |
\caption{Admissible substitution rules}\label{fig:subst-rules} |
586 |
\end{center} |
|
587 |
\end{figure} |
|
18537 | 588 |
|
20537 | 589 |
Note that @{text "instantiate"} does not require an explicit |
590 |
side-condition, because @{text "\<Gamma>"} may never contain schematic |
|
591 |
variables. |
|
592 |
||
593 |
In principle, variables could be substituted in hypotheses as well, |
|
20543 | 594 |
but this would disrupt the monotonicity of reasoning: deriving |
595 |
@{text "\<Gamma>\<vartheta> \<turnstile> B\<vartheta>"} from @{text "\<Gamma> \<turnstile> B"} is |
|
596 |
correct, but @{text "\<Gamma>\<vartheta> \<supseteq> \<Gamma>"} does not necessarily hold: |
|
597 |
the result belongs to a different proof context. |
|
20542 | 598 |
|
61416 | 599 |
\<^medskip> |
61477 | 600 |
An \<^emph>\<open>oracle\<close> is a function that produces axioms on the |
20543 | 601 |
fly. Logically, this is an instance of the @{text "axiom"} rule |
602 |
(\figref{fig:prim-rules}), but there is an operational difference. |
|
603 |
The system always records oracle invocations within derivations of |
|
29768 | 604 |
theorems by a unique tag. |
20542 | 605 |
|
606 |
Axiomatizations should be limited to the bare minimum, typically as |
|
607 |
part of the initial logical basis of an object-logic formalization. |
|
20543 | 608 |
Later on, theories are usually developed in a strictly definitional |
609 |
fashion, by stating only certain equalities over new constants. |
|
20542 | 610 |
|
61477 | 611 |
A \<^emph>\<open>simple definition\<close> consists of a constant declaration @{text |
20543 | 612 |
"c :: \<sigma>"} together with an axiom @{text "\<turnstile> c \<equiv> t"}, where @{text "t |
613 |
:: \<sigma>"} is a closed term without any hidden polymorphism. The RHS |
|
614 |
may depend on further defined constants, but not @{text "c"} itself. |
|
615 |
Definitions of functions may be presented as @{text "c \<^vec>x \<equiv> |
|
616 |
t"} instead of the puristic @{text "c \<equiv> \<lambda>\<^vec>x. t"}. |
|
20542 | 617 |
|
61477 | 618 |
An \<^emph>\<open>overloaded definition\<close> consists of a collection of axioms |
20543 | 619 |
for the same constant, with zero or one equations @{text |
620 |
"c((\<^vec>\<alpha>)\<kappa>) \<equiv> t"} for each type constructor @{text "\<kappa>"} (for |
|
621 |
distinct variables @{text "\<^vec>\<alpha>"}). The RHS may mention |
|
622 |
previously defined constants as above, or arbitrary constants @{text |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
623 |
"d(\<alpha>\<^sub>i)"} for some @{text "\<alpha>\<^sub>i"} projected from @{text |
20543 | 624 |
"\<^vec>\<alpha>"}. Thus overloaded definitions essentially work by |
625 |
primitive recursion over the syntactic structure of a single type |
|
58555 | 626 |
argument. See also @{cite \<open>\S4.3\<close> "Haftmann-Wenzel:2006:classes"}. |
58618 | 627 |
\<close> |
20498 | 628 |
|
58618 | 629 |
text %mlref \<open> |
20521 | 630 |
\begin{mldecls} |
46253 | 631 |
@{index_ML Logic.all: "term -> term -> term"} \\ |
632 |
@{index_ML Logic.mk_implies: "term * term -> term"} \\ |
|
633 |
\end{mldecls} |
|
634 |
\begin{mldecls} |
|
20521 | 635 |
@{index_ML_type ctyp} \\ |
636 |
@{index_ML_type cterm} \\ |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
58728
diff
changeset
|
637 |
@{index_ML Thm.ctyp_of: "Proof.context -> typ -> ctyp"} \\ |
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
58728
diff
changeset
|
638 |
@{index_ML Thm.cterm_of: "Proof.context -> term -> cterm"} \\ |
46497
89ccf66aa73d
renamed Thm.capply to Thm.apply, and Thm.cabs to Thm.lambda in conformance with similar operations in structure Term and Logic;
wenzelm
parents:
46262
diff
changeset
|
639 |
@{index_ML Thm.apply: "cterm -> cterm -> cterm"} \\ |
89ccf66aa73d
renamed Thm.capply to Thm.apply, and Thm.cabs to Thm.lambda in conformance with similar operations in structure Term and Logic;
wenzelm
parents:
46262
diff
changeset
|
640 |
@{index_ML Thm.lambda: "cterm -> cterm -> cterm"} \\ |
60938 | 641 |
@{index_ML Thm.all: "Proof.context -> cterm -> cterm -> cterm"} \\ |
46253 | 642 |
@{index_ML Drule.mk_implies: "cterm * cterm -> cterm"} \\ |
20547 | 643 |
\end{mldecls} |
644 |
\begin{mldecls} |
|
20521 | 645 |
@{index_ML_type thm} \\ |
50126
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
646 |
@{index_ML Thm.peek_status: "thm -> {oracle: bool, unfinished: bool, failed: bool}"} \\ |
42933 | 647 |
@{index_ML Thm.transfer: "theory -> thm -> thm"} \\ |
20542 | 648 |
@{index_ML Thm.assume: "cterm -> thm"} \\ |
649 |
@{index_ML Thm.forall_intr: "cterm -> thm -> thm"} \\ |
|
650 |
@{index_ML Thm.forall_elim: "cterm -> thm -> thm"} \\ |
|
651 |
@{index_ML Thm.implies_intr: "cterm -> thm -> thm"} \\ |
|
652 |
@{index_ML Thm.implies_elim: "thm -> thm -> thm"} \\ |
|
653 |
@{index_ML Thm.generalize: "string list * string list -> int -> thm -> thm"} \\ |
|
60642
48dd1cefb4ae
simplified Thm.instantiate and derivatives: the LHS refers to non-certified variables -- this merely serves as index into already certified structures (or is ignored);
wenzelm
parents:
59902
diff
changeset
|
654 |
@{index_ML Thm.instantiate: "((indexname * sort) * ctyp) list * ((indexname * typ) * cterm) list |
48dd1cefb4ae
simplified Thm.instantiate and derivatives: the LHS refers to non-certified variables -- this merely serves as index into already certified structures (or is ignored);
wenzelm
parents:
59902
diff
changeset
|
655 |
-> thm -> thm"} \\ |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
656 |
@{index_ML Thm.add_axiom: "Proof.context -> |
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
657 |
binding * term -> theory -> (string * thm) * theory"} \\ |
39821 | 658 |
@{index_ML Thm.add_oracle: "binding * ('a -> cterm) -> theory -> |
659 |
(string * ('a -> thm)) * theory"} \\ |
|
61261
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
wenzelm
parents:
61255
diff
changeset
|
660 |
@{index_ML Thm.add_def: "Defs.context -> bool -> bool -> |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
661 |
binding * term -> theory -> (string * thm) * theory"} \\ |
20547 | 662 |
\end{mldecls} |
663 |
\begin{mldecls} |
|
61261
ddb2da7cb2e4
more explicit Defs.context: use proper name spaces as far as possible;
wenzelm
parents:
61255
diff
changeset
|
664 |
@{index_ML Theory.add_deps: "Defs.context -> string -> |
61255
15865e0c5598
eliminated separate type Theory.dep: use typeargs uniformly for consts/types;
wenzelm
parents:
61246
diff
changeset
|
665 |
Defs.entry -> Defs.entry list -> theory -> theory"} \\ |
20521 | 666 |
\end{mldecls} |
667 |
||
61439 | 668 |
\<^descr> @{ML Thm.peek_status}~@{text "thm"} informs about the current |
50126
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
669 |
status of the derivation object behind the given theorem. This is a |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
670 |
snapshot of a potentially ongoing (parallel) evaluation of proofs. |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
671 |
The three Boolean values indicate the following: @{verbatim oracle} |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
672 |
if the finished part contains some oracle invocation; @{verbatim |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
673 |
unfinished} if some future proofs are still pending; @{verbatim |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
674 |
failed} if some future proof has failed, rendering the theorem |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
675 |
invalid! |
3dec88149176
theorem status about oracles/futures is no longer printed by default;
wenzelm
parents:
48985
diff
changeset
|
676 |
|
61439 | 677 |
\<^descr> @{ML Logic.all}~@{text "a B"} produces a Pure quantification |
46253 | 678 |
@{text "\<And>a. B"}, where occurrences of the atomic term @{text "a"} in |
679 |
the body proposition @{text "B"} are replaced by bound variables. |
|
680 |
(See also @{ML lambda} on terms.) |
|
681 |
||
61439 | 682 |
\<^descr> @{ML Logic.mk_implies}~@{text "(A, B)"} produces a Pure |
46253 | 683 |
implication @{text "A \<Longrightarrow> B"}. |
684 |
||
61439 | 685 |
\<^descr> Types @{ML_type ctyp} and @{ML_type cterm} represent certified |
39864 | 686 |
types and terms, respectively. These are abstract datatypes that |
20542 | 687 |
guarantee that its values have passed the full well-formedness (and |
688 |
well-typedness) checks, relative to the declarations of type |
|
46253 | 689 |
constructors, constants etc.\ in the background theory. The |
690 |
abstract types @{ML_type ctyp} and @{ML_type cterm} are part of the |
|
691 |
same inference kernel that is mainly responsible for @{ML_type thm}. |
|
692 |
Thus syntactic operations on @{ML_type ctyp} and @{ML_type cterm} |
|
55837 | 693 |
are located in the @{ML_structure Thm} module, even though theorems are |
46253 | 694 |
not yet involved at that stage. |
20542 | 695 |
|
61439 | 696 |
\<^descr> @{ML Thm.ctyp_of}~@{text "ctxt \<tau>"} and @{ML |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
58728
diff
changeset
|
697 |
Thm.cterm_of}~@{text "ctxt t"} explicitly check types and terms, |
29768 | 698 |
respectively. This also involves some basic normalizations, such |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
58728
diff
changeset
|
699 |
expansion of type and term abbreviations from the underlying |
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
58728
diff
changeset
|
700 |
theory context. |
46253 | 701 |
Full re-certification is relatively slow and should be avoided in |
702 |
tight reasoning loops. |
|
20547 | 703 |
|
61439 | 704 |
\<^descr> @{ML Thm.apply}, @{ML Thm.lambda}, @{ML Thm.all}, @{ML |
46253 | 705 |
Drule.mk_implies} etc.\ compose certified terms (or propositions) |
706 |
incrementally. This is equivalent to @{ML Thm.cterm_of} after |
|
46262 | 707 |
unchecked @{ML_op "$"}, @{ML lambda}, @{ML Logic.all}, @{ML |
46253 | 708 |
Logic.mk_implies} etc., but there can be a big difference in |
709 |
performance when large existing entities are composed by a few extra |
|
710 |
constructions on top. There are separate operations to decompose |
|
711 |
certified terms and theorems to produce certified terms again. |
|
20542 | 712 |
|
61439 | 713 |
\<^descr> Type @{ML_type thm} represents proven propositions. This is |
39864 | 714 |
an abstract datatype that guarantees that its values have been |
55837 | 715 |
constructed by basic principles of the @{ML_structure Thm} module. |
52788 | 716 |
Every @{ML_type thm} value refers its background theory, |
717 |
cf.\ \secref{sec:context-theory}. |
|
20542 | 718 |
|
61439 | 719 |
\<^descr> @{ML Thm.transfer}~@{text "thy thm"} transfers the given |
61477 | 720 |
theorem to a \<^emph>\<open>larger\<close> theory, see also \secref{sec:context}. |
42933 | 721 |
This formal adjustment of the background context has no logical |
722 |
significance, but is occasionally required for formal reasons, e.g.\ |
|
723 |
when theorems that are imported from more basic theories are used in |
|
724 |
the current situation. |
|
725 |
||
61439 | 726 |
\<^descr> @{ML Thm.assume}, @{ML Thm.forall_intr}, @{ML |
20542 | 727 |
Thm.forall_elim}, @{ML Thm.implies_intr}, and @{ML Thm.implies_elim} |
728 |
correspond to the primitive inferences of \figref{fig:prim-rules}. |
|
729 |
||
61439 | 730 |
\<^descr> @{ML Thm.generalize}~@{text "(\<^vec>\<alpha>, \<^vec>x)"} |
20542 | 731 |
corresponds to the @{text "generalize"} rules of |
20543 | 732 |
\figref{fig:subst-rules}. Here collections of type and term |
733 |
variables are generalized simultaneously, specified by the given |
|
734 |
basic names. |
|
20521 | 735 |
|
61439 | 736 |
\<^descr> @{ML Thm.instantiate}~@{text "(\<^vec>\<alpha>\<^sub>s, |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
737 |
\<^vec>x\<^sub>\<tau>)"} corresponds to the @{text "instantiate"} rules |
20542 | 738 |
of \figref{fig:subst-rules}. Type variables are substituted before |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
739 |
term variables. Note that the types in @{text "\<^vec>x\<^sub>\<tau>"} |
20542 | 740 |
refer to the instantiated versions. |
741 |
||
61439 | 742 |
\<^descr> @{ML Thm.add_axiom}~@{text "ctxt (name, A)"} declares an |
35927 | 743 |
arbitrary proposition as axiom, and retrieves it as a theorem from |
744 |
the resulting theory, cf.\ @{text "axiom"} in |
|
745 |
\figref{fig:prim-rules}. Note that the low-level representation in |
|
746 |
the axiom table may differ slightly from the returned theorem. |
|
20542 | 747 |
|
61439 | 748 |
\<^descr> @{ML Thm.add_oracle}~@{text "(binding, oracle)"} produces a named |
28290 | 749 |
oracle rule, essentially generating arbitrary axioms on the fly, |
750 |
cf.\ @{text "axiom"} in \figref{fig:prim-rules}. |
|
20521 | 751 |
|
61439 | 752 |
\<^descr> @{ML Thm.add_def}~@{text "ctxt unchecked overloaded (name, c |
35927 | 753 |
\<^vec>x \<equiv> t)"} states a definitional axiom for an existing constant |
754 |
@{text "c"}. Dependencies are recorded via @{ML Theory.add_deps}, |
|
755 |
unless the @{text "unchecked"} option is set. Note that the |
|
756 |
low-level representation in the axiom table may differ slightly from |
|
757 |
the returned theorem. |
|
20542 | 758 |
|
61439 | 759 |
\<^descr> @{ML Theory.add_deps}~@{text "ctxt name c\<^sub>\<tau> \<^vec>d\<^sub>\<sigma>"} |
42401
9bfaf6819291
updated some theory primitives, which now depend on auxiliary context;
wenzelm
parents:
40255
diff
changeset
|
760 |
declares dependencies of a named specification for constant @{text |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52788
diff
changeset
|
761 |
"c\<^sub>\<tau>"}, relative to existing specifications for constants @{text |
61255
15865e0c5598
eliminated separate type Theory.dep: use typeargs uniformly for consts/types;
wenzelm
parents:
61246
diff
changeset
|
762 |
"\<^vec>d\<^sub>\<sigma>"}. This also works for type constructors. |
58618 | 763 |
\<close> |
20521 | 764 |
|
765 |
||
58618 | 766 |
text %mlantiq \<open> |
39832 | 767 |
\begin{matharray}{rcl} |
768 |
@{ML_antiquotation_def "ctyp"} & : & @{text ML_antiquotation} \\ |
|
769 |
@{ML_antiquotation_def "cterm"} & : & @{text ML_antiquotation} \\ |
|
770 |
@{ML_antiquotation_def "cprop"} & : & @{text ML_antiquotation} \\ |
|
771 |
@{ML_antiquotation_def "thm"} & : & @{text ML_antiquotation} \\ |
|
772 |
@{ML_antiquotation_def "thms"} & : & @{text ML_antiquotation} \\ |
|
773 |
@{ML_antiquotation_def "lemma"} & : & @{text ML_antiquotation} \\ |
|
774 |
\end{matharray} |
|
775 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55029
diff
changeset
|
776 |
@{rail \<open> |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
777 |
@@{ML_antiquotation ctyp} typ |
39832 | 778 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
779 |
@@{ML_antiquotation cterm} term |
39832 | 780 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
781 |
@@{ML_antiquotation cprop} prop |
39832 | 782 |
; |
42510
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
783 |
@@{ML_antiquotation thm} thmref |
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
784 |
; |
b9c106763325
use @{rail} antiquotation (with some nested markup);
wenzelm
parents:
42401
diff
changeset
|
785 |
@@{ML_antiquotation thms} thmrefs |
39832 | 786 |
; |
55029
61a6bf7d4b02
clarified @{rail} syntax: prefer explicit \<newline> symbol;
wenzelm
parents:
54883
diff
changeset
|
787 |
@@{ML_antiquotation lemma} ('(' @'open' ')')? ((prop +) + @'and') \<newline> |
42517
b68e1c27709a
simplified keyword markup (without formal checking);
wenzelm
parents:
42510
diff
changeset
|
788 |
@'by' method method? |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55029
diff
changeset
|
789 |
\<close>} |
39832 | 790 |
|
61439 | 791 |
\<^descr> @{text "@{ctyp \<tau>}"} produces a certified type wrt.\ the |
39832 | 792 |
current background theory --- as abstract value of type @{ML_type |
793 |
ctyp}. |
|
794 |
||
61439 | 795 |
\<^descr> @{text "@{cterm t}"} and @{text "@{cprop \<phi>}"} produce a |
39832 | 796 |
certified term wrt.\ the current background theory --- as abstract |
797 |
value of type @{ML_type cterm}. |
|
798 |
||
61439 | 799 |
\<^descr> @{text "@{thm a}"} produces a singleton fact --- as abstract |
39832 | 800 |
value of type @{ML_type thm}. |
801 |
||
61439 | 802 |
\<^descr> @{text "@{thms a}"} produces a general fact --- as abstract |
39832 | 803 |
value of type @{ML_type "thm list"}. |
804 |
||
61439 | 805 |
\<^descr> @{text "@{lemma \<phi> by meth}"} produces a fact that is proven on |
39832 | 806 |
the spot according to the minimal proof, which imitates a terminal |
807 |
Isar proof. The result is an abstract value of type @{ML_type thm} |
|
808 |
or @{ML_type "thm list"}, depending on the number of propositions |
|
809 |
given here. |
|
810 |
||
811 |
The internal derivation object lacks a proper theorem name, but it |
|
812 |
is formally closed, unless the @{text "(open)"} option is specified |
|
813 |
(this may impact performance of applications with proof terms). |
|
814 |
||
815 |
Since ML antiquotations are always evaluated at compile-time, there |
|
816 |
is no run-time overhead even for non-trivial proofs. Nonetheless, |
|
817 |
the justification is syntactically limited to a single @{command |
|
818 |
"by"} step. More complex Isar proofs should be done in regular |
|
819 |
theory source, before compiling the corresponding ML text that uses |
|
820 |
the result. |
|
58618 | 821 |
\<close> |
39832 | 822 |
|
823 |
||
58618 | 824 |
subsection \<open>Auxiliary connectives \label{sec:logic-aux}\<close> |
20521 | 825 |
|
58618 | 826 |
text \<open>Theory @{text "Pure"} provides a few auxiliary connectives |
46254 | 827 |
that are defined on top of the primitive ones, see |
828 |
\figref{fig:pure-aux}. These special constants are useful in |
|
829 |
certain internal encodings, and are normally not directly exposed to |
|
830 |
the user. |
|
20501 | 831 |
|
832 |
\begin{figure}[htb] |
|
833 |
\begin{center} |
|
20498 | 834 |
\begin{tabular}{ll} |
34929 | 835 |
@{text "conjunction :: prop \<Rightarrow> prop \<Rightarrow> prop"} & (infix @{text "&&&"}) \\ |
836 |
@{text "\<turnstile> A &&& B \<equiv> (\<And>C. (A \<Longrightarrow> B \<Longrightarrow> C) \<Longrightarrow> C)"} \\[1ex] |
|
20543 | 837 |
@{text "prop :: prop \<Rightarrow> prop"} & (prefix @{text "#"}, suppressed) \\ |
20521 | 838 |
@{text "#A \<equiv> A"} \\[1ex] |
839 |
@{text "term :: \<alpha> \<Rightarrow> prop"} & (prefix @{text "TERM"}) \\ |
|
840 |
@{text "term x \<equiv> (\<And>A. A \<Longrightarrow> A)"} \\[1ex] |
|
56243 | 841 |
@{text "type :: \<alpha> itself"} & (prefix @{text "TYPE"}) \\ |
20521 | 842 |
@{text "(unspecified)"} \\ |
20498 | 843 |
\end{tabular} |
20521 | 844 |
\caption{Definitions of auxiliary connectives}\label{fig:pure-aux} |
20501 | 845 |
\end{center} |
846 |
\end{figure} |
|
847 |
||
34929 | 848 |
The introduction @{text "A \<Longrightarrow> B \<Longrightarrow> A &&& B"}, and eliminations |
849 |
(projections) @{text "A &&& B \<Longrightarrow> A"} and @{text "A &&& B \<Longrightarrow> B"} are |
|
850 |
available as derived rules. Conjunction allows to treat |
|
851 |
simultaneous assumptions and conclusions uniformly, e.g.\ consider |
|
852 |
@{text "A \<Longrightarrow> B \<Longrightarrow> C &&& D"}. In particular, the goal mechanism |
|
853 |
represents multiple claims as explicit conjunction internally, but |
|
854 |
this is refined (via backwards introduction) into separate sub-goals |
|
855 |
before the user commences the proof; the final result is projected |
|
856 |
into a list of theorems using eliminations (cf.\ |
|
20537 | 857 |
\secref{sec:tactical-goals}). |
20498 | 858 |
|
20537 | 859 |
The @{text "prop"} marker (@{text "#"}) makes arbitrarily complex |
860 |
propositions appear as atomic, without changing the meaning: @{text |
|
861 |
"\<Gamma> \<turnstile> A"} and @{text "\<Gamma> \<turnstile> #A"} are interchangeable. See |
|
862 |
\secref{sec:tactical-goals} for specific operations. |
|
20521 | 863 |
|
20543 | 864 |
The @{text "term"} marker turns any well-typed term into a derivable |
865 |
proposition: @{text "\<turnstile> TERM t"} holds unconditionally. Although |
|
866 |
this is logically vacuous, it allows to treat terms and proofs |
|
867 |
uniformly, similar to a type-theoretic framework. |
|
20498 | 868 |
|
20537 | 869 |
The @{text "TYPE"} constructor is the canonical representative of |
870 |
the unspecified type @{text "\<alpha> itself"}; it essentially injects the |
|
871 |
language of types into that of terms. There is specific notation |
|
53071 | 872 |
@{text "TYPE(\<tau>)"} for @{text "TYPE\<^bsub>\<tau> itself\<^esub>"}. |
34929 | 873 |
Although being devoid of any particular meaning, the term @{text |
20537 | 874 |
"TYPE(\<tau>)"} accounts for the type @{text "\<tau>"} within the term |
875 |
language. In particular, @{text "TYPE(\<alpha>)"} may be used as formal |
|
876 |
argument in primitive definitions, in order to circumvent hidden |
|
877 |
polymorphism (cf.\ \secref{sec:terms}). For example, @{text "c |
|
878 |
TYPE(\<alpha>) \<equiv> A[\<alpha>]"} defines @{text "c :: \<alpha> itself \<Rightarrow> prop"} in terms of |
|
879 |
a proposition @{text "A"} that depends on an additional type |
|
880 |
argument, which is essentially a predicate on types. |
|
58618 | 881 |
\<close> |
20501 | 882 |
|
58618 | 883 |
text %mlref \<open> |
20521 | 884 |
\begin{mldecls} |
885 |
@{index_ML Conjunction.intr: "thm -> thm -> thm"} \\ |
|
886 |
@{index_ML Conjunction.elim: "thm -> thm * thm"} \\ |
|
887 |
@{index_ML Drule.mk_term: "cterm -> thm"} \\ |
|
888 |
@{index_ML Drule.dest_term: "thm -> cterm"} \\ |
|
889 |
@{index_ML Logic.mk_type: "typ -> term"} \\ |
|
890 |
@{index_ML Logic.dest_type: "term -> typ"} \\ |
|
891 |
\end{mldecls} |
|
892 |
||
61439 | 893 |
\<^descr> @{ML Conjunction.intr} derives @{text "A &&& B"} from @{text |
20542 | 894 |
"A"} and @{text "B"}. |
895 |
||
61439 | 896 |
\<^descr> @{ML Conjunction.elim} derives @{text "A"} and @{text "B"} |
34929 | 897 |
from @{text "A &&& B"}. |
20542 | 898 |
|
61439 | 899 |
\<^descr> @{ML Drule.mk_term} derives @{text "TERM t"}. |
20542 | 900 |
|
61439 | 901 |
\<^descr> @{ML Drule.dest_term} recovers term @{text "t"} from @{text |
20543 | 902 |
"TERM t"}. |
20542 | 903 |
|
61439 | 904 |
\<^descr> @{ML Logic.mk_type}~@{text "\<tau>"} produces the term @{text |
20542 | 905 |
"TYPE(\<tau>)"}. |
906 |
||
61439 | 907 |
\<^descr> @{ML Logic.dest_type}~@{text "TYPE(\<tau>)"} recovers the type |
20542 | 908 |
@{text "\<tau>"}. |
58618 | 909 |
\<close> |
18537 | 910 |
|
20480 | 911 |
|
58618 | 912 |
subsection \<open>Sort hypotheses\<close> |
52406 | 913 |
|
58618 | 914 |
text \<open>Type variables are decorated with sorts, as explained in |
52406 | 915 |
\secref{sec:types}. This constrains type instantiation to certain |
916 |
ranges of types: variable @{text "\<alpha>\<^sub>s"} may only be assigned to types |
|
917 |
@{text "\<tau>"} that belong to sort @{text "s"}. Within the logic, sort |
|
918 |
constraints act like implicit preconditions on the result @{text |
|
919 |
"\<lparr>\<alpha>\<^sub>1 : s\<^sub>1\<rparr>, \<dots>, \<lparr>\<alpha>\<^sub>n : s\<^sub>n\<rparr>, \<Gamma> \<turnstile> \<phi>"} where the type variables @{text |
|
920 |
"\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n"} cover the propositions @{text "\<Gamma>"}, @{text "\<phi>"}, as |
|
921 |
well as the proof of @{text "\<Gamma> \<turnstile> \<phi>"}. |
|
922 |
||
61477 | 923 |
These \<^emph>\<open>sort hypothesis\<close> of a theorem are passed monotonically |
52406 | 924 |
through further derivations. They are redundant, as long as the |
925 |
statement of a theorem still contains the type variables that are |
|
926 |
accounted here. The logical significance of sort hypotheses is |
|
927 |
limited to the boundary case where type variables disappear from the |
|
928 |
proposition, e.g.\ @{text "\<lparr>\<alpha>\<^sub>s : s\<rparr> \<turnstile> \<phi>"}. Since such dangling type |
|
929 |
variables can be renamed arbitrarily without changing the |
|
930 |
proposition @{text "\<phi>"}, the inference kernel maintains sort |
|
931 |
hypotheses in anonymous form @{text "s \<turnstile> \<phi>"}. |
|
932 |
||
933 |
In most practical situations, such extra sort hypotheses may be |
|
934 |
stripped in a final bookkeeping step, e.g.\ at the end of a proof: |
|
935 |
they are typically left over from intermediate reasoning with type |
|
936 |
classes that can be satisfied by some concrete type @{text "\<tau>"} of |
|
937 |
sort @{text "s"} to replace the hypothetical type variable @{text |
|
58618 | 938 |
"\<alpha>\<^sub>s"}.\<close> |
52406 | 939 |
|
58618 | 940 |
text %mlref \<open> |
52406 | 941 |
\begin{mldecls} |
942 |
@{index_ML Thm.extra_shyps: "thm -> sort list"} \\ |
|
943 |
@{index_ML Thm.strip_shyps: "thm -> thm"} \\ |
|
944 |
\end{mldecls} |
|
945 |
||
61439 | 946 |
\<^descr> @{ML Thm.extra_shyps}~@{text "thm"} determines the extraneous |
52406 | 947 |
sort hypotheses of the given theorem, i.e.\ the sorts that are not |
948 |
present within type variables of the statement. |
|
949 |
||
61439 | 950 |
\<^descr> @{ML Thm.strip_shyps}~@{text "thm"} removes any extraneous |
52406 | 951 |
sort hypotheses that can be witnessed from the type signature. |
58618 | 952 |
\<close> |
52406 | 953 |
|
58618 | 954 |
text %mlex \<open>The following artificial example demonstrates the |
52406 | 955 |
derivation of @{prop False} with a pending sort hypothesis involving |
58618 | 956 |
a logically empty sort.\<close> |
52406 | 957 |
|
958 |
class empty = |
|
959 |
assumes bad: "\<And>(x::'a) y. x \<noteq> y" |
|
960 |
||
961 |
theorem (in empty) false: False |
|
962 |
using bad by blast |
|
963 |
||
59902 | 964 |
ML_val \<open>@{assert} (Thm.extra_shyps @{thm false} = [@{sort empty}])\<close> |
52406 | 965 |
|
58618 | 966 |
text \<open>Thanks to the inference kernel managing sort hypothesis |
52406 | 967 |
according to their logical significance, this example is merely an |
61477 | 968 |
instance of \<^emph>\<open>ex falso quodlibet consequitur\<close> --- not a collapse |
58618 | 969 |
of the logical framework!\<close> |
52406 | 970 |
|
971 |
||
58618 | 972 |
section \<open>Object-level rules \label{sec:obj-rules}\<close> |
18537 | 973 |
|
58618 | 974 |
text \<open> |
29768 | 975 |
The primitive inferences covered so far mostly serve foundational |
976 |
purposes. User-level reasoning usually works via object-level rules |
|
977 |
that are represented as theorems of Pure. Composition of rules |
|
61477 | 978 |
involves \<^emph>\<open>backchaining\<close>, \<^emph>\<open>higher-order unification\<close> modulo |
29771 | 979 |
@{text "\<alpha>\<beta>\<eta>"}-conversion of @{text "\<lambda>"}-terms, and so-called |
61477 | 980 |
\<^emph>\<open>lifting\<close> of rules into a context of @{text "\<And>"} and @{text |
29774 | 981 |
"\<Longrightarrow>"} connectives. Thus the full power of higher-order Natural |
982 |
Deduction in Isabelle/Pure becomes readily available. |
|
58618 | 983 |
\<close> |
20491 | 984 |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
985 |
|
58618 | 986 |
subsection \<open>Hereditary Harrop Formulae\<close> |
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
987 |
|
58618 | 988 |
text \<open> |
29768 | 989 |
The idea of object-level rules is to model Natural Deduction |
58555 | 990 |
inferences in the style of Gentzen @{cite "Gentzen:1935"}, but we allow |
991 |
arbitrary nesting similar to @{cite extensions91}. The most basic |
|
61477 | 992 |
rule format is that of a \<^emph>\<open>Horn Clause\<close>: |
29768 | 993 |
\[ |
994 |
\infer{@{text "A"}}{@{text "A\<^sub>1"} & @{text "\<dots>"} & @{text "A\<^sub>n"}} |
|
995 |
\] |
|
996 |
where @{text "A, A\<^sub>1, \<dots>, A\<^sub>n"} are atomic propositions |
|
997 |
of the framework, usually of the form @{text "Trueprop B"}, where |
|
998 |
@{text "B"} is a (compound) object-level statement. This |
|
999 |
object-level inference corresponds to an iterated implication in |
|
1000 |
Pure like this: |
|
1001 |
\[ |
|
1002 |
@{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> A"} |
|
1003 |
\] |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1004 |
As an example consider conjunction introduction: @{text "A \<Longrightarrow> B \<Longrightarrow> A \<and> |
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1005 |
B"}. Any parameters occurring in such rule statements are |
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1006 |
conceptionally treated as arbitrary: |
29768 | 1007 |
\[ |
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1008 |
@{text "\<And>x\<^sub>1 \<dots> x\<^sub>m. A\<^sub>1 x\<^sub>1 \<dots> x\<^sub>m \<Longrightarrow> \<dots> A\<^sub>n x\<^sub>1 \<dots> x\<^sub>m \<Longrightarrow> A x\<^sub>1 \<dots> x\<^sub>m"} |
29768 | 1009 |
\] |
20491 | 1010 |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1011 |
Nesting of rules means that the positions of @{text "A\<^sub>i"} may |
29770 | 1012 |
again hold compound rules, not just atomic propositions. |
61477 | 1013 |
Propositions of this format are called \<^emph>\<open>Hereditary Harrop |
1014 |
Formulae\<close> in the literature @{cite "Miller:1991"}. Here we give an |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1015 |
inductive characterization as follows: |
29768 | 1016 |
|
61416 | 1017 |
\<^medskip> |
29768 | 1018 |
\begin{tabular}{ll} |
1019 |
@{text "\<^bold>x"} & set of variables \\ |
|
1020 |
@{text "\<^bold>A"} & set of atomic propositions \\ |
|
1021 |
@{text "\<^bold>H = \<And>\<^bold>x\<^sup>*. \<^bold>H\<^sup>* \<Longrightarrow> \<^bold>A"} & set of Hereditary Harrop Formulas \\ |
|
1022 |
\end{tabular} |
|
61416 | 1023 |
\<^medskip> |
29768 | 1024 |
|
39861
b8d89db3e238
use continental paragraph style, which works better with mixture of (in)formal text;
wenzelm
parents:
39846
diff
changeset
|
1025 |
Thus we essentially impose nesting levels on propositions formed |
b8d89db3e238
use continental paragraph style, which works better with mixture of (in)formal text;
wenzelm
parents:
39846
diff
changeset
|
1026 |
from @{text "\<And>"} and @{text "\<Longrightarrow>"}. At each level there is a prefix |
b8d89db3e238
use continental paragraph style, which works better with mixture of (in)formal text;
wenzelm
parents:
39846
diff
changeset
|
1027 |
of parameters and compound premises, concluding an atomic |
29770 | 1028 |
proposition. Typical examples are @{text "\<longrightarrow>"}-introduction @{text |
1029 |
"(A \<Longrightarrow> B) \<Longrightarrow> A \<longrightarrow> B"} or mathematical induction @{text "P 0 \<Longrightarrow> (\<And>n. P n |
|
1030 |
\<Longrightarrow> P (Suc n)) \<Longrightarrow> P n"}. Even deeper nesting occurs in well-founded |
|
1031 |
induction @{text "(\<And>x. (\<And>y. y \<prec> x \<Longrightarrow> P y) \<Longrightarrow> P x) \<Longrightarrow> P x"}, but this |
|
34929 | 1032 |
already marks the limit of rule complexity that is usually seen in |
1033 |
practice. |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1034 |
|
61416 | 1035 |
\<^medskip> |
1036 |
Regular user-level inferences in Isabelle/Pure always |
|
29770 | 1037 |
maintain the following canonical form of results: |
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1038 |
|
61416 | 1039 |
\<^item> Normalization by @{text "(A \<Longrightarrow> (\<And>x. B x)) \<equiv> (\<And>x. A \<Longrightarrow> B x)"}, |
29774 | 1040 |
which is a theorem of Pure, means that quantifiers are pushed in |
1041 |
front of implication at each level of nesting. The normal form is a |
|
1042 |
Hereditary Harrop Formula. |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1043 |
|
61416 | 1044 |
\<^item> The outermost prefix of parameters is represented via |
29770 | 1045 |
schematic variables: instead of @{text "\<And>\<^vec>x. \<^vec>H \<^vec>x |
29774 | 1046 |
\<Longrightarrow> A \<^vec>x"} we have @{text "\<^vec>H ?\<^vec>x \<Longrightarrow> A ?\<^vec>x"}. |
1047 |
Note that this representation looses information about the order of |
|
1048 |
parameters, and vacuous quantifiers vanish automatically. |
|
58618 | 1049 |
\<close> |
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1050 |
|
58618 | 1051 |
text %mlref \<open> |
29771 | 1052 |
\begin{mldecls} |
54883
dd04a8b654fc
proper context for norm_hhf and derived operations;
wenzelm
parents:
53200
diff
changeset
|
1053 |
@{index_ML Simplifier.norm_hhf: "Proof.context -> thm -> thm"} \\ |
29771 | 1054 |
\end{mldecls} |
1055 |
||
61439 | 1056 |
\<^descr> @{ML Simplifier.norm_hhf}~@{text "ctxt thm"} normalizes the given |
29771 | 1057 |
theorem according to the canonical form specified above. This is |
1058 |
occasionally helpful to repair some low-level tools that do not |
|
1059 |
handle Hereditary Harrop Formulae properly. |
|
58618 | 1060 |
\<close> |
29771 | 1061 |
|
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1062 |
|
58618 | 1063 |
subsection \<open>Rule composition\<close> |
29769
03634a9e91ae
improved section on "Hereditary Harrop Formulae";
wenzelm
parents:
29768
diff
changeset
|
1064 |
|
58618 | 1065 |
text \<open> |
29771 | 1066 |
The rule calculus of Isabelle/Pure provides two main inferences: |
1067 |
@{inference resolution} (i.e.\ back-chaining of rules) and |
|
1068 |
@{inference assumption} (i.e.\ closing a branch), both modulo |
|
1069 |
higher-order unification. There are also combined variants, notably |
|
1070 |
@{inference elim_resolution} and @{inference dest_resolution}. |
|
20491 | 1071 |
|
29771 | 1072 |
To understand the all-important @{inference resolution} principle, |
1073 |
we first consider raw @{inference_def composition} (modulo |
|
1074 |
higher-order unification with substitution @{text "\<vartheta>"}): |
|
20498 | 1075 |
\[ |
29771 | 1076 |
\infer[(@{inference_def composition})]{@{text "\<^vec>A\<vartheta> \<Longrightarrow> C\<vartheta>"}} |
20498 | 1077 |
{@{text "\<^vec>A \<Longrightarrow> B"} & @{text "B' \<Longrightarrow> C"} & @{text "B\<vartheta> = B'\<vartheta>"}} |
1078 |
\] |
|
29771 | 1079 |
Here the conclusion of the first rule is unified with the premise of |
1080 |
the second; the resulting rule instance inherits the premises of the |
|
1081 |
first and conclusion of the second. Note that @{text "C"} can again |
|
1082 |
consist of iterated implications. We can also permute the premises |
|
1083 |
of the second rule back-and-forth in order to compose with @{text |
|
1084 |
"B'"} in any position (subsequently we shall always refer to |
|
1085 |
position 1 w.l.o.g.). |
|
20498 | 1086 |
|
29774 | 1087 |
In @{inference composition} the internal structure of the common |
1088 |
part @{text "B"} and @{text "B'"} is not taken into account. For |
|
1089 |
proper @{inference resolution} we require @{text "B"} to be atomic, |
|
1090 |
and explicitly observe the structure @{text "\<And>\<^vec>x. \<^vec>H |
|
1091 |
\<^vec>x \<Longrightarrow> B' \<^vec>x"} of the premise of the second rule. The |
|
1092 |
idea is to adapt the first rule by ``lifting'' it into this context, |
|
1093 |
by means of iterated application of the following inferences: |
|
20498 | 1094 |
\[ |
29771 | 1095 |
\infer[(@{inference_def imp_lift})]{@{text "(\<^vec>H \<Longrightarrow> \<^vec>A) \<Longrightarrow> (\<^vec>H \<Longrightarrow> B)"}}{@{text "\<^vec>A \<Longrightarrow> B"}} |
20498 | 1096 |
\] |
1097 |
\[ |
|
29771 | 1098 |
\infer[(@{inference_def all_lift})]{@{text "(\<And>\<^vec>x. \<^vec>A (?\<^vec>a \<^vec>x)) \<Longrightarrow> (\<And>\<^vec>x. B (?\<^vec>a \<^vec>x))"}}{@{text "\<^vec>A ?\<^vec>a \<Longrightarrow> B ?\<^vec>a"}} |
20498 | 1099 |
\] |
29771 | 1100 |
By combining raw composition with lifting, we get full @{inference |
1101 |
resolution} as follows: |
|
20498 | 1102 |
\[ |
29771 | 1103 |
\infer[(@{inference_def resolution})] |
20498 | 1104 |
{@{text "(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> \<^vec>A (?\<^vec>a \<^vec>x))\<vartheta> \<Longrightarrow> C\<vartheta>"}} |
1105 |
{\begin{tabular}{l} |
|
1106 |
@{text "\<^vec>A ?\<^vec>a \<Longrightarrow> B ?\<^vec>a"} \\ |
|
1107 |
@{text "(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> B' \<^vec>x) \<Longrightarrow> C"} \\ |
|
1108 |
@{text "(\<lambda>\<^vec>x. B (?\<^vec>a \<^vec>x))\<vartheta> = B'\<vartheta>"} \\ |
|
1109 |
\end{tabular}} |
|
1110 |
\] |
|
1111 |
||
29774 | 1112 |
Continued resolution of rules allows to back-chain a problem towards |
1113 |
more and sub-problems. Branches are closed either by resolving with |
|
1114 |
a rule of 0 premises, or by producing a ``short-circuit'' within a |
|
1115 |
solved situation (again modulo unification): |
|
29771 | 1116 |
\[ |
1117 |
\infer[(@{inference_def assumption})]{@{text "C\<vartheta>"}} |
|
1118 |
{@{text "(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> A \<^vec>x) \<Longrightarrow> C"} & @{text "A\<vartheta> = H\<^sub>i\<vartheta>"}~~\text{(for some~@{text i})}} |
|
1119 |
\] |
|
20498 | 1120 |
|
52422 | 1121 |
%FIXME @{inference_def elim_resolution}, @{inference_def dest_resolution} |
58618 | 1122 |
\<close> |
18537 | 1123 |
|
58618 | 1124 |
text %mlref \<open> |
29768 | 1125 |
\begin{mldecls} |
46262 | 1126 |
@{index_ML_op "RSN": "thm * (int * thm) -> thm"} \\ |
1127 |
@{index_ML_op "RS": "thm * thm -> thm"} \\ |
|
46256 | 1128 |
|
46262 | 1129 |
@{index_ML_op "RLN": "thm list * (int * thm list) -> thm list"} \\ |
1130 |
@{index_ML_op "RL": "thm list * thm list -> thm list"} \\ |
|
46256 | 1131 |
|
46262 | 1132 |
@{index_ML_op "MRS": "thm list * thm -> thm"} \\ |
1133 |
@{index_ML_op "OF": "thm * thm list -> thm"} \\ |
|
29768 | 1134 |
\end{mldecls} |
1135 |
||
61439 | 1136 |
\<^descr> @{text "rule\<^sub>1 RSN (i, rule\<^sub>2)"} resolves the conclusion of |
46256 | 1137 |
@{text "rule\<^sub>1"} with the @{text i}-th premise of @{text "rule\<^sub>2"}, |
1138 |
according to the @{inference resolution} principle explained above. |
|
1139 |
Unless there is precisely one resolvent it raises exception @{ML |
|
1140 |
THM}. |
|
1141 |
||
1142 |
This corresponds to the rule attribute @{attribute THEN} in Isar |
|
1143 |
source language. |
|
1144 |
||
61439 | 1145 |
\<^descr> @{text "rule\<^sub>1 RS rule\<^sub>2"} abbreviates @{text "rule\<^sub>1 RSN (1, |
46256 | 1146 |
rule\<^sub>2)"}. |
29768 | 1147 |
|
61439 | 1148 |
\<^descr> @{text "rules\<^sub>1 RLN (i, rules\<^sub>2)"} joins lists of rules. For |
46256 | 1149 |
every @{text "rule\<^sub>1"} in @{text "rules\<^sub>1"} and @{text "rule\<^sub>2"} in |
1150 |
@{text "rules\<^sub>2"}, it resolves the conclusion of @{text "rule\<^sub>1"} with |
|
1151 |
the @{text "i"}-th premise of @{text "rule\<^sub>2"}, accumulating multiple |
|
1152 |
results in one big list. Note that such strict enumerations of |
|
1153 |
higher-order unifications can be inefficient compared to the lazy |
|
1154 |
variant seen in elementary tactics like @{ML resolve_tac}. |
|
1155 |
||
61439 | 1156 |
\<^descr> @{text "rules\<^sub>1 RL rules\<^sub>2"} abbreviates @{text "rules\<^sub>1 RLN (1, |
46256 | 1157 |
rules\<^sub>2)"}. |
1158 |
||
61439 | 1159 |
\<^descr> @{text "[rule\<^sub>1, \<dots>, rule\<^sub>n] MRS rule"} resolves @{text "rule\<^sub>i"} |
46256 | 1160 |
against premise @{text "i"} of @{text "rule"}, for @{text "i = n, \<dots>, |
1161 |
1"}. By working from right to left, newly emerging premises are |
|
1162 |
concatenated in the result, without interfering. |
|
1163 |
||
61439 | 1164 |
\<^descr> @{text "rule OF rules"} is an alternative notation for @{text |
47498 | 1165 |
"rules MRS rule"}, which makes rule composition look more like |
1166 |
function application. Note that the argument @{text "rules"} need |
|
1167 |
not be atomic. |
|
46256 | 1168 |
|
1169 |
This corresponds to the rule attribute @{attribute OF} in Isar |
|
1170 |
source language. |
|
58618 | 1171 |
\<close> |
30272 | 1172 |
|
52407 | 1173 |
|
58618 | 1174 |
section \<open>Proof terms \label{sec:proof-terms}\<close> |
52407 | 1175 |
|
58618 | 1176 |
text \<open>The Isabelle/Pure inference kernel can record the proof of |
52407 | 1177 |
each theorem as a proof term that contains all logical inferences in |
1178 |
detail. Rule composition by resolution (\secref{sec:obj-rules}) and |
|
1179 |
type-class reasoning is broken down to primitive rules of the |
|
1180 |
logical framework. The proof term can be inspected by a separate |
|
1181 |
proof-checker, for example. |
|
1182 |
||
61477 | 1183 |
According to the well-known \<^emph>\<open>Curry-Howard isomorphism\<close>, a proof |
52407 | 1184 |
can be viewed as a @{text "\<lambda>"}-term. Following this idea, proofs in |
1185 |
Isabelle are internally represented by a datatype similar to the one |
|
1186 |
for terms described in \secref{sec:terms}. On top of these |
|
1187 |
syntactic terms, two more layers of @{text "\<lambda>"}-calculus are added, |
|
1188 |
which correspond to @{text "\<And>x :: \<alpha>. B x"} and @{text "A \<Longrightarrow> B"} |
|
1189 |
according to the propositions-as-types principle. The resulting |
|
1190 |
3-level @{text "\<lambda>"}-calculus resembles ``@{text "\<lambda>HOL"}'' in the |
|
1191 |
more abstract setting of Pure Type Systems (PTS) |
|
58555 | 1192 |
@{cite "Barendregt-Geuvers:2001"}, if some fine points like schematic |
52407 | 1193 |
polymorphism and type classes are ignored. |
1194 |
||
61416 | 1195 |
\<^medskip> |
61477 | 1196 |
\<^emph>\<open>Proof abstractions\<close> of the form @{text "\<^bold>\<lambda>x :: \<alpha>. prf"} |
52407 | 1197 |
or @{text "\<^bold>\<lambda>p : A. prf"} correspond to introduction of @{text |
61477 | 1198 |
"\<And>"}/@{text "\<Longrightarrow>"}, and \<^emph>\<open>proof applications\<close> of the form @{text |
52407 | 1199 |
"p \<cdot> t"} or @{text "p \<bullet> q"} correspond to elimination of @{text |
1200 |
"\<And>"}/@{text "\<Longrightarrow>"}. Actual types @{text "\<alpha>"}, propositions @{text |
|
1201 |
"A"}, and terms @{text "t"} might be suppressed and reconstructed |
|
1202 |
from the overall proof term. |
|
1203 |
||
61416 | 1204 |
\<^medskip> |
1205 |
Various atomic proofs indicate special situations within |
|
52407 | 1206 |
the proof construction as follows. |
1207 |
||
61477 | 1208 |
A \<^emph>\<open>bound proof variable\<close> is a natural number @{text "b"} that |
52407 | 1209 |
acts as de-Bruijn index for proof term abstractions. |
1210 |
||
61477 | 1211 |
A \<^emph>\<open>minimal proof\<close> ``@{text "?"}'' is a dummy proof term. This |
52407 | 1212 |
indicates some unrecorded part of the proof. |
1213 |
||
1214 |
@{text "Hyp A"} refers to some pending hypothesis by giving its |
|
1215 |
proposition. This indicates an open context of implicit hypotheses, |
|
1216 |
similar to loose bound variables or free variables within a term |
|
1217 |
(\secref{sec:terms}). |
|
1218 |
||
61477 | 1219 |
An \<^emph>\<open>axiom\<close> or \<^emph>\<open>oracle\<close> @{text "a : A[\<^vec>\<tau>]"} refers |
52407 | 1220 |
some postulated @{text "proof constant"}, which is subject to |
1221 |
schematic polymorphism of theory content, and the particular type |
|
1222 |
instantiation may be given explicitly. The vector of types @{text |
|
1223 |
"\<^vec>\<tau>"} refers to the schematic type variables in the generic |
|
1224 |
proposition @{text "A"} in canonical order. |
|
1225 |
||
61477 | 1226 |
A \<^emph>\<open>proof promise\<close> @{text "a : A[\<^vec>\<tau>]"} is a placeholder |
52407 | 1227 |
for some proof of polymorphic proposition @{text "A"}, with explicit |
1228 |
type instantiation as given by the vector @{text "\<^vec>\<tau>"}, as |
|
1229 |
above. Unlike axioms or oracles, proof promises may be |
|
61477 | 1230 |
\<^emph>\<open>fulfilled\<close> eventually, by substituting @{text "a"} by some |
52407 | 1231 |
particular proof @{text "q"} at the corresponding type instance. |
1232 |
This acts like Hindley-Milner @{text "let"}-polymorphism: a generic |
|
1233 |
local proof definition may get used at different type instances, and |
|
1234 |
is replaced by the concrete instance eventually. |
|
1235 |
||
61477 | 1236 |
A \<^emph>\<open>named theorem\<close> wraps up some concrete proof as a closed |
52407 | 1237 |
formal entity, in the manner of constant definitions for proof |
61477 | 1238 |
terms. The \<^emph>\<open>proof body\<close> of such boxed theorems involves some |
52407 | 1239 |
digest about oracles and promises occurring in the original proof. |
1240 |
This allows the inference kernel to manage this critical information |
|
1241 |
without the full overhead of explicit proof terms. |
|
58618 | 1242 |
\<close> |
52407 | 1243 |
|
52411 | 1244 |
|
58618 | 1245 |
subsection \<open>Reconstructing and checking proof terms\<close> |
52411 | 1246 |
|
58618 | 1247 |
text \<open>Fully explicit proof terms can be large, but most of this |
52411 | 1248 |
information is redundant and can be reconstructed from the context. |
1249 |
Therefore, the Isabelle/Pure inference kernel records only |
|
61477 | 1250 |
\<^emph>\<open>implicit\<close> proof terms, by omitting all typing information in |
52411 | 1251 |
terms, all term and type labels of proof abstractions, and some |
1252 |
argument terms of applications @{text "p \<cdot> t"} (if possible). |
|
1253 |
||
1254 |
There are separate operations to reconstruct the full proof term |
|
61477 | 1255 |
later on, using \<^emph>\<open>higher-order pattern unification\<close> |
58555 | 1256 |
@{cite "nipkow-patterns" and "Berghofer-Nipkow:2000:TPHOL"}. |
52411 | 1257 |
|
61477 | 1258 |
The \<^emph>\<open>proof checker\<close> expects a fully reconstructed proof term, |
52411 | 1259 |
and can turn it into a theorem by replaying its primitive inferences |
58618 | 1260 |
within the kernel.\<close> |
52411 | 1261 |
|
52412 | 1262 |
|
58618 | 1263 |
subsection \<open>Concrete syntax of proof terms\<close> |
52412 | 1264 |
|
58618 | 1265 |
text \<open>The concrete syntax of proof terms is a slight extension of |
58555 | 1266 |
the regular inner syntax of Isabelle/Pure @{cite "isabelle-isar-ref"}. |
52412 | 1267 |
Its main syntactic category @{syntax (inner) proof} is defined as |
1268 |
follows: |
|
1269 |
||
1270 |
\begin{center} |
|
1271 |
\begin{supertabular}{rclr} |
|
1272 |
||
1273 |
@{syntax_def (inner) proof} & = & @{verbatim Lam} @{text params} @{verbatim "."} @{text proof} \\ |
|
52486
b1565e37678b
just one alternative proof syntax, which also works for Proof_Syntax.pretty_proof/Proof_Syntax.read_proof roundtrip;
wenzelm
parents:
52470
diff
changeset
|
1274 |
& @{text "|"} & @{text "\<^bold>\<lambda>"} @{text "params"} @{verbatim "."} @{text proof} \\ |
52412 | 1275 |
& @{text "|"} & @{text proof} @{verbatim "%"} @{text any} \\ |
1276 |
& @{text "|"} & @{text proof} @{text "\<cdot>"} @{text any} \\ |
|
1277 |
& @{text "|"} & @{text proof} @{verbatim "%%"} @{text proof} \\ |
|
1278 |
& @{text "|"} & @{text proof} @{text "\<bullet>"} @{text proof} \\ |
|
1279 |
& @{text "|"} & @{text "id | longid"} \\ |
|
1280 |
\\ |
|
1281 |
||
1282 |
@{text param} & = & @{text idt} \\ |
|
1283 |
& @{text "|"} & @{text idt} @{verbatim ":"} @{text prop} \\ |
|
1284 |
& @{text "|"} & @{verbatim "("} @{text param} @{verbatim ")"} \\ |
|
1285 |
\\ |
|
1286 |
||
1287 |
@{text params} & = & @{text param} \\ |
|
1288 |
& @{text "|"} & @{text param} @{text params} \\ |
|
1289 |
||
1290 |
\end{supertabular} |
|
1291 |
\end{center} |
|
1292 |
||
1293 |
Implicit term arguments in partial proofs are indicated by ``@{text |
|
1294 |
"_"}''. Type arguments for theorems and axioms may be specified |
|
1295 |
using @{text "p \<cdot> TYPE(type)"} (they must appear before any other |
|
1296 |
term argument of a theorem or axiom, but may be omitted altogether). |
|
1297 |
||
61416 | 1298 |
\<^medskip> |
1299 |
There are separate read and print operations for proof |
|
52412 | 1300 |
terms, in order to avoid conflicts with the regular term language. |
58618 | 1301 |
\<close> |
52412 | 1302 |
|
58618 | 1303 |
text %mlref \<open> |
52408 | 1304 |
\begin{mldecls} |
1305 |
@{index_ML_type proof} \\ |
|
1306 |
@{index_ML_type proof_body} \\ |
|
52487
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1307 |
@{index_ML proofs: "int Unsynchronized.ref"} \\ |
52411 | 1308 |
@{index_ML Reconstruct.reconstruct_proof: |
1309 |
"theory -> term -> proof -> proof"} \\ |
|
1310 |
@{index_ML Reconstruct.expand_proof: "theory -> |
|
1311 |
(string * term option) list -> proof -> proof"} \\ |
|
52412 | 1312 |
@{index_ML Proof_Checker.thm_of_proof: "theory -> proof -> thm"} \\ |
1313 |
@{index_ML Proof_Syntax.read_proof: "theory -> bool -> bool -> string -> proof"} \\ |
|
1314 |
@{index_ML Proof_Syntax.pretty_proof: "Proof.context -> proof -> Pretty.T"} \\ |
|
52408 | 1315 |
\end{mldecls} |
1316 |
||
61439 | 1317 |
\<^descr> Type @{ML_type proof} represents proof terms; this is a |
52408 | 1318 |
datatype with constructors @{index_ML Abst}, @{index_ML AbsP}, |
1319 |
@{index_ML_op "%"}, @{index_ML_op "%%"}, @{index_ML PBound}, |
|
1320 |
@{index_ML MinProof}, @{index_ML Hyp}, @{index_ML PAxm}, @{index_ML |
|
1321 |
Oracle}, @{index_ML Promise}, @{index_ML PThm} as explained above. |
|
52436 | 1322 |
%FIXME OfClass (!?) |
52408 | 1323 |
|
61439 | 1324 |
\<^descr> Type @{ML_type proof_body} represents the nested proof |
52408 | 1325 |
information of a named theorem, consisting of a digest of oracles |
1326 |
and named theorem over some proof term. The digest only covers the |
|
1327 |
directly visible part of the proof: in order to get the full |
|
1328 |
information, the implicit graph of nested theorems needs to be |
|
1329 |
traversed (e.g.\ using @{ML Proofterm.fold_body_thms}). |
|
1330 |
||
61439 | 1331 |
\<^descr> @{ML Thm.proof_of}~@{text "thm"} and @{ML |
52408 | 1332 |
Thm.proof_body_of}~@{text "thm"} produce the proof term or proof |
1333 |
body (with digest of oracles and theorems) from a given theorem. |
|
1334 |
Note that this involves a full join of internal futures that fulfill |
|
1335 |
pending proof promises, and thus disrupts the natural bottom-up |
|
1336 |
construction of proofs by introducing dynamic ad-hoc dependencies. |
|
1337 |
Parallel performance may suffer by inspecting proof terms at |
|
1338 |
run-time. |
|
1339 |
||
61439 | 1340 |
\<^descr> @{ML proofs} specifies the detail of proof recording within |
52487
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1341 |
@{ML_type thm} values produced by the inference kernel: @{ML 0} |
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1342 |
records only the names of oracles, @{ML 1} records oracle names and |
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1343 |
propositions, @{ML 2} additionally records full proof terms. |
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1344 |
Officially named theorems that contribute to a result are recorded |
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1345 |
in any case. |
48bc24467008
backout dedd7952a62c: static "proofs" value within theory prevents later inferencing with different configuration;
wenzelm
parents:
52486
diff
changeset
|
1346 |
|
61439 | 1347 |
\<^descr> @{ML Reconstruct.reconstruct_proof}~@{text "thy prop prf"} |
52411 | 1348 |
turns the implicit proof term @{text "prf"} into a full proof of the |
1349 |
given proposition. |
|
1350 |
||
1351 |
Reconstruction may fail if @{text "prf"} is not a proof of @{text |
|
1352 |
"prop"}, or if it does not contain sufficient information for |
|
1353 |
reconstruction. Failure may only happen for proofs that are |
|
1354 |
constructed manually, but not for those produced automatically by |
|
1355 |
the inference kernel. |
|
1356 |
||
61439 | 1357 |
\<^descr> @{ML Reconstruct.expand_proof}~@{text "thy [thm\<^sub>1, \<dots>, thm\<^sub>n] |
52411 | 1358 |
prf"} expands and reconstructs the proofs of all specified theorems, |
1359 |
with the given (full) proof. Theorems that are not unique specified |
|
1360 |
via their name may be disambiguated by giving their proposition. |
|
1361 |
||
61439 | 1362 |
\<^descr> @{ML Proof_Checker.thm_of_proof}~@{text "thy prf"} turns the |
52411 | 1363 |
given (full) proof into a theorem, by replaying it using only |
1364 |
primitive rules of the inference kernel. |
|
1365 |
||
61439 | 1366 |
\<^descr> @{ML Proof_Syntax.read_proof}~@{text "thy b\<^sub>1 b\<^sub>2 s"} reads in a |
52412 | 1367 |
proof term. The Boolean flags indicate the use of sort and type |
1368 |
information. Usually, typing information is left implicit and is |
|
1369 |
inferred during proof reconstruction. %FIXME eliminate flags!? |
|
1370 |
||
61439 | 1371 |
\<^descr> @{ML Proof_Syntax.pretty_proof}~@{text "ctxt prf"} |
52412 | 1372 |
pretty-prints the given proof term. |
58618 | 1373 |
\<close> |
52408 | 1374 |
|
58618 | 1375 |
text %mlex \<open>Detailed proof information of a theorem may be retrieved |
1376 |
as follows:\<close> |
|
52410 | 1377 |
|
1378 |
lemma ex: "A \<and> B \<longrightarrow> B \<and> A" |
|
1379 |
proof |
|
1380 |
assume "A \<and> B" |
|
1381 |
then obtain B and A .. |
|
1382 |
then show "B \<and> A" .. |
|
1383 |
qed |
|
1384 |
||
58618 | 1385 |
ML_val \<open> |
52410 | 1386 |
(*proof body with digest*) |
1387 |
val body = Proofterm.strip_thm (Thm.proof_body_of @{thm ex}); |
|
1388 |
||
1389 |
(*proof term only*) |
|
1390 |
val prf = Proofterm.proof_of body; |
|
1391 |
Pretty.writeln (Proof_Syntax.pretty_proof @{context} prf); |
|
1392 |
||
1393 |
(*all theorems used in the graph of nested proofs*) |
|
1394 |
val all_thms = |
|
1395 |
Proofterm.fold_body_thms |
|
1396 |
(fn (name, _, _) => insert (op =) name) [body] []; |
|
58618 | 1397 |
\<close> |
52410 | 1398 |
|
58618 | 1399 |
text \<open>The result refers to various basic facts of Isabelle/HOL: |
52410 | 1400 |
@{thm [source] HOL.impI}, @{thm [source] HOL.conjE}, @{thm [source] |
1401 |
HOL.conjI} etc. The combinator @{ML Proofterm.fold_body_thms} |
|
1402 |
recursively explores the graph of the proofs of all theorems being |
|
1403 |
used here. |
|
1404 |
||
61416 | 1405 |
\<^medskip> |
1406 |
Alternatively, we may produce a proof term manually, and |
|
58618 | 1407 |
turn it into a theorem as follows:\<close> |
52410 | 1408 |
|
58618 | 1409 |
ML_val \<open> |
52410 | 1410 |
val thy = @{theory}; |
1411 |
val prf = |
|
1412 |
Proof_Syntax.read_proof thy true false |
|
1413 |
"impI \<cdot> _ \<cdot> _ \<bullet> \ |
|
52486
b1565e37678b
just one alternative proof syntax, which also works for Proof_Syntax.pretty_proof/Proof_Syntax.read_proof roundtrip;
wenzelm
parents:
52470
diff
changeset
|
1414 |
\ (\<^bold>\<lambda>H: _. \ |
52410 | 1415 |
\ conjE \<cdot> _ \<cdot> _ \<cdot> _ \<bullet> H \<bullet> \ |
52486
b1565e37678b
just one alternative proof syntax, which also works for Proof_Syntax.pretty_proof/Proof_Syntax.read_proof roundtrip;
wenzelm
parents:
52470
diff
changeset
|
1416 |
\ (\<^bold>\<lambda>(H: _) Ha: _. conjI \<cdot> _ \<cdot> _ \<bullet> Ha \<bullet> H))"; |
52410 | 1417 |
val thm = |
1418 |
prf |
|
1419 |
|> Reconstruct.reconstruct_proof thy @{prop "A \<and> B \<longrightarrow> B \<and> A"} |
|
1420 |
|> Proof_Checker.thm_of_proof thy |
|
1421 |
|> Drule.export_without_context; |
|
58618 | 1422 |
\<close> |
52410 | 1423 |
|
61416 | 1424 |
text \<open> |
1425 |
\<^medskip> |
|
1426 |
See also @{file "~~/src/HOL/Proofs/ex/XML_Data.thy"} |
|
52630
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52487
diff
changeset
|
1427 |
for further examples, with export and import of proof terms via |
fe411c1dc180
more robust proof export / import due to Stefan Berghofer;
wenzelm
parents:
52487
diff
changeset
|
1428 |
XML/ML data representation. |
58618 | 1429 |
\<close> |
52410 | 1430 |
|
18537 | 1431 |
end |