doc-src/Logics/syntax.tex
author blanchet
Mon, 19 Apr 2010 18:14:45 +0200
changeset 36230 43d10a494c91
parent 14209 180cd69a5dbb
child 42637 381fdcab0f36
permissions -rw-r--r--
added warning about inconsistent context to Metis; it makes more sense here than in Sledgehammer, because Sledgehammer is unsound and there's no point in having people panicking about the consistency of their context when their context is in fact consistent
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6120
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     1
%% $Id$
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     2
%% THIS FILE IS COMMON TO ALL LOGIC MANUALS
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     3
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     4
\chapter{Syntax definitions}
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     5
The syntax of each logic is presented using a context-free grammar.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     6
These grammars obey the following conventions:
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     7
\begin{itemize}
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     8
\item identifiers denote nonterminal symbols
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
     9
\item \texttt{typewriter} font denotes terminal symbols
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    10
\item parentheses $(\ldots)$ express grouping
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    11
\item constructs followed by a Kleene star, such as $id^*$ and $(\ldots)^*$
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    12
can be repeated~0 or more times 
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    13
\item alternatives are separated by a vertical bar,~$|$
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    14
\item the symbol for alphanumeric identifiers is~{\it id\/} 
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    15
\item the symbol for scheme variables is~{\it var}
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    16
\end{itemize}
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    17
To reduce the number of nonterminals and grammar rules required, Isabelle's
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    18
syntax module employs {\bf priorities},\index{priorities} or precedences.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    19
Each grammar rule is given by a mixfix declaration, which has a priority,
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    20
and each argument place has a priority.  This general approach handles
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    21
infix operators that associate either to the left or to the right, as well
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    22
as prefix and binding operators.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    23
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    24
In a syntactically valid expression, an operator's arguments never involve
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    25
an operator of lower priority unless brackets are used.  Consider
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    26
first-order logic, where $\exists$ has lower priority than $\disj$,
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    27
which has lower priority than $\conj$.  There, $P\conj Q \disj R$
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    28
abbreviates $(P\conj Q) \disj R$ rather than $P\conj (Q\disj R)$.  Also,
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    29
$\exists x.P\disj Q$ abbreviates $\exists x.(P\disj Q)$ rather than
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    30
$(\exists x.P)\disj Q$.  Note especially that $P\disj(\exists x.Q)$
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    31
becomes syntactically invalid if the brackets are removed.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    32
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    33
A {\bf binder} is a symbol associated with a constant of type
9695
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 6120
diff changeset
    34
$(\sigma\To\tau)\To\tau'$.  For instance, we may declare~$\forall$ as a binder
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 6120
diff changeset
    35
for the constant~$All$, which has type $(\alpha\To o)\To o$.  This defines the
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 6120
diff changeset
    36
syntax $\forall x.t$ to mean $All(\lambda x.t)$.  We can also write $\forall
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 6120
diff changeset
    37
x@1\ldots x@m.t$ to abbreviate $\forall x@1.  \ldots \forall x@m.t$; this is
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 6120
diff changeset
    38
possible for any constant provided that $\tau$ and $\tau'$ are the same type.
14209
paulson
parents: 9695
diff changeset
    39
The Hilbert description operator $\varepsilon x.P\,x$ has type $(\alpha\To
paulson
parents: 9695
diff changeset
    40
bool)\To\alpha$ and normally binds only one variable.  
paulson
parents: 9695
diff changeset
    41
ZF's bounded quantifier $\forall x\in A.P(x)$ cannot be declared as a
9695
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 6120
diff changeset
    42
binder because it has type $[i, i\To o]\To o$.  The syntax for binders allows
6120
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    43
type constraints on bound variables, as in
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    44
\[ \forall (x{::}\alpha) \; (y{::}\beta) \; z{::}\gamma. Q(x,y,z) \]
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    45
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    46
To avoid excess detail, the logic descriptions adopt a semi-formal style.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    47
Infix operators and binding operators are listed in separate tables, which
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    48
include their priorities.  Grammar descriptions do not include numeric
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    49
priorities; instead, the rules appear in order of decreasing priority.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    50
This should suffice for most purposes; for full details, please consult the
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    51
actual syntax definitions in the {\tt.thy} files.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    52
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    53
Each nonterminal symbol is associated with some Isabelle type.  For
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    54
example, the formulae of first-order logic have type~$o$.  Every
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    55
Isabelle expression of type~$o$ is therefore a formula.  These include
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    56
atomic formulae such as $P$, where $P$ is a variable of type~$o$, and more
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    57
generally expressions such as $P(t,u)$, where $P$, $t$ and~$u$ have
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    58
suitable types.  Therefore, `expression of type~$o$' is listed as a
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    59
separate possibility in the grammar for formulae.
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    60
f40d61cd6b32 removal of FOL and ZF
paulson
parents:
diff changeset
    61