All Projects → Lysxia → system-F

Lysxia / system-F

Licence: other
Formalization of the polymorphic lambda calculus and its parametricity theorem

Programming Languages

Coq
218 projects

Projects that are alternatives of or similar to system-F

vanilla-lang
An implementation of a predicative polymorphic language with bidirectional type inference and algebraic data types
Stars: ✭ 73 (+265%)
Mutual labels:  lambda-calculus, polymorphism, system-f
lambda-calculus
An introduction to the Lambda Calculus
Stars: ✭ 59 (+195%)
Mutual labels:  lambda-calculus, system-f
Dblib Linear
Formalisation of the linear lambda calculus in Coq
Stars: ✭ 10 (-50%)
Mutual labels:  lambda-calculus, coq
Zion
A statically-typed strictly-evaluated garbage-collected readable programming language.
Stars: ✭ 33 (+65%)
Mutual labels:  lambda-calculus, polymorphism
Type-Theory
Lecture note on Lambda Calculus and Types for FLOLAC
Stars: ✭ 26 (+30%)
Mutual labels:  lambda-calculus, system-f
Iron
Coq formalizations of functional languages.
Stars: ✭ 114 (+470%)
Mutual labels:  lambda-calculus, coq
koika
A core language for rule-based hardware design 🦑
Stars: ✭ 103 (+415%)
Mutual labels:  coq
hydra-battles
Variations on Kirby & Paris' hydra battles and other entertaining math in Coq (collaborative, documented, includes exercises) [maintainer=@Casteran]
Stars: ✭ 38 (+90%)
Mutual labels:  coq
abella
An interactive theorem prover based on lambda-tree syntax
Stars: ✭ 81 (+305%)
Mutual labels:  lambda-calculus
stablesort
Stable sort algorithms and their stability proofs in Coq
Stars: ✭ 19 (-5%)
Mutual labels:  coq
PUMPKIN-PATCH
Proof Updater Mechanically Passing Knowledge Into New Proofs, Assisting The Coq Hacker
Stars: ✭ 43 (+115%)
Mutual labels:  coq
Java-Programs
Java Practiced Problems including concepts of OOPS, Interface, String , Collection.
Stars: ✭ 51 (+155%)
Mutual labels:  polymorphism
Actuary
Formalization of the basic actuarial mathematics using Coq
Stars: ✭ 17 (-15%)
Mutual labels:  coq
coqeal
The Coq Effective Algebra Library [maintainers=@CohenCyril,@proux01]
Stars: ✭ 62 (+210%)
Mutual labels:  coq
coqdocjs
Collection of scripts to improve the output of coqdoc [maintainers=@chdoc,@palmskog]
Stars: ✭ 28 (+40%)
Mutual labels:  coq
coqffi
Coq to OCaml FFI made easy [maintainer=@lthms]
Stars: ✭ 27 (+35%)
Mutual labels:  coq
meta-cedille
Minimalistic dependent type theory with syntactic metaprogramming
Stars: ✭ 40 (+100%)
Mutual labels:  lambda-calculus
gidti
Book: Gentle Introduction to Dependent Types with Idris
Stars: ✭ 70 (+250%)
Mutual labels:  lambda-calculus
poly collection
Fast containers of polymorphic objects.
Stars: ✭ 58 (+190%)
Mutual labels:  polymorphism
hs-to-coq
Convert Haskell source code to Coq source code.
Stars: ✭ 64 (+220%)
Mutual labels:  coq

Parametricity of the polymorphic lambda calculus

This is a formalization of the polymorphic lambda calculus (System F) with a proof of Reynolds's parametricity theorem.

The formalization uses a dependently-typed representation, which ensures that all terms are well-typed by construction. This enables a natural style of denotational semantics.

References

  • Types, Abstraction and Parametric Polymorphism, by John C. Reynolds, IFIP 1983.
  • Theorems for free!, by Philip Wadler, ICFP 1989.

Highlights

Syntax

Types

(**
<<
t ::= t -> t     (* Function *)
    | forall t   (* Type generalization *)
    | i          (* Type variable (DeBruijn index) *)
    | unit       (* Unit type *)
    | t * t      (* Product *)
    | t + t      (* Sum *)
>>
  *)
Inductive ty (n : nat) : Type :=
| Arrow : ty n -> ty n -> ty n
| Forall : ty (S n) -> ty n
| Tyvar : bnat n -> ty n

(* Basic data types *)
| Unit : ty n
| Prod : ty n -> ty n -> ty n
| Sum : ty n -> ty n -> ty n
.

Terms

(**
<<
u ::= tyfun u   (* Type abstraction *)
    | fun u     (* Value abstraction *)
    | u u       (* Application *)
    | i         (* Variable *)
    | c         (* Constant *)
>>
  *)
Inductive tm (n : nat) (vs : list (ty n)) : ty n -> Type :=
| TAbs {t}
  : tm (S n) (map (shift_ty 0) vs) t ->
    tm n vs (Forall t)
| Abs {t1 t2}
  : tm n (t1 :: vs) t2 ->
    tm n vs (Arrow t1 t2)
| App {t1 t2}
  : tm n vs (Arrow t1 t2) ->
    tm n vs t1 ->
    tm n vs t2
| Var (v : bnat (length vs))
  : tm n vs (lookup_list vs v)
| Con {t}
  : cn t ->
    tm n vs t
.

Semantics

Signatures of the denotation functions. Simplified versions, where tm0 is tm specialized to the empty context (n = 0 and vs = []).

(** Semantics of types as Coq types *)
Definition eval_ty0 : ty 0 -> Type.

(** Semantics of terms as Coq values *)
Definition eval_tm0 {t : ty 0} : tm0 t -> eval_ty0 t.

(** Relational semantics of types *)
Definition eval2_ty0 (t : ty 0) : eval_ty0 t -> eval_ty0 t -> Prop.

Parametricity theorem

(** For any term [u] of type [t], the interpretation of [u] ([eval_tm0 u])
    satisfies the relational interpretation of [t] ([eval2_ty t]). *)
Theorem parametricity0 (t : ty 0) (u : tm0 t)
  : eval2_ty0 t (eval_tm0 u) (eval_tm0 u).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].