natural numbers
This commit is contained in:
parent
fae534dae0
commit
9250789219
15 changed files with 305 additions and 10 deletions
|
@ -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