18537
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{logic}%
|
|
4 |
%
|
|
5 |
\isadelimtheory
|
|
6 |
\isanewline
|
|
7 |
\isanewline
|
|
8 |
\isanewline
|
|
9 |
%
|
|
10 |
\endisadelimtheory
|
|
11 |
%
|
|
12 |
\isatagtheory
|
|
13 |
\isacommand{theory}\isamarkupfalse%
|
|
14 |
\ logic\ \isakeyword{imports}\ base\ \isakeyword{begin}%
|
|
15 |
\endisatagtheory
|
|
16 |
{\isafoldtheory}%
|
|
17 |
%
|
|
18 |
\isadelimtheory
|
|
19 |
%
|
|
20 |
\endisadelimtheory
|
|
21 |
%
|
20471
|
22 |
\isamarkupchapter{Primitive logic \label{ch:logic}%
|
18537
|
23 |
}
|
|
24 |
\isamarkuptrue%
|
|
25 |
%
|
20481
|
26 |
\begin{isamarkuptext}%
|
|
27 |
The logical foundations of Isabelle/Isar are that of the Pure logic,
|
|
28 |
which has been introduced as a natural-deduction framework in
|
20493
|
29 |
\cite{paulson700}. This is essentially the same logic as ``\isa{{\isasymlambda}HOL}'' in the more abstract setting of Pure Type Systems (PTS)
|
20481
|
30 |
\cite{Barendregt-Geuvers:2001}, although there are some key
|
20491
|
31 |
differences in the specific treatment of simple types in
|
|
32 |
Isabelle/Pure.
|
20481
|
33 |
|
|
34 |
Following type-theoretic parlance, the Pure logic consists of three
|
|
35 |
levels of \isa{{\isasymlambda}}-calculus with corresponding arrows: \isa{{\isasymRightarrow}} for syntactic function space (terms depending on terms), \isa{{\isasymAnd}} for universal quantification (proofs depending on terms), and
|
|
36 |
\isa{{\isasymLongrightarrow}} for implication (proofs depending on proofs).
|
|
37 |
|
20537
|
38 |
Derivations are relative to a logical theory, which declares type
|
|
39 |
constructors, constants, and axioms. Theory declarations support
|
|
40 |
schematic polymorphism, which is strictly speaking outside the
|
|
41 |
logic.\footnote{This is the deeper logical reason, why the theory
|
|
42 |
context \isa{{\isasymTheta}} is separate from the proof context \isa{{\isasymGamma}}
|
|
43 |
of the core calculus.}%
|
20481
|
44 |
\end{isamarkuptext}%
|
|
45 |
\isamarkuptrue%
|
|
46 |
%
|
20451
|
47 |
\isamarkupsection{Types \label{sec:types}%
|
18537
|
48 |
}
|
|
49 |
\isamarkuptrue%
|
|
50 |
%
|
|
51 |
\begin{isamarkuptext}%
|
20481
|
52 |
The language of types is an uninterpreted order-sorted first-order
|
|
53 |
algebra; types are qualified by ordered type classes.
|
20451
|
54 |
|
20481
|
55 |
\medskip A \emph{type class} is an abstract syntactic entity
|
|
56 |
declared in the theory context. The \emph{subclass relation} \isa{c\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlisub {\isadigit{2}}} is specified by stating an acyclic
|
20491
|
57 |
generating relation; the transitive closure is maintained
|
|
58 |
internally. The resulting relation is an ordering: reflexive,
|
|
59 |
transitive, and antisymmetric.
|
20451
|
60 |
|
20537
|
61 |
A \emph{sort} is a list of type classes written as \isa{s\ {\isacharequal}\ {\isacharbraceleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlisub m{\isacharbraceright}}, which represents symbolic
|
20481
|
62 |
intersection. Notationally, the curly braces are omitted for
|
|
63 |
singleton intersections, i.e.\ any class \isa{c} may be read as
|
|
64 |
a sort \isa{{\isacharbraceleft}c{\isacharbraceright}}. The ordering on type classes is extended to
|
20491
|
65 |
sorts according to the meaning of intersections: \isa{{\isacharbraceleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}\ c\isactrlisub m{\isacharbraceright}\ {\isasymsubseteq}\ {\isacharbraceleft}d\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ d\isactrlisub n{\isacharbraceright}} iff
|
|
66 |
\isa{{\isasymforall}j{\isachardot}\ {\isasymexists}i{\isachardot}\ c\isactrlisub i\ {\isasymsubseteq}\ d\isactrlisub j}. The empty intersection
|
|
67 |
\isa{{\isacharbraceleft}{\isacharbraceright}} refers to the universal sort, which is the largest
|
|
68 |
element wrt.\ the sort order. The intersections of all (finitely
|
|
69 |
many) classes declared in the current theory are the minimal
|
|
70 |
elements wrt.\ the sort order.
|
20451
|
71 |
|
20491
|
72 |
\medskip A \emph{fixed type variable} is a pair of a basic name
|
20537
|
73 |
(starting with a \isa{{\isacharprime}} character) and a sort constraint, e.g.\
|
|
74 |
\isa{{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ s{\isacharparenright}} which is usually printed as \isa{{\isasymalpha}\isactrlisub s}.
|
|
75 |
A \emph{schematic type variable} is a pair of an indexname and a
|
|
76 |
sort constraint, e.g.\ \isa{{\isacharparenleft}{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ {\isadigit{0}}{\isacharparenright}{\isacharcomma}\ s{\isacharparenright}} which is usually
|
|
77 |
printed as \isa{{\isacharquery}{\isasymalpha}\isactrlisub s}.
|
20481
|
78 |
|
|
79 |
Note that \emph{all} syntactic components contribute to the identity
|
20493
|
80 |
of type variables, including the sort constraint. The core logic
|
|
81 |
handles type variables with the same name but different sorts as
|
|
82 |
different, although some outer layers of the system make it hard to
|
|
83 |
produce anything like this.
|
18537
|
84 |
|
20493
|
85 |
A \emph{type constructor} \isa{{\isasymkappa}} is a \isa{k}-ary operator
|
|
86 |
on types declared in the theory. Type constructor application is
|
20537
|
87 |
written postfix as \isa{{\isacharparenleft}{\isasymalpha}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlisub k{\isacharparenright}{\isasymkappa}}. For
|
|
88 |
\isa{k\ {\isacharequal}\ {\isadigit{0}}} the argument tuple is omitted, e.g.\ \isa{prop}
|
|
89 |
instead of \isa{{\isacharparenleft}{\isacharparenright}prop}. For \isa{k\ {\isacharequal}\ {\isadigit{1}}} the parentheses
|
|
90 |
are omitted, e.g.\ \isa{{\isasymalpha}\ list} instead of \isa{{\isacharparenleft}{\isasymalpha}{\isacharparenright}list}.
|
|
91 |
Further notation is provided for specific constructors, notably the
|
|
92 |
right-associative infix \isa{{\isasymalpha}\ {\isasymRightarrow}\ {\isasymbeta}} instead of \isa{{\isacharparenleft}{\isasymalpha}{\isacharcomma}\ {\isasymbeta}{\isacharparenright}fun}.
|
20481
|
93 |
|
20537
|
94 |
A \emph{type} is defined inductively over type variables and type
|
|
95 |
constructors as follows: \isa{{\isasymtau}\ {\isacharequal}\ {\isasymalpha}\isactrlisub s\ {\isacharbar}\ {\isacharquery}{\isasymalpha}\isactrlisub s\ {\isacharbar}\ {\isacharparenleft}{\isasymtau}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlsub k{\isacharparenright}k}.
|
20451
|
96 |
|
20514
|
97 |
A \emph{type abbreviation} is a syntactic definition \isa{{\isacharparenleft}\isactrlvec {\isasymalpha}{\isacharparenright}{\isasymkappa}\ {\isacharequal}\ {\isasymtau}} of an arbitrary type expression \isa{{\isasymtau}} over
|
20537
|
98 |
variables \isa{\isactrlvec {\isasymalpha}}. Type abbreviations appear as type
|
|
99 |
constructors in the syntax, but are expanded before entering the
|
|
100 |
logical core.
|
20451
|
101 |
|
20481
|
102 |
A \emph{type arity} declares the image behavior of a type
|
20494
|
103 |
constructor wrt.\ the algebra of sorts: \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ s\isactrlisub k{\isacharparenright}s} means that \isa{{\isacharparenleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub k{\isacharparenright}{\isasymkappa}} is
|
|
104 |
of sort \isa{s} if every argument type \isa{{\isasymtau}\isactrlisub i} is
|
|
105 |
of sort \isa{s\isactrlisub i}. Arity declarations are implicitly
|
|
106 |
completed, i.e.\ \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}c} entails \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}c{\isacharprime}} for any \isa{c{\isacharprime}\ {\isasymsupseteq}\ c}.
|
20451
|
107 |
|
20491
|
108 |
\medskip The sort algebra is always maintained as \emph{coregular},
|
|
109 |
which means that type arities are consistent with the subclass
|
20537
|
110 |
relation: for any type constructor \isa{{\isasymkappa}}, and classes \isa{c\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlisub {\isadigit{2}}}, and arities \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s\isactrlisub {\isadigit{1}}{\isacharparenright}c\isactrlisub {\isadigit{1}}} and \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s\isactrlisub {\isadigit{2}}{\isacharparenright}c\isactrlisub {\isadigit{2}}} holds \isa{\isactrlvec s\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ \isactrlvec s\isactrlisub {\isadigit{2}}} component-wise.
|
20491
|
111 |
|
|
112 |
The key property of a coregular order-sorted algebra is that sort
|
20537
|
113 |
constraints can be solved in a most general fashion: for each type
|
|
114 |
constructor \isa{{\isasymkappa}} and sort \isa{s} there is a most general
|
|
115 |
vector of argument sorts \isa{{\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ s\isactrlisub k{\isacharparenright}} such
|
|
116 |
that a type scheme \isa{{\isacharparenleft}{\isasymalpha}\isactrlbsub s\isactrlisub {\isadigit{1}}\isactrlesub {\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlbsub s\isactrlisub k\isactrlesub {\isacharparenright}{\isasymkappa}} is of sort \isa{s}.
|
|
117 |
Consequently, unification on the algebra of types has most general
|
|
118 |
solutions (modulo equivalence of sorts). This means that
|
|
119 |
type-inference will produce primary types as expected
|
|
120 |
\cite{nipkow-prehofer}.%
|
18537
|
121 |
\end{isamarkuptext}%
|
|
122 |
\isamarkuptrue%
|
|
123 |
%
|
20481
|
124 |
\isadelimmlref
|
|
125 |
%
|
|
126 |
\endisadelimmlref
|
|
127 |
%
|
|
128 |
\isatagmlref
|
|
129 |
%
|
|
130 |
\begin{isamarkuptext}%
|
|
131 |
\begin{mldecls}
|
|
132 |
\indexmltype{class}\verb|type class| \\
|
|
133 |
\indexmltype{sort}\verb|type sort| \\
|
20494
|
134 |
\indexmltype{arity}\verb|type arity| \\
|
20481
|
135 |
\indexmltype{typ}\verb|type typ| \\
|
20519
|
136 |
\indexml{map-atyps}\verb|map_atyps: (typ -> typ) -> typ -> typ| \\
|
20494
|
137 |
\indexml{fold-atyps}\verb|fold_atyps: (typ -> 'a -> 'a) -> typ -> 'a -> 'a| \\
|
20481
|
138 |
\indexml{Sign.subsort}\verb|Sign.subsort: theory -> sort * sort -> bool| \\
|
|
139 |
\indexml{Sign.of-sort}\verb|Sign.of_sort: theory -> typ * sort -> bool| \\
|
20520
|
140 |
\indexml{Sign.add-types}\verb|Sign.add_types: (string * int * mixfix) list -> theory -> theory| \\
|
20481
|
141 |
\indexml{Sign.add-tyabbrs-i}\verb|Sign.add_tyabbrs_i: |\isasep\isanewline%
|
20520
|
142 |
\verb| (string * string list * typ * mixfix) list -> theory -> theory| \\
|
20481
|
143 |
\indexml{Sign.primitive-class}\verb|Sign.primitive_class: string * class list -> theory -> theory| \\
|
|
144 |
\indexml{Sign.primitive-classrel}\verb|Sign.primitive_classrel: class * class -> theory -> theory| \\
|
|
145 |
\indexml{Sign.primitive-arity}\verb|Sign.primitive_arity: arity -> theory -> theory| \\
|
|
146 |
\end{mldecls}
|
|
147 |
|
|
148 |
\begin{description}
|
|
149 |
|
|
150 |
\item \verb|class| represents type classes; this is an alias for
|
|
151 |
\verb|string|.
|
|
152 |
|
|
153 |
\item \verb|sort| represents sorts; this is an alias for
|
|
154 |
\verb|class list|.
|
|
155 |
|
|
156 |
\item \verb|arity| represents type arities; this is an alias for
|
20494
|
157 |
triples of the form \isa{{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec s{\isacharcomma}\ s{\isacharparenright}} for \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}s} described above.
|
20481
|
158 |
|
|
159 |
\item \verb|typ| represents types; this is a datatype with
|
|
160 |
constructors \verb|TFree|, \verb|TVar|, \verb|Type|.
|
|
161 |
|
20537
|
162 |
\item \verb|map_atyps|~\isa{f\ {\isasymtau}} applies the mapping \isa{f}
|
|
163 |
to all atomic types (\verb|TFree|, \verb|TVar|) occurring in \isa{{\isasymtau}}.
|
20519
|
164 |
|
20537
|
165 |
\item \verb|fold_atyps|~\isa{f\ {\isasymtau}} iterates the operation \isa{f} over all occurrences of atomic types (\verb|TFree|, \verb|TVar|)
|
|
166 |
in \isa{{\isasymtau}}; the type structure is traversed from left to right.
|
20494
|
167 |
|
20481
|
168 |
\item \verb|Sign.subsort|~\isa{thy\ {\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ s\isactrlisub {\isadigit{2}}{\isacharparenright}}
|
|
169 |
tests the subsort relation \isa{s\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ s\isactrlisub {\isadigit{2}}}.
|
|
170 |
|
20537
|
171 |
\item \verb|Sign.of_sort|~\isa{thy\ {\isacharparenleft}{\isasymtau}{\isacharcomma}\ s{\isacharparenright}} tests whether type
|
|
172 |
\isa{{\isasymtau}} is of sort \isa{s}.
|
20481
|
173 |
|
20537
|
174 |
\item \verb|Sign.add_types|~\isa{{\isacharbrackleft}{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ k{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}} declares a new
|
20494
|
175 |
type constructors \isa{{\isasymkappa}} with \isa{k} arguments and
|
20481
|
176 |
optional mixfix syntax.
|
|
177 |
|
20494
|
178 |
\item \verb|Sign.add_tyabbrs_i|~\isa{{\isacharbrackleft}{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec {\isasymalpha}{\isacharcomma}\ {\isasymtau}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}}
|
|
179 |
defines a new type abbreviation \isa{{\isacharparenleft}\isactrlvec {\isasymalpha}{\isacharparenright}{\isasymkappa}\ {\isacharequal}\ {\isasymtau}} with
|
20491
|
180 |
optional mixfix syntax.
|
20481
|
181 |
|
20537
|
182 |
\item \verb|Sign.primitive_class|~\isa{{\isacharparenleft}c{\isacharcomma}\ {\isacharbrackleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlisub n{\isacharbrackright}{\isacharparenright}} declares a new class \isa{c}, together with class
|
20494
|
183 |
relations \isa{c\ {\isasymsubseteq}\ c\isactrlisub i}, for \isa{i\ {\isacharequal}\ {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ n}.
|
20481
|
184 |
|
|
185 |
\item \verb|Sign.primitive_classrel|~\isa{{\isacharparenleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ c\isactrlisub {\isadigit{2}}{\isacharparenright}} declares class relation \isa{c\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlisub {\isadigit{2}}}.
|
|
186 |
|
20494
|
187 |
\item \verb|Sign.primitive_arity|~\isa{{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec s{\isacharcomma}\ s{\isacharparenright}} declares
|
20537
|
188 |
the arity \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}s}.
|
20481
|
189 |
|
|
190 |
\end{description}%
|
|
191 |
\end{isamarkuptext}%
|
|
192 |
\isamarkuptrue%
|
|
193 |
%
|
|
194 |
\endisatagmlref
|
|
195 |
{\isafoldmlref}%
|
|
196 |
%
|
|
197 |
\isadelimmlref
|
|
198 |
%
|
|
199 |
\endisadelimmlref
|
|
200 |
%
|
20451
|
201 |
\isamarkupsection{Terms \label{sec:terms}%
|
18537
|
202 |
}
|
|
203 |
\isamarkuptrue%
|
|
204 |
%
|
|
205 |
\begin{isamarkuptext}%
|
20451
|
206 |
\glossary{Term}{FIXME}
|
18537
|
207 |
|
20491
|
208 |
The language of terms is that of simply-typed \isa{{\isasymlambda}}-calculus
|
20520
|
209 |
with de-Bruijn indices for bound variables (cf.\ \cite{debruijn72}
|
20537
|
210 |
or \cite{paulson-ml2}), with the types being determined determined
|
|
211 |
by the corresponding binders. In contrast, free variables and
|
|
212 |
constants are have an explicit name and type in each occurrence.
|
20514
|
213 |
|
|
214 |
\medskip A \emph{bound variable} is a natural number \isa{b},
|
20537
|
215 |
which accounts for the number of intermediate binders between the
|
|
216 |
variable occurrence in the body and its binding position. For
|
20514
|
217 |
example, the de-Bruijn term \isa{{\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ {\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ {\isadigit{1}}\ {\isacharplus}\ {\isadigit{0}}}
|
20537
|
218 |
would correspond to \isa{{\isasymlambda}x\isactrlisub {\isasymtau}{\isachardot}\ {\isasymlambda}y\isactrlisub {\isasymtau}{\isachardot}\ x\ {\isacharplus}\ y} in a
|
|
219 |
named representation. Note that a bound variable may be represented
|
|
220 |
by different de-Bruijn indices at different occurrences, depending
|
|
221 |
on the nesting of abstractions.
|
|
222 |
|
|
223 |
A \emph{loose variables} is a bound variable that is outside the
|
|
224 |
scope of local binders. The types (and names) for loose variables
|
|
225 |
can be managed as a separate context, that is maintained inside-out
|
|
226 |
like a stack of hypothetical binders. The core logic only operates
|
|
227 |
on closed terms, without any loose variables.
|
20514
|
228 |
|
20537
|
229 |
A \emph{fixed variable} is a pair of a basic name and a type, e.g.\
|
|
230 |
\isa{{\isacharparenleft}x{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed \isa{x\isactrlisub {\isasymtau}}. A
|
|
231 |
\emph{schematic variable} is a pair of an indexname and a type,
|
|
232 |
e.g.\ \isa{{\isacharparenleft}{\isacharparenleft}x{\isacharcomma}\ {\isadigit{0}}{\isacharparenright}{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed as \isa{{\isacharquery}x\isactrlisub {\isasymtau}}.
|
20491
|
233 |
|
20537
|
234 |
\medskip A \emph{constant} is a pair of a basic name and a type,
|
|
235 |
e.g.\ \isa{{\isacharparenleft}c{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed as \isa{c\isactrlisub {\isasymtau}}. Constants are declared in the context as polymorphic
|
|
236 |
families \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}, meaning that valid all substitution
|
|
237 |
instances \isa{c\isactrlisub {\isasymtau}} for \isa{{\isasymtau}\ {\isacharequal}\ {\isasymsigma}{\isasymvartheta}} are valid.
|
20514
|
238 |
|
20537
|
239 |
The vector of \emph{type arguments} of constant \isa{c\isactrlisub {\isasymtau}}
|
|
240 |
wrt.\ the declaration \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} is defined as the codomain of
|
|
241 |
the matcher \isa{{\isasymvartheta}\ {\isacharequal}\ {\isacharbraceleft}{\isacharquery}{\isasymalpha}\isactrlisub {\isadigit{1}}\ {\isasymmapsto}\ {\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isacharquery}{\isasymalpha}\isactrlisub n\ {\isasymmapsto}\ {\isasymtau}\isactrlisub n{\isacharbraceright}} presented in canonical order \isa{{\isacharparenleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharparenright}}. Within a given theory context,
|
|
242 |
there is a one-to-one correspondence between any constant \isa{c\isactrlisub {\isasymtau}} and the application \isa{c{\isacharparenleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharparenright}} of its type arguments. For example, with \isa{plus\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}}, the instance \isa{plus\isactrlbsub nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ nat\isactrlesub } corresponds to \isa{plus{\isacharparenleft}nat{\isacharparenright}}.
|
20481
|
243 |
|
20514
|
244 |
Constant declarations \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} may contain sort constraints
|
|
245 |
for type variables in \isa{{\isasymsigma}}. These are observed by
|
|
246 |
type-inference as expected, but \emph{ignored} by the core logic.
|
|
247 |
This means the primitive logic is able to reason with instances of
|
20537
|
248 |
polymorphic constants that the user-level type-checker would reject
|
|
249 |
due to violation of type class restrictions.
|
20481
|
250 |
|
20537
|
251 |
\medskip A \emph{term} is defined inductively over variables and
|
|
252 |
constants, with abstraction and application as follows: \isa{t\ {\isacharequal}\ b\ {\isacharbar}\ x\isactrlisub {\isasymtau}\ {\isacharbar}\ {\isacharquery}x\isactrlisub {\isasymtau}\ {\isacharbar}\ c\isactrlisub {\isasymtau}\ {\isacharbar}\ {\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ t\ {\isacharbar}\ t\isactrlisub {\isadigit{1}}\ t\isactrlisub {\isadigit{2}}}. Parsing and printing takes care of
|
|
253 |
converting between an external representation with named bound
|
|
254 |
variables. Subsequently, we shall use the latter notation instead
|
|
255 |
of internal de-Bruijn representation.
|
20499
|
256 |
|
20537
|
257 |
The inductive relation \isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}} assigns a (unique) type to a
|
|
258 |
term according to the structure of atomic terms, abstractions, and
|
|
259 |
applicatins:
|
20499
|
260 |
\[
|
20502
|
261 |
\infer{\isa{a\isactrlisub {\isasymtau}\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}}}{}
|
20499
|
262 |
\qquad
|
20502
|
263 |
\infer{\isa{{\isacharparenleft}{\isasymlambda}x\isactrlsub {\isasymtau}{\isachardot}\ t{\isacharparenright}\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymsigma}}}{\isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}}
|
|
264 |
\qquad
|
|
265 |
\infer{\isa{t\ u\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}}{\isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymsigma}} & \isa{u\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}}}
|
20514
|
266 |
\]
|
|
267 |
A \emph{well-typed term} is a term that can be typed according to these rules.
|
|
268 |
|
|
269 |
Typing information can be omitted: type-inference is able to
|
|
270 |
reconstruct the most general type of a raw term, while assigning
|
|
271 |
most general types to all of its variables and constants.
|
|
272 |
Type-inference depends on a context of type constraints for fixed
|
|
273 |
variables, and declarations for polymorphic constants.
|
|
274 |
|
20537
|
275 |
The identity of atomic terms consists both of the name and the type
|
|
276 |
component. This means that different variables \isa{x\isactrlbsub {\isasymtau}\isactrlisub {\isadigit{1}}\isactrlesub } and \isa{x\isactrlbsub {\isasymtau}\isactrlisub {\isadigit{2}}\isactrlesub } may become the same after type
|
|
277 |
instantiation. Some outer layers of the system make it hard to
|
|
278 |
produce variables of the same name, but different types. In
|
|
279 |
particular, type-inference always demands ``consistent'' type
|
|
280 |
constraints for free variables. In contrast, mixed instances of
|
|
281 |
polymorphic constants occur frequently.
|
20514
|
282 |
|
|
283 |
\medskip The \emph{hidden polymorphism} of a term \isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}
|
|
284 |
is the set of type variables occurring in \isa{t}, but not in
|
20537
|
285 |
\isa{{\isasymsigma}}. This means that the term implicitly depends on type
|
|
286 |
arguments that are not accounted in result type, i.e.\ there are
|
|
287 |
different type instances \isa{t{\isasymvartheta}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} and \isa{t{\isasymvartheta}{\isacharprime}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} with the same type. This slightly
|
|
288 |
pathological situation demands special care.
|
20514
|
289 |
|
20537
|
290 |
\medskip A \emph{term abbreviation} is a syntactic definition \isa{c\isactrlisub {\isasymsigma}\ {\isasymequiv}\ t} of a closed term \isa{t} of type \isa{{\isasymsigma}},
|
|
291 |
without any hidden polymorphism. A term abbreviation looks like a
|
|
292 |
constant in the syntax, but is fully expanded before entering the
|
|
293 |
logical core. Abbreviations are usually reverted when printing
|
|
294 |
terms, using the collective \isa{t\ {\isasymrightarrow}\ c\isactrlisub {\isasymsigma}} as rules for
|
|
295 |
higher-order rewriting.
|
20519
|
296 |
|
20537
|
297 |
\medskip Canonical operations on \isa{{\isasymlambda}}-terms include \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-conversion: \isa{{\isasymalpha}}-conversion refers to capture-free
|
20519
|
298 |
renaming of bound variables; \isa{{\isasymbeta}}-conversion contracts an
|
20537
|
299 |
abstraction applied to an argument term, substituting the argument
|
20519
|
300 |
in the body: \isa{{\isacharparenleft}{\isasymlambda}x{\isachardot}\ b{\isacharparenright}a} becomes \isa{b{\isacharbrackleft}a{\isacharslash}x{\isacharbrackright}}; \isa{{\isasymeta}}-conversion contracts vacuous application-abstraction: \isa{{\isasymlambda}x{\isachardot}\ f\ x} becomes \isa{f}, provided that the bound variable
|
20537
|
301 |
does not occur in \isa{f}.
|
20519
|
302 |
|
20537
|
303 |
Terms are normally treated modulo \isa{{\isasymalpha}}-conversion, which is
|
|
304 |
implicit in the de-Bruijn representation. Names for bound variables
|
|
305 |
in abstractions are maintained separately as (meaningless) comments,
|
|
306 |
mostly for parsing and printing. Full \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-conversion is
|
|
307 |
commonplace in various higher operations (\secref{sec:rules}) that
|
|
308 |
are based on higher-order unification and matching.%
|
18537
|
309 |
\end{isamarkuptext}%
|
|
310 |
\isamarkuptrue%
|
|
311 |
%
|
20514
|
312 |
\isadelimmlref
|
|
313 |
%
|
|
314 |
\endisadelimmlref
|
|
315 |
%
|
|
316 |
\isatagmlref
|
|
317 |
%
|
18537
|
318 |
\begin{isamarkuptext}%
|
20514
|
319 |
\begin{mldecls}
|
|
320 |
\indexmltype{term}\verb|type term| \\
|
20519
|
321 |
\indexml{op aconv}\verb|op aconv: term * term -> bool| \\
|
|
322 |
\indexml{map-term-types}\verb|map_term_types: (typ -> typ) -> term -> term| \\ %FIXME rename map_types
|
|
323 |
\indexml{fold-types}\verb|fold_types: (typ -> 'a -> 'a) -> term -> 'a -> 'a| \\
|
20514
|
324 |
\indexml{map-aterms}\verb|map_aterms: (term -> term) -> term -> term| \\
|
|
325 |
\indexml{fold-aterms}\verb|fold_aterms: (term -> 'a -> 'a) -> term -> 'a -> 'a| \\
|
|
326 |
\indexml{fastype-of}\verb|fastype_of: term -> typ| \\
|
20519
|
327 |
\indexml{lambda}\verb|lambda: term -> term -> term| \\
|
|
328 |
\indexml{betapply}\verb|betapply: term * term -> term| \\
|
20520
|
329 |
\indexml{Sign.add-consts-i}\verb|Sign.add_consts_i: (string * typ * mixfix) list -> theory -> theory| \\
|
20519
|
330 |
\indexml{Sign.add-abbrevs}\verb|Sign.add_abbrevs: string * bool ->|\isasep\isanewline%
|
20520
|
331 |
\verb| ((string * mixfix) * term) list -> theory -> theory| \\
|
20519
|
332 |
\indexml{Sign.const-typargs}\verb|Sign.const_typargs: theory -> string * typ -> typ list| \\
|
|
333 |
\indexml{Sign.const-instance}\verb|Sign.const_instance: theory -> string * typ list -> typ| \\
|
20514
|
334 |
\end{mldecls}
|
18537
|
335 |
|
20514
|
336 |
\begin{description}
|
18537
|
337 |
|
20537
|
338 |
\item \verb|term| represents de-Bruijn terms, with comments in
|
|
339 |
abstractions, and explicitly named free variables and constants;
|
|
340 |
this is a datatype with constructors \verb|Bound|, \verb|Free|, \verb|Var|, \verb|Const|, \verb|Abs|, \verb|op $|.
|
20519
|
341 |
|
|
342 |
\item \isa{t}~\verb|aconv|~\isa{u} checks \isa{{\isasymalpha}}-equivalence of two terms. This is the basic equality relation
|
|
343 |
on type \verb|term|; raw datatype equality should only be used
|
|
344 |
for operations related to parsing or printing!
|
|
345 |
|
20537
|
346 |
\item \verb|map_term_types|~\isa{f\ t} applies the mapping \isa{f} to all types occurring in \isa{t}.
|
|
347 |
|
|
348 |
\item \verb|fold_types|~\isa{f\ t} iterates the operation \isa{f} over all occurrences of types in \isa{t}; the term
|
|
349 |
structure is traversed from left to right.
|
20519
|
350 |
|
20537
|
351 |
\item \verb|map_aterms|~\isa{f\ t} applies the mapping \isa{f}
|
|
352 |
to all atomic terms (\verb|Bound|, \verb|Free|, \verb|Var|, \verb|Const|) occurring in \isa{t}.
|
|
353 |
|
|
354 |
\item \verb|fold_aterms|~\isa{f\ t} iterates the operation \isa{f} over all occurrences of atomic terms (\verb|Bound|, \verb|Free|,
|
|
355 |
\verb|Var|, \verb|Const|) in \isa{t}; the term structure is
|
20519
|
356 |
traversed from left to right.
|
|
357 |
|
20537
|
358 |
\item \verb|fastype_of|~\isa{t} determines the type of a
|
|
359 |
well-typed term. This operation is relatively slow, despite the
|
|
360 |
omission of any sanity checks.
|
20519
|
361 |
|
20537
|
362 |
\item \verb|lambda|~\isa{a\ b} produces an abstraction \isa{{\isasymlambda}a{\isachardot}\ b}, where occurrences of the atomic term \isa{a} in the
|
|
363 |
body \isa{b} are replaced by bound variables.
|
20519
|
364 |
|
20537
|
365 |
\item \verb|betapply|~\isa{{\isacharparenleft}t{\isacharcomma}\ u{\isacharparenright}} produces an application \isa{t\ u}, with topmost \isa{{\isasymbeta}}-conversion if \isa{t} is an
|
|
366 |
abstraction.
|
20519
|
367 |
|
|
368 |
\item \verb|Sign.add_consts_i|~\isa{{\isacharbrackleft}{\isacharparenleft}c{\isacharcomma}\ {\isasymsigma}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}} declares a
|
|
369 |
new constant \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} with optional mixfix syntax.
|
|
370 |
|
|
371 |
\item \verb|Sign.add_abbrevs|~\isa{print{\isacharunderscore}mode\ {\isacharbrackleft}{\isacharparenleft}{\isacharparenleft}c{\isacharcomma}\ t{\isacharparenright}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}}
|
|
372 |
declares a new term abbreviation \isa{c\ {\isasymequiv}\ t} with optional
|
|
373 |
mixfix syntax.
|
|
374 |
|
20520
|
375 |
\item \verb|Sign.const_typargs|~\isa{thy\ {\isacharparenleft}c{\isacharcomma}\ {\isasymtau}{\isacharparenright}} and \verb|Sign.const_instance|~\isa{thy\ {\isacharparenleft}c{\isacharcomma}\ {\isacharbrackleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharbrackright}{\isacharparenright}}
|
20537
|
376 |
convert between the representations of polymorphic constants: the
|
|
377 |
full type instance vs.\ the compact type arguments form (depending
|
|
378 |
on the most general declaration given in the context).
|
20514
|
379 |
|
|
380 |
\end{description}%
|
18537
|
381 |
\end{isamarkuptext}%
|
|
382 |
\isamarkuptrue%
|
|
383 |
%
|
20514
|
384 |
\endisatagmlref
|
|
385 |
{\isafoldmlref}%
|
|
386 |
%
|
|
387 |
\isadelimmlref
|
|
388 |
%
|
|
389 |
\endisadelimmlref
|
|
390 |
%
|
20451
|
391 |
\isamarkupsection{Theorems \label{sec:thms}%
|
18537
|
392 |
}
|
|
393 |
\isamarkuptrue%
|
|
394 |
%
|
|
395 |
\begin{isamarkuptext}%
|
20521
|
396 |
\glossary{Proposition}{FIXME A \seeglossary{term} of
|
|
397 |
\seeglossary{type} \isa{prop}. Internally, there is nothing
|
|
398 |
special about propositions apart from their type, but the concrete
|
|
399 |
syntax enforces a clear distinction. Propositions are structured
|
|
400 |
via implication \isa{A\ {\isasymLongrightarrow}\ B} or universal quantification \isa{{\isasymAnd}x{\isachardot}\ B\ x} --- anything else is considered atomic. The canonical
|
|
401 |
form for propositions is that of a \seeglossary{Hereditary Harrop
|
|
402 |
Formula}. FIXME}
|
20481
|
403 |
|
20502
|
404 |
\glossary{Theorem}{A proven proposition within a certain theory and
|
|
405 |
proof context, formally \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}}; both contexts are
|
|
406 |
rarely spelled out explicitly. Theorems are usually normalized
|
|
407 |
according to the \seeglossary{HHF} format. FIXME}
|
18537
|
408 |
|
20519
|
409 |
\glossary{Fact}{Sometimes used interchangeably for
|
20502
|
410 |
\seeglossary{theorem}. Strictly speaking, a list of theorems,
|
|
411 |
essentially an extra-logical conjunction. Facts emerge either as
|
|
412 |
local assumptions, or as results of local goal statements --- both
|
|
413 |
may be simultaneous, hence the list representation. FIXME}
|
|
414 |
|
|
415 |
\glossary{Schematic variable}{FIXME}
|
|
416 |
|
|
417 |
\glossary{Fixed variable}{A variable that is bound within a certain
|
|
418 |
proof context; an arbitrary-but-fixed entity within a portion of
|
|
419 |
proof text. FIXME}
|
18537
|
420 |
|
20502
|
421 |
\glossary{Free variable}{Synonymous for \seeglossary{fixed
|
|
422 |
variable}. FIXME}
|
|
423 |
|
|
424 |
\glossary{Bound variable}{FIXME}
|
18537
|
425 |
|
20502
|
426 |
\glossary{Variable}{See \seeglossary{schematic variable},
|
|
427 |
\seeglossary{fixed variable}, \seeglossary{bound variable}, or
|
|
428 |
\seeglossary{type variable}. The distinguishing feature of
|
|
429 |
different variables is their binding scope. FIXME}
|
18537
|
430 |
|
20521
|
431 |
A \emph{proposition} is a well-formed term of type \isa{prop}, a
|
|
432 |
\emph{theorem} is a proven proposition (depending on a context of
|
|
433 |
hypotheses and the background theory). Primitive inferences include
|
20537
|
434 |
plain natural deduction rules for the primary connectives \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}} of the framework. There is also a builtin
|
|
435 |
notion of equality/equivalence \isa{{\isasymequiv}}.%
|
20521
|
436 |
\end{isamarkuptext}%
|
|
437 |
\isamarkuptrue%
|
|
438 |
%
|
20537
|
439 |
\isamarkupsubsection{Primitive connectives and rules%
|
20521
|
440 |
}
|
|
441 |
\isamarkuptrue%
|
|
442 |
%
|
|
443 |
\begin{isamarkuptext}%
|
20537
|
444 |
The theory \isa{Pure} contains declarations for the standard
|
|
445 |
connectives \isa{{\isasymAnd}}, \isa{{\isasymLongrightarrow}}, and \isa{{\isasymequiv}} of the logical
|
|
446 |
framework, see \figref{fig:pure-connectives}. The derivability
|
|
447 |
judgment \isa{A\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ A\isactrlisub n\ {\isasymturnstile}\ B} is defined
|
|
448 |
inductively by the primitive inferences given in
|
|
449 |
\figref{fig:prim-rules}, with the global restriction that hypotheses
|
|
450 |
\isa{{\isasymGamma}} may \emph{not} contain schematic variables. The builtin
|
|
451 |
equality is conceptually axiomatized as shown in
|
20521
|
452 |
\figref{fig:pure-equality}, although the implementation works
|
20537
|
453 |
directly with derived inference rules.
|
18537
|
454 |
|
20521
|
455 |
\begin{figure}[htb]
|
|
456 |
\begin{center}
|
20502
|
457 |
\begin{tabular}{ll}
|
|
458 |
\isa{all\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}{\isasymalpha}\ {\isasymRightarrow}\ prop{\isacharparenright}\ {\isasymRightarrow}\ prop} & universal quantification (binder \isa{{\isasymAnd}}) \\
|
|
459 |
\isa{{\isasymLongrightarrow}\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop\ {\isasymRightarrow}\ prop} & implication (right associative infix) \\
|
20521
|
460 |
\isa{{\isasymequiv}\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}\ {\isasymRightarrow}\ prop} & equality relation (infix) \\
|
20502
|
461 |
\end{tabular}
|
20537
|
462 |
\caption{Primitive connectives of Pure}\label{fig:pure-connectives}
|
20521
|
463 |
\end{center}
|
|
464 |
\end{figure}
|
18537
|
465 |
|
20502
|
466 |
\begin{figure}[htb]
|
|
467 |
\begin{center}
|
20499
|
468 |
\[
|
|
469 |
\infer[\isa{{\isacharparenleft}axiom{\isacharparenright}}]{\isa{{\isasymturnstile}\ A}}{\isa{A\ {\isasymin}\ {\isasymTheta}}}
|
|
470 |
\qquad
|
|
471 |
\infer[\isa{{\isacharparenleft}assume{\isacharparenright}}]{\isa{A\ {\isasymturnstile}\ A}}{}
|
|
472 |
\]
|
|
473 |
\[
|
20537
|
474 |
\infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}intro{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ b{\isacharbrackleft}x{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ b{\isacharbrackleft}x{\isacharbrackright}} & \isa{x\ {\isasymnotin}\ {\isasymGamma}}}
|
20499
|
475 |
\qquad
|
20537
|
476 |
\infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}elim{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ b{\isacharbrackleft}a{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ b{\isacharbrackleft}x{\isacharbrackright}}}
|
20499
|
477 |
\]
|
|
478 |
\[
|
|
479 |
\infer[\isa{{\isacharparenleft}{\isasymLongrightarrow}{\isacharunderscore}intro{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isacharminus}\ A\ {\isasymturnstile}\ A\ {\isasymLongrightarrow}\ B}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B}}
|
|
480 |
\qquad
|
|
481 |
\infer[\isa{{\isacharparenleft}{\isasymLongrightarrow}{\isacharunderscore}elim{\isacharparenright}}]{\isa{{\isasymGamma}\isactrlsub {\isadigit{1}}\ {\isasymunion}\ {\isasymGamma}\isactrlsub {\isadigit{2}}\ {\isasymturnstile}\ B}}{\isa{{\isasymGamma}\isactrlsub {\isadigit{1}}\ {\isasymturnstile}\ A\ {\isasymLongrightarrow}\ B} & \isa{{\isasymGamma}\isactrlsub {\isadigit{2}}\ {\isasymturnstile}\ A}}
|
|
482 |
\]
|
20521
|
483 |
\caption{Primitive inferences of Pure}\label{fig:prim-rules}
|
|
484 |
\end{center}
|
|
485 |
\end{figure}
|
|
486 |
|
|
487 |
\begin{figure}[htb]
|
|
488 |
\begin{center}
|
|
489 |
\begin{tabular}{ll}
|
20537
|
490 |
\isa{{\isasymturnstile}\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ b{\isacharbrackleft}x{\isacharbrackright}{\isacharparenright}\ a\ {\isasymequiv}\ b{\isacharbrackleft}a{\isacharbrackright}} & \isa{{\isasymbeta}}-conversion \\
|
20521
|
491 |
\isa{{\isasymturnstile}\ x\ {\isasymequiv}\ x} & reflexivity \\
|
|
492 |
\isa{{\isasymturnstile}\ x\ {\isasymequiv}\ y\ {\isasymLongrightarrow}\ P\ x\ {\isasymLongrightarrow}\ P\ y} & substitution \\
|
|
493 |
\isa{{\isasymturnstile}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ f\ x\ {\isasymequiv}\ g\ x{\isacharparenright}\ {\isasymLongrightarrow}\ f\ {\isasymequiv}\ g} & extensionality \\
|
20537
|
494 |
\isa{{\isasymturnstile}\ {\isacharparenleft}A\ {\isasymLongrightarrow}\ B{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}B\ {\isasymLongrightarrow}\ A{\isacharparenright}\ {\isasymLongrightarrow}\ A\ {\isasymequiv}\ B} & logical equivalence \\
|
20521
|
495 |
\end{tabular}
|
20537
|
496 |
\caption{Conceptual axiomatization of \isa{{\isasymequiv}}}\label{fig:pure-equality}
|
20502
|
497 |
\end{center}
|
|
498 |
\end{figure}
|
20499
|
499 |
|
20537
|
500 |
The introduction and elimination rules for \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}} are analogous to formation of dependently typed \isa{{\isasymlambda}}-terms representing the underlying proof objects. Proof terms
|
|
501 |
are irrelevant in the Pure logic, though, they may never occur
|
|
502 |
within propositions. The system provides a runtime option to record
|
|
503 |
explicit proof terms for primitive inferences. Thus all three
|
|
504 |
levels of \isa{{\isasymlambda}}-calculus become explicit: \isa{{\isasymRightarrow}} for
|
|
505 |
terms, and \isa{{\isasymAnd}{\isacharslash}{\isasymLongrightarrow}} for proofs (cf.\
|
|
506 |
\cite{Berghofer-Nipkow:2000:TPHOL}).
|
20499
|
507 |
|
20537
|
508 |
Observe that locally fixed parameters (as in \isa{{\isasymAnd}{\isacharunderscore}intro}) need
|
|
509 |
not be recorded in the hypotheses, because the simple syntactic
|
|
510 |
types of Pure are always inhabitable. Typing ``assumptions'' \isa{x\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}} are (implicitly) present only with occurrences of \isa{x\isactrlisub {\isasymtau}} in the statement body.\footnote{This is the key
|
|
511 |
difference ``\isa{{\isasymlambda}HOL}'' in the PTS framework
|
|
512 |
\cite{Barendregt-Geuvers:2001}, where \isa{x\ {\isacharcolon}\ A} hypotheses are
|
|
513 |
treated explicitly for types, in the same way as propositions.}
|
20502
|
514 |
|
20521
|
515 |
\medskip FIXME \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence and primitive definitions
|
|
516 |
|
|
517 |
Since the basic representation of terms already accounts for \isa{{\isasymalpha}}-conversion, Pure equality essentially acts like \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence on terms, while coinciding with bi-implication.
|
20502
|
518 |
|
|
519 |
\medskip The axiomatization of a theory is implicitly closed by
|
20537
|
520 |
forming all instances of type and term variables: \isa{{\isasymturnstile}\ A{\isasymvartheta}} holds for any substitution instance of an axiom
|
|
521 |
\isa{{\isasymturnstile}\ A}. By pushing substitution through derivations
|
|
522 |
inductively, we get admissible \isa{generalize} and \isa{instance} rules shown in \figref{fig:subst-rules}.
|
20502
|
523 |
|
|
524 |
\begin{figure}[htb]
|
|
525 |
\begin{center}
|
20499
|
526 |
\[
|
20502
|
527 |
\infer{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isacharquery}{\isasymalpha}{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isasymalpha}{\isacharbrackright}} & \isa{{\isasymalpha}\ {\isasymnotin}\ {\isasymGamma}}}
|
|
528 |
\quad
|
|
529 |
\infer[\quad\isa{{\isacharparenleft}generalize{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isacharquery}x{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}x{\isacharbrackright}} & \isa{x\ {\isasymnotin}\ {\isasymGamma}}}
|
20499
|
530 |
\]
|
|
531 |
\[
|
20502
|
532 |
\infer{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isasymtau}{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isacharquery}{\isasymalpha}{\isacharbrackright}}}
|
|
533 |
\quad
|
|
534 |
\infer[\quad\isa{{\isacharparenleft}instantiate{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}t{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isacharquery}x{\isacharbrackright}}}
|
20499
|
535 |
\]
|
20502
|
536 |
\caption{Admissible substitution rules}\label{fig:subst-rules}
|
|
537 |
\end{center}
|
|
538 |
\end{figure}
|
20499
|
539 |
|
20537
|
540 |
Note that \isa{instantiate} does not require an explicit
|
|
541 |
side-condition, because \isa{{\isasymGamma}} may never contain schematic
|
|
542 |
variables.
|
|
543 |
|
|
544 |
In principle, variables could be substituted in hypotheses as well,
|
|
545 |
but this would disrupt monotonicity reasoning: deriving \isa{{\isasymGamma}{\isasymvartheta}\ {\isasymturnstile}\ B{\isasymvartheta}} from \isa{{\isasymGamma}\ {\isasymturnstile}\ B} is correct, but
|
|
546 |
\isa{{\isasymGamma}{\isasymvartheta}\ {\isasymsupseteq}\ {\isasymGamma}} does not necessarily hold --- the result
|
|
547 |
belongs to a different proof context.%
|
20521
|
548 |
\end{isamarkuptext}%
|
|
549 |
\isamarkuptrue%
|
|
550 |
%
|
|
551 |
\isadelimmlref
|
|
552 |
%
|
|
553 |
\endisadelimmlref
|
|
554 |
%
|
|
555 |
\isatagmlref
|
|
556 |
%
|
|
557 |
\begin{isamarkuptext}%
|
|
558 |
\begin{mldecls}
|
|
559 |
\indexmltype{ctyp}\verb|type ctyp| \\
|
|
560 |
\indexmltype{cterm}\verb|type cterm| \\
|
|
561 |
\indexmltype{thm}\verb|type thm| \\
|
|
562 |
\end{mldecls}
|
|
563 |
|
|
564 |
\begin{description}
|
|
565 |
|
|
566 |
\item \verb|ctyp| FIXME
|
20499
|
567 |
|
20521
|
568 |
\item \verb|cterm| FIXME
|
|
569 |
|
|
570 |
\item \verb|thm| FIXME
|
|
571 |
|
|
572 |
\end{description}%
|
|
573 |
\end{isamarkuptext}%
|
|
574 |
\isamarkuptrue%
|
|
575 |
%
|
|
576 |
\endisatagmlref
|
|
577 |
{\isafoldmlref}%
|
|
578 |
%
|
|
579 |
\isadelimmlref
|
|
580 |
%
|
|
581 |
\endisadelimmlref
|
|
582 |
%
|
|
583 |
\isamarkupsubsection{Auxiliary connectives%
|
|
584 |
}
|
|
585 |
\isamarkuptrue%
|
|
586 |
%
|
|
587 |
\begin{isamarkuptext}%
|
20537
|
588 |
Theory \isa{Pure} also defines a few auxiliary connectives, see
|
|
589 |
\figref{fig:pure-aux}. These are normally not exposed to the user,
|
|
590 |
but appear in internal encodings only.
|
20502
|
591 |
|
|
592 |
\begin{figure}[htb]
|
|
593 |
\begin{center}
|
20499
|
594 |
\begin{tabular}{ll}
|
20521
|
595 |
\isa{conjunction\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop\ {\isasymRightarrow}\ prop} & (infix \isa{{\isacharampersand}}) \\
|
|
596 |
\isa{{\isasymturnstile}\ A\ {\isacharampersand}\ B\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}C{\isachardot}\ {\isacharparenleft}A\ {\isasymLongrightarrow}\ B\ {\isasymLongrightarrow}\ C{\isacharparenright}\ {\isasymLongrightarrow}\ C{\isacharparenright}} \\[1ex]
|
20537
|
597 |
\isa{prop\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop} & (prefix \isa{{\isacharhash}}, hidden) \\
|
20521
|
598 |
\isa{{\isacharhash}A\ {\isasymequiv}\ A} \\[1ex]
|
|
599 |
\isa{term\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ prop} & (prefix \isa{TERM}) \\
|
|
600 |
\isa{term\ x\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}A{\isachardot}\ A\ {\isasymLongrightarrow}\ A{\isacharparenright}} \\[1ex]
|
|
601 |
\isa{TYPE\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ itself} & (prefix \isa{TYPE}) \\
|
|
602 |
\isa{{\isacharparenleft}unspecified{\isacharparenright}} \\
|
20499
|
603 |
\end{tabular}
|
20521
|
604 |
\caption{Definitions of auxiliary connectives}\label{fig:pure-aux}
|
20502
|
605 |
\end{center}
|
|
606 |
\end{figure}
|
|
607 |
|
20537
|
608 |
Derived conjunction rules include introduction \isa{A\ {\isasymLongrightarrow}\ B\ {\isasymLongrightarrow}\ A\ {\isacharampersand}\ B}, and destructions \isa{A\ {\isacharampersand}\ B\ {\isasymLongrightarrow}\ A} and \isa{A\ {\isacharampersand}\ B\ {\isasymLongrightarrow}\ B}.
|
|
609 |
Conjunction allows to treat simultaneous assumptions and conclusions
|
|
610 |
uniformly. For example, multiple claims are intermediately
|
|
611 |
represented as explicit conjunction, but this is usually refined
|
|
612 |
into separate sub-goals before the user continues the proof; the
|
|
613 |
final result is projected into a list of theorems (cf.\
|
|
614 |
\secref{sec:tactical-goals}).
|
20502
|
615 |
|
20537
|
616 |
The \isa{prop} marker (\isa{{\isacharhash}}) makes arbitrarily complex
|
|
617 |
propositions appear as atomic, without changing the meaning: \isa{{\isasymGamma}\ {\isasymturnstile}\ A} and \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isacharhash}A} are interchangeable. See
|
|
618 |
\secref{sec:tactical-goals} for specific operations.
|
20502
|
619 |
|
20537
|
620 |
The \isa{term} marker turns any well-formed term into a
|
|
621 |
derivable proposition: \isa{{\isasymturnstile}\ TERM\ t} holds unconditionally.
|
|
622 |
Although this is logically vacuous, it allows to treat terms and
|
|
623 |
proofs uniformly, similar to a type-theoretic framework.
|
20502
|
624 |
|
20537
|
625 |
The \isa{TYPE} constructor is the canonical representative of
|
|
626 |
the unspecified type \isa{{\isasymalpha}\ itself}; it essentially injects the
|
|
627 |
language of types into that of terms. There is specific notation
|
|
628 |
\isa{TYPE{\isacharparenleft}{\isasymtau}{\isacharparenright}} for \isa{TYPE\isactrlbsub {\isasymtau}\ itself\isactrlesub }.
|
|
629 |
Although being devoid of any particular meaning, the \isa{TYPE{\isacharparenleft}{\isasymtau}{\isacharparenright}} accounts for the type \isa{{\isasymtau}} within the term
|
|
630 |
language. In particular, \isa{TYPE{\isacharparenleft}{\isasymalpha}{\isacharparenright}} may be used as formal
|
|
631 |
argument in primitive definitions, in order to circumvent hidden
|
|
632 |
polymorphism (cf.\ \secref{sec:terms}). For example, \isa{c\ TYPE{\isacharparenleft}{\isasymalpha}{\isacharparenright}\ {\isasymequiv}\ A{\isacharbrackleft}{\isasymalpha}{\isacharbrackright}} defines \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ itself\ {\isasymRightarrow}\ prop} in terms of
|
|
633 |
a proposition \isa{A} that depends on an additional type
|
|
634 |
argument, which is essentially a predicate on types.%
|
18537
|
635 |
\end{isamarkuptext}%
|
|
636 |
\isamarkuptrue%
|
|
637 |
%
|
20521
|
638 |
\isadelimmlref
|
|
639 |
%
|
|
640 |
\endisadelimmlref
|
|
641 |
%
|
|
642 |
\isatagmlref
|
|
643 |
%
|
|
644 |
\begin{isamarkuptext}%
|
|
645 |
\begin{mldecls}
|
|
646 |
\indexml{Conjunction.intr}\verb|Conjunction.intr: thm -> thm -> thm| \\
|
|
647 |
\indexml{Conjunction.elim}\verb|Conjunction.elim: thm -> thm * thm| \\
|
|
648 |
\indexml{Drule.mk-term}\verb|Drule.mk_term: cterm -> thm| \\
|
|
649 |
\indexml{Drule.dest-term}\verb|Drule.dest_term: thm -> cterm| \\
|
|
650 |
\indexml{Logic.mk-type}\verb|Logic.mk_type: typ -> term| \\
|
|
651 |
\indexml{Logic.dest-type}\verb|Logic.dest_type: term -> typ| \\
|
|
652 |
\end{mldecls}
|
|
653 |
|
|
654 |
\begin{description}
|
|
655 |
|
|
656 |
\item FIXME
|
|
657 |
|
|
658 |
\end{description}%
|
|
659 |
\end{isamarkuptext}%
|
|
660 |
\isamarkuptrue%
|
|
661 |
%
|
|
662 |
\endisatagmlref
|
|
663 |
{\isafoldmlref}%
|
|
664 |
%
|
|
665 |
\isadelimmlref
|
|
666 |
%
|
|
667 |
\endisadelimmlref
|
|
668 |
%
|
20491
|
669 |
\isamarkupsection{Rules \label{sec:rules}%
|
18537
|
670 |
}
|
|
671 |
\isamarkuptrue%
|
|
672 |
%
|
|
673 |
\begin{isamarkuptext}%
|
|
674 |
FIXME
|
|
675 |
|
20491
|
676 |
A \emph{rule} is any Pure theorem in HHF normal form; there is a
|
|
677 |
separate calculus for rule composition, which is modeled after
|
|
678 |
Gentzen's Natural Deduction \cite{Gentzen:1935}, but allows
|
|
679 |
rules to be nested arbitrarily, similar to \cite{extensions91}.
|
|
680 |
|
|
681 |
Normally, all theorems accessible to the user are proper rules.
|
|
682 |
Low-level inferences are occasional required internally, but the
|
|
683 |
result should be always presented in canonical form. The higher
|
|
684 |
interfaces of Isabelle/Isar will always produce proper rules. It is
|
|
685 |
important to maintain this invariant in add-on applications!
|
|
686 |
|
|
687 |
There are two main principles of rule composition: \isa{resolution} (i.e.\ backchaining of rules) and \isa{by{\isacharminus}assumption} (i.e.\ closing a branch); both principles are
|
20519
|
688 |
combined in the variants of \isa{elim{\isacharminus}resolution} and \isa{dest{\isacharminus}resolution}. Raw \isa{composition} is occasionally
|
20491
|
689 |
useful as well, also it is strictly speaking outside of the proper
|
|
690 |
rule calculus.
|
|
691 |
|
|
692 |
Rules are treated modulo general higher-order unification, which is
|
|
693 |
unification modulo the equational theory of \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-conversion
|
|
694 |
on \isa{{\isasymlambda}}-terms. Moreover, propositions are understood modulo
|
|
695 |
the (derived) equivalence \isa{{\isacharparenleft}A\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ B\ x{\isacharparenright}{\isacharparenright}\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ A\ {\isasymLongrightarrow}\ B\ x{\isacharparenright}}.
|
|
696 |
|
|
697 |
This means that any operations within the rule calculus may be
|
|
698 |
subject to spontaneous \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-HHF conversions. It is common
|
|
699 |
practice not to contract or expand unnecessarily. Some mechanisms
|
|
700 |
prefer an one form, others the opposite, so there is a potential
|
|
701 |
danger to produce some oscillation!
|
|
702 |
|
|
703 |
Only few operations really work \emph{modulo} HHF conversion, but
|
|
704 |
expect a normal form: quantifiers \isa{{\isasymAnd}} before implications
|
|
705 |
\isa{{\isasymLongrightarrow}} at each level of nesting.
|
|
706 |
|
18537
|
707 |
\glossary{Hereditary Harrop Formula}{The set of propositions in HHF
|
|
708 |
format is defined inductively as \isa{H\ {\isacharequal}\ {\isacharparenleft}{\isasymAnd}x\isactrlsup {\isacharasterisk}{\isachardot}\ H\isactrlsup {\isacharasterisk}\ {\isasymLongrightarrow}\ A{\isacharparenright}}, for variables \isa{x} and atomic propositions \isa{A}.
|
|
709 |
Any proposition may be put into HHF form by normalizing with the rule
|
|
710 |
\isa{{\isacharparenleft}A\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ B\ x{\isacharparenright}{\isacharparenright}\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ A\ {\isasymLongrightarrow}\ B\ x{\isacharparenright}}. In Isabelle, the outermost
|
|
711 |
quantifier prefix is represented via \seeglossary{schematic
|
|
712 |
variables}, such that the top-level structure is merely that of a
|
|
713 |
\seeglossary{Horn Clause}}.
|
|
714 |
|
20499
|
715 |
\glossary{HHF}{See \seeglossary{Hereditary Harrop Formula}.}
|
|
716 |
|
|
717 |
|
|
718 |
\[
|
|
719 |
\infer[\isa{{\isacharparenleft}assumption{\isacharparenright}}]{\isa{C{\isasymvartheta}}}
|
|
720 |
{\isa{{\isacharparenleft}{\isasymAnd}\isactrlvec x{\isachardot}\ \isactrlvec H\ \isactrlvec x\ {\isasymLongrightarrow}\ A\ \isactrlvec x{\isacharparenright}\ {\isasymLongrightarrow}\ C} & \isa{A{\isasymvartheta}\ {\isacharequal}\ H\isactrlsub i{\isasymvartheta}}~~\text{(for some~\isa{i})}}
|
|
721 |
\]
|
|
722 |
|
|
723 |
|
|
724 |
\[
|
|
725 |
\infer[\isa{{\isacharparenleft}compose{\isacharparenright}}]{\isa{\isactrlvec A{\isasymvartheta}\ {\isasymLongrightarrow}\ C{\isasymvartheta}}}
|
|
726 |
{\isa{\isactrlvec A\ {\isasymLongrightarrow}\ B} & \isa{B{\isacharprime}\ {\isasymLongrightarrow}\ C} & \isa{B{\isasymvartheta}\ {\isacharequal}\ B{\isacharprime}{\isasymvartheta}}}
|
|
727 |
\]
|
|
728 |
|
|
729 |
|
|
730 |
\[
|
|
731 |
\infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}lift{\isacharparenright}}]{\isa{{\isacharparenleft}{\isasymAnd}\isactrlvec x{\isachardot}\ \isactrlvec A\ {\isacharparenleft}{\isacharquery}\isactrlvec a\ \isactrlvec x{\isacharparenright}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymAnd}\isactrlvec x{\isachardot}\ B\ {\isacharparenleft}{\isacharquery}\isactrlvec a\ \isactrlvec x{\isacharparenright}{\isacharparenright}}}{\isa{\isactrlvec A\ {\isacharquery}\isactrlvec a\ {\isasymLongrightarrow}\ B\ {\isacharquery}\isactrlvec a}}
|
|
732 |
\]
|
|
733 |
\[
|
|
734 |
\infer[\isa{{\isacharparenleft}{\isasymLongrightarrow}{\isacharunderscore}lift{\isacharparenright}}]{\isa{{\isacharparenleft}\isactrlvec H\ {\isasymLongrightarrow}\ \isactrlvec A{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}\isactrlvec H\ {\isasymLongrightarrow}\ B{\isacharparenright}}}{\isa{\isactrlvec A\ {\isasymLongrightarrow}\ B}}
|
|
735 |
\]
|
|
736 |
|
|
737 |
The \isa{resolve} scheme is now acquired from \isa{{\isasymAnd}{\isacharunderscore}lift},
|
|
738 |
\isa{{\isasymLongrightarrow}{\isacharunderscore}lift}, and \isa{compose}.
|
|
739 |
|
|
740 |
\[
|
|
741 |
\infer[\isa{{\isacharparenleft}resolution{\isacharparenright}}]
|
|
742 |
{\isa{{\isacharparenleft}{\isasymAnd}\isactrlvec x{\isachardot}\ \isactrlvec H\ \isactrlvec x\ {\isasymLongrightarrow}\ \isactrlvec A\ {\isacharparenleft}{\isacharquery}\isactrlvec a\ \isactrlvec x{\isacharparenright}{\isacharparenright}{\isasymvartheta}\ {\isasymLongrightarrow}\ C{\isasymvartheta}}}
|
|
743 |
{\begin{tabular}{l}
|
|
744 |
\isa{\isactrlvec A\ {\isacharquery}\isactrlvec a\ {\isasymLongrightarrow}\ B\ {\isacharquery}\isactrlvec a} \\
|
|
745 |
\isa{{\isacharparenleft}{\isasymAnd}\isactrlvec x{\isachardot}\ \isactrlvec H\ \isactrlvec x\ {\isasymLongrightarrow}\ B{\isacharprime}\ \isactrlvec x{\isacharparenright}\ {\isasymLongrightarrow}\ C} \\
|
|
746 |
\isa{{\isacharparenleft}{\isasymlambda}\isactrlvec x{\isachardot}\ B\ {\isacharparenleft}{\isacharquery}\isactrlvec a\ \isactrlvec x{\isacharparenright}{\isacharparenright}{\isasymvartheta}\ {\isacharequal}\ B{\isacharprime}{\isasymvartheta}} \\
|
|
747 |
\end{tabular}}
|
|
748 |
\]
|
|
749 |
|
|
750 |
|
|
751 |
FIXME \isa{elim{\isacharunderscore}resolution}, \isa{dest{\isacharunderscore}resolution}%
|
18537
|
752 |
\end{isamarkuptext}%
|
|
753 |
\isamarkuptrue%
|
|
754 |
%
|
|
755 |
\isadelimtheory
|
|
756 |
%
|
|
757 |
\endisadelimtheory
|
|
758 |
%
|
|
759 |
\isatagtheory
|
|
760 |
\isacommand{end}\isamarkupfalse%
|
|
761 |
%
|
|
762 |
\endisatagtheory
|
|
763 |
{\isafoldtheory}%
|
|
764 |
%
|
|
765 |
\isadelimtheory
|
|
766 |
%
|
|
767 |
\endisadelimtheory
|
|
768 |
\isanewline
|
|
769 |
\end{isabellebody}%
|
|
770 |
%%% Local Variables:
|
|
771 |
%%% mode: latex
|
|
772 |
%%% TeX-master: "root"
|
|
773 |
%%% End:
|