doc-src/Logics/intro.tex
author paulson
Fri, 27 Nov 1998 13:13:22 +0100
changeset 5980 2e9314c07146
parent 3486 10cf84e5d2c2
permissions -rw-r--r--
added Real/Hyperreal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     1
%% $Id$
287
6b62a6ddbe15 first draft of Springer book
lcp
parents: 111
diff changeset
     2
\chapter{Basic Concepts}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     3
Several logics come with Isabelle.  Many of them are sufficiently developed
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     4
to serve as comfortable reasoning environments.  They are also good
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     5
starting points for defining new logics.  Each logic is distributed with
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     6
sample proofs, some of which are described in this document.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     7
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
     8
\begin{ttdescription}
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
     9
\item[\thydx{FOL}] is many-sorted first-order logic with natural
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    10
deduction.  It comes in both constructive and classical versions.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    11
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    12
\item[\thydx{ZF}] is axiomatic set theory, using the Zermelo-Fraenkel
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    13
axioms~\cite{suppes72}.  It is built upon classical~\FOL{}.
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    14
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    15
\item[\thydx{CCL}] is Martin Coen's Classical Computational Logic,
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    16
  which is the basis of a preliminary method for deriving programs from
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    17
  proofs~\cite{coen92}.  It is built upon classical~\FOL{}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    18
 
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    19
\item[\thydx{LCF}] is a version of Scott's Logic for Computable
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    20
  Functions, which is also implemented by the~{\sc lcf}
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    21
  system~\cite{paulson87}.  It is built upon classical~\FOL{}.
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    22
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    23
\item[\thydx{HOL}] is the higher-order logic of Church~\cite{church40},
343
8d77f767bd26 final Springer copy
lcp
parents: 318
diff changeset
    24
which is also implemented by Gordon's~{\sc hol} system~\cite{mgordon-hol}.
8d77f767bd26 final Springer copy
lcp
parents: 318
diff changeset
    25
This object-logic should not be confused with Isabelle's meta-logic, which is
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    26
also a form of higher-order logic.
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    27
3139
wenzelm
parents: 343
diff changeset
    28
\item[\thydx{HOLCF}] is a version of {\sc lcf}, defined as an
wenzelm
parents: 343
diff changeset
    29
  extension of {\tt HOL}\@.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    30
 
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    31
\item[\thydx{CTT}] is a version of Martin-L\"of's Constructive Type
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    32
Theory~\cite{nordstrom90}, with extensional equality.  Universes are not
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    33
included.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    34
 
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    35
\item[\thydx{LK}] is another version of first-order logic, a classical
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    36
sequent calculus.  Sequents have the form $A@1,\ldots,A@m\turn
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    37
B@1,\ldots,B@n$; rules are applied using associative matching.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    38
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    39
\item[\thydx{Modal}] implements the modal logics $T$, $S4$,
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    40
  and~$S43$.  It is built upon~\LK{}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    41
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    42
\item[\thydx{Cube}] is Barendregt's $\lambda$-cube.
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    43
\end{ttdescription}
3151
c9a6b415dae6 minor tuning;
wenzelm
parents: 3139
diff changeset
    44
The logics {\tt CCL}, {\tt LCF}, {\tt HOLCF}, {\tt Modal} and {\tt
3486
10cf84e5d2c2 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3216
diff changeset
    45
  Cube} are currently undocumented.  All object-logics' sources are
3151
c9a6b415dae6 minor tuning;
wenzelm
parents: 3139
diff changeset
    46
distributed with Isabelle (see the directory \texttt{src}).  They are
3216
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    47
also available for browsing on the WWW at:
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    48
\begin{ttbox}
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    49
http://www4.informatik.tu-muenchen.de/~nipkow/isabelle/
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    50
\end{ttbox}
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    51
Note that this is not necessarily consistent with your local sources!
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    52
3216
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    53
\medskip You should not read this manual before reading {\em
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    54
  Introduction to Isabelle\/} and performing some Isabelle proofs.
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    55
Consult the {\em Reference Manual} for more information on tactics,
fdcb907f9c93 improved www4 ref;
wenzelm
parents: 3151
diff changeset
    56
packages, etc.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    57
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    58
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    59
\section{Syntax definitions}
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    60
The syntax of each logic is presented using a context-free grammar.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    61
These grammars obey the following conventions:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    62
\begin{itemize}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    63
\item identifiers denote nonterminal symbols
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    64
\item {\tt typewriter} font denotes terminal symbols
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    65
\item parentheses $(\ldots)$ express grouping
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    66
\item constructs followed by a Kleene star, such as $id^*$ and $(\ldots)^*$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    67
can be repeated~0 or more times 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    68
\item alternatives are separated by a vertical bar,~$|$
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    69
\item the symbol for alphanumeric identifiers is~{\it id\/} 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    70
\item the symbol for scheme variables is~{\it var}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    71
\end{itemize}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    72
To reduce the number of nonterminals and grammar rules required, Isabelle's
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    73
syntax module employs {\bf priorities},\index{priorities} or precedences.
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    74
Each grammar rule is given by a mixfix declaration, which has a priority,
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    75
and each argument place has a priority.  This general approach handles
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    76
infix operators that associate either to the left or to the right, as well
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    77
as prefix and binding operators.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    78
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    79
In a syntactically valid expression, an operator's arguments never involve
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    80
an operator of lower priority unless brackets are used.  Consider
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    81
first-order logic, where $\exists$ has lower priority than $\disj$,
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
    82
which has lower priority than $\conj$.  There, $P\conj Q \disj R$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    83
abbreviates $(P\conj Q) \disj R$ rather than $P\conj (Q\disj R)$.  Also,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    84
$\exists x.P\disj Q$ abbreviates $\exists x.(P\disj Q)$ rather than
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    85
$(\exists x.P)\disj Q$.  Note especially that $P\disj(\exists x.Q)$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    86
becomes syntactically invalid if the brackets are removed.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    87
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    88
A {\bf binder} is a symbol associated with a constant of type
3139
wenzelm
parents: 343
diff changeset
    89
$(\sigma\To\tau)\To\tau'$.  For instance, we may declare~$\forall$ as
wenzelm
parents: 343
diff changeset
    90
a binder for the constant~$All$, which has type $(\alpha\To o)\To o$.
wenzelm
parents: 343
diff changeset
    91
This defines the syntax $\forall x.t$ to mean $All(\lambda x.t)$.  We
wenzelm
parents: 343
diff changeset
    92
can also write $\forall x@1\ldots x@m.t$ to abbreviate $\forall x@1.
wenzelm
parents: 343
diff changeset
    93
\ldots \forall x@m.t$; this is possible for any constant provided that
wenzelm
parents: 343
diff changeset
    94
$\tau$ and $\tau'$ are the same type.  \HOL's description operator
wenzelm
parents: 343
diff changeset
    95
$\varepsilon x.P\,x$ has type $(\alpha\To bool)\To\alpha$ and can bind
wenzelm
parents: 343
diff changeset
    96
only one variable, except when $\alpha$ is $bool$.  \ZF's bounded
wenzelm
parents: 343
diff changeset
    97
quantifier $\forall x\in A.P(x)$ cannot be declared as a binder
wenzelm
parents: 343
diff changeset
    98
because it has type $[i, i\To o]\To o$.  The syntax for binders allows
wenzelm
parents: 343
diff changeset
    99
type constraints on bound variables, as in
3151
c9a6b415dae6 minor tuning;
wenzelm
parents: 3139
diff changeset
   100
\[ \forall (x{::}\alpha) \; (y{::}\beta) \; z{::}\gamma. Q(x,y,z) \]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   101
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   102
To avoid excess detail, the logic descriptions adopt a semi-formal style.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   103
Infix operators and binding operators are listed in separate tables, which
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   104
include their priorities.  Grammar descriptions do not include numeric
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   105
priorities; instead, the rules appear in order of decreasing priority.
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   106
This should suffice for most purposes; for full details, please consult the
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   107
actual syntax definitions in the {\tt.thy} files.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   108
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   109
Each nonterminal symbol is associated with some Isabelle type.  For
343
8d77f767bd26 final Springer copy
lcp
parents: 318
diff changeset
   110
example, the formulae of first-order logic have type~$o$.  Every
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   111
Isabelle expression of type~$o$ is therefore a formula.  These include
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   112
atomic formulae such as $P$, where $P$ is a variable of type~$o$, and more
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   113
generally expressions such as $P(t,u)$, where $P$, $t$ and~$u$ have
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   114
suitable types.  Therefore, `expression of type~$o$' is listed as a
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
separate possibility in the grammar for formulae.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   116
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   117
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   118
\section{Proof procedures}\label{sec:safe}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   119
Most object-logics come with simple proof procedures.  These are reasonably
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   120
powerful for interactive use, though often simplistic and incomplete.  You
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   121
can do single-step proofs using \verb|resolve_tac| and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   122
\verb|assume_tac|, referring to the inference rules of the logic by {\sc
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   123
ml} identifiers.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   124
318
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   125
For theorem proving, rules can be classified as {\bf safe} or {\bf unsafe}.
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   126
A rule is safe if applying it to a provable goal always yields provable
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   127
subgoals.  If a rule is safe then it can be applied automatically to a goal
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   128
without destroying our chances of finding a proof.  For instance, all the
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   129
rules of the classical sequent calculus {\sc lk} are safe.  Universal
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   130
elimination is unsafe if the formula $\all{x}P(x)$ is deleted after use.
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   131
Other unsafe rules include the following:
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   132
\[ \infer[({\disj}I1)]{P\disj Q}{P} \qquad 
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   133
   \infer[({\imp}E)]{Q}{P\imp Q & P} \qquad
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   134
   \infer[({\exists}I)]{\exists x.P}{P[t/x]} 
a0e27395abe3 penultimate Springer draft
lcp
parents: 287
diff changeset
   135
\]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   136
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   137
Proof procedures use safe rules whenever possible, delaying the application
3486
10cf84e5d2c2 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3216
diff changeset
   138
of unsafe rules.  Those safe rules are preferred that generate the fewest
10cf84e5d2c2 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3216
diff changeset
   139
subgoals.  Safe rules are (by definition) deterministic, while the unsafe
10cf84e5d2c2 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3216
diff changeset
   140
rules require search.  The design of a suitable set of rules can be as
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   141
important as the strategy for applying them.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   142
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   143
Many of the proof procedures use backtracking.  Typically they attempt to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   144
solve subgoal~$i$ by repeatedly applying a certain tactic to it.  This
343
8d77f767bd26 final Springer copy
lcp
parents: 318
diff changeset
   145
tactic, which is known as a {\bf step tactic}, resolves a selection of
3486
10cf84e5d2c2 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3216
diff changeset
   146
rules with subgoal~$i$.  This may replace one subgoal by many;  the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   147
search persists until there are fewer subgoals in total than at the start.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   148
Backtracking happens when the search reaches a dead end: when the step
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   149
tactic fails.  Alternative outcomes are then searched by a depth-first or
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   150
best-first strategy.