SSL Prelim.thy
Sprache: Isabelle
|
|
(*:maxLineLen=78:*)
theory Prelim
imports Base
begin
chapter ‹Preliminaries›
section ‹Contexts \label{sec:context}›
text ‹
A logical context represents the background that is required for formulating
statements and composing proofs. It acts as a medium to produce formal
content, depending on earlier material (declarations, results etc.).
For example, derivations within the Isabelle/Pure logic can be described as
a judgment ‹Γ ⊨\Θ φ›, which means that a proposition ‹φ› is derivable from
hypotheses ‹Γ› within the theory ‹Θ›. There are logical reasons for keeping
‹Θ› and ‹Γ› separate: theories can be liberal about supporting type
constructors and schematic polymorphism of constants and axioms, while the
inner calculus of ‹Γ ⊨ φ› is strictly limited to Simple Type Theory (with
fixed type variables in the assumptions).
┉
Contexts and derivations are linked by the following key principles:
▪ Transfer: monotonicity of derivations admits results to be transferred
into a ∗‹larger› context, i.e.\ ‹Γ ⊨\Θ φ› implies ‹Γ' ⊨\Θ' φ› for contexts
‹Θ' ⊇ Θ› and ‹Γ' ⊇ Γ›.
▪ Export: discharge of hypotheses admits results to be exported into a
∗‹smaller› context, i.e.\ ‹Γ' ⊨\Θ φ› implies ‹Γ ⊨\Θ Δ ==> φ› where ‹Γ' ⊇ Γ›
and ‹Δ = Γ' - Γ›. Note that ‹Θ› remains unchanged here, only the ‹Γ› part is
affected.
┉
By modeling the main characteristics of the primitive ‹Θ› and ‹Γ› above, and
abstracting over any particular logical content, we arrive at the
fundamental notions of ∗‹theory context› and ∗‹proof context› in
Isabelle/Isar. These implement a certain policy to manage arbitrary
∗‹context data›. There is a strongly-typed mechanism to declare new kinds of
data at compile time.
The internal bootstrap process of Isabelle/Pure eventually reaches a stage
where certain data slots provide the logical content of ‹Θ› and ‹Γ› sketched
above, but this does not stop there! Various additional data slots support
all kinds of mechanisms that are not necessarily part of the core logic.
For example, there would be data for canonical introduction and elimination
rules for arbitrary operators (depending on the object-logic and
application), which enables users to perform standard proof steps implicitly
(cf.\ the ‹rule› method cite‹"isabelle-isar-ref"›).
┉
Thus Isabelle/Isar is able to bring forth more and more concepts
successively. In particular, an object-logic like Isabelle/HOL continues the
Isabelle/Pure setup by adding specific components for automated reasoning
(classical reasoner, tableau prover, structured induction etc.) and derived
specification mechanisms (inductive predicates, recursive functions etc.).
All of this is ultimately based on the generic data management by theory and
proof contexts introduced here.
›
subsection ‹Theory context \label{sec:context-theory}›
text ‹
A ∗‹theory› is a data container with explicit name and unique identifier.
Theories are related by a (nominal) sub-theory relation, which corresponds
to the dependency graph of the original construction; each theory is derived
from a certain sub-graph of ancestor theories. To this end, the system
maintains a set of symbolic ``identification stamps'' within each theory.
The ‹begin› operation starts a new theory by importing several parent
theories (with merged contents) and entering a special mode of nameless
incremental updates, until the final ‹end› operation is performed.
┉
The example in \figref{fig:ex-theory} below shows a theory graph derived
from ‹Pure›, with theory ‹Length› importing ‹Nat› and ‹List›. The body of
‹Length› consists of a sequence of updates, resulting in locally a linear
sub-theory relation for each intermediate step.
\begin{figure}[htb]
\begin{center}
\begin{tabular}{rcccl}
& & ‹Pure› \\
& & ‹↓› \\
& & ‹FOL› \\
& $\swarrow$ & & $\searrow$ & \\
‹Nat› & & & & ‹List› \\
& $\searrow$ & & $\swarrow$ \\
& & ‹Length› \\
& & \multicolumn{3}{l}{~~@{keyword "begin"}} \\
& & $\vdots$~~ \\
& & \multicolumn{3}{l}{~~@{command "end"}} \\
\end{tabular}
\caption{A theory definition depending on ancestors}\label{fig:ex-theory}
\end{center}
\end{figure}
┉
Derived formal entities may retain a reference to the background theory in
order to indicate the formal context from which they were produced. This
provides an immutable certificate of the background theory.
›
text %mlref ‹
\begin{mldecls}
@{define_ML_type theory} \\
@{define_ML Context.eq_thy: "theory * theory -> bool"} \\
@{define_ML Context.subthy: "theory * theory -> bool"} \\
@{define_ML Theory.begin_theory: "string * Position.T -> theory list -> theory"} \\
@{define_ML Theory.parents_of: "theory -> theory list"} \\
@{define_ML Theory.ancestors_of: "theory -> theory list"} \\
\end{mldecls}
🚫 Type 🚫‹theory› represents theory contexts.
🚫 🚫‹Context.eq_thy›~‹(thy1, thy2)› check strict identity of two
theories.
🚫 🚫‹Context.subthy›~‹(thy1, thy2)› compares theories according to the
intrinsic graph structure of the construction. This sub-theory relation is a
nominal approximation of inclusion (‹⊆›) of the corresponding content
(according to the semantics of the ML modules that implement the data).
🚫 🚫‹Theory.begin_theory›~‹name parents› constructs a new theory based
on the given parents. This ML function is normally not invoked directly.
🚫 🚫‹Theory.parents_of›~‹thy› returns the direct ancestors of ‹thy›.
🚫 🚫‹Theory.ancestors_of›~‹thy› returns all ancestors of ‹thy› (not
including ‹thy› itself).
›
text %mlantiq ‹
\begin{matharray}{rcl}
@{ML_antiquotation_def "theory"} & : & ‹ML_antiquotation› \\
@{ML_antiquotation_def "theory_context"} & : & ‹ML_antiquotation› \\
\end{matharray}
🚫‹
@@{ML_antiquotation theory} embedded?
;
@@{ML_antiquotation theory_context} embedded
›
🚫 ‹@{theory}› refers to the background theory of the current context --- as
abstract value.
🚫 ‹@{theory A}› refers to an explicitly named ancestor theory ‹A› of the
background theory of the current context --- as abstract value.
🚫 ‹@{theory_context A}› is similar to ‹@{theory A}›, but presents the result
as initial 🚫‹Proof.context› (see also 🚫
›
subsection ‹Proof context \label{sec:context-proof}›
text ‹
A proof context is a container for pure data that refers to the theory from
which it is derived. The ‹init› operation creates a proof context from a
given theory. There is an explicit ‹transfer› operation to force
resynchronization with updates to the background theory -- this is rarely
required in practice.
Entities derived in a proof context need to record logical requirements
explicitly, since there is no separate context identification or symbolic
inclusion as for theories. For example, hypotheses used in primitive
derivations (cf.\ \secref{sec:thms}) are recorded separately within the
sequent ‹Γ ⊨ φ›, just to make double sure. Results could still leak into an
alien proof context due to programming errors, but Isabelle/Isar includes
some extra validity checks in critical positions, notably at the end of a
sub-proof.
Proof contexts may be manipulated arbitrarily, although the common
discipline is to follow block structure as a mental model: a given context
is extended consecutively, and results are exported back into the original
context. Note that an Isar proof state models block-structured reasoning
explicitly, using a stack of proof contexts internally. For various
technical reasons, the background theory of an Isar proof state must not be
changed while the proof is still under construction!
›
text %mlref ‹
\begin{mldecls}
@{define_ML_type Proof.context} \\
@{define_ML Proof_Context.init_global: "theory -> Proof.context"} \\
@{define_ML Proof_Context.theory_of: "Proof.context -> theory"} \\
@{define_ML Proof_Context.transfer: "theory -> Proof.context -> Proof.context"} \\
\end{mldecls}
🚫
\<^descr> \<^ML>\<open>Proof_Context.init_global\<close>~\<open>thy\<close> produces a proof context derived
from \<open>thy\<close>, initializing all data.
\<^descr> \<^ML>\<open>Proof_Context.theory_of\<close>~\<open>ctxt\<close> selects the background theory from
\<open>ctxt\<close>.
\<^descr> \<^ML>\<open>Proof_Context.transfer\<close>~\<open>thy ctxt\<close> promotes the background theory of
\<open>ctxt\<close> to the super theory \<open>thy\<close>.
\<close>
text %mlantiq \<open>
\begin{matharray}{rcl}
@{ML_antiquotation_def "context"} & : & \<open>ML_antiquotation\<close> \\
\end{matharray}
{context}\<lose> refers to \<^emph>\<open>the\<close> context at compile-time --- as abstract
value. Independently of (local) theory
meaningful java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 13
This is probably the most common antiquotation in current shall usedin the step \<t>o>ave\<close states java.lang.StringIndexOutOfBoundsException: Range [95, 96) out of bounds for length 95
with Isarjava.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
\<close>
subsection \<open>Generic contexts \label the <theory_text><penby\<lose command
\>
A java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
Occasionally, this enables uniform java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
typically extra-logical information. Operations on java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 5
usualinjections ,andjava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 71
oneithercomponentof the disjointsumjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
Moreover, there are java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 5
generic
text\open
operation, formatthe\open><nter\< rulerepresentsthemostbasicinference
\<close>
text %mlref \<context involved.
\begin{mldecls}
@{define_ML_type Context.generic} \\
@{define_MLThe nextexampleperformsbackwards introductionof\<open\Inter\A\close,the intersection
@{ of all sets agiven Thisrequiresnestedproofofset
\end{}
<descr \^L_type\open>ontext.eneric<>is thedirect sumof \<ML_type\opentheory<lose
and \<^java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 8
\<^descr> \<^ML>\<open>Context.theory_of\<close>~\<
generic \<open>context\<closen
\<^descr> \< fixx: aand \A
generic**java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
that this re-initializes the context data with each invocation proof
\close>
assumeA\in <>
\open
The main java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 7
data. New data types can be java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Range [14, 5) out of bounds for length 77
theory, proof, generic.
\<close>
paragraph \<open>Theory data\ \infer\openx\in <\A\close>{infer*<x\in \close>{<in <>\close}java.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114
text \<open>declarations
<medskip
\begin{
\<open>\<\>
\<open \^medskip
\<open>\<val> extend: T \<followed by an additional refinement claim usingtherule
\<open>\<val> merge: T \<times> T \<rightarrow> T\<close> & merge data \\
\end{tabular}
\<^medskip>
The \<open>empty\<close> value acts as initial default for \<^emph>\<open>any\<close> theory that does not
declare actual data content; \<open>extend\<close> is obsolete: it needs to be the
identity function.
The \<open>merge\<close> operation needs to join the data from two theories in a
conservative manner. The standard derived from the proofbodyjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
thoseparts of \<open>data\<^sub>2\<close> into \<open>data\<^sub>1\<close> that are not yet present,
while keeping the general order of things. The \<^ML>\<open>Library.merge\<close>
function on plain lists may serve as canonical template. Particularly note
that shared parts of the data must not be duplicated by naive concatenation,
or a theory graph that resembles a chain of diamonds would cause an
java.lang.StringIndexOutOfBoundsException: Range [21, 13) out of bounds for length 21
Sometimes, the data consists of a single item that cannot be ``merged'' in a
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 76
\<open> o>A that\x\i>A< <\>\\ .to
\<close and java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 43
text \<open>declarations need to implement java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 5
<>
\begin{java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 5
\<open>\<type> T\<close> & representing typethen C
\<open>\<val> init: theoryfixjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
\<^medskip>
The \<open>init\<close> operation is supposed to produce a pure value from the given
background theory and should be somehow ``immediate''. Whenever a proof
context is initialized, which happens frequently, the the system invokes the
\<open>init\<close> operation of \<^(*<*)
that one needs to be economic about the total number of proof data
declarations in the system, i.e.\ each ML module should declare at most one,
sometimes two data slots for its internal use. Repeated data declarations to
simulate a record type should be avoided!
\<close>
paragraph \<open>Generic data\<close>
text \<open>
provides a hybrid interface for both theory and proof data. The \<open>init\<close>
operation for proof contexts is predefined to select the current data value
from the background theory.
\<^bigskip>
Any of the above data declarations over type \<open>T\<close> result in an ML structure
java.lang.StringIndexOutOfBoundsException: Range [30, 6) out of bounds for length 31
\<^medskip>
\begin{tabular}{ll}
\<open(>)
\<open>put: T \<rightarrow> context \<rightarrow> context\<close> \\
\
\end{ext\open>
\<^medskip>
These other operationsprovide access for particularkind of
context(heory, ,orgeneric) This interface observes theML
discipline for types and scopes: there is no other way to access the
corresponding data slot of a context. \<losejava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
/ML module may maintainabstract values authentically.
\<close
text %mlref \<open>
\egin{ldecls
@{fragment of higher logic\^><""<> type-heoretic
@{ Proof_Data} \\
@{define_ML_functor Generic_Data} \\
e{ldecls}
\<^descr> \<
according to the specification\^medskip>
structure provides data \egin{tabular}{ll}
<descr \<ML_functor>\<open>Proof_Data\<close>\<open>(spec)\<close> is analogous to \<^ML_functor>\<open>Theory_Data\<close>
for type \^ML_type>\open>Proof.ontext\<lose>.
\<^descr> \<^ML_functor>\<open>Generic_Data\< \openA\Longrightarrow> B\<close> & implication (proofs depending on proofs) \\
text %mlex \<open>
Thefollowing artificial example demonstrates theory data: we maintain a set
of terms that are supposed to be wellformed wrt.\ the enclosing theory. The
public interface is as follows:
\<close>
ML \<open>
signature WELLFORMED_TERMS =
sig
-> term list
val add: term -> theory -> theory
end;
\<close>
text \<open>
The implementation uses private theory data On top of this most primitive layer of proofs, Puretop of this most primitive layer of proofs,Pure implements a generic
calculus for deductionrules similar to \<^cite>\<open>"Schroeder-Heister:1984"\<close>. Here object-logic inferences are internalized as
\<lose>
ML \<open>
structure Wellformed_Terms: WELLFORMED_TERMS =
struct
structure Terms = Theory_Data
(
type T =
val <open>Primitive inferences\<close>
fun merge (ts1, ts2) =
Ord_Listjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
);
val get = Terms.get;
unadd raw_t thy =
let
val t = Sign.cert_term thy raw_t;
in
Terms.map (Ord_List.insert Term_Ord.fast_term_ord t) thy
end;
end;
\<close>
\open>
Type \ prooftermsare implicit.Thesubsequent inference ules define\<open><amma>\turnstile \phi><lose>
java.lang.StringIndexOutOfBoundsException: Range [13, 2) out of bounds for length 78
stored java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9
the declaration order, since \[
of elements.\infer{\<pen><turnstile>A<lose>{<openA\close>\mbox{is }java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
how \^><open>erge<close> operationjoins the data slotsofthe two
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 4
different java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 4
append etc.mustnever be used fortheory merges!
\<^medskip>
Our intended invariant is achieved as follows:
infer{<open><Gamma>\turnstile>Ba\>{<pen\Gamma>\turnstile>\Andx.B()<lose>
\<^enum>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
infer{<pen\Gamma>-A<turnstile>A\Longrightarrow>B<close>\open>\Gamma> \turnstile \close}
(viaqquad
checks.
Note that all basic operations of the inference kernel (\java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
tools Furthermo, Pure provides a built-in equality <open><equiv>: \alpha> \<Rightarrow> \<alpha> \<Rightarrow> prop\<close> with
wrt. the background theory, since constraints of term constants
can be on \<open>\<lambda<close>terms.
In most cases, user-space context data does not have to take such invariants
too seriously. The situation is different in the implementation\^medskip>
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
constants,axioms etc.
\<close>
\<Rightarrowprop\close>as()derivabilityjudgmentand connectives <\and>: \Rightarrow>o
\openjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
A<emph\open>configuration \close>is namedoptional valueofsome basic type
(Boolean, integer, representedas theoremsof .Afterthei object-logicsetup
ofgeneralcontextdata (secrefsec:ontextdata}
used insteade. <theory_text><pend\close> <t\open>inductive\close> \^theory_text>\<pen>\<close>,\<theory_text>\<open>function\<close>).
concrete declarations for end-users using existing notation for attributes
\close>
For example, the predefined configuration option @{attribute show_types}
controls output of explicit type constraints for variables in printed terms
(cf.\ \secref{sec:read-print}). Its value can be modified within Isar text
like this:
\<close>
experiment
begin
declare [[show_types = false]]
\<comment> \<open>declaration within (local) theory context\<close>
notepad
begin
note [[show_types = true]]
\<comment>
term x
have "x = x"subsection \<open>Reasoning with rules \label{sec:framework-resolution}\<close>
using [[show_types = false]]
\<comment> \<open>declaration within proof (backward Primitive inferences mostly serve foundational purposes. The
.
end
end
text \<open>
Configuration options connectives in right-ssociative manner.
can depend on the application context. This allows to Thanks to the Pure theorem \<^prop>\<open>(A \<LongrightarrowAndx x) <>(<nd>x.A\Longrightarrow>Bx\close>the
another slot within the ,orfall back on aglobalpreference
statements observethe formwhere quantifiers are pulled
The operations to declare configuration options and get/map their values are
modeledas directreplacements forhistoric global references,onlythat
\ge 0\close> and \<pen>\<lose atomic,and <>\^sub>,\dots> \^>\close>being recursivelyofthesame
relying format.Following theconventionthat quantifiers areimplicit,
references.
\<close>
text %mlref \<open>
\begin{mldecls}
@define_MLConfig.et:Proof- aConfigT- '}\\
@{define_ML Pure theorem as follows:
@{define_ML Attrib.setup_config_bool: "binding -> open>IntI:<close>\^\<open> <in>A \Longrightarrow>x\in>B\Longrightarrow>x\in>A <>B<close>
Config.T" \
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int Config.T"} \\
@define_ML .setup_config_real b - (ontext.eneric - real)-
." \\
@{define_ML Attrib.setup_config_string\[
string Config.T" <>nterI:<lose~<prop><pen><ndA.A\<in \A \Longrightarrow> x \<in> A) \<Longrightarrow> x \<in> \<Inter>\<A>\<close>
\end{mldecls}
\<^descr> \<^ML>\<\^medskip>
context.
\<^descr> \<^ML>\<open>Config.map\<close>~\ subgoals \open\<sub>1, \<dots>, A\<^sub>n\<close> entail the result \<open>C\<close>; for \<open>n = 0\<close> the goal is
of \<open>config\<close>.
\<^descr> \ protective marker \<open># :: prop \<Rightarrow> prop\<close>, which is defined as identity and
of type \^ML_type><open>bool\close> with the given \open>default\<close>
depending on the application context. The resulting \<open>config\<closejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/ its value in given ontext. There is an implicit update of the
background theory that registers the option as attribute with some concrete infer(@{inference_def init}){<open> \<ongrightarrow> #C\<close>}{} &
syntax.
\<^descr> \<^ML>\<open>Attrib \end{rray}
\\]
\<close>
text% \open>
The following example shows how to declare and use a Boolean configuration
efault value \^><pen>false\close>java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
<close>
\open>
val my_flag =
.etup_config_bool \<^binding>\<open>my_flag\<close> (K false)
for \open>x\<^ub>, <dots> \^subn<>(\open>n \ge>0<>.
text \< [
Now user can refer to @{attribute my_flag} in declarations, while ML
tools can retrieve the current {<open>\<nd\^vec>x.\<vec \^vec>x <Longrightarrow> \<^vec>A (\<^vec>a \<^vec>x))\<vartheta> \<Longrightarrow> C\<vartheta>\<close>}
\<close>
ML_val \<open>\< \open>\^vec>A <^ec \Longrightarrow> B \<^vec>a\<close> \\
declare ]
ML_val \< \<open>(<And><^ec>.\<vecH\^vec>x <Longrightarrow> B' \<^vec>x) \<Longrightarrow> C\<close> \\
notepad
begin
{
note [[my_flag = false]]
ML_val \open\^assert (onfig.get \^context>my_flag =false)\close>
}
ML_val \<open>\<^assert> <^medskip>
end
text \<java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 4
Here is another example involving ML type \<^ML_type>\<open>real\<close> (floating-point
numbers).
\<close>
ML \<open>
val airspeed_velocity =
Attrib.setup_config_real \<^binding>\<open>airspeed_velocity\<close> (K 0.0)
\<close>
declare [[airspeed_velocity = 10]]
declare [[airspeed_velocity = 9.9]]
section \<open>Names \label{sec:names}\<close>
text \open>
In principle, a name is just a string, end}
representing additional]
considered as a long name consisting of qualifier followingillustratesorientedreasoningin
\<open>baz\<close>. The individual constituents of a java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 0
e.g.\ begin{@ \ljava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
\<^medskip>
Subsequently weshall specific categories of names. Roughly
speaking these correspond to logical entities as follows:
\<^item> Basic names (\secref{sec:basic-name}): free and bound variables.
\<^item> Indexed names (\secref{sec:indexname}): schematic variables.
\<^item> Long names (\secref{sec:long-name}): constants of any kind (type
constructors, term constants, other concepts defined in user space). Such
entities are typically managed via name spaces (\secref{sec:name-space}).
\<close>
subsection \<open>Basic names \label{sec:basic-name}\<close>
text \<open>
A \<^emph>\<open>basic name\<close> essentially consists of a single Isabelle identifier. There
are conventions to mark separate classes of basic names, by attaching a
suffix of underscores: one underscore means \<^emph>\<open>internal name\<close>, two
underscores means \<^emph>\<open>Skolem name\<close>, three underscores means \<^emph>\<open>internal Skolem
name\<close>.
For example, the basic name \<open>foo\<close> has the internal version \<open>foo_\<close>, with
Skolem versions \<open>foo__\<close> and \<open>foo___\<close>, respectively.
These special versions provide copies of the basic name space, apart from
anything that normally appears in the user text. For example, system
generated variables in Isar proof contexts are usually marked as internal,
which prevents mysterious names like \<open>xaa\<close> to appear in human-readable text.
\<^medskip>
Manipulating binding scopes often requires on-the-fly renamings. A \<^emph>\<open>name
context\<close> contains a collection of already used names. The \<open>declare\<close>
operation adds names to the context.
The \<open>invents\<close> operation derives a number of fresh names from a given
starting point. For example, the first three names derived from \<open>a\<close> are \<open>a\<close>,
\<open>b\<close>, \<open>c\<close>.
The \<open>variants\<close> operation produces fresh names by incrementing tentative
names as base-26 numbers (with digits \<open>a..z\<close>) until all clashes are
resolved. For example, name \<open>foo\<close> results in variants \<open>fooa\<close>, \<open>foob\<close>,
\<open>fooc\<close>, \dots, \<open>fooaa\<close>, \<open>fooab\<close> etc.; each renaming step picks the next
unused variant from this sequence.
\<close>
text %mlref \open>A\<nd B \Longrightarrow> A \<and> B) \<Longrightarrow> #\<dots>\<close> & \<open>(resolution A \<and> B \<Longrightarrow> A)\<close> \\
\egin{mldecls}
@{define_ML Name.internal: "string -> string"} \\
{define_MLNameskolem: "string -> string"} \\
\end{mldecls}
\begin{mldecls}
@{define_ML_type Name.context} \ }
@{define_ML Name.context: Name.context} \\
@{define_ML Name.declare: "string -> Name. Compositions of @inference assumption} after @{inference resolution} occurs
@define_ML Name.invent: "Name.context -> string -> int -> string list"} \\
.variant: "string -> Name.context -> string * Name.context"} \\
contrast, Isar uses a combined refinement rule as follows:\footnote{For
\begin{ simplicity and clarity, the presentation ignores \<^emph>\<open>weak premises\<close> as
@{define_ML Variable.names_of: "Proof.context -> Name.context"} \\
\end{mldecls}
\<^ \java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
underscore.
\<^descr> \<^ML>\<open>Name.skolem\<close>~\<open>name\<close> produces a Skolem name by adding two underscores.
\<^descr> Type \<^ML_type>\<open>Name.context\<close> represents the context of already used names;
the initial value is \<^ML>\<open>Name.context\<close>.
\<^descr> \<^ML>\<open>Name.declare\<close>~\<open>name\<close> enters a used name into the context.
\<^descr> \<^ML>\<open>Name.invent\<close>~\<open>context name n\<close> produces \<open>n\<close> fresh names derived from
\<open>name\<close>.
\<^descr> \<^ML>\<open>Name.variant\<close>~\<open>name context\<close> produces a fresh variant of \<open>name\<close>; the
result is declared to the context.
\<^descr> \<^ML>\<open>Variable.names_of\<close>~\<open>ctxt\<close> retrieves the context of declared type and
term variable names. Projecting a proof context down to a primitive name
context is occasionally useful when invoking lower-level operations. Regular
management of ``fresh variables'' is done by suitable operations of
structure \<^ML_structure>\<open>Variable\<close>, which is also able to provide an
official status of ``locally fixed variable'' within the logical environment
(cf.\ \secref{sec:variables}).
\<close>
text %mlex \<open>
The following simple examples demonstrate how to produce fresh names from
the initial \<^ML>\< \infer[(@inference }java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
\<close>
ML_val \<open>
val list1 = Name.invent Name.context "a" 5;
\<^assert> (list1 = ["a", "b", "c", "d", "e"]);
val list2 =
#1 (fold_map\opens:<lose>&
\<^assert> (list2 = ["x", "xa", "a", "aa", "'a", o\^vec> <a\Longrightarrow B \<vec>\close>\quad for schematic\<pen><^vec>\close>\
\<close>
text \<open>
\^medskip>
The same works relatively to the formal context as follows. <>\lambda><^ec>.G<sub> \^> <vecx)<vartheta>=H\^>i\vartheta><close qfor G\<^sub>j\<close> some \<open>\^sub>\close> \
experiment fixes a b c :: 'a
begin
ML_val \<open>
valnames=Variablen<context;
vallist1=inventa ;
\<^assert> ( \<^theory_textof\>\^>oa\>\^\openshow< enablestofitthe resultofasubproof
val list2 =
ames;
\mayaproperof see
<>
end
subsection \<open>Indexed names \label{sec:indexname}\<close>
text<
nindexedname\<close or\openindexname<close)is apairof basicname a natural
number representationefficient byincrementing
secondcomponent.The waytorenametwocollectionsof
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 71
\<open>maxidx\<close
tionby \<pen>maxidx+1<;themaximumindexof anemptycollection
<-\<java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 20
Occasionallynamesareinjectedintothesamepairofindexed
names: then \<open>(x, -1)\<close> <|c> <theory_text<theoremname:props for< \\
& & \quad^theory_text><open>ixes vars\close> \
\open>x i)<lose>as apacked string:
\<^item> \<open>?x\<close> if \<open>x\<close & quad\<^theory_text>\<open>shows name: props "proof"\<close> \\
>?xi\close>if\open>\<close>does notend withdigit,
\\?.i<otherwise
Indexnames indexnumbersseveral have
been applied. Results\<openproof<>&\open=< <t>\>"refinement\<sup>*proper_proof"<>\
checkpoints of a .Thisworks by producingvariants
of the corresponding basic name components. For example, the collection
\<open>?x1, ?x7, ?x42\<close> becomes \&\<pen>\<>&\^><subgoal for proof\close \
<lose
open>\close>& \open>=< <^theory_text>\<open>proof "method\<^sup>?" "tatement<s>"qed"ethod\s>?"<lose \
begin{ldecls}
@{define_ML_type indexname = "string * int"} \\
\ndmldeclsjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
\^descr>Type\^ML_type><open>ndexname\<close>represents indexed names. This is an
abbreviation for \<^ML_type>\<open>string * int\<& \<open>|\<close> & \<^theory_text>\<open>define clause \
non-,exceptfor situations \<pen>(,-1)<> is to inject basic
names into this type. <>\close> &\^heory_text\open>then"<^up>"goal< \
<>
subsection \< <java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 126
text \<open>
A<emph\open>name\<>consistsasequenceofnon- namecomponents The
aasas`\Abc<>.
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 86
\<>java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 95
access path to &\<>\close <t\openo( proof"<>\
block-,although our free-form long names do really enforce any
discipline.
For example, an item named ``\<open>A.b.c\<close>'' may beg:-syntax}
\<open>c\<close>, within a local structure \<open>b\<close>,
practice,long -3levelsof .User java.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
ar structure of
names!
The empty name is commonly used as an indication of unnamed entities, or
into the corresponding name space, whenever
this makes any sense. The basic operations on long names map empty names
higher- matching. Simultaneous propositions or facts may be
\<close>
text %
\ \^medskip>
@define_MLLong_Name.ase_name:"-string}\java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
{define_MLLong_Name.qualifier: "string -> string"} \\
@{define_ML Long_Name.append: "string -> string -> string"} \\
{ .:"tring - " \
@{define_ML Long_Name.explode: "string -> string list"} \\
\end{mldecls}
\^descr>\<ML><open>Long_Name.base_name\close>\<pen>name\close> returns the base name of a long name.
\^descr <ML>\openL.\close~<name\<lose>returns qualifierof a longname.
\^descr>\^ML><open>Long_Name.ppend\<lose>~\<open>name\<^sub>1 name\<^sub>2\<close> appends two long names.
\<^descr> \<^ML>\<open>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
between the as produced by \<^\>oteclose> <theory_text\open>ssume<,\^heory_text\open>have\close>,or<theory_text\open>how<close> <theory_text\open>note<close> occurs
names.
\<close>
subsection \<open>Name spaces \label{sec:name-space}\<close>
text \<open>
A \<open>name space\<close> manages a \egintabular}rcl}
between partially qualified names and qualified
names (in both <theory_text>\openwith a\<>&\open>\equiv><lose>&\<theory_text\open>from and this\<close> \\
\<open
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 82
determined binding a namingpolicy from java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
\<^medskip>
A \<openproofmethods ymbolically as over ethods
introduced formal entity.It consistsof a base name,prefixes for
qualification (separate ones for system java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mechanisms)) a slotfor the original source position, and some additional
flags.
\<^medskip>
A \<open>naming\<close> provides `mjava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 77
binding.,the is implicitin the theory or proof context.
resulttothe goal(`@m }'and`@method (ure)
a fully qualified internal name to be entered into a name space. The main
equation \ecref{:framework-resolution}). The secondary arguments to ``@{method
context is as follows:
\<^medskip>
\begin{tabular}{l}
\<open>binding + naming \<longrightarrow> long name + name space accesses\<close>
\end{tabular}
\^bigskip>
As a general principle, there is a separate name space for each kind of
formal entity, e.g.\ fact, logical constant, type constructor, type class.
It is usually clear from the occurrence in concrete syntax (or from the
scope) Thedefault method for \^theory_text><proof\close>is `{method standard}'(subsumes
name \<open>c\<close> may be used uniformly for a constant, type constructor, and type
.
There are common schemes to name derived entities systematically according
g\java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 90
canonical introductionrule related to constant \<open>\<close> This technique of
mapping names from one space into another requires some care in order to
avoid .In particular, theorem names derived from a type
constructor or type class should get an additional `<theory_text><penunfolding \close' directlyon goal by applying .
usual qualification. This leads to the following conventions for derived
\<medskip>
\java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
begint{}
logical entity & fact name \\\hline
constant \<open>c\<close> & \<open>c.intro\<close> \\
type \<open>c\<close> & \<open>c_type.intro\<close> \\
class \<open>c\<close> & \<open>c_class.intro\<close> \\
\end{tabular}
\<close>
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
\begin{mldecls}
@{define_ML_type binding} \\
@{define_ML .empty:binding}\\
@{define_MLtrule a (
@{define_ML Binding.\secref{sec:framework-subproof.Further derived concepts will support
@{define_ML Binding.prefix: " calculational reasoning (see \secref{sec:framework-calc}).
@{define_ML Binding.concealed: "binding -> binding"} \\
@{define_ML Binding.print: "binding -> string"} \\
\end{mldecls}
subsection <Context labelsec:ramework-context}\<close>
@{define_ML_type Name_Space.naming} \\
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@{define_ML Name_Space.add_path: "string -> Name_Space.naming -> Name_Space.naming"} \\
@{define_ML Name_Space.full_name: "Name_Space.naming -> binding -> string"} \\
\end{mldecls}
\begin{mldecls}
Name_Space.T} \\
@{define_MLwith additional information -,term,local
@{define_ML Name_Space.merge: "Name_Space.T * Name_Space.T -> Name_Space.T"} \\
@{define_ML Name_Space.declare: "Context.generic -> bool ->
binding -> Name_Space.T -> string * Name_Space.T"} \\
@{define_ML Name_Space.intern: "Name_Space.T -> string -> string"} \\
@{define_ML Name_Space.extern: "Proof.context -> Name_Space.T -> string -> string"} \\
@{define_ML Name_Space.is_concealed: "Name_Space.T -> string -> bool"}
\{mldecls}
ype\^\open>inding\close>represents abstractconcept of name .
\<^descr> arbitrary-utf ofa ype
context <>x< mayanything \^theory_text><open>assume \<guillemotleft>inference\<guillemotright>\<close> element provides
general interface to hypotheses: \^theory_text>\<open>assume \<guillemotleft>inference\<guillemotright> A\<close> produces \<open>A \<turnstile> A\<close>
that this lacks proper source position information; see also the ML
antiquotation @{ }.
\<^descr> \<^ML>\<open>Binding.qualify\<close>~\<open>mandatory name binding\<close> prefixes qualifier \<open>name\<close>
to\open>\close> \<>mandatory\<close> flag tells if this name component always needs
to be given in name space accesses --- this is mostly \<open>false\<close> in practice.
Note default inference for \<^theory_text>\<open>assume\<close> is @{inference export} as given below.
specification mechanisms.
\<^descr> \< \guillemotleft>expand\<guillemotright> x \<equiv> a\<close>, with the subsequent inference @{inference expand}.
system prefix. This part of extra system prefix. This part of extra
infrastructure for modular specifications, notably ``local theory targets''
(ee \{h:theory)
\quad
to an entity that serves foundational purposes only. This flag helps to mark
details of specification mechanism etc. Other tools should
not ]
\<^descr> \<^ML>\<open>Binding.print\<close>~\<open>binding\<close> \<^medskip>
human-readable output, together with some formal markup that might get used
inGUI -ends,for example.
purely forward .The\^theory_text>\open>obtain\<close> command takes a specification of
naming policy.
\<^descr> \<^ML>\<open>Name_Space.global_naming\<close> is the java.lang.StringIndexOutOfBoundsException: Range [0, 72) out of bounds for length 69
and lacks any path prefix. In a
a path prefix consisting of the theory name.
\<^descr> \<^ML>\<open>Name_Space.add_path\<close>~\<open>path naming\<close> augments the naming policy by
extending its path component.
\<descr>>\<^ML><open>Name_Space.full_name\<close>~\<open>naming binding\<close> turns a name binding (usually
a basic name)into fully qualified internal name, according to the given
naming policy.
\<^descr> Type \<^ML_type>\ qquad \<^theory_text>\<open>show thesis using \<langle>facts\<rangle> \<proof>\<close> \\
\<^descr> \<^ML>\<open>Name_Space.empty\<close>~\<open>kind\<close> and \<^ML>\<open>Name_Space.merge\< \quad <^theory_text>\open>fix "\<^vec>x" assume \<guillemotleft>elimination "case"\<guillemotright> "\<^vec>A \<^vec>x"\<close> \\
space\<^sub>2\^medskip>
to theory data management (\secref{sec:context-data}); \<open>kind\<close> is a formal
comment to characterize the purpose of a\[
\^escr>\^ML>\<open>ame_Space.\close>~\<open>context strict binding space\<close> enters a name
binding as \egin{}{ljava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
naming of the context.
\<^descr> \<^ML>\<open>Name_Space.intern\<close>~\<open>space name\<close> internalizes a \open>result:<lose &
external name.
This operation is mostly for parsing! Note that fully qualified names
stemming from java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 4
\<^ML>\<open Here thename `<>hesis<' a convention an
>Proofcontext\<close>).
\<^descr> \< shown before we haveoccasionally used \<open>C\<close>. The whole statement of
internal name.
rationis mostly for printing! User code should not rely on the
precise result too much.
\<^descr> \<^ML>\<open>Name_Space.is_concealed\<close>~\ involves multiplesubgoalsthatneedto separately.
to a strictly private entity that other tools are supposedjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 13
\<close>
text %lantiq \open>
\begin{matharray}{rcl}
@{L_antiquotation_def binding"}&:&\open>L_antiquotation< \
\end\closejava.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 8
\<^rail>\<open>
@@{ML_antiquotation binding} embedded
\<close>
\<^descr> \<open>@{binding name}\<close> produces a binding with base name \<open>name\<close> and the source
fix x
situations this is more appropriate than the more basic \<^ML>\<open> have " x \proof>
function.
\close>
text %mlex \<open>
some concrete binding
inlined into the text:
\<close>
ML_val \<open>Binding.pos_of \<^binding>\<open>here\<close>\<close>
text \open>
\<^medskip>
That position can be also printed3ex]\begin{inipage}[t]{0.45\textwidth}\<close>(*<*)next(*>*)
\<close>
ML_command
<open>writeln
("Look here" java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
text \<open>
This illustrates a key virtue of formalized bindings as opposed to raw
specifications of base names: the system can use this additional information
for feedbackjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
\<^medskip>
The following example refers to its source position directly, which is
occasionally useful for experimentation and diagnostic purposes**)
\<close>
ML_command \<open>warning ("Look here" ^ Position.here \<^here>)\<close>
end
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|