doc-src/Logics/intro.tex
author lcp
Mon, 21 Mar 1994 11:41:41 +0100
changeset 287 6b62a6ddbe15
parent 111 1b3cddf41b2d
child 318 a0e27395abe3
permissions -rw-r--r--
first draft of Springer book
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
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     8
\begin{quote}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     9
{\ttindexbold{FOL}} is many-sorted first-order logic with natural
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
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    12
{\ttindexbold{ZF}} is axiomatic set theory, using the Zermelo-Fraenkel
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    13
axioms~\cite{suppes72}.  It is built upon classical~\FOL{}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    14
 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    15
{\ttindexbold{HOL}} is the higher-order logic of Church~\cite{church40},
111
1b3cddf41b2d Various updates for Isabelle-93
lcp
parents: 104
diff changeset
    16
which is also implemented by Gordon's~{\sc hol} system~\cite{mgordon88a}.  This
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    17
object-logic should not be confused with Isabelle's meta-logic, which is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    18
also a form of higher-order logic.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    19
 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    20
{\ttindexbold{CTT}} is a version of Martin-L\"of's Constructive Type
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    21
Theory~\cite{nordstrom90}, with extensional equality.  Universes are not
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    22
included.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    23
 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    24
{\ttindexbold{LK}} is another version of first-order logic, a classical
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    25
sequent calculus.  Sequents have the form $A@1,\ldots,A@m\turn
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    26
B@1,\ldots,B@n$; rules are applied using associative matching.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    27
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    28
{\ttindexbold{Modal}} implements the modal logics $T$, $S4$, and~$S43$.  It
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    29
is built upon~\LK{}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    30
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    31
{\ttindexbold{Cube}} is Barendregt's $\lambda$-cube.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    32
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    33
{\ttindexbold{LCF}} is a version of Scott's Logic for Computable Functions,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    34
which is also implemented by the~{\sc lcf} system~\cite{paulson87}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    35
\end{quote}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    36
The logics {\tt Modal}, {\tt Cube} and {\tt LCF} are currently undocumented.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    37
287
6b62a6ddbe15 first draft of Springer book
lcp
parents: 111
diff changeset
    38
You should not read this before reading {\em Introduction to Isabelle\/}
6b62a6ddbe15 first draft of Springer book
lcp
parents: 111
diff changeset
    39
and performing some Isabelle proofs.  Consult the {\em Reference Manual}
6b62a6ddbe15 first draft of Springer book
lcp
parents: 111
diff changeset
    40
for more information on tactics, packages, etc.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    41
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    42
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    43
\section{Syntax definitions}
287
6b62a6ddbe15 first draft of Springer book
lcp
parents: 111
diff changeset
    44
The syntax of each logic syntax is defined using a context-free grammar.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    45
These grammars obey the following conventions:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    46
\begin{itemize}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    47
\item identifiers denote nonterminal symbols
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    48
\item {\tt typewriter} font denotes terminal symbols
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    49
\item parentheses $(\ldots)$ express grouping
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    50
\item constructs followed by a Kleene star, such as $id^*$ and $(\ldots)^*$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    51
can be repeated~0 or more times 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    52
\item alternatives are separated by a vertical bar,~$|$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    53
\item the symbol for alphanumeric identifier is~{\it id\/} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    54
\item the symbol for scheme variables is~{\it var}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    55
\end{itemize}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    56
To reduce the number of nonterminals and grammar rules required, Isabelle's
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    57
syntax module employs {\bf precedences}.  Each grammar rule is given by a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    58
mixfix declaration, which has a precedence, and each argument place has a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    59
precedence.  This general approach handles infix operators that associate
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    60
either to the left or to the right, as well as prefix and binding
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    61
operators.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    62
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    63
In a syntactically valid expression, an operator's arguments never involve
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    64
an operator of lower precedence unless brackets are used.  Consider
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    65
first-order logic, where $\exists$ has lower precedence than $\disj$,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    66
which has lower precedence than $\conj$.  There, $P\conj Q \disj R$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    67
abbreviates $(P\conj Q) \disj R$ rather than $P\conj (Q\disj R)$.  Also,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    68
$\exists x.P\disj Q$ abbreviates $\exists x.(P\disj Q)$ rather than
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    69
$(\exists x.P)\disj Q$.  Note especially that $P\disj(\exists x.Q)$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    70
becomes syntactically invalid if the brackets are removed.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    71
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    72
A {\bf binder} is a symbol associated with a constant of type
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    73
$(\sigma\To\tau)\To\tau'$.  For instance, we may declare~$\forall$ as a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    74
binder for the constant~$All$, which has type $(\alpha\To o)\To o$.  This
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    75
defines the syntax $\forall x.t$ to mean $\forall(\lambda x.t)$.  We can
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    76
also write $\forall x@1\ldots x@m.t$ to abbreviate $\forall x@1.  \ldots
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    77
\forall x@m.t$; this is possible for any constant provided that $\tau$ and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    78
$\tau'$ are the same type.  \HOL's description operator $\epsilon x.P(x)$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    79
has type $(\alpha\To bool)\To\alpha$ and can bind only one variable, except
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    80
when $\alpha$ is $bool$.  \ZF's bounded quantifier $\forall x\in A.P(x)$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    81
cannot be declared as a binder because it has type $[i, i\To o]\To o$.  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    82
syntax for binders allows type constraints on bound variables, as in
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    83
\[ \forall (x{::}\alpha) \; y{::}\beta. R(x,y) \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    84
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    85
To avoid excess detail, the logic descriptions adopt a semi-formal style.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    86
Infix operators and binding operators are listed in separate tables, which
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    87
include their precedences.  Grammars do not give numeric precedences;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    88
instead, the rules appear in order of decreasing precedence.  This should
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    89
suffice for most purposes; for detailed precedence information, consult the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    90
syntax definitions in the {\tt.thy} files.  Chapter~\ref{Defining-Logics}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    91
describes Isabelle's syntax module, including its use of precedences.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    92
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    93
Each nonterminal symbol is associated with some Isabelle type.  For
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    94
example, the {\bf formulae} of first-order logic have type~$o$.  Every
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    95
Isabelle expression of type~$o$ is therefore a formula.  These include
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    96
atomic formulae such as $P$, where $P$ is a variable of type~$o$, and more
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    97
generally expressions such as $P(t,u)$, where $P$, $t$ and~$u$ have
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    98
suitable types.  Therefore, ``expression of type~$o$'' is listed as a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    99
separate possibility in the grammar for formulae.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   100
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   101
Infix operators are represented internally by constants with the prefix
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   102
\hbox{\tt"op "}.  For instance, implication is the constant
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   103
\hbox{\tt"op~-->"}.  This permits infixes to be used in non-infix contexts
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   104
(just as with \ML's~{\tt op} keyword).  You also need to know the name of
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   105
the internal constant if you are writing code that inspects terms.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   106
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   107
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   108
\section{Proof procedures}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   109
Most object-logics come with simple proof procedures.  These are reasonably
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   110
powerful for interactive use, though often simplistic and incomplete.  You
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   111
can do single-step proofs using \verb|resolve_tac| and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   112
\verb|assume_tac|, referring to the inference rules of the logic by {\sc
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   113
ml} identifiers.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   114
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
Call a rule {\em safe\/} if applying it to a provable goal always yields
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   116
provable subgoals.  If a rule is safe then it can be applied automatically
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   117
to a goal without destroying our chances of finding a proof.  For instance,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   118
all the rules of the classical sequent calculus {\sc lk} are safe.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   119
Intuitionistic logic includes some unsafe rules, like disjunction
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   120
introduction ($P\disj Q$ can be true when $P$ is false) and existential
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   121
introduction ($\ex{x}P(x)$ can be true when $P(a)$ is false for certain
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   122
$a$).  Universal elimination is unsafe if the formula $\all{x}P(x)$ is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   123
deleted after use.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   124
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   125
Proof procedures use safe rules whenever possible, delaying the application
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   126
of unsafe rules. Those safe rules are preferred that generate the fewest
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   127
subgoals. Safe rules are (by definition) deterministic, while the unsafe
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   128
rules require search. The design of a suitable set of rules can be as
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   129
important as the strategy for applying them.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   130
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   131
Many of the proof procedures use backtracking.  Typically they attempt to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   132
solve subgoal~$i$ by repeatedly applying a certain tactic to it.  This
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   133
tactic, which is known as a {\it step tactic}, resolves a selection of
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   134
rules with subgoal~$i$. This may replace one subgoal by many; but the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   135
search persists until there are fewer subgoals in total than at the start.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   136
Backtracking happens when the search reaches a dead end: when the step
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   137
tactic fails.  Alternative outcomes are then searched by a depth-first or
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   138
best-first strategy.