doc-src/IsarImplementation/Thy/document/logic.tex
changeset 20537 b6b49903db7e
parent 20521 189811b39869
child 20542 a54ca4e90874
equal deleted inserted replaced
20536:f088edff8af8 20537:b6b49903db7e
    33 
    33 
    34   Following type-theoretic parlance, the Pure logic consists of three
    34   Following type-theoretic parlance, the Pure logic consists of three
    35   levels of \isa{{\isasymlambda}}-calculus with corresponding arrows: \isa{{\isasymRightarrow}} for syntactic function space (terms depending on terms), \isa{{\isasymAnd}} for universal quantification (proofs depending on terms), and
    35   levels of \isa{{\isasymlambda}}-calculus with corresponding arrows: \isa{{\isasymRightarrow}} for syntactic function space (terms depending on terms), \isa{{\isasymAnd}} for universal quantification (proofs depending on terms), and
    36   \isa{{\isasymLongrightarrow}} for implication (proofs depending on proofs).
    36   \isa{{\isasymLongrightarrow}} for implication (proofs depending on proofs).
    37 
    37 
    38   Pure derivations are relative to a logical theory, which declares
    38   Derivations are relative to a logical theory, which declares type
    39   type constructors, term constants, and axioms.  Theory declarations
    39   constructors, constants, and axioms.  Theory declarations support
    40   support schematic polymorphism, which is strictly speaking outside
    40   schematic polymorphism, which is strictly speaking outside the
    41   the logic.\footnote{Incidently, this is the main logical reason, why
    41   logic.\footnote{This is the deeper logical reason, why the theory
    42   the theory context \isa{{\isasymTheta}} is separate from the context \isa{{\isasymGamma}} of the core calculus.}%
    42   context \isa{{\isasymTheta}} is separate from the proof context \isa{{\isasymGamma}}
       
    43   of the core calculus.}%
    43 \end{isamarkuptext}%
    44 \end{isamarkuptext}%
    44 \isamarkuptrue%
    45 \isamarkuptrue%
    45 %
    46 %
    46 \isamarkupsection{Types \label{sec:types}%
    47 \isamarkupsection{Types \label{sec:types}%
    47 }
    48 }
    55   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
    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
    56   generating relation; the transitive closure is maintained
    57   generating relation; the transitive closure is maintained
    57   internally.  The resulting relation is an ordering: reflexive,
    58   internally.  The resulting relation is an ordering: reflexive,
    58   transitive, and antisymmetric.
    59   transitive, and antisymmetric.
    59 
    60 
    60   A \emph{sort} is a list of type classes written as \isa{{\isacharbraceleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlisub m{\isacharbraceright}}, which represents symbolic
    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
    61   intersection.  Notationally, the curly braces are omitted for
    62   intersection.  Notationally, the curly braces are omitted for
    62   singleton intersections, i.e.\ any class \isa{c} may be read as
    63   singleton intersections, i.e.\ any class \isa{c} may be read as
    63   a sort \isa{{\isacharbraceleft}c{\isacharbraceright}}.  The ordering on type classes is extended to
    64   a sort \isa{{\isacharbraceleft}c{\isacharbraceright}}.  The ordering on type classes is extended to
    64   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
    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
    65   \isa{{\isasymforall}j{\isachardot}\ {\isasymexists}i{\isachardot}\ c\isactrlisub i\ {\isasymsubseteq}\ d\isactrlisub j}.  The empty intersection
    66   \isa{{\isasymforall}j{\isachardot}\ {\isasymexists}i{\isachardot}\ c\isactrlisub i\ {\isasymsubseteq}\ d\isactrlisub j}.  The empty intersection
    67   element wrt.\ the sort order.  The intersections of all (finitely
    68   element wrt.\ the sort order.  The intersections of all (finitely
    68   many) classes declared in the current theory are the minimal
    69   many) classes declared in the current theory are the minimal
    69   elements wrt.\ the sort order.
    70   elements wrt.\ the sort order.
    70 
    71 
    71   \medskip A \emph{fixed type variable} is a pair of a basic name
    72   \medskip A \emph{fixed type variable} is a pair of a basic name
    72   (starting with a \isa{{\isacharprime}} character) and a sort constraint.  For
    73   (starting with a \isa{{\isacharprime}} character) and a sort constraint, e.g.\
    73   example, \isa{{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ s{\isacharparenright}} which is usually printed as \isa{{\isasymalpha}\isactrlisub s}.  A \emph{schematic type variable} is a pair of an
    74   \isa{{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ s{\isacharparenright}} which is usually printed as \isa{{\isasymalpha}\isactrlisub s}.
    74   indexname and a sort constraint.  For example, \isa{{\isacharparenleft}{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ {\isadigit{0}}{\isacharparenright}{\isacharcomma}\ s{\isacharparenright}} which is usually printed as \isa{{\isacharquery}{\isasymalpha}\isactrlisub s}.
    75   A \emph{schematic type variable} is a pair of an indexname and a
       
    76   sort constraint, e.g.\ \isa{{\isacharparenleft}{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ {\isadigit{0}}{\isacharparenright}{\isacharcomma}\ s{\isacharparenright}} which is usually
       
    77   printed as \isa{{\isacharquery}{\isasymalpha}\isactrlisub s}.
    75 
    78 
    76   Note that \emph{all} syntactic components contribute to the identity
    79   Note that \emph{all} syntactic components contribute to the identity
    77   of type variables, including the sort constraint.  The core logic
    80   of type variables, including the sort constraint.  The core logic
    78   handles type variables with the same name but different sorts as
    81   handles type variables with the same name but different sorts as
    79   different, although some outer layers of the system make it hard to
    82   different, although some outer layers of the system make it hard to
    80   produce anything like this.
    83   produce anything like this.
    81 
    84 
    82   A \emph{type constructor} \isa{{\isasymkappa}} is a \isa{k}-ary operator
    85   A \emph{type constructor} \isa{{\isasymkappa}} is a \isa{k}-ary operator
    83   on types declared in the theory.  Type constructor application is
    86   on types declared in the theory.  Type constructor application is
    84   usually written postfix as \isa{{\isacharparenleft}{\isasymalpha}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlisub k{\isacharparenright}{\isasymkappa}}.
    87   written postfix as \isa{{\isacharparenleft}{\isasymalpha}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlisub k{\isacharparenright}{\isasymkappa}}.  For
    85   For \isa{k\ {\isacharequal}\ {\isadigit{0}}} the argument tuple is omitted, e.g.\ \isa{prop} instead of \isa{{\isacharparenleft}{\isacharparenright}prop}.  For \isa{k\ {\isacharequal}\ {\isadigit{1}}} the
    88   \isa{k\ {\isacharequal}\ {\isadigit{0}}} the argument tuple is omitted, e.g.\ \isa{prop}
    86   parentheses are omitted, e.g.\ \isa{{\isasymalpha}\ list} instead of \isa{{\isacharparenleft}{\isasymalpha}{\isacharparenright}list}.  Further notation is provided for specific constructors,
    89   instead of \isa{{\isacharparenleft}{\isacharparenright}prop}.  For \isa{k\ {\isacharequal}\ {\isadigit{1}}} the parentheses
    87   notably the right-associative infix \isa{{\isasymalpha}\ {\isasymRightarrow}\ {\isasymbeta}} instead of
    90   are omitted, e.g.\ \isa{{\isasymalpha}\ list} instead of \isa{{\isacharparenleft}{\isasymalpha}{\isacharparenright}list}.
    88   \isa{{\isacharparenleft}{\isasymalpha}{\isacharcomma}\ {\isasymbeta}{\isacharparenright}fun}.
    91   Further notation is provided for specific constructors, notably the
       
    92   right-associative infix \isa{{\isasymalpha}\ {\isasymRightarrow}\ {\isasymbeta}} instead of \isa{{\isacharparenleft}{\isasymalpha}{\isacharcomma}\ {\isasymbeta}{\isacharparenright}fun}.
    89   
    93   
    90   A \emph{type} \isa{{\isasymtau}} is defined inductively over type variables
    94   A \emph{type} is defined inductively over type variables and type
    91   and type constructors as follows: \isa{{\isasymtau}\ {\isacharequal}\ {\isasymalpha}\isactrlisub s\ {\isacharbar}\ {\isacharquery}{\isasymalpha}\isactrlisub s\ {\isacharbar}\ {\isacharparenleft}{\isasymtau}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlsub k{\isacharparenright}k}.
    95   constructors as follows: \isa{{\isasymtau}\ {\isacharequal}\ {\isasymalpha}\isactrlisub s\ {\isacharbar}\ {\isacharquery}{\isasymalpha}\isactrlisub s\ {\isacharbar}\ {\isacharparenleft}{\isasymtau}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlsub k{\isacharparenright}k}.
    92 
    96 
    93   A \emph{type abbreviation} is a syntactic definition \isa{{\isacharparenleft}\isactrlvec {\isasymalpha}{\isacharparenright}{\isasymkappa}\ {\isacharequal}\ {\isasymtau}} of an arbitrary type expression \isa{{\isasymtau}} over
    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
    94   variables \isa{\isactrlvec {\isasymalpha}}.  Type abbreviations looks like type
    98   variables \isa{\isactrlvec {\isasymalpha}}.  Type abbreviations appear as type
    95   constructors at the surface, but are fully expanded before entering
    99   constructors in the syntax, but are expanded before entering the
    96   the logical core.
   100   logical core.
    97 
   101 
    98   A \emph{type arity} declares the image behavior of a type
   102   A \emph{type arity} declares the image behavior of a type
    99   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
   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
   100   of sort \isa{s} if every argument type \isa{{\isasymtau}\isactrlisub i} is
   104   of sort \isa{s} if every argument type \isa{{\isasymtau}\isactrlisub i} is
   101   of sort \isa{s\isactrlisub i}.  Arity declarations are implicitly
   105   of sort \isa{s\isactrlisub i}.  Arity declarations are implicitly
   102   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}.
   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}.
   103 
   107 
   104   \medskip The sort algebra is always maintained as \emph{coregular},
   108   \medskip The sort algebra is always maintained as \emph{coregular},
   105   which means that type arities are consistent with the subclass
   109   which means that type arities are consistent with the subclass
   106   relation: for each type constructor \isa{{\isasymkappa}} and classes \isa{c\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlisub {\isadigit{2}}}, any arity \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s\isactrlisub {\isadigit{1}}{\isacharparenright}c\isactrlisub {\isadigit{1}}} has a corresponding arity \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s\isactrlisub {\isadigit{2}}{\isacharparenright}c\isactrlisub {\isadigit{2}}} where \isa{\isactrlvec s\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ \isactrlvec s\isactrlisub {\isadigit{2}}} holds component-wise.
   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.
   107 
   111 
   108   The key property of a coregular order-sorted algebra is that sort
   112   The key property of a coregular order-sorted algebra is that sort
   109   constraints may be always solved in a most general fashion: for each
   113   constraints can be solved in a most general fashion: for each type
   110   type constructor \isa{{\isasymkappa}} and sort \isa{s} there is a most
   114   constructor \isa{{\isasymkappa}} and sort \isa{s} there is a most general
   111   general vector of argument sorts \isa{{\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ s\isactrlisub k{\isacharparenright}} such 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
   115   vector of argument sorts \isa{{\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ s\isactrlisub k{\isacharparenright}} such
   112   of sort \isa{s}.  Consequently, the unification problem on the
   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}.
   113   algebra of types has most general solutions (modulo renaming and
   117   Consequently, unification on the algebra of types has most general
   114   equivalence of sorts).  Moreover, the usual type-inference algorithm
   118   solutions (modulo equivalence of sorts).  This means that
   115   will produce primary types as expected \cite{nipkow-prehofer}.%
   119   type-inference will produce primary types as expected
       
   120   \cite{nipkow-prehofer}.%
   116 \end{isamarkuptext}%
   121 \end{isamarkuptext}%
   117 \isamarkuptrue%
   122 \isamarkuptrue%
   118 %
   123 %
   119 \isadelimmlref
   124 \isadelimmlref
   120 %
   125 %
   152   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.
   157   triples of the form \isa{{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec s{\isacharcomma}\ s{\isacharparenright}} for \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}s} described above.
   153 
   158 
   154   \item \verb|typ| represents types; this is a datatype with
   159   \item \verb|typ| represents types; this is a datatype with
   155   constructors \verb|TFree|, \verb|TVar|, \verb|Type|.
   160   constructors \verb|TFree|, \verb|TVar|, \verb|Type|.
   156 
   161 
   157   \item \verb|map_atyps|~\isa{f\ {\isasymtau}} applies mapping \isa{f} to
   162   \item \verb|map_atyps|~\isa{f\ {\isasymtau}} applies the mapping \isa{f}
   158   all atomic types (\verb|TFree|, \verb|TVar|) occurring in \isa{{\isasymtau}}.
   163   to all atomic types (\verb|TFree|, \verb|TVar|) occurring in \isa{{\isasymtau}}.
   159 
   164 
   160   \item \verb|fold_atyps|~\isa{f\ {\isasymtau}} iterates operation \isa{f}
   165   \item \verb|fold_atyps|~\isa{f\ {\isasymtau}} iterates the operation \isa{f} over all occurrences of atomic types (\verb|TFree|, \verb|TVar|)
   161   over all occurrences of atoms (\verb|TFree|, \verb|TVar|) in \isa{{\isasymtau}}; the type structure is traversed from left to right.
   166   in \isa{{\isasymtau}}; the type structure is traversed from left to right.
   162 
   167 
   163   \item \verb|Sign.subsort|~\isa{thy\ {\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ s\isactrlisub {\isadigit{2}}{\isacharparenright}}
   168   \item \verb|Sign.subsort|~\isa{thy\ {\isacharparenleft}s\isactrlisub {\isadigit{1}}{\isacharcomma}\ s\isactrlisub {\isadigit{2}}{\isacharparenright}}
   164   tests the subsort relation \isa{s\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ s\isactrlisub {\isadigit{2}}}.
   169   tests the subsort relation \isa{s\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ s\isactrlisub {\isadigit{2}}}.
   165 
   170 
   166   \item \verb|Sign.of_sort|~\isa{thy\ {\isacharparenleft}{\isasymtau}{\isacharcomma}\ s{\isacharparenright}} tests whether a type
   171   \item \verb|Sign.of_sort|~\isa{thy\ {\isacharparenleft}{\isasymtau}{\isacharcomma}\ s{\isacharparenright}} tests whether type
   167   is of a given sort.
   172   \isa{{\isasymtau}} is of sort \isa{s}.
   168 
   173 
   169   \item \verb|Sign.add_types|~\isa{{\isacharbrackleft}{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ k{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}} declares new
   174   \item \verb|Sign.add_types|~\isa{{\isacharbrackleft}{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ k{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}} declares a new
   170   type constructors \isa{{\isasymkappa}} with \isa{k} arguments and
   175   type constructors \isa{{\isasymkappa}} with \isa{k} arguments and
   171   optional mixfix syntax.
   176   optional mixfix syntax.
   172 
   177 
   173   \item \verb|Sign.add_tyabbrs_i|~\isa{{\isacharbrackleft}{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec {\isasymalpha}{\isacharcomma}\ {\isasymtau}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}}
   178   \item \verb|Sign.add_tyabbrs_i|~\isa{{\isacharbrackleft}{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec {\isasymalpha}{\isacharcomma}\ {\isasymtau}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}}
   174   defines a new type abbreviation \isa{{\isacharparenleft}\isactrlvec {\isasymalpha}{\isacharparenright}{\isasymkappa}\ {\isacharequal}\ {\isasymtau}} with
   179   defines a new type abbreviation \isa{{\isacharparenleft}\isactrlvec {\isasymalpha}{\isacharparenright}{\isasymkappa}\ {\isacharequal}\ {\isasymtau}} with
   175   optional mixfix syntax.
   180   optional mixfix syntax.
   176 
   181 
   177   \item \verb|Sign.primitive_class|~\isa{{\isacharparenleft}c{\isacharcomma}\ {\isacharbrackleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlisub n{\isacharbrackright}{\isacharparenright}} declares new class \isa{c}, together with class
   182   \item \verb|Sign.primitive_class|~\isa{{\isacharparenleft}c{\isacharcomma}\ {\isacharbrackleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlisub n{\isacharbrackright}{\isacharparenright}} declares a new class \isa{c}, together with class
   178   relations \isa{c\ {\isasymsubseteq}\ c\isactrlisub i}, for \isa{i\ {\isacharequal}\ {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ n}.
   183   relations \isa{c\ {\isasymsubseteq}\ c\isactrlisub i}, for \isa{i\ {\isacharequal}\ {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ n}.
   179 
   184 
   180   \item \verb|Sign.primitive_classrel|~\isa{{\isacharparenleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ c\isactrlisub {\isadigit{2}}{\isacharparenright}} declares class relation \isa{c\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlisub {\isadigit{2}}}.
   185   \item \verb|Sign.primitive_classrel|~\isa{{\isacharparenleft}c\isactrlisub {\isadigit{1}}{\isacharcomma}\ c\isactrlisub {\isadigit{2}}{\isacharparenright}} declares class relation \isa{c\isactrlisub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlisub {\isadigit{2}}}.
   181 
   186 
   182   \item \verb|Sign.primitive_arity|~\isa{{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec s{\isacharcomma}\ s{\isacharparenright}} declares
   187   \item \verb|Sign.primitive_arity|~\isa{{\isacharparenleft}{\isasymkappa}{\isacharcomma}\ \isactrlvec s{\isacharcomma}\ s{\isacharparenright}} declares
   183   arity \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}s}.
   188   the arity \isa{{\isasymkappa}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}\isactrlvec s{\isacharparenright}s}.
   184 
   189 
   185   \end{description}%
   190   \end{description}%
   186 \end{isamarkuptext}%
   191 \end{isamarkuptext}%
   187 \isamarkuptrue%
   192 \isamarkuptrue%
   188 %
   193 %
   200 \begin{isamarkuptext}%
   205 \begin{isamarkuptext}%
   201 \glossary{Term}{FIXME}
   206 \glossary{Term}{FIXME}
   202 
   207 
   203   The language of terms is that of simply-typed \isa{{\isasymlambda}}-calculus
   208   The language of terms is that of simply-typed \isa{{\isasymlambda}}-calculus
   204   with de-Bruijn indices for bound variables (cf.\ \cite{debruijn72}
   209   with de-Bruijn indices for bound variables (cf.\ \cite{debruijn72}
   205   or \cite{paulson-ml2}), and named free variables and constants.
   210   or \cite{paulson-ml2}), with the types being determined determined
   206   Terms with loose bound variables are usually considered malformed.
   211   by the corresponding binders.  In contrast, free variables and
   207   The types of variables and constants is stored explicitly at each
   212   constants are have an explicit name and type in each occurrence.
   208   occurrence in the term.
       
   209 
   213 
   210   \medskip A \emph{bound variable} is a natural number \isa{b},
   214   \medskip A \emph{bound variable} is a natural number \isa{b},
   211   which refers to the next binder that is \isa{b} steps upwards
   215   which accounts for the number of intermediate binders between the
   212   from the occurrence of \isa{b} (counting from zero).  Bindings
   216   variable occurrence in the body and its binding position.  For
   213   may be introduced as abstractions within the term, or as a separate
       
   214   context (an inside-out list).  This associates each bound variable
       
   215   with a type.  A \emph{loose variables} is a bound variable that is
       
   216   outside the current scope of local binders or the context.  For
       
   217   example, the de-Bruijn term \isa{{\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ {\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ {\isadigit{1}}\ {\isacharplus}\ {\isadigit{0}}}
   217   example, the de-Bruijn term \isa{{\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ {\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ {\isadigit{1}}\ {\isacharplus}\ {\isadigit{0}}}
   218   corresponds to \isa{{\isasymlambda}x\isactrlisub {\isasymtau}{\isachardot}\ {\isasymlambda}y\isactrlisub {\isasymtau}{\isachardot}\ x\ {\isacharplus}\ y} in a named
   218   would correspond to \isa{{\isasymlambda}x\isactrlisub {\isasymtau}{\isachardot}\ {\isasymlambda}y\isactrlisub {\isasymtau}{\isachardot}\ x\ {\isacharplus}\ y} in a
   219   representation.  Also note that the very same bound variable may get
   219   named representation.  Note that a bound variable may be represented
   220   different numbers at different occurrences.
   220   by different de-Bruijn indices at different occurrences, depending
   221 
   221   on the nesting of abstractions.
   222   A \emph{fixed variable} is a pair of a basic name and a type.  For
   222 
   223   example, \isa{{\isacharparenleft}x{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed \isa{x\isactrlisub {\isasymtau}}.  A \emph{schematic variable} is a pair of an
   223   A \emph{loose variables} is a bound variable that is outside the
   224   indexname and a type.  For example, \isa{{\isacharparenleft}{\isacharparenleft}x{\isacharcomma}\ {\isadigit{0}}{\isacharparenright}{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is
   224   scope of local binders.  The types (and names) for loose variables
   225   usually printed as \isa{{\isacharquery}x\isactrlisub {\isasymtau}}.
   225   can be managed as a separate context, that is maintained inside-out
   226 
   226   like a stack of hypothetical binders.  The core logic only operates
   227   \medskip A \emph{constant} is a atomic terms consisting of a basic
   227   on closed terms, without any loose variables.
   228   name and a type.  Constants are declared in the context as
   228 
   229   polymorphic families \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}, meaning that any \isa{c\isactrlisub {\isasymtau}} is a valid constant for all substitution instances
   229   A \emph{fixed variable} is a pair of a basic name and a type, e.g.\
   230   \isa{{\isasymtau}\ {\isasymle}\ {\isasymsigma}}.
   230   \isa{{\isacharparenleft}x{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed \isa{x\isactrlisub {\isasymtau}}.  A
   231 
   231   \emph{schematic variable} is a pair of an indexname and a type,
   232   The list of \emph{type arguments} of \isa{c\isactrlisub {\isasymtau}} wrt.\ the
   232   e.g.\ \isa{{\isacharparenleft}{\isacharparenleft}x{\isacharcomma}\ {\isadigit{0}}{\isacharparenright}{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed as \isa{{\isacharquery}x\isactrlisub {\isasymtau}}.
   233   declaration \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} is the codomain of the type matcher
   233 
   234   presented in canonical order (according to the left-to-right
   234   \medskip A \emph{constant} is a pair of a basic name and a type,
   235   occurrences of type variables in in \isa{{\isasymsigma}}).  Thus \isa{c\isactrlisub {\isasymtau}} can be represented more compactly as \isa{c{\isacharparenleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharparenright}}.  For example, the instance \isa{plus\isactrlbsub nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ nat\isactrlesub } of some \isa{plus\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}} has the singleton list \isa{nat} as type arguments, the
   235   e.g.\ \isa{{\isacharparenleft}c{\isacharcomma}\ {\isasymtau}{\isacharparenright}} which is usually printed as \isa{c\isactrlisub {\isasymtau}}.  Constants are declared in the context as polymorphic
   236   constant may be represented as \isa{plus{\isacharparenleft}nat{\isacharparenright}}.
   236   families \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}, meaning that valid all substitution
       
   237   instances \isa{c\isactrlisub {\isasymtau}} for \isa{{\isasymtau}\ {\isacharequal}\ {\isasymsigma}{\isasymvartheta}} are valid.
       
   238 
       
   239   The vector of \emph{type arguments} of constant \isa{c\isactrlisub {\isasymtau}}
       
   240   wrt.\ the declaration \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} is defined as the codomain of
       
   241   the matcher \isa{{\isasymvartheta}\ {\isacharequal}\ {\isacharbraceleft}{\isacharquery}{\isasymalpha}\isactrlisub {\isadigit{1}}\ {\isasymmapsto}\ {\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isacharquery}{\isasymalpha}\isactrlisub n\ {\isasymmapsto}\ {\isasymtau}\isactrlisub n{\isacharbraceright}} presented in canonical order \isa{{\isacharparenleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharparenright}}.  Within a given theory context,
       
   242   there is a one-to-one correspondence between any constant \isa{c\isactrlisub {\isasymtau}} and the application \isa{c{\isacharparenleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharparenright}} of its type arguments.  For example, with \isa{plus\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}}, the instance \isa{plus\isactrlbsub nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ nat\isactrlesub } corresponds to \isa{plus{\isacharparenleft}nat{\isacharparenright}}.
   237 
   243 
   238   Constant declarations \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} may contain sort constraints
   244   Constant declarations \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} may contain sort constraints
   239   for type variables in \isa{{\isasymsigma}}.  These are observed by
   245   for type variables in \isa{{\isasymsigma}}.  These are observed by
   240   type-inference as expected, but \emph{ignored} by the core logic.
   246   type-inference as expected, but \emph{ignored} by the core logic.
   241   This means the primitive logic is able to reason with instances of
   247   This means the primitive logic is able to reason with instances of
   242   polymorphic constants that the user-level type-checker would reject.
   248   polymorphic constants that the user-level type-checker would reject
   243 
   249   due to violation of type class restrictions.
   244   \medskip A \emph{term} \isa{t} is defined inductively over
   250 
   245   variables and constants, with abstraction and application as
   251   \medskip A \emph{term} is defined inductively over variables and
   246   follows: \isa{t\ {\isacharequal}\ b\ {\isacharbar}\ x\isactrlisub {\isasymtau}\ {\isacharbar}\ {\isacharquery}x\isactrlisub {\isasymtau}\ {\isacharbar}\ c\isactrlisub {\isasymtau}\ {\isacharbar}\ {\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ t\ {\isacharbar}\ t\isactrlisub {\isadigit{1}}\ t\isactrlisub {\isadigit{2}}}.  Parsing and printing takes
   252   constants, with abstraction and application as follows: \isa{t\ {\isacharequal}\ b\ {\isacharbar}\ x\isactrlisub {\isasymtau}\ {\isacharbar}\ {\isacharquery}x\isactrlisub {\isasymtau}\ {\isacharbar}\ c\isactrlisub {\isasymtau}\ {\isacharbar}\ {\isasymlambda}\isactrlisub {\isasymtau}{\isachardot}\ t\ {\isacharbar}\ t\isactrlisub {\isadigit{1}}\ t\isactrlisub {\isadigit{2}}}.  Parsing and printing takes care of
   247   care of converting between an external representation with named
   253   converting between an external representation with named bound
   248   bound variables.  Subsequently, we shall use the latter notation
   254   variables.  Subsequently, we shall use the latter notation instead
   249   instead of internal de-Bruijn representation.
   255   of internal de-Bruijn representation.
   250 
   256 
   251   The subsequent inductive relation \isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}} assigns a
   257   The inductive relation \isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}} assigns a (unique) type to a
   252   (unique) type to a term, using the special type constructor \isa{{\isacharparenleft}{\isasymalpha}{\isacharcomma}\ {\isasymbeta}{\isacharparenright}fun}, which is written \isa{{\isasymalpha}\ {\isasymRightarrow}\ {\isasymbeta}}.
   258   term according to the structure of atomic terms, abstractions, and
       
   259   applicatins:
   253   \[
   260   \[
   254   \infer{\isa{a\isactrlisub {\isasymtau}\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}}}{}
   261   \infer{\isa{a\isactrlisub {\isasymtau}\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}}}{}
   255   \qquad
   262   \qquad
   256   \infer{\isa{{\isacharparenleft}{\isasymlambda}x\isactrlsub {\isasymtau}{\isachardot}\ t{\isacharparenright}\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymsigma}}}{\isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}}
   263   \infer{\isa{{\isacharparenleft}{\isasymlambda}x\isactrlsub {\isasymtau}{\isachardot}\ t{\isacharparenright}\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymsigma}}}{\isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}}
   257   \qquad
   264   \qquad
   263   reconstruct the most general type of a raw term, while assigning
   270   reconstruct the most general type of a raw term, while assigning
   264   most general types to all of its variables and constants.
   271   most general types to all of its variables and constants.
   265   Type-inference depends on a context of type constraints for fixed
   272   Type-inference depends on a context of type constraints for fixed
   266   variables, and declarations for polymorphic constants.
   273   variables, and declarations for polymorphic constants.
   267 
   274 
   268   The identity of atomic terms consists both of the name and the type.
   275   The identity of atomic terms consists both of the name and the type
   269   Thus different entities \isa{c\isactrlbsub {\isasymtau}\isactrlisub {\isadigit{1}}\isactrlesub } and
   276   component.  This means that different variables \isa{x\isactrlbsub {\isasymtau}\isactrlisub {\isadigit{1}}\isactrlesub } and \isa{x\isactrlbsub {\isasymtau}\isactrlisub {\isadigit{2}}\isactrlesub } may become the same after type
   270   \isa{c\isactrlbsub {\isasymtau}\isactrlisub {\isadigit{2}}\isactrlesub } may well identified by type
   277   instantiation.  Some outer layers of the system make it hard to
   271   instantiation, by mapping \isa{{\isasymtau}\isactrlisub {\isadigit{1}}} and \isa{{\isasymtau}\isactrlisub {\isadigit{2}}} to the same \isa{{\isasymtau}}.  Although,
   278   produce variables of the same name, but different types.  In
   272   different type instances of constants of the same basic name are
   279   particular, type-inference always demands ``consistent'' type
   273   commonplace, this rarely happens for variables: type-inference
   280   constraints for free variables.  In contrast, mixed instances of
   274   always demands ``consistent'' type constraints.
   281   polymorphic constants occur frequently.
   275 
   282 
   276   \medskip The \emph{hidden polymorphism} of a term \isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}
   283   \medskip The \emph{hidden polymorphism} of a term \isa{t\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}
   277   is the set of type variables occurring in \isa{t}, but not in
   284   is the set of type variables occurring in \isa{t}, but not in
   278   \isa{{\isasymsigma}}.  This means that the term implicitly depends on the
   285   \isa{{\isasymsigma}}.  This means that the term implicitly depends on type
   279   values of various type variables that are not visible in the overall
   286   arguments that are not accounted in result type, i.e.\ there are
   280   type, i.e.\ there are different type instances \isa{t{\isasymvartheta}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} and \isa{t{\isasymvartheta}{\isacharprime}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} with the same type.  This
   287   different type instances \isa{t{\isasymvartheta}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} and \isa{t{\isasymvartheta}{\isacharprime}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} with the same type.  This slightly
   281   slightly pathological situation is apt to cause strange effects.
   288   pathological situation demands special care.
   282 
   289 
   283   \medskip A \emph{term abbreviation} is a syntactic definition \isa{c\isactrlisub {\isasymsigma}\ {\isasymequiv}\ t} of an arbitrary closed term \isa{t} of type
   290   \medskip A \emph{term abbreviation} is a syntactic definition \isa{c\isactrlisub {\isasymsigma}\ {\isasymequiv}\ t} of a closed term \isa{t} of type \isa{{\isasymsigma}},
   284   \isa{{\isasymsigma}} without any hidden polymorphism.  A term abbreviation
   291   without any hidden polymorphism.  A term abbreviation looks like a
   285   looks like a constant at the surface, but is fully expanded before
   292   constant in the syntax, but is fully expanded before entering the
   286   entering the logical core.  Abbreviations are usually reverted when
   293   logical core.  Abbreviations are usually reverted when printing
   287   printing terms, using rules \isa{t\ {\isasymrightarrow}\ c\isactrlisub {\isasymsigma}} has a
   294   terms, using the collective \isa{t\ {\isasymrightarrow}\ c\isactrlisub {\isasymsigma}} as rules for
   288   higher-order term rewrite system.
   295   higher-order rewriting.
   289 
   296 
   290   \medskip Canonical operations on \isa{{\isasymlambda}}-terms include \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-conversion. \isa{{\isasymalpha}}-conversion refers to capture-free
   297   \medskip Canonical operations on \isa{{\isasymlambda}}-terms include \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-conversion: \isa{{\isasymalpha}}-conversion refers to capture-free
   291   renaming of bound variables; \isa{{\isasymbeta}}-conversion contracts an
   298   renaming of bound variables; \isa{{\isasymbeta}}-conversion contracts an
   292   abstraction applied to some argument term, substituting the argument
   299   abstraction applied to an argument term, substituting the argument
   293   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
   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
   294   \isa{{\isadigit{0}}} does not occur in \isa{f}.
   301   does not occur in \isa{f}.
   295 
   302 
   296   Terms are almost always treated module \isa{{\isasymalpha}}-conversion, which
   303   Terms are normally treated modulo \isa{{\isasymalpha}}-conversion, which is
   297   is implicit in the de-Bruijn representation.  The names in
   304   implicit in the de-Bruijn representation.  Names for bound variables
   298   abstractions of bound variables are maintained only as a comment for
   305   in abstractions are maintained separately as (meaningless) comments,
   299   parsing and printing.  Full \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence is usually
   306   mostly for parsing and printing.  Full \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-conversion is
   300   taken for granted higher rules (\secref{sec:rules}), anything
   307   commonplace in various higher operations (\secref{sec:rules}) that
   301   depending on higher-order unification or rewriting.%
   308   are based on higher-order unification and matching.%
   302 \end{isamarkuptext}%
   309 \end{isamarkuptext}%
   303 \isamarkuptrue%
   310 \isamarkuptrue%
   304 %
   311 %
   305 \isadelimmlref
   312 \isadelimmlref
   306 %
   313 %
   326   \indexml{Sign.const-instance}\verb|Sign.const_instance: theory -> string * typ list -> typ| \\
   333   \indexml{Sign.const-instance}\verb|Sign.const_instance: theory -> string * typ list -> typ| \\
   327   \end{mldecls}
   334   \end{mldecls}
   328 
   335 
   329   \begin{description}
   336   \begin{description}
   330 
   337 
   331   \item \verb|term| represents de-Bruijn terms with comments in
   338   \item \verb|term| represents de-Bruijn terms, with comments in
   332   abstractions for bound variable names.  This is a datatype with
   339   abstractions, and explicitly named free variables and constants;
   333   constructors \verb|Bound|, \verb|Free|, \verb|Var|, \verb|Const|, \verb|Abs|, \verb|op $|.
   340   this is a datatype with constructors \verb|Bound|, \verb|Free|, \verb|Var|, \verb|Const|, \verb|Abs|, \verb|op $|.
   334 
   341 
   335   \item \isa{t}~\verb|aconv|~\isa{u} checks \isa{{\isasymalpha}}-equivalence of two terms.  This is the basic equality relation
   342   \item \isa{t}~\verb|aconv|~\isa{u} checks \isa{{\isasymalpha}}-equivalence of two terms.  This is the basic equality relation
   336   on type \verb|term|; raw datatype equality should only be used
   343   on type \verb|term|; raw datatype equality should only be used
   337   for operations related to parsing or printing!
   344   for operations related to parsing or printing!
   338 
   345 
   339   \item \verb|map_term_types|~\isa{f\ t} applies mapping \isa{f}
   346   \item \verb|map_term_types|~\isa{f\ t} applies the mapping \isa{f} to all types occurring in \isa{t}.
   340   to all types occurring in \isa{t}.
   347 
   341 
   348   \item \verb|fold_types|~\isa{f\ t} iterates the operation \isa{f} over all occurrences of types in \isa{t}; the term
   342   \item \verb|fold_types|~\isa{f\ t} iterates operation \isa{f}
   349   structure is traversed from left to right.
   343   over all occurrences of types in \isa{t}; the term structure is
   350 
       
   351   \item \verb|map_aterms|~\isa{f\ t} applies the mapping \isa{f}
       
   352   to all atomic terms (\verb|Bound|, \verb|Free|, \verb|Var|, \verb|Const|) occurring in \isa{t}.
       
   353 
       
   354   \item \verb|fold_aterms|~\isa{f\ t} iterates the operation \isa{f} over all occurrences of atomic terms (\verb|Bound|, \verb|Free|,
       
   355   \verb|Var|, \verb|Const|) in \isa{t}; the term structure is
   344   traversed from left to right.
   356   traversed from left to right.
   345 
   357 
   346   \item \verb|map_aterms|~\isa{f\ t} applies mapping \isa{f} to
   358   \item \verb|fastype_of|~\isa{t} determines the type of a
   347   all atomic terms (\verb|Bound|, \verb|Free|, \verb|Var|, \verb|Const|)
   359   well-typed term.  This operation is relatively slow, despite the
   348   occurring in \isa{t}.
   360   omission of any sanity checks.
   349 
   361 
   350   \item \verb|fold_aterms|~\isa{f\ t} iterates operation \isa{f}
   362   \item \verb|lambda|~\isa{a\ b} produces an abstraction \isa{{\isasymlambda}a{\isachardot}\ b}, where occurrences of the atomic term \isa{a} in the
   351   over all occurrences of atomic terms in (\verb|Bound|, \verb|Free|,
   363   body \isa{b} are replaced by bound variables.
   352   \verb|Var|, \verb|Const|) \isa{t}; the term structure is traversed
   364 
   353   from left to right.
   365   \item \verb|betapply|~\isa{{\isacharparenleft}t{\isacharcomma}\ u{\isacharparenright}} produces an application \isa{t\ u}, with topmost \isa{{\isasymbeta}}-conversion if \isa{t} is an
   354 
   366   abstraction.
   355   \item \verb|fastype_of|~\isa{t} recomputes the type of a
       
   356   well-formed term, while omitting any sanity checks.  This operation
       
   357   is relatively slow.
       
   358 
       
   359   \item \verb|lambda|~\isa{a\ b} produces an abstraction \isa{{\isasymlambda}a{\isachardot}\ b}, where occurrences of the original (atomic) term \isa{a} in the body \isa{b} are replaced by bound variables.
       
   360 
       
   361   \item \verb|betapply|~\isa{t\ u} produces an application \isa{t\ u}, with topmost \isa{{\isasymbeta}}-conversion if \isa{t} happens to
       
   362   be an abstraction.
       
   363 
   367 
   364   \item \verb|Sign.add_consts_i|~\isa{{\isacharbrackleft}{\isacharparenleft}c{\isacharcomma}\ {\isasymsigma}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}} declares a
   368   \item \verb|Sign.add_consts_i|~\isa{{\isacharbrackleft}{\isacharparenleft}c{\isacharcomma}\ {\isasymsigma}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}} declares a
   365   new constant \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} with optional mixfix syntax.
   369   new constant \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}} with optional mixfix syntax.
   366 
   370 
   367   \item \verb|Sign.add_abbrevs|~\isa{print{\isacharunderscore}mode\ {\isacharbrackleft}{\isacharparenleft}{\isacharparenleft}c{\isacharcomma}\ t{\isacharparenright}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}}
   371   \item \verb|Sign.add_abbrevs|~\isa{print{\isacharunderscore}mode\ {\isacharbrackleft}{\isacharparenleft}{\isacharparenleft}c{\isacharcomma}\ t{\isacharparenright}{\isacharcomma}\ mx{\isacharparenright}{\isacharcomma}\ {\isasymdots}{\isacharbrackright}}
   368   declares a new term abbreviation \isa{c\ {\isasymequiv}\ t} with optional
   372   declares a new term abbreviation \isa{c\ {\isasymequiv}\ t} with optional
   369   mixfix syntax.
   373   mixfix syntax.
   370 
   374 
   371   \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}}
   375   \item \verb|Sign.const_typargs|~\isa{thy\ {\isacharparenleft}c{\isacharcomma}\ {\isasymtau}{\isacharparenright}} and \verb|Sign.const_instance|~\isa{thy\ {\isacharparenleft}c{\isacharcomma}\ {\isacharbrackleft}{\isasymtau}\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymtau}\isactrlisub n{\isacharbrackright}{\isacharparenright}}
   372   convert between the two representations of constants, namely full
   376   convert between the representations of polymorphic constants: the
   373   type instance vs.\ compact type arguments form (depending on the
   377   full type instance vs.\ the compact type arguments form (depending
   374   most general declaration given in the context).
   378   on the most general declaration given in the context).
   375 
   379 
   376   \end{description}%
   380   \end{description}%
   377 \end{isamarkuptext}%
   381 \end{isamarkuptext}%
   378 \isamarkuptrue%
   382 \isamarkuptrue%
   379 %
   383 %
   425   different variables is their binding scope. FIXME}
   429   different variables is their binding scope. FIXME}
   426 
   430 
   427   A \emph{proposition} is a well-formed term of type \isa{prop}, a
   431   A \emph{proposition} is a well-formed term of type \isa{prop}, a
   428   \emph{theorem} is a proven proposition (depending on a context of
   432   \emph{theorem} is a proven proposition (depending on a context of
   429   hypotheses and the background theory).  Primitive inferences include
   433   hypotheses and the background theory).  Primitive inferences include
   430   plain natural deduction rules for the primary connectives \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}} of the framework.  There are separate (derived)
   434   plain natural deduction rules for the primary connectives \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}} of the framework.  There is also a builtin
   431   rules for equality/equivalence \isa{{\isasymequiv}} and internal conjunction
   435   notion of equality/equivalence \isa{{\isasymequiv}}.%
   432   \isa{{\isacharampersand}}.%
   436 \end{isamarkuptext}%
   433 \end{isamarkuptext}%
   437 \isamarkuptrue%
   434 \isamarkuptrue%
   438 %
   435 %
   439 \isamarkupsubsection{Primitive connectives and rules%
   436 \isamarkupsubsection{Standard connectives and rules%
       
   437 }
   440 }
   438 \isamarkuptrue%
   441 \isamarkuptrue%
   439 %
   442 %
   440 \begin{isamarkuptext}%
   443 \begin{isamarkuptext}%
   441 The basic theory is called \isa{Pure}, it contains declarations
   444 The theory \isa{Pure} contains declarations for the standard
   442   for the standard logical connectives \isa{{\isasymAnd}}, \isa{{\isasymLongrightarrow}}, and
   445   connectives \isa{{\isasymAnd}}, \isa{{\isasymLongrightarrow}}, and \isa{{\isasymequiv}} of the logical
   443   \isa{{\isasymequiv}} of the framework, see \figref{fig:pure-connectives}.
   446   framework, see \figref{fig:pure-connectives}.  The derivability
   444   The derivability judgment \isa{A\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ A\isactrlisub n\ {\isasymturnstile}\ B} is
   447   judgment \isa{A\isactrlisub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ A\isactrlisub n\ {\isasymturnstile}\ B} is defined
   445   defined inductively by the primitive inferences given in
   448   inductively by the primitive inferences given in
   446   \figref{fig:prim-rules}, with the global syntactic restriction that
   449   \figref{fig:prim-rules}, with the global restriction that hypotheses
   447   hypotheses may never contain schematic variables.  The builtin
   450   \isa{{\isasymGamma}} may \emph{not} contain schematic variables.  The builtin
   448   equality is conceptually axiomatized shown in
   451   equality is conceptually axiomatized as shown in
   449   \figref{fig:pure-equality}, although the implementation works
   452   \figref{fig:pure-equality}, although the implementation works
   450   directly with (derived) inference rules.
   453   directly with derived inference rules.
   451 
   454 
   452   \begin{figure}[htb]
   455   \begin{figure}[htb]
   453   \begin{center}
   456   \begin{center}
   454   \begin{tabular}{ll}
   457   \begin{tabular}{ll}
   455   \isa{all\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}{\isasymalpha}\ {\isasymRightarrow}\ prop{\isacharparenright}\ {\isasymRightarrow}\ prop} & universal quantification (binder \isa{{\isasymAnd}}) \\
   458   \isa{all\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}{\isasymalpha}\ {\isasymRightarrow}\ prop{\isacharparenright}\ {\isasymRightarrow}\ prop} & universal quantification (binder \isa{{\isasymAnd}}) \\
   456   \isa{{\isasymLongrightarrow}\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop\ {\isasymRightarrow}\ prop} & implication (right associative infix) \\
   459   \isa{{\isasymLongrightarrow}\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop\ {\isasymRightarrow}\ prop} & implication (right associative infix) \\
   457   \isa{{\isasymequiv}\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}\ {\isasymRightarrow}\ prop} & equality relation (infix) \\
   460   \isa{{\isasymequiv}\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ {\isasymalpha}\ {\isasymRightarrow}\ prop} & equality relation (infix) \\
   458   \end{tabular}
   461   \end{tabular}
   459   \caption{Standard connectives of Pure}\label{fig:pure-connectives}
   462   \caption{Primitive connectives of Pure}\label{fig:pure-connectives}
   460   \end{center}
   463   \end{center}
   461   \end{figure}
   464   \end{figure}
   462 
   465 
   463   \begin{figure}[htb]
   466   \begin{figure}[htb]
   464   \begin{center}
   467   \begin{center}
   466   \infer[\isa{{\isacharparenleft}axiom{\isacharparenright}}]{\isa{{\isasymturnstile}\ A}}{\isa{A\ {\isasymin}\ {\isasymTheta}}}
   469   \infer[\isa{{\isacharparenleft}axiom{\isacharparenright}}]{\isa{{\isasymturnstile}\ A}}{\isa{A\ {\isasymin}\ {\isasymTheta}}}
   467   \qquad
   470   \qquad
   468   \infer[\isa{{\isacharparenleft}assume{\isacharparenright}}]{\isa{A\ {\isasymturnstile}\ A}}{}
   471   \infer[\isa{{\isacharparenleft}assume{\isacharparenright}}]{\isa{A\ {\isasymturnstile}\ A}}{}
   469   \]
   472   \]
   470   \[
   473   \[
   471   \infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}intro{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ b\ x}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ b\ x} & \isa{x\ {\isasymnotin}\ {\isasymGamma}}}
   474   \infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}intro{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ b{\isacharbrackleft}x{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ b{\isacharbrackleft}x{\isacharbrackright}} & \isa{x\ {\isasymnotin}\ {\isasymGamma}}}
   472   \qquad
   475   \qquad
   473   \infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}elim{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ b\ a}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ b\ x}}
   476   \infer[\isa{{\isacharparenleft}{\isasymAnd}{\isacharunderscore}elim{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isasymturnstile}\ b{\isacharbrackleft}a{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ b{\isacharbrackleft}x{\isacharbrackright}}}
   474   \]
   477   \]
   475   \[
   478   \[
   476   \infer[\isa{{\isacharparenleft}{\isasymLongrightarrow}{\isacharunderscore}intro{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isacharminus}\ A\ {\isasymturnstile}\ A\ {\isasymLongrightarrow}\ B}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B}}
   479   \infer[\isa{{\isacharparenleft}{\isasymLongrightarrow}{\isacharunderscore}intro{\isacharparenright}}]{\isa{{\isasymGamma}\ {\isacharminus}\ A\ {\isasymturnstile}\ A\ {\isasymLongrightarrow}\ B}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B}}
   477   \qquad
   480   \qquad
   478   \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}}
   481   \infer[\isa{{\isacharparenleft}{\isasymLongrightarrow}{\isacharunderscore}elim{\isacharparenright}}]{\isa{{\isasymGamma}\isactrlsub {\isadigit{1}}\ {\isasymunion}\ {\isasymGamma}\isactrlsub {\isadigit{2}}\ {\isasymturnstile}\ B}}{\isa{{\isasymGamma}\isactrlsub {\isadigit{1}}\ {\isasymturnstile}\ A\ {\isasymLongrightarrow}\ B} & \isa{{\isasymGamma}\isactrlsub {\isadigit{2}}\ {\isasymturnstile}\ A}}
   482   \end{figure}
   485   \end{figure}
   483 
   486 
   484   \begin{figure}[htb]
   487   \begin{figure}[htb]
   485   \begin{center}
   488   \begin{center}
   486   \begin{tabular}{ll}
   489   \begin{tabular}{ll}
   487   \isa{{\isasymturnstile}\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ b\ x{\isacharparenright}\ a\ {\isasymequiv}\ b\ a} & \isa{{\isasymbeta}}-conversion \\
   490   \isa{{\isasymturnstile}\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ b{\isacharbrackleft}x{\isacharbrackright}{\isacharparenright}\ a\ {\isasymequiv}\ b{\isacharbrackleft}a{\isacharbrackright}} & \isa{{\isasymbeta}}-conversion \\
   488   \isa{{\isasymturnstile}\ x\ {\isasymequiv}\ x} & reflexivity \\
   491   \isa{{\isasymturnstile}\ x\ {\isasymequiv}\ x} & reflexivity \\
   489   \isa{{\isasymturnstile}\ x\ {\isasymequiv}\ y\ {\isasymLongrightarrow}\ P\ x\ {\isasymLongrightarrow}\ P\ y} & substitution \\
   492   \isa{{\isasymturnstile}\ x\ {\isasymequiv}\ y\ {\isasymLongrightarrow}\ P\ x\ {\isasymLongrightarrow}\ P\ y} & substitution \\
   490   \isa{{\isasymturnstile}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ f\ x\ {\isasymequiv}\ g\ x{\isacharparenright}\ {\isasymLongrightarrow}\ f\ {\isasymequiv}\ g} & extensionality \\
   493   \isa{{\isasymturnstile}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ f\ x\ {\isasymequiv}\ g\ x{\isacharparenright}\ {\isasymLongrightarrow}\ f\ {\isasymequiv}\ g} & extensionality \\
   491   \isa{{\isasymturnstile}\ {\isacharparenleft}A\ {\isasymLongrightarrow}\ B{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}B\ {\isasymLongrightarrow}\ A{\isacharparenright}\ {\isasymLongrightarrow}\ A\ {\isasymequiv}\ B} & coincidence with equivalence \\
   494   \isa{{\isasymturnstile}\ {\isacharparenleft}A\ {\isasymLongrightarrow}\ B{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}B\ {\isasymLongrightarrow}\ A{\isacharparenright}\ {\isasymLongrightarrow}\ A\ {\isasymequiv}\ B} & logical equivalence \\
   492   \end{tabular}
   495   \end{tabular}
   493   \caption{Conceptual axiomatization of builtin equality}\label{fig:pure-equality}
   496   \caption{Conceptual axiomatization of \isa{{\isasymequiv}}}\label{fig:pure-equality}
   494   \end{center}
   497   \end{center}
   495   \end{figure}
   498   \end{figure}
   496 
   499 
   497   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
   500   The introduction and elimination rules for \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}} are analogous to formation of dependently typed \isa{{\isasymlambda}}-terms representing the underlying proof objects.  Proof terms
   498   are \emph{irrelevant} in the Pure logic, they may never occur within
   501   are irrelevant in the Pure logic, though, they may never occur
   499   propositions, i.e.\ the \isa{{\isasymLongrightarrow}} arrow is non-dependent.  The
   502   within propositions.  The system provides a runtime option to record
   500   system provides a runtime option to record explicit proof terms for
   503   explicit proof terms for primitive inferences.  Thus all three
   501   primitive inferences, cf.\ \cite{Berghofer-Nipkow:2000:TPHOL}.  Thus
   504   levels of \isa{{\isasymlambda}}-calculus become explicit: \isa{{\isasymRightarrow}} for
   502   the three-fold \isa{{\isasymlambda}}-structure can be made explicit.
   505   terms, and \isa{{\isasymAnd}{\isacharslash}{\isasymLongrightarrow}} for proofs (cf.\
   503 
   506   \cite{Berghofer-Nipkow:2000:TPHOL}).
   504   Observe that locally fixed parameters (as used in rule \isa{{\isasymAnd}{\isacharunderscore}intro}) need not be recorded in the hypotheses, because the
   507 
   505   simple syntactic types of Pure are always inhabitable.  The typing
   508   Observe that locally fixed parameters (as in \isa{{\isasymAnd}{\isacharunderscore}intro}) need
   506   ``assumption'' \isa{x\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}} is logically vacuous, it disappears
   509   not be recorded in the hypotheses, because the simple syntactic
   507   automatically whenever the statement body ceases to mention variable
   510   types of Pure are always inhabitable.  Typing ``assumptions'' \isa{x\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}} are (implicitly) present only with occurrences of \isa{x\isactrlisub {\isasymtau}} in the statement body.\footnote{This is the key
   508   \isa{x\isactrlisub {\isasymtau}}.\footnote{This greatly simplifies many basic
   511   difference ``\isa{{\isasymlambda}HOL}'' in the PTS framework
   509   reasoning steps, and is the key difference to the formulation of
   512   \cite{Barendregt-Geuvers:2001}, where \isa{x\ {\isacharcolon}\ A} hypotheses are
   510   this logic as ``\isa{{\isasymlambda}HOL}'' in the PTS framework
   513   treated explicitly for types, in the same way as propositions.}
   511   \cite{Barendregt-Geuvers:2001}.}
       
   512 
   514 
   513   \medskip FIXME \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence and primitive definitions
   515   \medskip FIXME \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence and primitive definitions
   514 
   516 
   515   Since the basic representation of terms already accounts for \isa{{\isasymalpha}}-conversion, Pure equality essentially acts like \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence on terms, while coinciding with bi-implication.
   517   Since the basic representation of terms already accounts for \isa{{\isasymalpha}}-conversion, Pure equality essentially acts like \isa{{\isasymalpha}{\isasymbeta}{\isasymeta}}-equivalence on terms, while coinciding with bi-implication.
   516 
   518 
   517   \medskip The axiomatization of a theory is implicitly closed by
   519   \medskip The axiomatization of a theory is implicitly closed by
   518   forming all instances of type and term variables: \isa{{\isasymturnstile}\ A{\isasymvartheta}} for
   520   forming all instances of type and term variables: \isa{{\isasymturnstile}\ A{\isasymvartheta}} holds for any substitution instance of an axiom
   519   any substitution instance of axiom \isa{{\isasymturnstile}\ A}.  By pushing
   521   \isa{{\isasymturnstile}\ A}.  By pushing substitution through derivations
   520   substitution through derivations inductively, we get admissible
   522   inductively, we get admissible \isa{generalize} and \isa{instance} rules shown in \figref{fig:subst-rules}.
   521   substitution rules for theorems shown in \figref{fig:subst-rules}.
       
   522   Alternatively, the term substitution rules could be derived from
       
   523   \isa{{\isasymAnd}{\isacharunderscore}intro{\isacharslash}elim}.  The versions for types are genuine
       
   524   admissible rules, due to the lack of true polymorphism in the logic.
       
   525 
   523 
   526   \begin{figure}[htb]
   524   \begin{figure}[htb]
   527   \begin{center}
   525   \begin{center}
   528   \[
   526   \[
   529   \infer{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isacharquery}{\isasymalpha}{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isasymalpha}{\isacharbrackright}} & \isa{{\isasymalpha}\ {\isasymnotin}\ {\isasymGamma}}}
   527   \infer{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isacharquery}{\isasymalpha}{\isacharbrackright}}}{\isa{{\isasymGamma}\ {\isasymturnstile}\ B{\isacharbrackleft}{\isasymalpha}{\isacharbrackright}} & \isa{{\isasymalpha}\ {\isasymnotin}\ {\isasymGamma}}}
   537   \]
   535   \]
   538   \caption{Admissible substitution rules}\label{fig:subst-rules}
   536   \caption{Admissible substitution rules}\label{fig:subst-rules}
   539   \end{center}
   537   \end{center}
   540   \end{figure}
   538   \end{figure}
   541 
   539 
   542   Since \isa{{\isasymGamma}} may never contain any schematic variables, the
   540   Note that \isa{instantiate} does not require an explicit
   543   \isa{instantiate} do not require an explicit side-condition.  In
   541   side-condition, because \isa{{\isasymGamma}} may never contain schematic
   544   principle, variables could be substituted in hypotheses as well, but
   542   variables.
   545   this could disrupt monotonicity of the basic calculus: derivations
   543 
   546   could leave the current proof context.%
   544   In principle, variables could be substituted in hypotheses as well,
       
   545   but this would disrupt monotonicity reasoning: deriving \isa{{\isasymGamma}{\isasymvartheta}\ {\isasymturnstile}\ B{\isasymvartheta}} from \isa{{\isasymGamma}\ {\isasymturnstile}\ B} is correct, but
       
   546   \isa{{\isasymGamma}{\isasymvartheta}\ {\isasymsupseteq}\ {\isasymGamma}} does not necessarily hold --- the result
       
   547   belongs to a different proof context.%
   547 \end{isamarkuptext}%
   548 \end{isamarkuptext}%
   548 \isamarkuptrue%
   549 \isamarkuptrue%
   549 %
   550 %
   550 \isadelimmlref
   551 \isadelimmlref
   551 %
   552 %
   582 \isamarkupsubsection{Auxiliary connectives%
   583 \isamarkupsubsection{Auxiliary connectives%
   583 }
   584 }
   584 \isamarkuptrue%
   585 \isamarkuptrue%
   585 %
   586 %
   586 \begin{isamarkuptext}%
   587 \begin{isamarkuptext}%
   587 Pure also provides various auxiliary connectives based on primitive
   588 Theory \isa{Pure} also defines a few auxiliary connectives, see
   588   definitions, see \figref{fig:pure-aux}.  These are normally not
   589   \figref{fig:pure-aux}.  These are normally not exposed to the user,
   589   exposed to the user, but appear in internal encodings only.
   590   but appear in internal encodings only.
   590 
   591 
   591   \begin{figure}[htb]
   592   \begin{figure}[htb]
   592   \begin{center}
   593   \begin{center}
   593   \begin{tabular}{ll}
   594   \begin{tabular}{ll}
   594   \isa{conjunction\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop\ {\isasymRightarrow}\ prop} & (infix \isa{{\isacharampersand}}) \\
   595   \isa{conjunction\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop\ {\isasymRightarrow}\ prop} & (infix \isa{{\isacharampersand}}) \\
   595   \isa{{\isasymturnstile}\ A\ {\isacharampersand}\ B\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}C{\isachardot}\ {\isacharparenleft}A\ {\isasymLongrightarrow}\ B\ {\isasymLongrightarrow}\ C{\isacharparenright}\ {\isasymLongrightarrow}\ C{\isacharparenright}} \\[1ex]
   596   \isa{{\isasymturnstile}\ A\ {\isacharampersand}\ B\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}C{\isachardot}\ {\isacharparenleft}A\ {\isasymLongrightarrow}\ B\ {\isasymLongrightarrow}\ C{\isacharparenright}\ {\isasymLongrightarrow}\ C{\isacharparenright}} \\[1ex]
   596   \isa{prop\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop} & (prefix \isa{{\isacharhash}}) \\
   597   \isa{prop\ {\isacharcolon}{\isacharcolon}\ prop\ {\isasymRightarrow}\ prop} & (prefix \isa{{\isacharhash}}, hidden) \\
   597   \isa{{\isacharhash}A\ {\isasymequiv}\ A} \\[1ex]
   598   \isa{{\isacharhash}A\ {\isasymequiv}\ A} \\[1ex]
   598   \isa{term\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ prop} & (prefix \isa{TERM}) \\
   599   \isa{term\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymRightarrow}\ prop} & (prefix \isa{TERM}) \\
   599   \isa{term\ x\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}A{\isachardot}\ A\ {\isasymLongrightarrow}\ A{\isacharparenright}} \\[1ex]
   600   \isa{term\ x\ {\isasymequiv}\ {\isacharparenleft}{\isasymAnd}A{\isachardot}\ A\ {\isasymLongrightarrow}\ A{\isacharparenright}} \\[1ex]
   600   \isa{TYPE\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ itself} & (prefix \isa{TYPE}) \\
   601   \isa{TYPE\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ itself} & (prefix \isa{TYPE}) \\
   601   \isa{{\isacharparenleft}unspecified{\isacharparenright}} \\
   602   \isa{{\isacharparenleft}unspecified{\isacharparenright}} \\
   602   \end{tabular}
   603   \end{tabular}
   603   \caption{Definitions of auxiliary connectives}\label{fig:pure-aux}
   604   \caption{Definitions of auxiliary connectives}\label{fig:pure-aux}
   604   \end{center}
   605   \end{center}
   605   \end{figure}
   606   \end{figure}
   606 
   607 
   607   Conjunction as an explicit connective allows to treat both
   608   Derived conjunction rules include introduction \isa{A\ {\isasymLongrightarrow}\ B\ {\isasymLongrightarrow}\ A\ {\isacharampersand}\ B}, and destructions \isa{A\ {\isacharampersand}\ B\ {\isasymLongrightarrow}\ A} and \isa{A\ {\isacharampersand}\ B\ {\isasymLongrightarrow}\ B}.
   608   simultaneous assumptions and conclusions uniformly.  The definition
   609   Conjunction allows to treat simultaneous assumptions and conclusions
   609   allows to derive the usual introduction \isa{{\isasymturnstile}\ A\ {\isasymLongrightarrow}\ B\ {\isasymLongrightarrow}\ A\ {\isacharampersand}\ B},
   610   uniformly.  For example, multiple claims are intermediately
   610   and destructions \isa{A\ {\isacharampersand}\ B\ {\isasymLongrightarrow}\ A} and \isa{A\ {\isacharampersand}\ B\ {\isasymLongrightarrow}\ B}.  For
   611   represented as explicit conjunction, but this is usually refined
   611   example, several claims may be stated at the same time, which is
   612   into separate sub-goals before the user continues the proof; the
   612   intermediately represented as an assumption, but the user only
   613   final result is projected into a list of theorems (cf.\
   613   encounters several sub-goals, and several resulting facts in the
   614   \secref{sec:tactical-goals}).
   614   very end (cf.\ \secref{sec:tactical-goals}).
   615 
   615 
   616   The \isa{prop} marker (\isa{{\isacharhash}}) makes arbitrarily complex
   616   The \isa{{\isacharhash}} marker allows complex propositions (nested \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}}) to appear formally as atomic, without changing
   617   propositions appear as atomic, without changing the meaning: \isa{{\isasymGamma}\ {\isasymturnstile}\ A} and \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isacharhash}A} are interchangeable.  See
   617   the meaning: \isa{{\isasymGamma}\ {\isasymturnstile}\ A} and \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isacharhash}A} are
   618   \secref{sec:tactical-goals} for specific operations.
   618   interchangeable.  See \secref{sec:tactical-goals} for specific
   619 
   619   operations.
   620   The \isa{term} marker turns any well-formed term into a
   620 
   621   derivable proposition: \isa{{\isasymturnstile}\ TERM\ t} holds unconditionally.
   621   The \isa{TERM} marker turns any well-formed term into a
   622   Although this is logically vacuous, it allows to treat terms and
   622   derivable proposition: \isa{{\isasymturnstile}\ TERM\ t} holds
   623   proofs uniformly, similar to a type-theoretic framework.
   623   unconditionally.  Despite its logically vacous meaning, this is
   624 
   624   occasionally useful to treat syntactic terms and proven propositions
   625   The \isa{TYPE} constructor is the canonical representative of
   625   uniformly, as in a type-theoretic framework.
   626   the unspecified type \isa{{\isasymalpha}\ itself}; it essentially injects the
   626 
   627   language of types into that of terms.  There is specific notation
   627   The \isa{TYPE} constructor (which is the canonical
   628   \isa{TYPE{\isacharparenleft}{\isasymtau}{\isacharparenright}} for \isa{TYPE\isactrlbsub {\isasymtau}\ itself\isactrlesub }.
   628   representative of the unspecified type \isa{{\isasymalpha}\ itself}) injects
   629   Although being devoid of any particular meaning, the \isa{TYPE{\isacharparenleft}{\isasymtau}{\isacharparenright}} accounts for the type \isa{{\isasymtau}} within the term
   629   the language of types into that of terms.  There is specific
   630   language.  In particular, \isa{TYPE{\isacharparenleft}{\isasymalpha}{\isacharparenright}} may be used as formal
   630   notation \isa{TYPE{\isacharparenleft}{\isasymtau}{\isacharparenright}} for \isa{TYPE\isactrlbsub {\isasymtau}\ itself\isactrlesub }.
   631   argument in primitive definitions, in order to circumvent hidden
   631   Although being devoid of any particular meaning, the term \isa{TYPE{\isacharparenleft}{\isasymtau}{\isacharparenright}} is able to carry the type \isa{{\isasymtau}} formally.  \isa{TYPE{\isacharparenleft}{\isasymalpha}{\isacharparenright}} may be used as an additional formal argument in primitive
   632   polymorphism (cf.\ \secref{sec:terms}).  For example, \isa{c\ TYPE{\isacharparenleft}{\isasymalpha}{\isacharparenright}\ {\isasymequiv}\ A{\isacharbrackleft}{\isasymalpha}{\isacharbrackright}} defines \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ itself\ {\isasymRightarrow}\ prop} in terms of
   632   definitions, in order to avoid hidden polymorphism (cf.\
   633   a proposition \isa{A} that depends on an additional type
   633   \secref{sec:terms}).  For example, \isa{c\ TYPE{\isacharparenleft}{\isasymalpha}{\isacharparenright}\ {\isasymequiv}\ A{\isacharbrackleft}{\isasymalpha}{\isacharbrackright}} turns
   634   argument, which is essentially a predicate on types.%
   634   out as a formally correct definition of some proposition \isa{A}
       
   635   that depends on an additional type argument.%
       
   636 \end{isamarkuptext}%
   635 \end{isamarkuptext}%
   637 \isamarkuptrue%
   636 \isamarkuptrue%
   638 %
   637 %
   639 \isadelimmlref
   638 \isadelimmlref
   640 %
   639 %