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