Prototype, extremely bad code implementation of CCHM Cubical Type Theory
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.2 KiB

3 years ago
  1. {-# LANGUAGE LambdaCase #-}
  2. module Presyntax where
  3. data Exp
  4. = Var String
  5. | App Exp Exp
  6. | Lam String Exp
  7. | Let String Exp Exp Exp
  8. | Sigma String Exp Exp
  9. | Pair Exp Exp
  10. | Proj1 Exp
  11. | Proj2 Exp
  12. | Pi String Exp Exp
  13. | Type
  14. | I
  15. | I0 | I1
  16. | IAnd Exp Exp
  17. | IOr Exp Exp
  18. | INot Exp
  19. | Path
  20. | Cut Exp Exp
  21. | Span (Int, Int) (Int, Int) Exp
  22. -- Formulas, partial elements, and the type of formulas
  23. | Partial [(Formula, Exp)]
  24. | PartialT
  25. -- Compositions
  26. | Comp
  27. -- Cubical subtypes
  28. | SubT
  29. deriving (Eq, Show, Ord)
  30. data Formula
  31. = Is0 String
  32. | Is1 String
  33. | And Formula Formula
  34. | Or Formula Formula
  35. | Top | Bot
  36. deriving (Eq, Ord)
  37. instance Show Formula where
  38. showsPrec p =
  39. \case
  40. Is1 i -> showString i
  41. Is0 i -> showString ('~':i)
  42. And x y -> showParen (p > and_prec) $
  43. showsPrec or_prec x
  44. . showString " && "
  45. . showsPrec or_prec y
  46. Or x y -> showParen (p > or_prec) $
  47. showsPrec or_prec x
  48. . showString " || "
  49. . showsPrec or_prec y
  50. Top -> showString "i1"
  51. Bot -> showString "i0"
  52. where
  53. and_prec = 2
  54. or_prec = 1
  55. data Statement
  56. = Assume [(String, Exp)]
  57. | Declare String Exp Exp
  58. | Eval Exp