Extensibella Example: lambda_calculus:typing

Language Specification

File: syntax.sos

[Reduce File] [Raw File]
Module lambda_calculus:typing

Builds on lambda_calculus:host

e ::= ...
    | tyabs(string, ty, e)

ty ::= intTy
     | arrowTy(ty, ty)

Projection ty :


----------------------------------------- [Proj-Tyabs]
|{e}- tyabs(X, Ty, Body) ~~> abs(X, Body)




------------------------------------ [E-Tyabs]
eval tyabs(X, Ty, Body) abs(X, Body)



----------------------------------------- [S-Tyabs-Eq]
subst X R tyabs(X, Ty, Body) abs(X, Body)


X != Y
subst X R Body B
-------------------------------------- [S-Tyabs-NEq]
subst X R tyabs(Y, Ty, Body) abs(Y, B)

File: typing.sos

[Reduce File] [Raw File]
Module lambda_calculus:typing

Judgment typeOf : [(string, ty)] e* ty

lookup G X Ty
------------------ [T-Var]
typeOf G var(X) Ty


typeOf (X, Ty1)::G Body Ty2
--------------------------------------- [T-Abs]
typeOf G abs(X, Body) arrowTy(Ty1, Ty2)


typeOf (X, Ty1)::G Body Ty2
---------------------------------------------- [T-Tyabs]
typeOf G tyabs(X, Ty1, Body) arrowTy(Ty1, Ty2)


typeOf G E1 arrowTy(Ty1, Ty2)
typeOf G E2 Ty1
----------------------------- [T-App]
typeOf G app(E1, E2) Ty2


---------------------- [T-Int]
typeOf G intE(I) intTy


typeOf G E1 intTy
typeOf G E2 intTy
--------------------------- [T-Plus]
typeOf G plus(E1, E2) intTy


|{e}- E ~~> E_T
typeOf G E_T Ty
--------------- [T-D]*
typeOf G E Ty

Reasoning

[Show All Proofs] [Hide All Proofs] [Raw File]

Click on a command or tactic to see a detailed view of its use.

Module lambda_calculus:typing.


Prove_Constraint lambda_calculus:host:proj_is. [Show Proof]



Add_Proj_Rel lambda_calculus:host:is_e.

Prove_Ext_Ind lambda_calculus:host:is_e. [Show Proof]



Prove_Constraint lambda_calculus:host:proj_same. [Show Proof]



Prove lambda_calculus:host:subst_exists. [Show Proof]



Prove lambda_calculus:host:subst_is. [Show Proof]



Prove lambda_calculus:host:eval_is. [Show Proof]



Prove lambda_calculus:host:subst_unique. [Show Proof]



Prove lambda_calculus:host:eval_unique. [Show Proof]



Prove_Constraint lambda_calculus:host:proj_subst. [Show Proof]


Prove_Constraint lambda_calculus:host:proj_subst_same. [Show Proof]



Prove_Constraint lambda_calculus:host:proj_eval. [Show Proof]


Prove_Constraint lambda_calculus:host:proj_eval_same. [Show Proof]



Add_Ext_Size lambda_calculus:host:eval.
Add_Proj_Rel lambda_calculus:host:eval.


Prove_Ext_Ind lambda_calculus:host:eval. [Show Proof]



Extensible_Theorem
  type_weakening : forall G E Ty G',
    IsE : is_e E ->
    Ty : typeOf G E Ty ->
    Lkp : (forall X XTy, lookup G X XTy -> lookup G' X XTy) ->
    typeOf G' E Ty
  on Ty. [Show Proof]


Theorem any_ctx : forall E Ty G,
  is_e E -> typeOf [] E Ty -> typeOf G E Ty. [Show Proof]



Extensible_Theorem
  tyabs_or_not : forall E,
    IsE : is_e E ->
    (exists X Ty B, E = tyabs X Ty B) \/
    ((exists X Ty B, E = tyabs X Ty B) -> false)
  on IsE. [Show Proof]



Extensible_Theorem
  subst_type_preservation : forall X R E S G TyE TyX G',
    IsE : is_e E ->
    IsX : is_string X ->
    IsR : is_e R ->
    S : subst X R E S ->
    TyE : typeOf G E TyE ->
    TyR : typeOf [] R TyX ->
    Lkp : lookup G X TyX ->
    Slct : select (X, TyX) G' G ->
    typeOf G' S TyE
  on TyE. [Show Proof]



Extensible_Theorem
  type_preservation : forall E Ty V,
    IsE : is_e E ->
    Ty : typeOf [] E Ty ->
    Ev : eval E V ->
    typeOf [] V Ty
  on Ev. [Show Proof]


/*
  Note we do not have type uniqueness because abs(X, var(X)) could
  have any arrow type.

  We also cannot prove progress because, in the generic case,
  we could show the projection would evaluate, but we do not have a
  projection constraint that would allow us to lift this back to the
  new syntax.
*/

Back to example home