sealed abstract class Term extends FutureValue with PrettyPrintable
This class represents a term (ML type term) in Isabelle. It can be transferred to and from the Isabelle process
transparently by internally using MLValues (see below).
In most respects, Term behaves as if it was an algebraic datatype defined as follows:
sealed abstract class Term final case class Const(name: String, typ: Typ) // Corresponds to ML constructor 'Const' final case class Free(name: String, typ: Typ) // Corresponds to ML constructor 'Free' final case class Var(name: String, index: Int, typ: Typ) // Corresponds to ML constructor 'Var' final case class Abs(name: String, typ: Typ, body: Term) // Corresponds to ML constructor 'Abs' final case class Bound private (index: Int) // Corresponds to ML constructor 'Bound' final case class App private (fun: Term, arg: Term) // Corresponds to ML constructor '$'
tl;dr for the explanation below: Terms can be treated as if they were the case classes above (even though
there actually are more classes), both in object
creation and in pattern matching, with the exception that
one should not use type patterns (e.g., case _ : Const =>).
Having Terms defined in terms of those case classes would mean that when retrieving a term from the Isabelle process, the whole term
needs to be retrieved. Since terms can be very large and might be transferred back and forth a lot
(with minor modifications), we choose an approach where terms may be partially stored in Scala, and partially in
the Isabelle process. That is, an instance of Term can be any of the above classes, or a reference to a term
in the object store in the Isabelle process, or both at the same time. And the same applies to subterms, too.
So for example, if we retrieve terms t,u from Isabelle to Scala, and then in Scala construct App(t,u),
and then transfer App(t,u) back to Isabelle, the terms t,u will never be serialized, and only the
constructor App will need to be transferred.
In order to faciliate this, the classes Const, Free, Var, Abs, Bound, App
(collectively referred to as a ConcreteTerm) additionally
store an reference Term.mlValue to the Isabelle object store (this reference is initialized lazily, thus
accessing it can force the term to be transferred to the Isabelle process). And furthermore, there is an additional
subclass MLValueTerm of Term that represents a term that is stored in Isabelle but not available in
Scala at class creation time. Instances of MLValueTerm never need to be created manually, though. You
just have to be aware that some terms might not be instances of the six ConcreteTerm "case classes".
(But if a ConcreteTerm is required, any term can be converted using term.concrete.)
Pattern matching works as expected, that is, when an MLValueTerm t, e.g., refers to an Isabelle term of the form
Const (name,typ), then t will match the pattern case Const(name,typ) =>. (Necessary information will be
transferred from the Isabelle process on demand.) Because of this, one can almost
completely ignore the existence of MLValueTerm. The only caveat is that one should not do a pattern match on the
type of the term. That is case _ : Const => will not match a term Const(name,typ) represented by an MLValueTerm.
Two terms are equal (w.r.t.~the equals method) iff they represent the same Isabelle terms. I.e.,
an MLValueTerm and a Const can be equal. (Equality tests try to transfer as little data as possible when
determining equality.)
Furthermore, there is a subclass Cterm of Term that represents an ML value of type cterm. This is
logically a term that is certified to be well-typed with respect to some Isabelle context.
In this implementation, a Cterm is also a Term, so it is possible to do, e.g., equality tests between
Cterms and regular terms (such as Const) without explicit conversions. Similarly, patterns such as
case Const(name,typ) => also match Cterms.
- Source
- Term.scala
- Alphabetic
- By Inheritance
- Term
- PrettyPrintable
- FutureValue
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
await: Unit
Blocks until this future value is computed.
Blocks until this future value is computed. (Or throws an exception if the computation fails.)
- Definition Classes
- FutureValue
-
abstract
val
concrete: ConcreteTerm
Transforms this term into a ConcreteTerm.
Transforms this term into a ConcreteTerm. A ConcreteTerm guarantees that the type of the term (App,Const,Abs...) corresponds to the top-level constructor on Isabelle side (
$,Const,Abs, ...). -
abstract
def
concreteComputed: Boolean
Indicates whether concrete has already been initialized.
Indicates whether concrete has already been initialized. (I.e., whether it can be accessed without delay and without incurring communication with the Isabelle process.
-
abstract
def
concreteRecursive(implicit ec: ExecutionContext): ConcreteTerm
Transforms this term into a ConcreteTerm (see concrete).
Transforms this term into a ConcreteTerm (see concrete). In contrast to concrete, it also replaces all subterms by concrete subterms.
-
implicit abstract
val
isabelle: Isabelle
Isabelle instance relative to which this term was constructed.
-
abstract
val
mlValue: MLValue[Term]
Transforms this term into an MLValue containing this term.
Transforms this term into an MLValue containing this term. This causes transfer of the term to Isabelle only the first time it is accessed (and not at all if the term came from the Isabelle process in the first place).
-
abstract
def
someFuture: Future[Any]
Returns a future that completes when the computation of this object is complete.
Returns a future that completes when the computation of this object is complete. (Or that holds an exception if that computation throws an exception.) However, upon successful completion, the future may return an arbitrary (and thus useless) value. May be faster to implement than forceFuture because there may be already a future available but that returns the wrong value.
- Definition Classes
- FutureValue
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
$(that: Term)(implicit ec: ExecutionContext): App
t $ uis shorthand for App(t,u) -
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(that: Any): Boolean
Equality of terms.
Equality of terms. Returns true iff the two Term instances represent the same term in the Isabelle process. (E.g., a Cterm and a Const can be equal.) May throw an exception if the computation of the terms fails. (But will not fail if await or a related FutureValue method has returned successfully on both terms.)
- Definition Classes
- Term → AnyRef → Any
-
def
fastType(implicit executionContext: ExecutionContext): Typ
Returns the type of this term, assuming the term is well-typed.
Returns the type of this term, assuming the term is well-typed. (The function does not verify whether the term is indeed well-typed. If it is not, no guarantee is made what type is returned.)
This method is analogous to
fastype_ofin Isabelle/ML but avoids transferring the term to/from Isabelle when determining the type. -
def
force: Term.this.type
Waits till the computation of this value (in the Isabelle process) has finished.
Waits till the computation of this value (in the Isabelle process) has finished. (Or until an exception is thrown.)
- returns
this value, but it is guaranteed to have completed the computation
- Definition Classes
- FutureValue
-
def
forceFuture(implicit ec: ExecutionContext): Future[Term.this.type]
A future containing this object with the computation completed.
A future containing this object with the computation completed. In particular, if this value throws an exception upon computation, the future holds that exception.
- Definition Classes
- FutureValue
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
Hash code compatible with equals.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
pretty(ctxt: Context, symbols: Symbols = Symbols.globalInstance)(implicit ec: ExecutionContext): String
Produces a string representation of this object.
Produces a string representation of this object. Uses the Isabelle pretty printer.
- ctxt
The Isabelle proof context to use (this contains syntax declarations etc.)
- symbols
Instance of Symbols for converting to Unicode. Default: global default instance Symbols.globalInstance. Use prettyRaw to avoid conversion to Unicode.
- Definition Classes
- PrettyPrintable
- Annotations
- @NotNull()
-
def
prettyRaw(ctxt: Context)(implicit ec: ExecutionContext): String
Produces a string representation of this object.
Produces a string representation of this object. Uses the Isabelle pretty printer. Does not convert to Unicode, i.e., the return value will contain substrings such as
\<forall>)- ctxt
The Isabelle proof context to use (this contains syntax declarations etc.)
- Definition Classes
- Term → PrettyPrintable
-
def
stateString: String
A utility method that returns "" if this value was successfully computed, " (computing)" if it still computes, and " (failed)" if it finished with an exception.
A utility method that returns "" if this value was successfully computed, " (computing)" if it still computes, and " (failed)" if it finished with an exception.
This can be useful to constructing human readable messages about this value.
- Definition Classes
- FutureValue
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )