Formalizations of Gradually Typed Languages in Agda.
The current release is v2.1.
The release v2.1 of this project has been checked by Agda
version 2.6.2 with the Agda standard library version 1.7.
This project depends on the Abstract Binding Trees library,
specifically release v1.0.
https://github.com/jsiek/abstract-binding-trees
After cloning that repository, make sure to add the path to abt.agda-lib
to the libraries file in your .agda directory and to add abt to
the defaults file.
The article "Parameterized Cast Calculi and Reusable Meta-theory for Gradually Typed Lambda Calculi" describes most of this Agda development. Here we provide a mapping from sections in that article to the files in this project.
ComposableCasts is named EfficientCastStruct)Labels: Definition of blame labels.
PrimitiveTypes and Types: Definition of gradual types and operators on them, such as precision, consistency, etc.
Variables: Definition of variables as de Bruijn indices.
GTLC: Syntax and type system of the Gradually Typed Lambda Calculus with pairs and sums.
GTLC-materialize: A version of the GTLC that uses the materialize rule (subsumption with precision) instead of using the consistency relation.
PreCastStructure: A record
definition PreCastStruct that abstracts the representation of a cast.
It includes a type constructor Cast for casts, operations on casts
(e.g. dom and cod) and categories of casts (Active, Inert,
Cross). This record definition does not depend on the
definition of terms. Two records extend PreCastStruct with their
respective definitions and lemmas:
CastStructure: contains two
record definitions: the CastStruct record and the
EfficientCastStruct. The CastStruct record extends
PreCastStruct with an applyCast operation that applies
an active cast to a value to produce a term.
The EfficientCastStruct record also extends
PreCastStruct with an applyCast operation,
but also includes a compose operation for compressing
two casts into a single cast. Two records extend CastStruct with their
respective lemmas:
CastsAllSafe .We maintain two variants of the parameterized cast calculus (CC):
Cast. This
includes the definition of substitution.ParamCastAux: defines Value, Frame,
plug, the wrapper reductions based on the idea of eta expansion,
and proves a canonical forms lemma for type dynamic.
This module is parameterized over a PreCastStruct.
ParamCastReductionOrig: Reduction
rules and proof of type safety for the first version of hte
Parameterized Cast Calculus, parameterized over a CastStruct.
ParamCastReduction: Reduction rules and
proof of type safety for the second version of hte Parameterized
Cast Calculus, parameterized over a CastStruct.
ParamCastDeterministic: A proof that reduction is deterministic.
EfficientParamCastAux: defines
SimpleValue, Value, and proves a canonical forms lemma for type
dynamic. This module is parameterized over PreCastStruct.
EfficientParamCasts: A
space-efficient reduction relation for the parameterized cast
calculus. This module requires a compose function for casts, so it
is parameterized over EfficientCastStruct. This module includes
a proof of progress.
Compilation of the GTLC to the corresponding variant of the Parameterized Cast Calculus (CC). The compilation is type preserving.
ParamCastCalculusOrig.ParamCastCalculus.Space-efficiency theorem:
PreserveHeight: Proves that the height of the casts in a program do not increase during reduction. Their size is bounded by their height, so this result contributes to the proof of space efficiency.
SpaceEfficient: A proof that the space-efficient reduction relation really is space efficient. That is, the casts that can accumulate during reduction only multiply the size of the program by a constant.
Blame-subtyping theorem:
M to contain only safe casts with the
label ℓ (CastsAllSafe). We show that the data type CastsAllSafe
is preserved during reduction.ℓ is safe cast (respects subtyping,
or a recursive safety definition if is coercion-based) in a term M
then M cannot reduce to blame ℓ". It is slightly different,
but equivalent to, the theorem statement in the Refined Criteria
paper (Siek, Vitousek, Cimini, and Boyland 2015).The gradual guarantee: We define this theorem as a simulation between less precise and more precise terms.
PreCastStructWithPrecision and
contains inversion lemmas about less precise and more precise values,
with inert casts wrapped around one or both sides.CastStructWithPrecision.
It contains multiple simulation lemmas and a catchup lemma:
the less precise side can catch up with a more precise value by
reducing to a value that is less precise.CastStructWithPrecision.
It contains the main theorem statement and proof of gradual-guarantee.GroundCast: Type safety of λB (Siek, Thiemann, Wadler 2015). ("lazy UD" of Siek, Garcia, and Taha 2009)
LazyGroundCast: λB but with active casts between function types.
GroundInertX: The cast representation in Refined Criteria (Siek, Vitousek, Cimini, and Boyland 2015). ("lazy UD" with inert cross cast)
GroundCoercion: Type safety of λC (Siek, Thiemann, Wadler 2015). ("lazy UD" of Siek, Garcia, and Taha 2009)
EfficientGroundCoercions: Type safety of λS (Siek, Thiemann, Wadler 2015). ("lazy UD" of Siek, Garcia, and Taha 2009)
HyperCoercions: A alternative to λS that optimizes the coercion representation by removing indirections. ("lazy UD")
SimpleCast: Type safety of the cast calculus of Siek and Taha (2006). (Called "partially-eager D" by Siek, Garcia, and Taha 2009).
SimpleFunCast: The same as above but casts between function types are values.
SimpleCoercions: Type safety for the cast calculus of Siek and Taha (2006) again, but the calculus is expressed with coercions.
LazyCast: Type safety for the "lazy D" calculus (Siek, Garcia, and Taha 2009).
LazyCoercions: Type safety for the "lazy D" calculus, with casts represented as coercions.
AGT: A space-efficient version of the GTLC inspired by Abstracting Gradual Typing (Garcia, Clark, and Tanter 2016). This is also closely related to the threesomes of Siek and Wadler (2011).
AbstractMachine: A space-efficient abstract machine. It's a variant of the SECD machine with optimized tail calls. It's parameterized with respect to casts.
GroundMachine: The abstract machine instantiated with the coercions from λS. ("lazy UD")
EquivCast: Proof of equivalence (simulation) between two instances of the Parameterized Cast Calculus.
EquivLamBLamC: Proof that λC simulates λB, by insantiating the above EquivCast module.
ForgetfulCast: Inspired by Greenberg's forgetful contracts. ( 🚧 UNDER CONSTRUCTION 🚧 )
TeX
48.5%
Agda
48.0%
BibTeX Style
2.7%
Formalizations of Gradually Typed Languages in Agda.
The current release is v2.1.
The release v2.1 of this project has been checked by Agda
version 2.6.2 with the Agda standard library version 1.7.
This project depends on the Abstract Binding Trees library,
specifically release v1.0.
https://github.com/jsiek/abstract-binding-trees
After cloning that repository, make sure to add the path to abt.agda-lib
to the libraries file in your .agda directory and to add abt to
the defaults file.
The article "Parameterized Cast Calculi and Reusable Meta-theory for Gradually Typed Lambda Calculi" describes most of this Agda development. Here we provide a mapping from sections in that article to the files in this project.
ComposableCasts is named EfficientCastStruct)Labels: Definition of blame labels.
PrimitiveTypes and Types: Definition of gradual types and operators on them, such as precision, consistency, etc.
Variables: Definition of variables as de Bruijn indices.
GTLC: Syntax and type system of the Gradually Typed Lambda Calculus with pairs and sums.
GTLC-materialize: A version of the GTLC that uses the materialize rule (subsumption with precision) instead of using the consistency relation.
PreCastStructure: A record
definition PreCastStruct that abstracts the representation of a cast.
It includes a type constructor Cast for casts, operations on casts
(e.g. dom and cod) and categories of casts (Active, Inert,
Cross). This record definition does not depend on the
definition of terms. Two records extend PreCastStruct with their
respective definitions and lemmas:
CastStructure: contains two
record definitions: the CastStruct record and the
EfficientCastStruct. The CastStruct record extends
PreCastStruct with an applyCast operation that applies
an active cast to a value to produce a term.
The EfficientCastStruct record also extends
PreCastStruct with an applyCast operation,
but also includes a compose operation for compressing
two casts into a single cast. Two records extend CastStruct with their
respective lemmas:
CastsAllSafe .We maintain two variants of the parameterized cast calculus (CC):
Cast. This
includes the definition of substitution.ParamCastAux: defines Value, Frame,
plug, the wrapper reductions based on the idea of eta expansion,
and proves a canonical forms lemma for type dynamic.
This module is parameterized over a PreCastStruct.
ParamCastReductionOrig: Reduction
rules and proof of type safety for the first version of hte
Parameterized Cast Calculus, parameterized over a CastStruct.
ParamCastReduction: Reduction rules and
proof of type safety for the second version of hte Parameterized
Cast Calculus, parameterized over a CastStruct.
ParamCastDeterministic: A proof that reduction is deterministic.
EfficientParamCastAux: defines
SimpleValue, Value, and proves a canonical forms lemma for type
dynamic. This module is parameterized over PreCastStruct.
EfficientParamCasts: A
space-efficient reduction relation for the parameterized cast
calculus. This module requires a compose function for casts, so it
is parameterized over EfficientCastStruct. This module includes
a proof of progress.
Compilation of the GTLC to the corresponding variant of the Parameterized Cast Calculus (CC). The compilation is type preserving.
ParamCastCalculusOrig.ParamCastCalculus.Space-efficiency theorem:
PreserveHeight: Proves that the height of the casts in a program do not increase during reduction. Their size is bounded by their height, so this result contributes to the proof of space efficiency.
SpaceEfficient: A proof that the space-efficient reduction relation really is space efficient. That is, the casts that can accumulate during reduction only multiply the size of the program by a constant.
Blame-subtyping theorem:
M to contain only safe casts with the
label ℓ (CastsAllSafe). We show that the data type CastsAllSafe
is preserved during reduction.ℓ is safe cast (respects subtyping,
or a recursive safety definition if is coercion-based) in a term M
then M cannot reduce to blame ℓ". It is slightly different,
but equivalent to, the theorem statement in the Refined Criteria
paper (Siek, Vitousek, Cimini, and Boyland 2015).The gradual guarantee: We define this theorem as a simulation between less precise and more precise terms.
PreCastStructWithPrecision and
contains inversion lemmas about less precise and more precise values,
with inert casts wrapped around one or both sides.CastStructWithPrecision.
It contains multiple simulation lemmas and a catchup lemma:
the less precise side can catch up with a more precise value by
reducing to a value that is less precise.CastStructWithPrecision.
It contains the main theorem statement and proof of gradual-guarantee.GroundCast: Type safety of λB (Siek, Thiemann, Wadler 2015). ("lazy UD" of Siek, Garcia, and Taha 2009)
LazyGroundCast: λB but with active casts between function types.
GroundInertX: The cast representation in Refined Criteria (Siek, Vitousek, Cimini, and Boyland 2015). ("lazy UD" with inert cross cast)
GroundCoercion: Type safety of λC (Siek, Thiemann, Wadler 2015). ("lazy UD" of Siek, Garcia, and Taha 2009)
EfficientGroundCoercions: Type safety of λS (Siek, Thiemann, Wadler 2015). ("lazy UD" of Siek, Garcia, and Taha 2009)
HyperCoercions: A alternative to λS that optimizes the coercion representation by removing indirections. ("lazy UD")
SimpleCast: Type safety of the cast calculus of Siek and Taha (2006). (Called "partially-eager D" by Siek, Garcia, and Taha 2009).
SimpleFunCast: The same as above but casts between function types are values.
SimpleCoercions: Type safety for the cast calculus of Siek and Taha (2006) again, but the calculus is expressed with coercions.
LazyCast: Type safety for the "lazy D" calculus (Siek, Garcia, and Taha 2009).
LazyCoercions: Type safety for the "lazy D" calculus, with casts represented as coercions.
AGT: A space-efficient version of the GTLC inspired by Abstracting Gradual Typing (Garcia, Clark, and Tanter 2016). This is also closely related to the threesomes of Siek and Wadler (2011).
AbstractMachine: A space-efficient abstract machine. It's a variant of the SECD machine with optimized tail calls. It's parameterized with respect to casts.
GroundMachine: The abstract machine instantiated with the coercions from λS. ("lazy UD")
EquivCast: Proof of equivalence (simulation) between two instances of the Parameterized Cast Calculus.
EquivLamBLamC: Proof that λC simulates λB, by insantiating the above EquivCast module.
ForgetfulCast: Inspired by Greenberg's forgetful contracts. ( 🚧 UNDER CONSTRUCTION 🚧 )
TeX
48.5%
Agda
48.0%
BibTeX Style
2.7%