natural numbers
This commit is contained in:
parent
fae534dae0
commit
9250789219
15 changed files with 305 additions and 10 deletions
|
@ -51,6 +51,15 @@ mutual
|
|||
DLam body1 == DLam body2 = body1.term == body2.term
|
||||
DLam {} == _ = False
|
||||
|
||||
Nat == Nat = True
|
||||
Nat == _ = False
|
||||
|
||||
Zero == Zero = True
|
||||
Zero == _ = False
|
||||
|
||||
Succ m == Succ n = m == n
|
||||
Succ _ == _ = False
|
||||
|
||||
E e == E f = e == f
|
||||
E _ == _ = False
|
||||
|
||||
|
@ -85,6 +94,11 @@ mutual
|
|||
q1 == q2 && t1 == t2 && r1.term == r2.term && a1 == a2
|
||||
CaseEnum {} == _ = False
|
||||
|
||||
CaseNat q1 q1' n1 r1 z1 s1 == CaseNat q2 q2' n2 r2 z2 s2 =
|
||||
q1 == q2 && q1' == q2' && n1 == n2 &&
|
||||
r1.term == r2.term && z1 == z2 && s1.term == s2.term
|
||||
CaseNat {} == _ = False
|
||||
|
||||
(fun1 :% dim1) == (fun2 :% dim2) = fun1 == fun2 && dim1 == dim2
|
||||
(_ :% _) == _ = False
|
||||
|
||||
|
|
|
@ -224,6 +224,15 @@ tests = "parser" :- [
|
|||
parseFails term "≡"
|
||||
],
|
||||
|
||||
"naturals" :- [
|
||||
parsesAs term "ℕ" Nat,
|
||||
parsesAs term "Nat" Nat,
|
||||
parsesAs term "zero" Zero,
|
||||
parsesAs term "succ n" (Succ $ V "n"),
|
||||
parsesAs term "3" (Succ (Succ (Succ Zero)) :# Nat),
|
||||
parseFails term "succ"
|
||||
],
|
||||
|
||||
"case" :- [
|
||||
parsesAs term
|
||||
"case1 f s return x ⇒ A x of { (l, r) ⇒ add l r }" $
|
||||
|
@ -251,7 +260,15 @@ tests = "parser" :- [
|
|||
parsesAs term "caseω t return A of {}" $
|
||||
Case Any (V "t") (Nothing, V "A") (CaseEnum []),
|
||||
parsesAs term "case# t return A of {}" $
|
||||
Case Any (V "t") (Nothing, V "A") (CaseEnum [])
|
||||
Case Any (V "t") (Nothing, V "A") (CaseEnum []),
|
||||
parsesAs term "caseω n return A of { 0 ⇒ a; succ n' ⇒ b }" $
|
||||
Case Any (V "n") (Nothing, V "A") $
|
||||
CaseNat (V "a") (Just "n'", Zero, Nothing, V "b"),
|
||||
parsesAs term "caseω n return ℕ of { succ _ [1.ih] ⇒ ih; zero ⇒ 0; }" $
|
||||
Case Any (V "n") (Nothing, Nat) $
|
||||
CaseNat (Zero :# Nat) (Nothing, One, Just "ih", V "ih"),
|
||||
parseFails term "caseω n return A of { zero ⇒ a }",
|
||||
parseFails term "caseω n return ℕ of { succ ⇒ 5 }"
|
||||
],
|
||||
|
||||
"definitions" :- [
|
||||
|
|
|
@ -363,6 +363,18 @@ tests = "typechecker" :- [
|
|||
check_ empty01 sone (Tag "a") (enum ["b", "c"])
|
||||
],
|
||||
|
||||
"enum matching" :- [
|
||||
testTC "ω.x : {tt} ⊢ 1 · case1 x return {tt} of { 'tt ⇒ 'tt } ⇒ {tt}" $
|
||||
inferAs (ctx [< ("x", enum ["tt"])]) sone
|
||||
(CaseEnum One (BV 0) (SN (enum ["tt"])) $
|
||||
singleton "tt" (Tag "tt"))
|
||||
(enum ["tt"]),
|
||||
testTCFail "ω.x : {tt} ⊢ 1 · case1 x return {tt} of { 'ff ⇒ 'tt } ⇏" $
|
||||
infer_ (ctx [< ("x", enum ["tt"])]) sone
|
||||
(CaseEnum One (BV 0) (SN (enum ["tt"])) $
|
||||
singleton "ff" (Tag "tt"))
|
||||
],
|
||||
|
||||
"equalities" :- [
|
||||
testTC "1 · (δ i ⇒ a) ⇐ a ≡ a" $
|
||||
check_ empty sone (DLam $ SN $ FT "a")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue