Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Require Import Coq.Lists.List.
  2.  
  3. Set Implicit Arguments.
  4.  
  5. Inductive type : Set :=
  6. | TNat : type
  7. | TArrow : type -> type -> type.
  8.  
  9. Definition ctx := list type.
  10.  
  11. Inductive var : ctx -> type -> Set :=
  12. | VarZ : forall t Gamma, var (t :: Gamma) t
  13. | VarS : forall s t Gamma, var Gamma t -> var (s :: Gamma) t.
  14.  
  15. Inductive tm (Gamma : ctx) : type -> Set :=
  16. | Lit : nat -> tm Gamma TNat
  17. | Add : tm Gamma TNat -> tm Gamma TNat -> tm Gamma TNat
  18. | Var : forall t, var Gamma t -> tm Gamma t
  19. | Lam : forall s t, tm (s :: Gamma) t -> tm Gamma (TArrow s t)
  20. | App : forall s t, tm Gamma (TArrow s t) -> tm Gamma s -> tm Gamma t.
  21.  
  22. Class Bridge (A : Type) :=
  23. { ty : type ;
  24. reflect : forall {Gamma}, A -> tm Gamma ty ;
  25. reify : forall {Gamma}, tm Gamma ty -> option A ;
  26. }.
  27.  
  28. Instance nat_Bridge : Bridge nat :=
  29. { ty := TNat ;
  30. reflect {Gamma} n := Lit Gamma n ;
  31. reify {Gamma} e :=
  32. match e with
  33. | Lit _ n => Some n
  34. | _ => None
  35. end ;
  36. }.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement