Quelle HOL_Specific.thy
Sprache: Isabelle
|
|
(*:maxLineLen=78:*)
theory HOL_Specific
imports
Main
"HOL-Library.Old_Datatype"
"HOL-Library.Old_Recdef"
"HOL-Library.Dlist"
"HOL-Library.FSet"
Base
begin
chapter ‹Higher-Order Logic›
text ‹
Isabelle/HOL is based on Higher-Order Logic, a polymorphic version of
Church's Simple Theory of Types. HOL can be best understood as a
simply-typed version of classical set theory. The logic was first
implemented in Gordon's HOL system cite‹"mgordon-hol"›. It extends
Church's original logic cite‹"church40"› by explicit type variables (naive
polymorphism) and a sound axiomatization scheme for new types based on
subsets of existing types.
Andrews's book cite‹andrews86› is a full description of the original
Church-style higher-order logic, with proofs of correctness and completeness
wrt.\ certain set-theoretic interpretations. The particular extensions of
Gordon-style HOL are explained semantically in two chapters of the 1993 HOL
book cite‹pitts93›.
Experience with HOL over decades has demonstrated that higher-order logic is
widely applicable in many areas of mathematics and computer science. In a
sense, Higher-Order Logic is simpler than First-Order Logic, because there
are fewer restrictions and special cases. Note that HOL is ∗‹weaker› than
FOL with axioms for ZF set theory, which is traditionally considered the
standard foundation of regular mathematics, but for most applications this
does not matter. If you prefer ML to Lisp, you will probably prefer HOL to
ZF.
┉ The syntax of HOL follows ‹λ›-calculus and functional programming.
Function application is curried. To apply the function ‹f› of type ‹τ1 →
τ2 → τ3› to the arguments ‹a› and ‹b› in HOL, you simply write ‹f a b› (as
in ML or Haskell). There is no ``apply'' operator; the existing application
of the Pure ‹λ›-calculus is re-used. Note that in HOL ‹f (a, b)› means ``‹f›
applied to the pair ‹(a, b)› (which is notation for ‹Pair a b›). The latter
typically introduces extra formal efforts that can be avoided by currying
functions by default. Explicit tuples are as infrequent in HOL
formalizations as in good ML or Haskell programs.
┉ Isabelle/HOL has a distinct feel, compared to other object-logics like
Isabelle/ZF. It identifies object-level types with meta-level types, taking
advantage of the default type-inference mechanism of Isabelle/Pure. HOL
fully identifies object-level functions with meta-level functions, with
native abstraction and application.
These identifications allow Isabelle to support HOL particularly nicely, but
they also mean that HOL requires some sophistication from the user. In
particular, an understanding of Hindley-Milner type-inference with
type-classes, which are both used extensively in the standard libraries and
applications.
›
chapter ‹Derived specification elements›
section ‹Inductive and coinductive definitions \label{sec:hol-inductive}›
text ‹
\begin{matharray}{rcl}
@{command_def (HOL) "inductive"} & : & ‹local_theory → local_theory› \\
@{command_def (HOL) "inductive_set"} & : & ‹local_theory → local_theory› \\
@{command_def (HOL) "coinductive"} & : & ‹local_theory → local_theory› \\
@{command_def (HOL) "coinductive_set"} & : & ‹local_theory → local_theory› \\
@{command_def "print_inductives"}‹*› & : & ‹context →› \\
@{attribute_def (HOL) mono} & : & ‹attribute› \\
\end{matharray}
An ∗‹inductive definition› specifies the least predicate or set ‹R› closed
under given rules: applying a rule to elements of ‹R› yields a result within
‹R›. For example, a structural operational semantics is an inductive
definition of an evaluation relation.
Dually, a ∗‹coinductive definition› specifies the greatest predicate or set
‹R› that is consistent with given rules: every element of ‹R› can be seen as
arising by applying a rule to elements of ‹R›. An important example is using
bisimulation relations to formalise equivalence of processes and infinite
data structures.
Both inductive and coinductive definitions are based on the Knaster-Tarski
fixed-point theorem for complete lattices. The collection of introduction
rules given by the user determines a functor on subsets of set-theoretic
relations. The required monotonicity of the recursion scheme is proven as a
prerequisite to the fixed-point definition and the resulting consequences.
This works by pushing inclusion through logical connectives and any other
operator that might be wrapped around recursive occurrences of the defined
relation: there must be a monotonicity theorem of the form \<open>A \<le> B \<Longrightarrow> \<M> A \<le> \<M>
B\<close>, for each premise \<open>\<M> R t\<close> in an introduction rule. The default rule
declarations of Isabelle/HOL already take care of most common situations.
\<^rail>\<open>
(@@{command (HOL) inductive} | @@{command (HOL) inductive_set} |
@@{command (HOL) coinductive} | @@{command (HOL) coinductive_set})
@{syntax vars} @{syntax for_fixes} \<newline>
(@'where' @{syntax multi_specs})? (@'monos' @{syntax thms})?
;
@@{command print_inductives} ('!'?)
;
@@{attribute (HOL) mono} (() | 'add' | 'del')
\<close>
\<^descr> @{command (HOL) "inductive"} and @{command (HOL) "coinductive"} define
(co)inductive predicates from the introduction rules.
The propositions given as \<open>clauses\<close> in the @{keyword "where"} part are
either rules of the usual \<open>\<And>/\<Longrightarrow>\<close> format (with arbitrary nesting), or
equalities using \<open>\<equiv>\<close>. The latter specifies extra-logical abbreviations in
the sense of @{command_ref abbreviation}. Introducing maxLineLen=8*)
simultaneously with theactual introduction rules is occasionally useful for
complex specifications.
The optional @{keyword "for"} part contains a list of parameters of the
(coinductive predicates that remain fixed throughout the definition, in
contrast to arguments of the relation that may vary in each occurrence
thegiven <>\<close>.
The optional @{keyword "monos"} declaration contains additional
\<^emph>\<open>monotonicity java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 28
r injava.lang.StringIndexOutOfBoundsException: Range [42, 43) out of bounds for length 42
L "nductive_set" and {command HOL) coinductive_set"}
are wrappers for to the previous commands for native HOL predicates. This
allows to define (co)inductive sets, where multiple arguments are simulated
via tuples.
\<^descr> @{command "print_inductives"} prints (co)inductive definitions and
java.lang.StringIndexOutOfBoundsException: Range [43, 14) out of bounds for length 80
\<^descr> @{attribute (HOL) mono} declares monotonicity rules in the context. These
rule are involved in the automated monotonicity proof of the above inductive
and coinductive definitions.
\
subsection \<open>Derived rules\<close>
text \open>
A (co)inductive definition of \<open>R\<close> provides the following main theorems:
\<^descr> \<open>R.introstypically introduces formal that bycurrying
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 76
usingthe names giventhemthe file;
\<^descr> \<open>R.advantage of the default- mechanism of Isabelle/Pure. HOL
\<^descrbstraction and application.
<descr>\open>R.simps\close>is the equation unrolling the fixpoint of the predicate one
stepjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
When several predicates \<open>R\<^sub>1, \<dots>, R\<^sub>n\<close> <open>
of introductionrules is called \<open>R\<^sub>1_\<dots>_R\<^sub>n.intros\<close>, the case analysis rules
are called \<open>R\<^sub>1.cases, \<dots>, R\<^@{command_def (HOL) "inductive_set"} & : & \<open>local_theory \<command_def (HOL) "coinductive"} & : & \<open>local_theory \<rightarrow> local_theory\<close> \\
is called \<open>R\ {command_def "rint_inductives"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
\close>
subsection given rules:applyingatojava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 91
text <open>
The context maintains a of theorems that areusedin
city proofs. Newrules can be declared via the @{attribute (HOL)
mono} attribute. See the main Isabelle/HOL sources for some examples. The
general format of such monotonicity theorems is as follows:
\<^item> Theorems of the form \<open>A \<le> B \<Longrightarrow> \ bisimulation relations to formalise equivalence of processes and infinite
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
such fixed-point theorem for complete lattices. The collection of introduction
\^item> Monotonicity theorems for logical operators, which are of the general form
prerequisitetothe fixed- definitionandthe java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 76
the operator that mig be around recursive java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 0
\[
infer\<>P\<^sub> \or> P<sub>2 \longrightarrow>Q\<sub> <or>Q^>\close>{<open>P<sub>1\longrightarrow> Q\<^sub>1\<close> & \<open>P\<^sub>2 \<longrightarrow> Q\<^sub>2\<close>}
\]
\<^item> De Morgan style equations for reasoning about the ``polarity'' of
\
\^rop>\<pen>\<ot> <not> P \<longleftrightarrow> P\<close> \qquad\qquad
\<^prop>\<open>\<not> (P \<and> Q) \<longleftrightarrow> \<not> P \<or> \<notjava.lang.StringIndexOutOfBoundsException: Range [79, 80) out of bounds for length 25
\]
\<^item> Equations for reducing complex operators to more primitive ones whose
monotonicity can easily be proved, e.g.
\[
\<^prop><pen>P \<longrightarrow> Q) \<longleftrightarrow> \<not> P \<or> Q\<close> \qquad\qquad
\<prop\<>BallA\equiv>\forall>x. <in>A\longrightarrow>P \<close>
\]
\<java.lang.StringIndexOutOfBoundsException: Range [2, 7) out of bounds for length 0
subsubsection \<open>Examples\<close>
text \<open>The finite powerset operator can be defined inductively like this:\<close>
(*<*)experiment begin(*>*)
inductive_set Fin :: "'a set \<Rightarrow> 'a set set" for A :: "'a set"
where
empty: "
| B \< Fin <Longrightarrow>insert B<>Fin"
\<openTaccessible a relation defined as:<close>
inductive acc :: "('a \<Rightarrow> 'a monotonicity proofs. New rules can be declared via the @{attribute (HOL)
for ::"a \Rightarrow'a \<Rightarrow> bool" (infix \<open>\<prec>\<close> 50)
where acc: "(\<And>y. y \<prec> x \<Longrightarrow> acc r y) \ formatof such monotonicitytheorems is as follows:
(*<)end**)
ext \open
Common as -
inductive definitions with parameters, but without arguments.
\<close>
(<*)experiment begin**)
inductive AND for A B ::bool
where "java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
inductive ORprop>\<open>(P \<longrightarrow> Q) \<longleftrightarrow> \<not> P \<or> Q\<close> \qquad\qquad
where "A \<Longrightarrow> OR A B"
| "B \<Longrightarrow> OR A B"
inductive EXISTS B :: "'a\<ightarrow>bool"
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
(*<*)end(*>*)
text \<open>
Here the \<open>cases\<close> or \<open>induct\<close> rules produced by the @{command inductive}
packagecoincide with the expected elimination rules for Natural Deduction.
Already in the original article by Gerhard Gentzen \<^cite
there is a hint | insert: "a \<in> A \<Longrightarrow> B \<in> Fin A \<Longrightarrow> insert a B \<in> Fin A"
introductions.
\<close>
section \<open>Recursive functions \label{sec:recursion}\<close>
text \<open>
\beginCommon logical connectives can be easily characterized as non-recursive
@{command_def (HOL<lose>
java.lang.StringIndexOutOfBoundsException: Range [15, 4) out of bounds for length 94
@{where "A \<Longrightarrow> B \<Longrightarrow> AND A B"
@{command_def (HOL) "termination"} & : & \<open>local_theory \<rightarrow> proof(prove)\<close> \\
@{command_def (HOL) "fun_cases"} & : & \<open>local_theory \<rightarrow> local_theory\<close> \\
\end{matharray}
\<^rail>\<open>
@@{command (HOL) primrec} @{syntax specification}
;
(@@{command (HOL) fun} | @@{command (HOL) function}) opts? @{syntax specification}
;
opts: '(' (('sequential' | 'domintros') + ',') ')'
;
@@{command (HOL) termination} @{syntax term}?
;
@@{command (HOL) fun_cases} (@{syntax thmdecl}? @{syntax prop} + @'and')
\<close>
\<^descr> @{command (HOL) "primrec"} defines primitive recursive functions over
datatypes (see also @{command_ref (HOL) datatype}). The given \<open>equations\<close>
specify reduction rules that are produced by instantiating the generic
combinator for primitive recursion that is available for each datatype.
Each equation needs to be of the form:
@{text [display] "f x\<^sub>1 \<dots> x\<^sub>m (C y\<^sub>1 \<dots> y\<^sub>k) z\<^sub>1 \<dots> z\<^sub>n = rhs"}
such that \<open>C\<close> is a datatype constructor, \<open>rhs\<close> contains only the free
variables on the left-hand side (or from the context), and all recursive
occurrences of \<open>f\<close> in \<open>rhs\<close> are of the form \<open>f \<dots> y\<^sub>i \<dots>\<close> for some \<open>i\<close>. At
most one reduction rule for each constructor can be given. The order does
not matter. For missing constructors, the function is defined to return a
default value, but this equation is made difficult to access for users.
The reduction rules are declared as @{attribute simp} by default, which
enables standard proof methods like @{method simp} and @{method auto} to
normalize expressions of \<open>f\<close> applied to datatype constructions, by
simulating symbolic computation via rewriting.
\<^descr> @{command (HOL) "function"} defines functions by general wellfounded
recursion. A detailed description with examples can be found in \<^cite>\<open>"isabelle-function"\<close>. The function is specified by a set of (possibly
conditional) recursive equations with arbitrary pattern matching. The
command generates proof obligations for the completeness and the
compatibility of patterns.
The defined function is considered partial, and the resulting simplification
rules (named \<open>f.psimps\<close>) and induction rule (named \<open>f.pinduct\<close>) are guarded
by a generated domain predicate \<open>f_dom\<close>. The @{command (HOL) "termination"}
command can then be used to establish that the function is total.
\<^descr> @{command (HOL) "fun"} is a java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
""B a \<Longrightarrow> B"
text \<open>
details.
\<^descr> @{command (HOL) "termination"}~\<open>f\<close> commences a termination proof for the
previously defined function <pen\close. this omitted, command refers tocommandrefers too
the most recent function definition. After the proof isite>\<open>"Gentzen:1935"\<close>
recursive equations and the induction principle established.
\<^descr> @{command (HOL) "fun_cases"} generates introductions, and the elimination can be constructed systematically.
unctionequations. It expects one or more function equations and produces
\<open>Recursive functions \label{sec:recursion}\<close>
function definition.
Recursive definitions introduced by the @{command (HOL) "function"} command
accommodate reasoning by induction (cf.\ @{method induct}): rule \<open>f.induct\<close>
refers to a specific induction rule, with parameters named according to the
ser-ommand_de> proof(prove)\<close>\\
(HOL) "primrec"}, the @{command_def (HOL) "fun_cases :&\open>local_theory \<rightarrow> local_theory\<close> \\
recursion on the datatype where the recursion is carried out.
equations provided by these packages may be referred later as theorem
list \<open>f.simps\<close>, where \<open>java.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 5
Individual equations may be named explicitly as well.
The @{command (HOL) "function"} command accepts the following options.
\<^descr> \<open>sequential\<close> enables a preprocessor which disambiguates overlapping
patterns by making them mutually disjoint. Earlier equations take precedence
over later ones. This allows to give the specification in a format very
similar to functional programming. Note that the resulting simplification
and induction rules correspond to the transformed specification, not the one
given originally. This usually means that each equation given by the user
may result in several theorems. Also note that this automatic transformation
only works for ML-style datatype patterns.
\<^descr> \<open>domintros\<close> enables the automated generation of introduction rules for the
domain predicate. While mostly not needed, they can be helpful in some
proofs about partial functions.
\<close>
subsubsection \<open>Example: evaluation of expressions\<close>
text \<open>
Subsequently, we define mutual datatypes for arithmetic and boolean
expressions, and use @{command primrec} for evaluation functions that follow
the same recursive structure.
\<close>
(*<*)experiment begin(*>*)
datatype 'a aexp =
IF "'a bexp" "'a aexp" "'a aexp"
| Sum "'a aexp" "'a aexp"
| Diff "'a aexp" "'a aexp"
| Var 'a
| Num nat
and 'a bexp =
Less "'a aexp" "'a aexp"
| And "'a bexp" "'a bexp"
| Neg "'a bexp"
text \<open>\<^medskip> Evaluation of arithmetic and boolean expressions\<close>
primrec evala :: "('a \<Rightarrow> nat) \<Rightarrow> 'a aexp \<Rightarrow> nat"
and evalb :: "('a \<Rightarrow> nat) \<Rightarrow> 'a bexp \<Rightarrow> bool"
where
"evala env (IF b a1 a2) = (if evalb env b then evala env a1 else evala env a2)"
| "evala env (Sum a1 a2) = evala env a1 + evala env a2"
| "evala env (Diff a1 a2) = evala env a1 - evala env a2"
| "evala env (Var v) = env v"
| "evala env (Num n) = n"
| "evalb env (Less a1 a2) = (evala env a1 < evala env a2)"
| "evalb env (And b1 b2) = (evalb env b1 \<and> evalb env b2)"
| "evalb env (Neg b) = (\<not> evalb env b)"
text \<open>
Since the value of an expression depends on the value of its variables, the
functions \<^const>\<open>evala\<close> and \<^const>\<open>evalb\<close> take an additional parameter, an
\<^emph>\<open>environment\<close> that maps variables to their values.
\<^medskip>
Substitution on expressions can be defined similarly. The mapping \<open>f\<close> of
type \<^typ>\<open>'a \<Rightarrow> 'a aexp\<close> given as a parameter is lifted canonically on the
types \<^typ>\<open>'a aexp\<close> nd \<typ\<open'a bexp\<,respectively.
\<close>
primrec substa :: "('a \<Rightarrow> 'b aexp) \<Rightarrow> 'a aexp \<Rightarrow> 'b aexp"
and substb :: "('a \<Rightarrow> 'b aexp) \<Rightarrow> 'a bexp \<Rightarrow> 'b bexp"
where
"substa f (IF b a1 a2) = IF (substb f b) (substa f a1) (substa f a2)"
| "substa f (Sum a1 a2) = Sum (substa f a1) (substa f a2)"
| "substa f (Diff a1 a2) = Diff (substa f a1) (substa f a2)"
| "substa f (Var v) = f v"
| "substa f (Num n) = Num n"
| "substb f (Less a1 a2) = Less (substa f a1) (substa f @@command (HOL) }@{yntax }?
| "substb f (And b1 b2) = And (substb f b1) (substb f b2)"
| "substb f (Neg b) = Neg (substb f b)"
text \<open>
In textbooks about semanticsdatatypes (see also @{command_ref (HOL) datatype}). The given \<open>equations\<close>
express the relationship between substitutioncombinator for primitive recursion that is available for each datatype.
exp<close>and\<typ\open>' bexp\<close>, we can prove such a theorem by mutual
by simplification.
\<close>
lemma subst_one:
"evala env (substa (Var (v := a')) a) = evala (env (v := evala env a')) a"
"evalb env (substb (Var (v := a')) b) = evalb (env (v := evala env a')) b"
by (induct a and b) simp_all
lemma subst_all:
"evala env (substa s a) = evala (\<lambda>x. evala env (s x)) a"
"evalb env (substb s b) = evalb (\<lambda>x. evala env (s x)) b"
by (induct a and b) simp_all
(*<*)end(*>*)
java.lang.StringIndexOutOfBoundsException: Range [59, 13) out of bounds for length 71
text \<open>Functions on datatypes with nested recursion are also defined
by mutual primitive recursion.\<close>
(*<*)experiment begin(*>*)
datatype ('a, 'b) "term" = Var 'a | App 'b "('a, 'b) term list"
text \<open>
A java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 87
follows, by working simultaneously on \<^typ>\<open>('a, 'b) term list\<close>:
\<close>
primrec subst_term :: "('a \<Rightarrow> ('a, 'b) term) \<Rightarrow> ('a, 'b) term \<Rightarrow> ('a, 'b) term" and
subst_term_list :: "('a \<Rightarrow> ('a, 'b) term) \<Rightarrow> ('a, 'b) term list \<Rightarrow> ('a, 'b) term list"
where
"subst_term f (Var a) = f a"
| "subst_term f (App b ts) = App b (subst_term_list f ts)"
| "subst_term_list f [] = []"
| "subst_term_list f (t # ts) = subst_term f t # subst_term_list f tsjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
text \<open>
The recursion scheme follows the structure of the unfolded definition of
type \<^typ>\<open>('a, 'b) term\<close>. To prove properties of this substitution
function, mutual induction is needed:
\<close>
lemma "subst_term (subst_term f1 \<circ> f2) t =
subst_term f1 (subst_term f2 t)" and
"subst_term_list (subst_term f1 \<circ> f2) ts =
subst_term_list f1 (subst_term_list f2 ts)"
by ( (induct t and ts rule: : subst_term.induct subst_term_list.induct) simp_all
(*<*)end(*>*)
subsubsection \<open>Example: a map function for infinitely branching trees\<close>
text \<open>Defining functions on infinitely branching user-specified equations. Cases are numbered starting from 1. For @{command
recursion is just as easy.\<close>
**experiment begin((*>
datatype 'a tree text\<open>
primrec map_tree :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a tree \<Rightarrow> 'b tree"
where
"map_tree f (Atom a) = Atom (f a)"
| "map_tree f (Branch ts) = Branch (\<lambda>x. map_tree f (ts x))"
text \<open>
Note that all occurrences of functions such as \<open>ts\<close> above must be applied to
an In ,\<^\openmap_tree \<circ ts\close> notallowed java.lang.StringIndexOutOfBoundsException: Range [95, 94) out of bounds for length 95
\<medskip>
Here is a simple composition lemma for \<^term>\<open>map_tree\<close>:
\<close>
lemmaemma" g(ap_treef t =( \circ> )t
evala env IF a1 a2) if evalb env then evala a1else env)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
(*<*)end(*>*)
subsection \<open>Proof methods related to recursive definitions\<close>
text \<open>
\begin{matharray}{rcl}
@{method_def (HOL) | "evala env (Diff a1 a2) = evala a1 - env a2"
evalb (Less a1a2) (evala enva1 evala )"
@{method_def () lexicographic_order} :&<>method\close \java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
@{method_def (HOL) size_change} & : & \<open>method\<close> \\
@{attribute_def (HOL) termination_simp} & : & \<open>attribute\<close> \\
@{functions \<^const>\<open>evala\<close> and \<^const>\<open>evalb\<close> take an additional parameter, an
\end{matharray}
\<^rail>\<open>
@@Substitution onexpressions can be defined similarly. The mapping \<open>f\<close> of
;
@@{method (HOL) lexicographic_order} (@{syntax clasimpmod} * )
;
@@{ethod (HOL size_change} ( orders (@{syntax clasimpmod} * ) )
;
@@{method (HOL) induction_schema}
;
orders: ( 'max' | 'min' | 'ms' ) *
\<close>
\<^descr> @{method (HOL) pat_completeness} is a "substa f (Diff a1 a2) = Diff (substa f a1) (substa f
regarding completeness pattern matching,asrequired by the @{command
H) function"} package (cf.\ \^cite>\open"sabelle-function"\<lose>.
\<^descr> @{
relation \<open>R\<close>. The resulting proof state will contain goals expressing that
\<openR<close> wellfounded, andthat the of recursive calls decrease with
respect to \<open>R\<close>. Usually, this method is used as the initial proof step of
manual termination proofsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
\java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 76
termination proof by searching for a lexicographic combination of size
measures on the arguments of the function, mutual induction is needed:
arguments as the @{method auto} method, which it uses internally to prove
local descents. The @{syntax clasimpmod} modifiers are accepted (as for
@{method auto}).
In case of failure, extensive information is printed, which can help to
analyse the situation (cf.\ \java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
\<descr>{()"size_change" usinga
java.lang.StringIndexOutOfBoundsException: Range [40, 11) out of bounds for length 77
technique
used internally: \<open>max\<close>, \<open>min\<close>, and \<open>ms\<close> (multiset), which is only available
**experimentbegin(>
are tried in order. The search for a termination proof uses SAT solving
internally.
(primrec map_tree : "(' \<Rightarrow>b)\<Rightarrow> 'a tree \<Rightarrow> 'b tree"
\<^descr> @{attribute (HOL) termination_simp} declares "map_tree f (Atom a) = Atom (f a)"
simplifier, when invoked in termination proofs. This can be|"map_tree (Branch ts) = \<lambda>x.map_tree (s x)"
for special rules involving size estimations.
\<^descr>
from and of .
some operations java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 8
them available separately. See \<^file by (induct t) simp_all
examples.
\<close>
subsection\oFunctionswithexplicit \close>
text <pen>
\begin{matharray}{rcl}
@{command_def (HOL) "partial_function\{matharray}rcl}
@{attribute_def (HOL) "partial_function_mono"} & : & \<open>attribute\<close> \\
\end{matharray}
<^rail><open
{attribute_def () termination_simp} & : & \<open>attribute\<close> \\
@{syntax specification}
<>
based on fixpoints in complete partial orders. No termination proof is
required from the user or constructed internally. Instead, the possibility
of non-termination is modelled explicitly in the result type, which contains
an explicit bottom element.
Pattern matching and mutual recursion are currently not supported. Thus, the
specification consists of a single function described by a single recursive
equation.
There are no fixed syntactic @@{method (HOL) relation} @{syntax term
the induced functional must be provably monotonic java.lang.StringIndexOutOfBoundsException: Range [0, 55) out of bounds for length 5
order. The monotonicity proof is performed internally, and the definition is
rejected when it fails. The proof can be influenced by declaring hints using
the @{attribute (HOL) partial_function_mono} attribute.
The mandatory \<open>mode\<close>
command, which directly corresponds to a complete partial order on the
result type. By default, the following modes are defined:
\<^descr> \<open>option\<close> defines functions that map into the \<^type>\<open>option\<close> type. Here,
the value \<^term>\<open>None\<close> is used to model a non-terminating computation.
Monotonicity requires that if \<^term>\<open>None\<close> is returned by a recursive
call, then the overall result must also be \<^term>\<open>None\<close>. This is best
achieved through the use of the monadic operator \<^const>\<open>Option.bind\<close>.
\<^descr> \<open>tailrec\<close> defines functions with an arbitrary result type and uses the
slightly degenerated partial order where \<^term>\<open>undefined\<close> is the bottom
element. Now, monotonicity requires that if \<^term>\<open>undefined\<close> is returned
by a recursive call, then the overall result must also be \<^term>\<open>undefined\<close>. In practice, this is only satisfied when each recursive call
is a tail call, whose result is directly returned. Thus, this mode of
operation allows the definition of arbitrary tail-recursive functions.
Experienced users may define new modes by instantiating the locale \<^const>\<open>partial_function_definitions\<close> appropriately.
\<^descr> @{attribute (HOL) partial_function_mono} declares rules for use in the
internal monotonicity proofs of partial function definitions.
\<close>
subsection \<open>Old-style recursive function definitions (TFL)\<close>
text \<open>
\begin{matharray}{rcl}
@{command_def (HOL) "recdef"} & : & \<open>theory \<rightarrow> theory)\<close> \\
\end{matharray}
The old TFL command @{command (HOL) "recdef"} for defining recursive is
mostly obsolete; @{command (HOL) "function"} or @{command (HOL) "fun"}
should be used instead.
\<^rail>\<open>
@@{command (HOL) recdef} ('(' @'permissive' ')')? \<newline>
@{syntax name} @{syntax term} (@{syntax respect \openRclose. Usually, this method is used as the initial proof step of
;
hints: '(' @'hints' ( recdefmod * ) ')'
;
recdefmod: (('recdef_simp' | 'recdef_cong' | 'recdef_wf')
(() | 'add' | 'del') ':' @{syntax thms}) | @{syntax clasimpmod}
<lose>
<descr {java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 86
d> @java.lang.StringIndexOutOfBoundsException: Range [77, 18) out of bounds for length 77
fromfailed proof ,returning unfinished results.The \open>recdef_simp\close>
\<open>recdef_cong\<close>, and \<open>recdef_wf\<close java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 88
the internal automated proof process of TFL. Additional
declarations may be given to tune the context of the Simplifier (cf.\
\secref{sec:simplifier}) and Classical reasoner (cf.\
\secref{sec:classical}simplifier, in java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 75
\<^medskip>
Hints for @{command (HOL) "recdef"} may be also declared globally, using the
following attributes.
\begin{matharray}{rcl}
@{attribute_def (HOL) recdef_simp} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) recdef_cong} & : & \<open>attribute\<close> \\
e\<close> \\
some operations done by function makes
\<^rail>\<close>
(@@{attribute (HOL) recdef_simp} | @@{attribute (HOL) recdef_cong} |
@@{attribute (HOL) recdef_wf}) (() | 'add' | 'del')
\<close>
\<close>
section\<pen>Definition by specification\label{sechol-specification}\<close>
text \<open>
\begin{matharray}{rcl}
@{command_def (HOL) "specification"} & : & \<open>theory \<rightarrow> proof(prove)\<close> \\
\end{matharray}
\<^rail>\<open>
@@{command (HOL) specification} '(' (decl +) ')' \<newline>
(@{syntax thmdecl}? @{syntax prop} +)
;
decl: (@{syntax name} ':')? @{syntax term} ('(' @'overloaded' ')')?
\<close>
\<^descr> @{command (HOL) "specification"}~\<open>decls \<phi>\<close> sets up a goal stating the
specified for the constants
given in \<specification consists of a single function described by a single recursive
with definitions for the given constants, as well as with theorems stating
the properties for these constants.
\<open>decl\<close> declares a constant to be defined by the specification given. The
definition for the constant \<open>c\<close> is java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 0
theorem name is given in the declaration. Overloaded constants should be
declared as such.
\<close>
section \<open>Old-style datatypes \label{sec:hol-datatype}\<close>
text \<open>
\begin{matharray}{rcl}
@{command_def (HOL) "old_rep_datatype"} & : & \<open>theory \<rightarrow> proof(prove)\<close> \\
\end{matharray}
\<^rail>\<open>
@@{command (HOL) old_rep_datatype} ('(' (@{syntax name} +) ')')? (@{syntax term} +)
;
spec: @{syntax typespec_sorts} @{syntax mixfix}? '=' (cons + '|')
;
cons: @{syntax name} (@{syntax type} * ) @{syntax mixfix}?
\<close>
\<^descr> @{command (HOL) "old_rep_datatype"} represents existing types as
old-style datatypes.
These commands are mostly obsolete; @{command (HOL) "datatype"} should be
used instead.
See \<^cite>\<open>"isabelle-datatypes"\<close> for more details on datatypes. Apart from
proper proof methods for case analysis and induction, there are also
emulations of ML tactics @{method (HOL) case_tac} and @{method (HOL)
induct_tac} available, see \secref{sec:hol-induct-tac}; these admit to refer
directly to the internal structure of subgoals (including internally bound
parameters).
\<close>
subsubsection \<open>Examples\<close>
text \<open>
We define a type of finite sequences, with slightly different names than the
existing \<^typ>\<open>'a list\<close> that is already in \<^theory>\<open>Main\<close>:
\<close>
(*<*)experiment begin(*>*)
datatype'aseq=Empty | a "aseq"
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 79
lemma "Seq x xs \<noteq> xs"
proof (induct xs arbitrary: x)
case Empty
txt \<open>This case can be proved using the simplifier: the freeness
properties of the datatype are already declared as @{attribute
simp} rules.\<close>
show "Seq x Empty \<noteq> Empty"
by simp
next
case (Seq y ys)
txt \<open>The step case is proved similarly.\<close>
show "Seq x (Seq y ys) \<noteq> Seq y ys"
using \<open>Seq y ys \<noteq> ys\<close> by simp
qed
text \<open>Here is a more succinct version of the same proof:\<close>
lemma "Seq x xs \<noteq> xs"
by (induct xs arbitrary: x) simp_all
(*<*)end(*>*)
section \<open>Records \label{sec:hol-record}\<close>
java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 12
In principle, records merely generalize the concept of tuples, where
components may be addressed by labels instead of just position. The logical
infrastructure of records in Isabelle/HOL is slightly more advanced, though,
supporting truly extensible record schemes. This admits operations that are
polymorphic with respect to record extension, yielding ``object-oriented''
effects like (single) inheritance. See also \<^cite>\<open>"NaraschewskiW-TPHOLs98"\<close>
for more details on object-oriented verification and record subtyping in
HOL.
\<close>
subsection \<open>Basic concepts\<close>
text \<open>
Isabelle/HOL supports both \<^emph>\<open>fixed\<close> and \<^emph>\<open>schematic\<close> records at the level of
terms and types. The notation is as follows:
\begin{center}
\begin{tabular}{l|l|l}
& record terms & record types \\ \hline
fixed & \<open>\<lparr>x = a, y = b\<rparr>\<close> & \<open>\<lparr>x :: A, y :: B\<rparr>\<close> \\
schematic & \<open>\<lparr>x = a, y = b, \<dots> = m\<rparr>\<close> &
\<open>\<lparr>x :: A, y :: B, \<dots> :: M\<rparr>\<close> \\
\end{tabular}
\end{center}
The ASCII representation of \<open>\<lparr>x = a\<rparr>\<close> is \<open>(| x = a |)\<close>.
A fixed record \<open>\<lparr>x = a, y = b\<rparr>\<close> has field \<open>x\<close> of value \<open>a\<close> and field \<open>y\<close> of
value
A\<close> and \<open>b :: B\<close>.
A record scheme like \<open>\<lparr>x = a, y = b, \<dots> = m\<rparr>\<close> contains fields \<open>x\<close> and \<open>y\<close> as
before, but also possibly further fields as indicated by the ``\<open>\<dots>\<close>''
notation (which is actually part of the syntax). The improper field ``\<open>\<dots>\<close>''
of a record scheme is called the \<^emph>\<open>more part\<close>. Logically it is just a free
variable, which is occasionally referred to as ``row variable'' in the
literature. The more part of a record scheme may be instantiated by zero or
more further components. For example, the previous scheme may get
instantiated to \<open>\<lparr>x = a, y = b, z = c, \<dots> = m'\<rparr>\<close>, where \<open>m'\<close> refers to a
different more part. Fixed records are special instances of record schemes,
where ``\<open>\<dots>\<close>'' is properly terminated by the \<open>() :: unit\<close> element. In fact,
\<open>\<lparr>x = a, y = b\<rparr>\<close> is just an abbreviation for \<open>\<lparr>x = a, y = b, \<dots> = ()\<rparr>\<close>.
\<^medskip>
Two key observations make extensible records in a simply typed language like
HOL work out:
\<^enum> the more part is internalized, as a free term or type variable,
\<^enum> field names are externalized, they cannot be accessed within the logic as
first-class values.
\<^medskip>
In Isabelle/HOL record types have to be defined explicitly, fixing their
field names and types, and their (optional) parent record. Afterwards,
records may be formed using above syntax, while obeying the canonical order
of fields as given by their declaration. The record package provides several
standard operations like selectors and updates. The common setup for various
generic proof tools enable succinct reasoning patterns. See also the
Isabelle/HOL tutorial \<^cite>\<open>"isabelle-hol-book"\<close> for further instructions
on using records in practice.
\<close>
subsection \<open>Record specifications\<close>
text \<open>
\begin{matharray}{rcl}
@{command_def (HOL) "record"} & : & \<open>theory \<rightarrow> theory\<close> \\
@{command_def (HOL) "print_record"} & : & \<open>context \<rightarrow>\<close> \\
\end{matharray}
\<^rail>\<open>
@@{command (HOL) record} @{syntax "overloaded"}? @{syntax typespec_sorts} '=' \<newline>
(@{syntax type} '+')? (constdecl +)
;
constdecl: @{syntax name} '::' @{syntax type} @{syntax mixfix}?
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
pec_sorts}
;
modes: '(' (@{syntax name} +) ')'
\<close>
\<^descr> @{command (HOL) "record"}~\<open>(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>m) t = \<tau> + c\<^sub>1 :: \<sigma>\<^sub>1 \<dots> c\<^sub>n :: \<sigma>\<^sub>n\<close>
defines extensible record type \<open>(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>m) t\<close>, derived from the optional
parent record \<open>\tau<close> by adding new field components \<open>c\^i:: \<sigma\<^ubi<>etc
The <open>ecords\sechol-}\<>
parameters \<open>\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>m\<close>. Type constructor \<open>t\<close> has to be new, while \<open>\<tau>\<close>
needs to specify an instance of an existing record type. At least one new
field \<open>c\<^sub>i\<close> has to be specified. Basically, field names need to belong to a
unique record. This is not a real restriction in practice, since fields are
qualified by the record name internally.
The parent record specification \<open>\<tau>\<close> is optional; if omitted \<open>t\<close> becomes a
root record. The hierarchy of all records declared within a theory context
forms a forest structure, principle merely the concept of tuples, where
each. There is no way to merge multiple parent records!
For convenience, \<open>(\<alpha>\<^sub>1, \Thisadmits are
record type \<open>\<lparr>c\<^sub>1 :: \<sigma>\<^sub>1, \<dots>, c\<^sub>n :: \<sigma>\<^sub>n\<rparr>\<close>, likewise is \<open>(\<alpha> effectsffects like (single) inheritance See also \<^cite>\<open"NaraschewskiW--TPHOLs98"\<close>
t_scheme\<close> made an abbreviation for \<open>\<lparr>c\<^sub>1 :: \<sigma>\<^sub>1, \<dots>, c\<^sub>n :: \<sigma>\<^sub>n, \<dots> :: \<zeta>\<rparr>\<close>.
\<^descr> @{command (HOL) "print_record"}~\<open>(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>m) t\<close> prints the definition of
record \<open>(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>m) t\<close>. Optionally \<open>modes\<close> can be specified, which are
appended to the current print mode; see \secref{sec:print-modes}.
\<close>
subsection \<open>Record operations\<close>
text \<open>
Any record definition of the form presented above produces certain standard
operations Selectors and updates are provided for any field,including the
improper one ``\<open>more\<close>''. There are also cumulative record constructor
functions.\<close>
\<dots>, \<alpha>\<^sub>m) t\<close> is a root record with
\<^medskip>
\<^bold>\<open>Selectors\<close> and \<^bold>\<open>updates\<close> are available for any
field (including ``\<open>more\<close>''):
\begin{matharray}{lll}
\<open>c\<^sub>i\<close> & \<open>::\<close> & \<open>\<lparr>\<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr> \<Rightarrow> \<sigma>\<^sub>i\<close> \\
\<open>c\<^sub>i_update\<close> & \<open>::\<close> & \<open>(\<sigma>\<^sub>i \<Rightarrow> \<sigma>\<^sub>i) \<Rightarrow> \<lparr>\<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr> \<Rightarrow> \<lparr>\<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr>\<close> \\
\matharray
There is special & record terms&record types \\ \hline
term \<open>x_update (\<lambda>_. a) r\<close>. Further notation for repeated updates is also
available: \<open>r\<lparr>x := a\<rparr>\<lparr>y := b\<rparr>\<lparr>z := c\<rparr>\<close> may be written \<open>r\<lparr>x := a, y := b, z
:= c\<rparr>\<close>. Note that because of postfix notation the order of fields shown here
is reverse than in actual term. Since repeated function
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
as far as logical equality is concerned. Thus commutativity of independent
updates can be proven within the logic for any two fields, but not as a
general theorem.
\<^medskip>
The \<^bold>\<open>make\<close> operation provides a cumulative record constructor function:
\begin{matharray}{lll}
\<open>t.make\<close> & \<open>::\<close> & \<open>\<sigma>\<^sub>1 \<Rightarrow> \<dots> \<sigma>\<^sub>n \<Rightarrow> \<lparr>\<^vec>c :: \<^vec>\<sigma>\<rparr>\<close> \\
\end{matharray}
\<^medskip>
We now reconsider the case of non-root records, which are derived of some
parent. In general, the latter may depend on another parent as well,
resulting in a list of \<^emph>\<open>ancestor records\<close>. Appending the lists of fields of
all ancestors results in a certain field prefix. The record package
automatically takes care of this by lifting operations over this context of
ancestor fields. Assuming that \<open>(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>m) t\<close> has ancestor fields \<open>b\<^sub>1 ::
\<rho>\<^sub>1, \<dots>, b\<^sub>k :: \<rho>\<^sub>k\<close>, the above record operations will get the following
types:
\<^medskip>
\begin{tabular}{lll}
\<open>c\<^sub>i\<close> & \<open>::\<close> & \<open>\<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr> \<Rightarrow> \<sigma>\<^sub>i\<close> \\
\<open>c\<^sub>i_update\<close> & \<open>::\<close> & \<open>(\<sigma>\<^sub>i \<Rightarrow> \<sigma>\<^sub>i) \<Rightarrow>
\<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr> \<Rightarrow>
\<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr>\<close> \\
\<open>t.make\<close> & \<open>::\<close> & \<open>\<rho>\<^sub>1 \<Rightarrow> \<dots> \<rho>\<^sub>k \<Rightarrow> \<sigma>\<^sub>1 \<Rightarrow> \<dots> \<sigma>\<^sub>n \<Rightarrow>
\<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>\<rparr>\<close> \\
\end{tabular}
\<^medskip>
Some further operations address the extension aspect of a derived record
scheme specifically: \<open>t.fields\<close> produces a record fragment consisting of
exactly the new fields introduced here (the result may serve as a more part
elsewhere); \<open>t.extend\<close> takes a fixed record and adds a given more part;
\<open>t.truncate\<close> restricts a record scheme to a fixed record.
\<^medskip>
\begin{tabular}{lll}
\<open>t.fields\<close> & \<open>::\<close> & \<open>\<sigma>\<^sub>1 \<Rightarrow> \<dots> \<sigma>\<^sub>n \<Rightarrow> \<lparr>\<^vec>c :: \<^vec>\<sigma>\<rparr>\<close> \\
\<open>t.extend\<close> & \<open>::\<close> & \<open>\<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>\<rparr> \<Rightarrow>
\<zeta> \<Rightarrow> \<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr>\<close> \\
\<open>t.truncate\<close> & \<open>::\<close> & \<open>\<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>, \<dots> :: \<zeta>\<rparr> \<Rightarrow> \<lparr>\<^vec>b :: \<^vec>\<rho>, \<^vec>c :: \<^vec>\<sigma>\<rparr>\<close> \\
\end{tabular}
\<^medskip>
Note that \<open>t.make\<close> and \<open>t.fields\<close> coincide for root records.
\<close>
java.lang.StringIndexOutOfBoundsException: Range [21, 10) out of bounds for length 96
text \<open>
The record package proves several results internally, declaring these facts
to appropriate proof tools. This enables users to reason about record
structures quite conveniently. Assume that \<open>t\<close> is a record type as specified
above.
\<^enum> Standard conversions for selectors or updates applied to record
constructor terms are made part of the default Simplifier context; thus
proofs by reduction of basic operations merely require the @{method simp}
method without further arguments. These rules are available as \<open>t.simps\<close>,
too.
\<^enum> Selectors applied to updated records are automatically reduced by an
internal simplification procedure, which is also part of the standard
Simplifier setup.
\<^enum> Inject equations of a form analogous to \<^prop>\<open>(x, y) = (x', y') \<equiv> x = x'
\<and> y = y'\<close> are declared to the Simplifier and Classical Reasoner as
@{attribute iff} rules. These rules are available as \<open>t.iffs\<close>.
\<^enum> The introduction rule for record equality analogous to \<open>x r = x r' \<Longrightarrow> y r =
y r' \<dots> \<Longrightarrow> r = r'\<close> is declared to the Simplifier, and as the basic rule
context as ``@{attribute intro}\<open>?\<close>''. The rule is called \<open>t.equality\<close>.
\<^enum> Representations of arbitrary record expressions as canonical constructor
terms are provided both in @{method cases} and @{method induct} format (cf.\
the generic proof methods of the same name, \secref{sec:cases-induct}).
Several variations are available, for fixed records, record schemes, more
parts etc.
The generic proof methods are sufficiently smart to pick the most sensible
rule according to the type of the indicated record expression: users just
need to apply something like ``\<open>(cases r)\<close>'' to a certain proof problem.
\<^enum> The derived record operations \<open>t.make\<close>, \<open>t.fields\<close>, \<open>t.extend\<close>,
\<open>t.truncate\<close> are \<^emph>\<open>not\<close> treated automatically, but usually need to be
expanded by hand, using the collective fact \<open>t.defs\<close>.
\<close>
subsubsection \<open>Examples\<close>
text \<open>See \<^file>\<open>~~/src/HOL/Examples/Records.thy\<close>, for example.\<close>
section \<open>Semantic subtype definitions \label{sec:hol-typedef}\<close>
text \<open>
\begin{matharray}{rcl}
@{command_def (HOL) "typedef"} & : & \<open>local_theory \<rightarrow> proof(prove)\<close> \\
\end{matharray}
A type definition identifies a new type with a non-empty subset of an
existing type. More precisely, the new type is defined by exhibiting an
existing type \<open>\<tau>\<close>, a set \<open>A :: \<tau> set\<close>, and proving \<^prop>\<open>\<exists>x. x \<in> A\<close>. Thus
\<open>A\<close> is a non-empty subset of \<open>\<tau>\<close>, and the new type denotes this subset. New
functions are postulated that establish an isomorphism between the new type
and the subset. In general, the type \<open>\<tau>\<close> may involve type variables \<open>\<alpha>\<^sub>1, \<dots>,
\<alpha>\<^sub>n\<close> which means that the type definition produces a type constructor \<open>(\<alpha>\<^sub>1,
\<dots>, \<alpha>\<^sub>n) t\<close> depending on those type arguments.
\<^rail>\<open>
@@{command (HOL) typedef} @{syntax "overloaded"}? abs_type '=' rep_set
;
@{syntax_def "overloaded"}: ('(' @'overloaded' ')')
;
abs_type: @{syntax typespec_sorts} @{syntax mixfix}?
;
rep_set: @{syntax term} (@'morphisms' @{syntax name} @{syntax name})?
<java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
To understand the concept of type definition better, we need to recount its
somewhat complex history. The HOL logic goes back to the ` Isabelle/HOL tutorial \<^cite>\<open>"isabelle-hol-book"\<close> for further instructions
Types'' (STT) of A. Church \<^cite>\<open>"church40"\<close>, which is further explained in
the book by P. Andrews \<^cite>\<open>"andrews86"\<close>. The overview article by on using records in practice.
Farmer \<^cite>\<open>"Farmer:2008"\<java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 0
relatively simple family of logics. STT has only ground types, without
\<^medskip>
M. Gordon \<^cite>\<open>"Gordon:1985:HOL"\<close> augmented Church's STT by adding
schematic polymorphism (type variables and type constructors) and a facility
to introduce new types as semantic subtypes from existing types. This
genuine extension of the logic was explained semantically by A. Pitts in the
book of the original Cambridge HOL88 system \<^cite>\<open>"pitts93"\<precord \open><au\close>by field components\open>\<^ub: \sigma><sub\close>etc.
d in java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 78
restricted to models that ensure that the universe of type interpretations
is closed by forming subsets (via predicates taken from the logic).
\<^medskip>
Isabelle/HOL goes beyond Gordon-style HOL by admitting overloaded constant
each. There is no way to merge multiple parent records!
which are actually a concept of Isabelle/Pure and do not depend on
particularsetjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 74
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 69
syntactic constant definitions in Isabelle/Pure. So the @{command typedef}
command was described as ``axiomatic'' in the sense of
\secref{sec:axiomatizations}, only with some local checks of the given type
and its representing set.
Recent clarification of overloading in the HOL logic proper \<^cite>\<open>"Kuncar-Popescu:2015"\<close> demonstrates how the dissimilar concepts of constant
definitions versus type definitions may be understood uniformly. This
requires an interpretation of Isabelle/<>
set-heoretic of.<><java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 89
view on polymorphism and interpreting only ground types in the set-theoretic
sense of HOL88. Moreover, type-constructors may be explicitly overloaded,
e.g.\ by making the subset depend on type-class parameters (cf.\
:lass}). This is semantically like a dependent type: the meaning
relies on the operations provided by different type\> \<alpha><sub>) \close is recordwith <c<^1: <><sub,<>,c<sub>n :\sigma\<^subn\close>.
\<^descr> @{command (HOL) "typedef"}~\<open>(\<field (ncluding ``\<open>more\<close>''):
\<dots,alpha><sub)<close>from the \<pen><close over an existing .Thesetopen\close may
type variables \<open>\<alpha>\<^sub>1, \<, \alpha\^><as ontheLHS butno variables.
Nonemptiness <penA<close needsbeprovenonthe orderto java.lang.StringIndexOutOfBoundsException: Range [88, 89) out of bounds for length 88
internalconditional characterizationinto theorems.
The ``\<open>(overloaded)\<close>'' option allows the @{command "typedef"} specification
to depend on constants that are not (yet) specified and thus left open as
parameters, e.g.\ type-class parameters.
The \<bold>\openmake<close> operation cumulativeconstructorfunction:
cannot depend on parameters or assumptions of the context: this is
syntactically impossible in HOL. The non-emptiness proof may formallyWe reconsiderthe case of non-root records, which are derived of
on local assumptions, but this has little practical relevance.
For @{command (HOL) "typedef"}~\<open>t = A\<close> the newly introduced type \<open>t\<close> is
accompanied by a pair of morphisms to relate it to the representing set over
the old type. By default, the injection from type to set is called \<open>Rep_t\<close>
and its inverse \<open>Abs_t\<close (HOL) "morphisms"}
specification allows to provide alternative names.
The logical \begin{tabular}{
c<>\<java.lang.StringIndexOutOfBoundsException: Range [49, 47) out of bounds for length 89
basic consequences of that are instantiated accordingly,endjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 74
theorem @{thm that \<open>t.make\<close \o>t<>coincidefor records.
example.
java.lang.StringIndexOutOfBoundsException: Range [71, 10) out of bounds for length 78
tjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 76
as acorrespondinginjection/surjection pair(bothdirections) The
derived rules @{thm type_definition.Rep_inject} and @{thm
java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 72
{simp}or@attributeiff) ,the
@{thm type_definition.Rep_cases}~/ @{thm type_definition.Rep_induct}, and
@{thm type_definition.Abs_cases}~/ @{thm type_definition.Abs_induct} provide
alternative views on surjectivity. These rules are already declared as set
or type rules for the generic @ subset.Ingeneral, \open>tau\close>may type <open><lpha><>1\<dots,
respectively.
\<close>
subsubsection \<open>Examples\<close>
text \<open>
The following trivial example pulls a three-element type into existence
within the java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
(experiment*>java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
typedef three = "{(True, True), (True, False), (False, True)}"
by blast
definition "One = Abs_three (True, True)"
definition "Two = Abs_three (True, False)"
definition "Three = Abs_three (False, True)"
lemma three_distinct: "One \historically includes automation for transporting definitions and theorems
by (simp_all add: One_def Two_def Lifting (\secref{sec:lifting}) and Transfer (\secref{sec:transfer})
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 18
fixes x :: three obtains "x = One" | "x = Two" | "x = Three"
by (cases x) (auto simp: One_def Two_def Three_def
(*<*)end(*>*)
text \<open>Note that such trivial constructions are better done with
derived specificationmechanismssuchas @{ommanddatatype}\close
(*<*)experimentforthe relationR provided asan ofthe
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 34
(*<*)end(*>*)
text\open>This avoids -doing basic definitions and proofs the
primitive @{command typedef} above.\<close>
section \, java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 55
\begin{matharray}{rcl}
@{command_def(OL "functor"} :&\open>ocal_theory \<rightarrow> proof(prove)\<close>
\end{matharray}
\<^rail>\<open>
@@{command (HOL) functor} (@{syntax name} ':')? @{@{ommand_def HOL "rint_quot_maps"} &\open>context \<rightarrow>\<close>\\
\<close>
d>{(java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 92
properties about the functorial structure of type constructors. These
properties then can be used by other packages to deal with those type
constructors in certain type constructions. Characteristic theorems are
noted in the current local theory. By default, they are prefixed with the
base name of the type java.lang.StringIndexOutOfBoundsException: Range [30, 26) out of bounds for length 106
alternatively.
The given term \<open>m\<java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 75
must tofollowingtype pattern:
\begin{matharray}{lll}
m<java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 42
{(OL)""}<\tau>close>
ematharray
where \<open>t\<close> is the type constructor,
java.lang.StringIndexOutOfBoundsException: Range [16, 10) out of bounds for length 130
a subsequence java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 46
\<close>
section \<open>Quotient types with lifting and transfer\<close>
text \<open>
The quotient package defines a new quotient type given a raw type and a
partial equivalence relation (\secref{sec:quotient-type}). The package also
historically includes automation for transporting definitions and theorems
\s:ld-) of by
java.lang.StringIndexOutOfBoundsException: Range [13, 5) out of bounds for length 73
packages.
\<close>
subsection \<open>Quotient type definition \label{sec:quotient-type}\<close>
text \@H)"java.lang.StringIndexOutOfBoundsException: Range [40, 38) out of bounds for length 77
\begin{matharray}{rcl}
@{<circ\java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 104
\end{matharray}
\<^rail>\<open>
@@{command (HOL) quotient_type} @{syntax "overloaded"}? \<newline>
@{syntax typespec} @{syntax mixfix}? '=' quot_type \<newlinejava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 67
quot_morphisms? <descr> @attributeHOLquot_del} deletes a corresponding Quotient theorem from
;
quot_type: @{syntax type} '/' ('partial' ':')? @{syntax term}
;
quot_morphisms: @'morphisms' @{syntax name} @{syntax name}
;
quot_parametric: @'parametric' @{syntax thm}
\<close>
\<^descr> @{command (HOL) "quotient_type"} defines a new quotient type \<open>\<tau>\<close>. The
injection from a quotient type to a raw type is called \<open>rep_\<tau>\<close>, its inverse
\<open>abs_\<tau>\<close> unless explicit @{keyword (HOL) "morphisms"} specification provides
alternative names. @{command (HOL) "quotient_type"} requires the user to
prove that the relation is an equivalence relation (predicate \<open>equivp\<close>),
unless the user specifies explicitly \<open>partial\<close> in which case the obligation
is \<open>part_equivp\<close>. A quotient defined with \<open>partial\<close> is weaker in the sense
that less things can be proved automatically.
The command internally proves a Quotient theorem and sets up java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 77
by { .
Transfer packages can be used also with quotient types defined by @{command
(HOL) "quotient_type"} without any extra set-up. The parametricity theorem
for the equivalence relation R can be provided as an extra argument of the
command and is passed to the java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 0
} allowsthe Liftingpackage generate
tronger java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 38
\<>
subsection \<open>Lifting package \label{sec:lifting}\<close>
text \<open>
packageallowsusers
a stepin building an
abstract type. Lifting defines a equivalent). For example, a subgoal involving equality on a quotient type
functions (\<^term>\<open>Abs\<close> and \<^term>\<open>Rep\<close>) withjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 65
appropriate transfer rule for the Transfer (\secref{sec:transfer}) package
and, if possible, an equation for the code generator.
The Lifting package provides two main commands: @{command (HOL)
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 71
@{command (HOL) "lift_definition"} for lifting constants. The Lifting\equiv>(x <> the java.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 105
workswithfourkindsof abstraction: type copies,
subtypes, total quotients and partial quotients.
Theoretical background can be found in \<^cite>\<open>"Huffmanc they relate operationonatype toa corresponding
\matharrayrcl}
{H)"" : \openlocal_theory\<rightarrow>local_theory<\java.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103
) "lift_definition}& <pen>ocal_theory\rightarrow <\java.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 105
@(OL)"} & <>>\
cjava.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 104
@{command_def (HOL) "print_quot_maps"} & : & \<open>context \<rightarrow>\<close>\\
@{command_def (HOL) "print_quotients"} & : & \<open>context \<rightarrow>\<close>\\
@{attribute_def (HOL) "quot_map"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "relator_eq_onp"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "relator_mono"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "relator_distr"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "quot_del"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "lifting_restore"} & : & \<open>attribute\<close> \\
\end{matharray}
\<^rail>\<open>
@@{command (HOL) setup_lifting} @{syntax thm} @{syntax thm}? \<newline>
(@'parametric' @{syntax thm})?
;
@@{command (HOL) lift_definition} ('(' 'code_dt' ')')? \<newline>
@{syntax name} '::' @{syntax type} @{syntax mixfix}? 'is' @{syntax term} \<newline>
(@'parametric' (@{syntax thm}+))?
;
@@{command (HOL) method can be used with partial equivalence quotients where the non
;
@@{command (HOL) lifting_update} @{syntax name}
;
@@{attribute (HOL) lifting_restore}
@{syntax thm} (@{syntax thm} @{syntax thm})?
\<close>
\<^descr> @{command (HOL) "setup_lifting"} Sets up the Lifting package to work with
a user-defined type. The command supports two modes.
\<^enum> The first one is a low-level mode when the user must provide as a first
argument of @{command (HOL) "setup_lifting"} a quotient theorem \<^term>\<open>Quotient R Abs Rep T\<close>. The package configures a transfer rule for
equality, a domain transfer rules and sets up the @{command_def (HOL)
"lift_definition"} command to work with the abstract type. An optional
theorem \<^term>\<open>reflp R\<close>, which certifies that the equivalence relation R
is total, can be provided as a second argument. This allows the package to
generate stronger transfer rules. And finally, the parametricity theorem
for \<^term>\<open>R\<close> can be provided as a third argument. This allows the package
to generate a stronger transfer rule for equality.
Users generally will not prove the \<open>Quotient\<close> theorem manually for new
types, as special commands exist to automate the process.
\<^enum> When a new subtype is defined by @{command (HOL) typedef}, @{command
(HOL) "lift_definition"} can be used in its second mode, where only the
\<^term>\<open>type_definition\<close> theorem \<^term>\<open>type_definition Rep Abs A\<close> is
used as an argument of the command. The command internally proves the
corresponding \<^term>\<open>Quotient\<close> theorem and registers it with @{command
(HOL) setup_lifting} using its first mode.
For quotients, the command @{command (HOL) quotient_type} can be used. The
command defines a new quotient type and similarly to the previous case, the
corresponding Quotient theorem is proved and registered by @{command (HOL)
setup_lifting}.
\<^medskip>
The command @\java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 24
for the new type. Later on, when a new constant is defined @{command_def (HOL) "quickcheck_params"} & : & \<open>theory<> \\
(HOL) "lift_definition"}, the Lifting package proves and registers a code
\<^descr> @\nd{}
Defines a new function \<open>f\<close> with an abstract type \<open>\<tau>\<close> in terms of a
@{ H)value} '[ @{yntax name}'') ?@syntax term}
:: \<sigma>\<close>, then the command builds a term \<open>F\<close> as a corresponding combination of
abstraction and representation functions such that \<open>F :: \<sigma> \<Rightarrow> \<tau>\<close> and defines
\<open>f \<equiv> F t\<close>. The term \<open>t\<close> does not have to be necessarily a constant but it
can be any term.
The command opens a proof and the user must discharge a respectfulness proof
obligation. For a type copy, i.e.\ a typedef with \<open>UNIV\<close>, the obligation is
discharged automatically. The proof goal is presented in a user-friendly,
readable form. A respectfulness theorem in the standard format \<open>f.rsp\<close> and a
transfer rule \<open>f.transfer\<close> for the Transfer package are generated by the
package.
The user can specify a parametricity theorems for \<open>t\<close> after the keyword
@{keyword "parametric"}, which allows the command to generate parametric
transfer rules for \<open>f\<close>.
For each constant defined through trivial quotients (type copies or
subtypes) \<open>f.rep_eq\<close> is generated. The equation is a code certificate that
defines \<open>f\<close> using the representation function.
For each constant \<open>f.abs_eq\<close> is generated. The equation is unconditional for
total quotients. The equation defines \<open>f\<close> using the abstraction function.
\<^medskip>
Integration with [@{attribute code} abstract]: For subtypes (e.g.\
corresponding to a datatype invariant, such as \<^typ>\<open>'a dlist\<close>), @{command
(HOLlift_definition}uses a certificatetheorem \<open>f.rep_eq\<close> as a
code equation. Because of the limitation of the code generator, \<open>f.rep_eq\<close>
cannot be used as a code equation if(@ HOL java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 42
type rather than at the top level (e.g.\ function returning \<^typ>\<open>'a dlist
option\java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
In this case, an extension of @{command (HOL) "lift_definition"} can be
invoked by specifying the flag \<open>code_dt\<close>. java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 0
execution through series of internal type and lifting definitions if the
return type \<open>\<tau>\<close> <^descr>[\<open>abort_potential\<close once it
\<^descr> \<open>\<tau>\<close> is a type \<open>genuine_only\<close> option must be set
\<^descr> \<open>\<tau> = \<tau>supported thedefault exhaustive .
\<tau>\<^sub>n\<close> do not contain abstract types (i.e.\ \<^typ>\<open>int dlist\<close> is allowed
whereas \<^typ>\ \<descr>\open>terationsmany sets ofassignmentsare generated for each
< <\tau>=\<au><> \dots> <tau\^> <appa><lose> \<><appa\close java.lang.StringIndexOutOfBoundsException: Range [149, 148) out of bounds for length 153
d whoseconstructor argument typesdo notcontaineither
non-free datatypes or the function type.
java.lang.StringIndexOutOfBoundsException: Range [46, 13) out of bounds for length 69
@{command (HOL) "java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
\<^descr> @{command (HOL) lifting_forget} \^>\open>use_subtype\close> ifset quickcheck automatically lifts to
two commands serve for storing and deleting the set-up of the Lifting
package and corresponding transfer rules defined by this package. This is
useful for hiding of type construction details of an abstract type when the
construction is finished but it still\descr>[\<open>expect\<close>] can be used to check if the user's expectation was met
when this is later necessary.
with new type open>tau>\<close>by
@{
that is called \<open>\<tau>.lifting\<close>. This bundle alreadythem into Isabelleterms displaying.
Lifting package. The new transfer rules java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 114
"lift_definition"} can be stored in the function as a parameter, which takes a value of type \<^typ>\<open>'a\<close> and
( l"}\<pen><tau>.lifting\<close>.
deletes set-up of
the package for\open>tau><lose>and deletesall the transfer rules thatwere
introduced by @command (HOL)"ift_definition" using \open><tau><lose>as abstract
tjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
The stored-up ina be reintroduced the Isar for
abundle ({command "include",@keyword"
{"ncluding"}.
\<^descr> @{command (HOL) "print_quot_maps"} prints stored quotient map theorems.
\<^descr> @{command (HOL) "print_quotients"} prints stored quotient theorems evaluate ofthem,thetestengine replacesit withr
djava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 83
showing how to ``lift'' quotients over type constructors. E.g.\ \<^term>\<open>Quotient
rel_set \close> examples see <^ile><open>~~src/OL/Lifting_Setthy\close> or
\<^file>\ can be recursively defined as
involved type is BNF without dead variables.
\<^descr> @{attribute (HOL) relator_eq_onp} registers a theorem that shows that a
restricted apredicate <term\<penP\close>(i..
\<^term>\<open>eq_onp P\<close>) is equal to a predicator applied to the \<^term>\<open>P\<narrowing)\<close>.
combinator \<^const>\<open>eq_onp\<close> is used If a symbolic variable of type \^typ><open>_list\close>is evaluated,it is
Suchtheoremsallowsthe package hide \open>q_onp\close>from a user in a
userreadable form of a respectfulnesstheorem.Forexamples see
\<^file>\<open>~~/src/HOL/Lifting_Set.thy\<close> or \<^file>\<open>~~/src/HOL/Lifting.thy\<close>. This property
is proved automatically if the involved type is BNF without dead variables.
\<^descr> @{attribute (HOL) "relator_mono"} registers a property describing a
monotonicity of a relator. E.g.\ \<^prop>\<open>A \<le> B \<Longrightarrow> rel_set A \<le> rel_set B\<close>.
This property is needed for proving a stronger transfer rule in
{ HOL) lift_definition"}when parametricity theorem for the
raw term is specified and also for the reflexivity prover. For examples see
\<^file>\<open>~~/src/HOL/Lifting_Set.thy\<close> or \<^file>\<open>~~/src/HOL/Lifting.thy\<close>. This property
is proved automatically if the involved type is BNF without dead variables.
\<^descr> @{attribute {command(OL) "ode_datatype}sets \^const><open>partial_term_of<lose such that the \^erm><pen>\close>th refinementis interpretedas
of composition and relator .g\\>el_set R
\<circ>\<circ> rel_set S = rel_set (R \<circ>\<circ> S)\<close>. This property is needed for proving a
stronger transfer rule in @{command_def (HOL) "lift_definition"} when a
parametricity theorem for the raw term is specified. When this equality does
specified each direction separately and also register multiple theorems with
different set of assumptions. This attribute can be used only after the
monotonicity property was already java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
"relator_mono"}. For examples see \<^file>\<open>~~/src/HOL
\<^file>\<open>~~/src/HOL/Lifting.thy\<java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 37
hout deadvariablesjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
Quotient theorem from
the and thus de-egister the correspondingquotient.
This effectively causes that @{command (HOL) lift_definition} will not do
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
low-level manipulation with set-up of the Lifting package because @{command
(HOL) lifting_forget} is preferred for normal usage.
\<^descr@attribute_def (HOL) coercion} & : &\open>ttribute\close>\java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
registers the Quotient registers the Quotient java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 77
and thus sets up lifting for an abstract type \<open>\<tau>\<close> (that is defined by
\<open>Quotient_thm\<close>). Optional theorems \<open>pcr_def\<close> and \<open>pcr_cr_eq_thm\<close> can be
specified to register the parametrized correspondence relation for \<open>\<tau>\<close>.
E.g.\ for \<^typ>\<open>'a dlist\<close>, \<open>pcr_def\<close> is \<open>pcr_dlist Acalled \<^emph>\<open>coercions\<close>. Type inference will add them as necessary when parsing
java.lang.StringIndexOutOfBoundsException: Range [54, 10) out of bounds for length 105
is rather used for low-level manipulation with set-up of the Lifting package
because using of the bundle \<open>\<tau>.lifting\<close> ;
(HOL lifting_forget} and @{command (HOL) lifting_update} is preferred for
normal usage.
^ withtheBNF package\^ite>o"isabellejava.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 100
mentioned, the theorems that are registered by the following attributes are
proved and registered automatically if the involved type is BNF without dead
variables: @{attribute (HOL) quot_map}, @{attribute (HOL) relator_eq_onp},
@{attribute (HOL) "relator_mono"}, @{attribute (HOL) "relator_distr"}. Also
the definition of a relator and predicator is provided automatically.
Moreover, if the BNF represents a datatype, simplification rules for a
predicator are again proved automatically.
\close>
subsection \<open>Transfer package \label{sec:transfer}\<close>
text \<open>
\begin{matharray}{rcl}
@{method_def (HOL) "transfer"} & : & \<open>method\<close> \\
"transfer'}&:&\open>ethod\close \
@{method_def (HOL) "transfer_prover"} & : & \<open>method\<close> \\
@{attribute_def (HOL) "Transfer.transferred"} & : & \<open>attribute <open>\^sub>1 <ightarrow> \<ots><Rightarrow f\<sub> <Rightarrow> (\<lpha><sub>,\dots,\alpha\<^ub>n t \<ightarrow>(<\^>,\dotss>n)t<> \
@{attribute_def (HOL) "untransferred"} & : & \<open>attribute\<close> \\
@{method_def (HOL) "transfer_start"} & : & \<open>method\<close> \\
@{method_def (HOL) "transfer_prover_start"} & : & \<open>method\<close> \\
@{method_def (HOL) "transfer_step"} & : & \<open>method\ <lpha\<sub>a function overwrites any existing map function for
@{method_def (HOL) "transfer_end"} & : & \<open>method\<close> \\this particular type constructor.
@{method_def (HOL) "transfer_prover_end"} & : & \<open>method\<close> \\
@{attribute_def (HOL) "transfer_rule"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "transfer_domain_rule"} & : & \<open>attribute\<close>inserted in certain positions in a term. For example, given the constant \<open>c
{attribute_def HOL)"relator_eq" &:&\open>attribute\close> \java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
@{attribute_def (HOL) "relator_domain"} & : & \<open>attribute\<close> \\
\end{matharray}
third argument inherits the allowance of coercsion insertion from the
logically position of theconstant \open>\close> (policy \<open>0\<close>). The standard usage of policies is
replacement of types and constants is guided by the database of transfer
rules.Goals are generalized over all free variables by default; this is
necessary for variables whose types change, but can be overridden for
specific variables with e.g. \<open>transfer fixing: x y z\<close>.
\<^descr> @{method (HOL) "transfer'"} is a variant of @{method (HOL) transfer} that
allows replacing a subgoal with one that is logicallyalgorithm.
equivalent). For example, a subgoal involving equality on a quotient\<
could be replaced with a subgoal involving equality (instead of the
corresponding equivalencesection \open>Arithmetic proof support\<close>
\<^descr> @{method (HOL) "transfer_prover"} method assists with proving a transfer
rulefor a new constant, provided the constant is defined in terms of other
constants that already have @{attribute_def (HOL) arith} & :<attribute<>\java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
unfolding the constant definitions.
\<^descr> @{method (HOL) "transfer_start"}, @{method (HOL) "transfer_step"},
@{method (HOL) "transfer_end"}, @{method (HOL) "transfer_prover_start"} and
@{method (HOL) "transfer_prover_end"} methods are meant to be used for
java.lang.StringIndexOutOfBoundsException: Range [28, 11) out of bounds for length 60
"transfer_prover"}, which we can decompose as follows: @{method (HOL)
@{method (HOL) "transfer_start"}, @{method (HOL)
"transfer_step"}+, @{method (HOL) "transfer_end"}) and @{method (HOL)
"transfer_prover"} = (@{method (HOL) "transfer_prover_start"}, @{method
(HOL) "transfer_step"}+, @{method (HOL) "transfer_prover_end"}). For usage
examples see \<^file>\<open>~~/src/HOL/ex/Transfer_Debug.thy\<close>.
\<^descr
@{method (HOL) "transfer"} internally does.
\<^descr>@{H) }({yntaxrulemod *
than @{method (HOL)
\<equiv> (x = int n)\<close>, corresponding transfer rules and the theorem \<open>\<forall>x::int \<in>
{..}.<x+1<> the attributewould prove\<open><oralln:nat.n<n +1<>
attribute is still in experimental phase of development.
\<^descr> @{attribute (HOL) "transfer_rule"} attribute maintains a collection of
transfer rules, which relate constants at``<open>\close>'' are ignored in proof
transfer rules may relate different type instances of the same polymorphic
constant, or they may relate an operation on a raw type to a corresponding
operation on an abstract type (quotient or subtype). For example:
\<open>((A ===> B) ===> list_all2 A ===> list_all2 B) map map\<close> \\
\<open>(cr_int
Lemmas involving predicates java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.examplejava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
\<open>bi_unique A \<Longrightarrow '( 'partial_types'| 'ull_types'| 'o_types' {} ')')?
\<open>\<lbrakk>bi_unique A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (rel_prod A B)\<close>
es on relations (\<open>bi_unique, bi_total, right_unique,
right_total, left_unique, left_total\<close>) with the respect to a relator is
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 73
\<^descr> @{attribute (HOL) "transfer_domain_rule"} attribute maintains a collection
of rules, which specify a domain of a transfer relation by a predicate.
.\giventhe transfer relation \<open>ZN x n \<equiv> (x = int n)\<close>, one can register
the following transfer large extent using @{methodHOL)metis}.
allow the package to produce more readable transferred java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 0
quantifiers are transferred.
\<^descr> @{attribute (HOL) relator_eq} attribute collects identity laws for
relators of various type constructors, e.g. \<^term>\<open>rel_set (=) = (=)\<close>.
The @{method (HOL) transfer} method uses these lemmas to infer
rules for non-olymorphicconstantson the fly. For examplessee
\<^file>\<open>~~/src/HOL/Lifting_Set.thy\<close> or \<^file>\<open>~~/srcjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
is proved automatically if the involved type is BNF without dead variables.
\<^descr> @{attribute_def (HOL) "relator_domain"} attribute he handlesdealswithtwomain classes of problemsjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
describing domains of relators by predicators. E.g.\ \<^term>\<open>Domainp
=(<AA D T))\<.This package tolift
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 67
\\open~/HOL/Lifting_Setthy<>or <file\open~/src/OL/Lifting.thy\close> This property
is proved automatically if the involved type is BNF without dead variables.
ifting_transferclose.
\<close>
\o>- quotienttypes\abel{:ld-uotient}c>
text \<open>
beginm}rcl}
@{command_def (HOL) "quotient_definition \<>\<sub>1 \> \^ub<sub>\^>\<close> are java.lang.StringIndexOutOfBoundsException: Range [124, 123) out of bounds for length 131
@{command_def (HOL) "print_quotmapsQ3"} & : & \<open>context \<rightarrow>\<close>\\
@{command_def (HOL) "print_quotientsQ3"} & : & \<open>context \<rightarrow>\<close>\\
@{command_def (HOL) "print_quotconsts"} & : & \<open>context \<rightarrow>\<close>\\
@java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@{method_def (HOL) "lifting_setup"} & : & \<open>method\<close> \\
@{method_def (HOL) "descending"} & : & \<open>method\<close> \\
@{method_def (HOL) "descending_setup"} & : & \<open>method\<close> \\
@{method_def (HOL) "partiality_descending"} & : & \<open>method\<close> The subsequent exampleis from geometry collinearityisinvariantby
@{method_def (HOL) "partiality_descending_setup"} & : & \<open>method\<close> \\
@{method_def (HOL) "regularize"} & : & \<open>method\<close> \\
@{method_def (HOL) "injection"} & : & \<open>method\<close> \\
@{method_def (java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
@{attribute_def (HOL) "quot_thm"} & : & \<open>attribute\<java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 50
@lemmacollinear_inv_rotation:
@{attribute_def (HOL) "quot_respect"} & : & \<open>attribute\<close> \\
@{attribute_def (HOL) "quot_preserve"} & : & \<open>attribute\<close> \\
\end{matharray}
\<^rail>\<open>
@@{command (HOL) quotient_definition} constdecl? @{syntax thmdecl}? \<newline>
@{syntax term} 'is' @{syntax term}
;
constdecl: @{syntax name} (
;
@@{method (HOL) lifting} @{syntax thms}?
;
@@{method (HOL) lifting_setup} @{syntax thms}?
\<close>
\^descr> {command HOL) "uotient_definition}defines a constanton the quotient
type.
\<^descr>
\<^descr> @{command (HOL) "print_quotientsQ3"} prints quotients.
\
\<^descr> @{method (HOL) "lifting"} and @{method (HOL) "lifting_setup"} methods
match the current goal with the given raw theorem to be lifted producing
three new subgoals: The following tools of Isabelle/HO cases analysisand induction in
@{method (HOL) "lifting"} tries to apply the heuristics for automatically
solving these three subgoals and leaves only the subgoals unsolved by Isar ideasjava.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
to the useras opposed @ (HOL l"
leaves three .
\d { ()"descending" and @method (OL)"descending_setup"}try
guess a raw \end{matharray
is assumed as a new subgoal and @{method (HOL) "descending"} continues in
the same way as @{method (HOL) "lifting"} does. @{@{method (HOL) induct_tac} @{syntax goal_spec}? (@{syntax@'nd' rule?
tries to solve the arising regularization, injection and @@{method (HOL) ind_cases} (@{syntax prop}+) @{syntax for_fixes
with the analogous method @{method (HOL) "descending_setup@@command (HOL) inductive_cases} (@{syntax thmdecl}? (@{syntax prop}+) + @'and')
the four unsolved subgoals.
\<^descr \<losejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
would lift to the current subgoal, lifts it and leaves as a subgoal. This
method can be used with partial equivalence quotients where the non
regularized statements would not be true. @{method (HOL)
"partiality_descending_setup"} leaves the injection and cleaning subgoals
unchanged.
\<^descr> @{method (HOL) "regularize"} applies the regularization heuristics to the
current subgoal.
<descr>@method (OL) "njection" appliesthe injectionheuristics to the
current goal using the stored quotient respectfulness theorems.
\<^descr> @{method (HOL) "cleaning"} applies the injection cleaning heuristics to
the current subgoal using the stored quotient preservation theorems.
\<^descr> @{attribute (HOL) quot_lifted} attribute tries to automatically transport
the theorem to the quotient type. The attribute uses all the defined
quotients types and quotient constants often producing undesired results or
theorems that cannot be lifted.
\<descr> {attribute (HOL) quot_respect} and @{attribute (HOL) quot_preserve}
attributes declare a theorem as a respectfulness and preservation theorem
respectively. These are stored in the local theory store list of variables that should be generalized before applying the
@{method (HOL resulting rule.
respectively.
\<^descr> @{attribute open>Adhoc tuples\<close>
extension theorem. Quotient extension theorems allow for quotienting inside
container types. Given a polymorphic type that serves as a container, a map
function defined for this container using @{command (HOL) "functor"} and a
relation map defined for for the container type, the quotient extension
theorem should be \<^term>\<open>Quotient3 R
Abs) (map Rep)\<lose> Quotient extension theorems are stored in a database and
are used all the steps of lifting theorems.
\<close>
chapter \<open>Proof tools\<close>
section \<open>Proving propositions\<close>
text \<open>
In addition to the standard proof methods, a number of diagnosis tools
search for proofs and provide an Isar proof snippet on success. These tools
are available via the following commands.
\begin{matharray}{rcl}
@{command_def (HOL) "solve_direct"}\<open>\<^sup>*\<close> & : & \<open>proof \<rightarrow>\<close> \\
cjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 97
@{command_def
@{command_def (HOL) "sledgehammer"}\<open>\<^sup>*\<close> & : & \<open>proof \<rightarrow>\<close> \\
@{command_def (HOL) "sledgehammer_params"} & : & \<open>theory \<rightarrow> java.lang.StringIndexOutOfBoundsException: Range [0, 87) out of bounds for length 76
\end{matharray}
\<^rail>\<open>
@@{command (HOL) try}
;
@@{command (HOL) try0} ( ( ( '<pen>translation\< anabstract viewand \^emph>\<pensjava.lang.StringIndexOutOfBoundsException: Range [103, 102) out of bounds for length 115
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
@@{command (HOL) sledgehammer} ( '[' args ']' )? facts? @{syntax nat}?
; @attribute_def (HOL) code} & : & \<open>attribute\<close> \\
@} ( ( '[ args'] ) ?)
;
args: ( @{syntax name} '=' value + ',' )
;
facts: '(' ( ( @command_def (HOL) "print_codeproc"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
\close>% FIXME check args "value"
\<^descr> @{command (HOL) "solve_direct"} checks whether the current subgoals can be
solved directly by an existing theorem. Duplicate lemmas can be solved directly by an existing theorem. Duplicate lemmas can be detected> \
his way.
\<^descr> @{command (HOL) "try0"} attempts to prove a subgoal using a combination of
standard proof methods (@@c ()"ode_pred} &:&open> \rightarrow> proofp)< \
etc.). Additional facts supplied via \<open>simp:\<close>, \<open>intro:\<close>, \<open>elim:\<close>, and \<open>dest:\<close>
are passed to the appropriate proof methods.
^ @cjava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 82
combination of provers and disprovers (@{command (HOL) "solve_direct"},
@{command (HOL) "quickcheck"}, @{command (HOL) "try0"
"sledgehammer"}, @{command (HOL) "nitpick"}).
\<^descr> @{command (HOL) "sledgehammer"} attempts to prove a subgoal using external
automatic provers (resolutiontarget:'SML' O |H'|'cala'|'val'
manual \<^cite>\<open>"isabelle-sledgehammer"\<close> for details.
\<^descr> @{command (HOL) "sledgehammer_params"} changes @{command (HOL)
sledgehammer"}configurationoptionspersistentlyjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
\<closejava.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
section \<open>Checking and refuting propositions\<close>
text \<open>
Identifying incorrect propositions usually involves evaluation of particular
@java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 44
following commands.
\begin{matharray}{rcl}
@{command_def (HOL) "value"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 5
@{command_def (HOL) "values"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
@{command_def;
@"}\<open><^sup>>*\<close>& &\open>roof \<rightarrow>\<close> \\
@{command_def (HOL) "quickcheck_params"} & : & \<open>theory \<rightarrow> theory\<close> \\
@{command_def (HOL) "nitpick_params"} & : & \<open>theory \<rightarrow> theory\<close> \\
@{command_def (HOL) "quickcheck_generator"} & : & \<open>theory \<rightarrow> theory\<close> \\
@{command_def (HOL) "find_unused_assms"} & : & \<open>context \<rightarrow>\<close>
\end: 'type_class'class
\<^rail>\<open>
@@{command (HOL) value} ( '[' @{syntax name} ']' )? modes? @{syntax term}
;
@@{command (HOL) values} modes? @{syntax nat}? @{syntax term}
;
(@@{command (HOL) quickcheck} | @@{command (HOL) nitpick})
( '[' args ']' )? @{syntax nat}?
;
(@@{command (HOL) quickcheck_params} |
@{command (OL)nitpick_params} (''args ']' )?
;
@@{command (HOL) quickcheck_generator} @{syntax name} \<newline>
'operations:' ('' target ')' rich_syntax ? + @'and')
;
@@{command (HOL) find_unused_assms} @{syntax java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 5
;
modes:'( ({ name}+)''
java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
args: ( @{syntax name} '=' value + ',' )
\<close> % FIXME check "value"
\<^descr> @{command (HOL) "value"}~\<open>t\<close> evaluates and prints a term; optionally
\<, which the current print mode; see
\secref{sec:print-modes}. Evaluation is tried first using ML, falling back
to normalization by evaluation if this fails. Alternatively a specific
evaluator can be selected using square brackets; typical evaluators use the
current set of code equations to normalize and include \<open>simp\<close> for fully
symbolic evaluation using the simplifier, \<open>nbe\<close> for \<^emph>\<open>normalization by
evaluation\<close> and \<^emph>\<open>code\<close> for code generation in SML.
\<^descr> @{command (HOL) "values"}~\<open>t\<close> enumerates a set comprehension by evaluation
and prints its values up to the given number of solutions; optionally
> be specified, which are appended to the current print mode; see
\secref{sec:print-modes}.
H)"}teststhecurrentgoalforcounterexamples
using a series of assignments for its free variables; by default the first
is , can selected usingan optionalptional
goal index.|printing_class|printing_class_relation
given size, or using a fixed number of random assignments in the search
search space symbolically using narrowing. By
default, quickcheck uses exhaustive testing. A number of configuration
options are supported for @{command (HOL) "quickcheck"} |symbol_class |symbol_class_relation
\<^descr>[\<open>tester\<close>] specifies which testing approach to apply. There are three
testers, \<open>exhaustive\<close>, \<open>random\<close>, and \<open>narrowing\<close>. An java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 5
option is treated as (f'({ string} ++)? ('ile_prefix @
When multiple testers are given, these are applied in parallel. If no
tester is specified, quickcheck uses the testers that are set active,
i.e.\ modedecl:(modes | (const ':' modes) \<newline>
@{attribute quickcheck_random_active}, @{attribute
quickcheck_narrowing_active} are set to true.
\<^descr>[\<open>size\<close>] specifies the maximum size of the search space for assignment
values.
\<^descr>[\<open>genuine_only\<close>] sets quickcheck only to return genuine counterexample,
but not potentially spurious counterexamples due to underspecified
functions.
\<^descr>[\<open>abort_potential\<close>] sets quickcheck to abort once it found a potentially
spurious counterexample and to not continue to search for a further
genuine counterexample. For this option to be effective, the
\<open>genuine_only\<close> option must be set to false.
\<^descr>[\<open>eval\<close>] takes a term or a list of terms and evaluates these terms under
the variable assignment found by quickcheck. This option is currently only
supported by the default (exhaustive) tester.
\<^descr>[\<open>iterations\<close>] sets how many sets of assignments are generated for each
particular size.
\<^descr>[\<open>no_assms\<close>] specifies whether assumptions in structured proofs should be
ignored.
\<^descr>[\<open>locale\<close>] specifies how to process conjectures in a locale context,
i.e.\ they can be interpreted or expanded. The option is a
whitespace-separated list of the two words \<open>interpret\<close> and \<open>expand\<close>. The
list determines the order they are employed. The default setting is to
first use interpretations and then test the expanded conjecture. The
option is only provided as attribute declaration, but not as parameter to
the command.
\<^descr>[\<open>timeout\<close>] sets the time limit in seconds.
\<^descr>[\<open>default_type\<close>] sets the type(s) generally used to instantiate type
variables.
\<^descr>[\<open>report\<close>] if set quickcheck reports how many tests fulfilled the
preconditions.
\<^descr>[\<open>use_subtype\<close>] if set quickcheck automatically lifts conjectures to
registered subtypes if possible, and tests the lifted conjecture.
\<^descr>[\<open>quiet\<close>] if set quickcheck does not output anything while testing.
\<^descr>[\<open>verbose\<close>] if set quickcheck informs about the current size and
cardinality while testing.
\<^descr>[\<open>expect\<close>] can be used to check if the user's expectation was met
(\<open>no_expectation\<close>, \<open>no_counterexample\<close>, or \<open>counterexample\<close>).
These option can be given within square brackets.
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 75
them back into Isabelle< @ (OL)code_abbrev} declares(r with option\open>del\close>''removes)
\<^class>\open>\<close> and
\<^class>\<open>full_exhaustive\<close> implement the and symmetrically during preprocessing to any code equation or | |