sealed abstract class Typ extends FutureValue with PrettyPrintable
This class represents a typ (ML type typ
) in Isabelle. It can be transferred to and from the Isabelle process
transparently by internally using MLValues (see below).
In most respects, Typ behaves as if it was an algebraic datatype defined as follows:
sealed abstract class Typ final case class Type(name: String, args: List[Typ]) // Corresponds to ML constructor 'Type' final case class TFree(name: String, sort: List[String]) // Corresponds to ML constructor 'TFree' final case class TVar(name: String, index: Int, sort: List[String]) // Corresponds to ML constructor 'TVar'
tl;dr for the explanation below: Types 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 Typs defined in terms of those case classes would mean that when retrieving a type from the Isabelle
process, the whole type
needs to be retrieved. Since types can be large and might be transferred back and forth a lot
(with minor modifications), we choose an approach where types may be partially stored in Scala, and partially in
the Isabelle process. That is, an instance of Typ can be any of the above classes, or a reference to a type
in the object store in the Isabelle process, or both at the same time. And the same applies to subterms of the type, too.
So for example, if we retrieve types t
,u
from Isabelle to Scala, and then in Scala construct Type("fun",List(t,u))
,
and then transfer Type("fun",List(t,u))
back to Isabelle, the types t
,u
will never be serialized, and only the
constructor Type
and the string "fun"
will need to be transferred.
In order to faciliate this, the classes Type, TFree, TVar
(collectively referred to as a ConcreteTyp) additionally
store an reference Typ.mlValue to the Isabelle object store (this reference is initialized lazily, thus
accessing it can force the type to be transferred to the Isabelle process). And furthermore, there is an additional
subclass MLValueTyp of Typ that represents a type that is stored in Isabelle but not available in
Scala at class creation time. Instances of MLValueTyp never need to be created manually, though. You
just have to be aware that some types might not be instances of the three ConcreteTyp "case classes".
(But if a ConcreteTyp is required, any term can be converted using typ.
concrete.)
Pattern matching works as expected, that is, when an MLValueTyp t
, e.g., refers to an Isabelle type of the form
TFree (name,sort)
, then t
will match the pattern case TFree(name,sort) =>
. (Necessary information will be
transferred from the Isabelle process on demand.) Because of this, one can almost
completely ignore the existence of MLValueTyp. The only caveat is that one should not do a pattern match on the
Scala-type of the Typ. That is case _ : TFree =>
will not match a term TFree(name,sort)
represented by
an MLValueTyp.
Two types are equal (w.r.t.~the equals
method) iff they represent the same Isabelle types. I.e.,
an MLValueTyp and a TFree can be equal. (Equality tests try to transfer as little data as possible when
determining equality.)
Furthermore, there is a subclass Ctyp of Typ that represents an ML value of type ctyp
. This is
logically a type with additional that is certified to be well-formed with respect to some Isabelle context.
In this implementation, a Ctyp is also a Typ, so it is possible to do, e.g., equality tests between
Ctyps and regular terms (such as TFree) without explicit conversions. Similarly, patterns such as
case TFree(name,sort) =>
also match Ctyps.
- Source
- Typ.scala
- Alphabetic
- By Inheritance
- Typ
- PrettyPrintable
- FutureValue
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
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: Typ
Transforms this term into a ConcreteTyp.
Transforms this term into a ConcreteTyp. A ConcreteTyp guarantees that the Scala-type of the Typ (Type,TFree,TVar) corresponds to the top-level constructor on Isabelle side (
Type
,TFree
,TVar
). - 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.
- implicit abstract val isabelle: Isabelle
Isabelle instance relative to which this type was constructed.
- abstract val mlValue: MLValue[Typ]
Transforms this type into an MLValue containing this type.
Transforms this type into an MLValue containing this type. This causes transfer of the type to Isabelle only the first time it is accessed (and not at all if the type 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: Typ)(implicit ec: ExecutionContext): Type
t -->: u
is shorthand forType("fun", t, u)
, i.e., for a function fromt
tou
. - 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(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(that: Any): Boolean
Equality of types.
Equality of types. Returns true iff the two Typ instances represent the same type in the Isabelle process. (E.g., a Ctyp and a TFree 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
- Typ → AnyRef → Any
- def force: Typ.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[Typ.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[_ <: AnyRef]
- 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
- Typ → 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(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])