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.

84 lines
1.3 KiB

3 years ago
3 years ago
3 years ago
3 years ago
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. | Typeω
  15. | I
  16. | I0 | I1
  17. | IAnd Exp Exp
  18. | IOr Exp Exp
  19. | INot Exp
  20. | Path
  21. | Cut Exp Exp
  22. | Span (Int, Int) (Int, Int) Exp
  23. -- Formulas, partial elements, and the type of formulas
  24. | Partial [(Formula, Exp)]
  25. | PartialT
  26. | PartialP
  27. -- Compositions
  28. | Comp
  29. -- Cubical subtypes
  30. | SubT
  31. -- Glueing
  32. | GlueTy
  33. | Glue
  34. | Unglue
  35. -- Bools
  36. | Bool
  37. | Tt
  38. | Ff
  39. | If
  40. deriving (Eq, Show, Ord)
  41. data Formula
  42. = Is0 String
  43. | Is1 String
  44. | And Formula Formula
  45. | Or Formula Formula
  46. | Top | Bot
  47. deriving (Eq, Ord)
  48. instance Show Formula where
  49. showsPrec p =
  50. \case
  51. Is1 i -> showString i
  52. Is0 i -> showString ('~':i)
  53. And x y -> showParen (p > and_prec) $
  54. showsPrec or_prec x
  55. . showString " && "
  56. . showsPrec or_prec y
  57. Or x y -> showParen (p > or_prec) $
  58. showsPrec or_prec x
  59. . showString " || "
  60. . showsPrec or_prec y
  61. Top -> showString "i1"
  62. Bot -> showString "i0"
  63. where
  64. and_prec = 2
  65. or_prec = 1
  66. data Statement
  67. = Assume [(String, Exp)]
  68. | Declare String Exp Exp
  69. | Eval Exp