more tests

This commit is contained in:
rhiannon morris 2023-03-26 16:15:19 +02:00
parent 5560cb6708
commit 5df2a4538c
2 changed files with 78 additions and 2 deletions

View file

@ -235,6 +235,11 @@ public export %inline
BVT : (i : Nat) -> (0 _ : LT i n) => Term q d n BVT : (i : Nat) -> (0 _ : LT i n) => Term q d n
BVT i = E $ BV i BVT i = E $ BV i
public export
makeNat : Nat -> Term q d n
makeNat 0 = Zero
makeNat (S k) = Succ $ makeNat k
public export public export
enum : List TagVal -> Term q d n enum : List TagVal -> Term q d n
enum = Enum . SortedSet.fromList enum = Enum . SortedSet.fromList

View file

@ -17,7 +17,8 @@ defGlobals = fromList
("b", mkPostulate Any $ FT "B"), ("b", mkPostulate Any $ FT "B"),
("f", mkPostulate Any $ Arr One (FT "A") (FT "A")), ("f", mkPostulate Any $ Arr One (FT "A") (FT "A")),
("id", mkDef Any (Arr One (FT "A") (FT "A")) ([< "x"] :\\ BVT 0)), ("id", mkDef Any (Arr One (FT "A") (FT "A")) ([< "x"] :\\ BVT 0)),
("eq-AB", mkPostulate Zero $ Eq0 (TYPE 0) (FT "A") (FT "B"))] ("eq-AB", mkPostulate Zero $ Eq0 (TYPE 0) (FT "A") (FT "B")),
("two", mkDef Any Nat (Succ (Succ Zero)))]
parameters (label : String) (act : Lazy (M ())) parameters (label : String) (act : Lazy (M ()))
{default defGlobals globals : Definitions Three} {default defGlobals globals : Definitions Three}
@ -71,7 +72,7 @@ tests = "equality & subtyping" :- [
subT empty (TYPE 2) (TYPE 1) (TYPE 0) subT empty (TYPE 2) (TYPE 1) (TYPE 0)
], ],
"pi" :- [ "function types" :- [
note #""𝐴𝐵" for (1·𝐴)𝐵"#, note #""𝐴𝐵" for (1·𝐴)𝐵"#,
note #""𝐴𝐵" for (0·𝐴)𝐵"#, note #""𝐴𝐵" for (0·𝐴)𝐵"#,
testEq "★₀ ⇾ ★₀ = ★₀ ⇾ ★₀" $ testEq "★₀ ⇾ ★₀ = ★₀ ⇾ ★₀" $
@ -417,6 +418,76 @@ tests = "equality & subtyping" :- [
(F "f") (F "f")
], ],
"natural numbers" :- [
testEq "zero = zero" $ equalT empty Nat Zero Zero,
testEq "succ two = succ two" $
equalT empty Nat (Succ (FT "two")) (Succ (FT "two")),
testNeq "succ two ≠ two" $
equalT empty Nat (Succ (FT "two")) (FT "two"),
testNeq "zero ≠ succ zero" $
equalT empty Nat Zero (Succ Zero),
testEq "0=1 ⊢ zero = succ zero" $
equalT empty01 Nat Zero (Succ Zero)
],
"natural elim" :- [
testEq "caseω 0 return {a,b} of {zero ⇒ 'a; succ _ ⇒ 'b} = 'a" $
equalT empty
(enum ["a", "b"])
(E $ CaseNat Any Zero (Zero :# Nat)
(SN $ enum ["a", "b"])
(Tag "a")
(SN $ Tag "b"))
(Tag "a"),
testEq "caseω 1 return {a,b} of {zero ⇒ 'a; succ _ ⇒ 'b} = 'b" $
equalT empty
(enum ["a", "b"])
(E $ CaseNat Any Zero (Succ Zero :# Nat)
(SN $ enum ["a", "b"])
(Tag "a")
(SN $ Tag "b"))
(Tag "b"),
testEq "caseω 4 return of {0 ⇒ 0; succ n ⇒ n} = 3" $
equalT empty
Nat
(E $ CaseNat Any Zero (makeNat 4 :# Nat)
(SN Nat)
Zero
(SY [< "n", Unused] $ BVT 1))
(makeNat 3)
],
todo "pair types",
"pairs" :- [
testEq "('a, 'b) = ('a, 'b) : {a} × {b}" $
equalT empty
(enum ["a"] `And` enum ["b"])
(Tag "a" `Pair` Tag "b")
(Tag "a" `Pair` Tag "b"),
testNeq "('a, 'b) ≠ ('b, 'a) : {a,b} × {a,b}" $
equalT empty
(enum ["a", "b"] `And` enum ["a", "b"])
(Tag "a" `Pair` Tag "b")
(Tag "b" `Pair` Tag "a"),
testEq "0=1 ⊢ ('a, 'b) = ('b, 'a) : {a,b} × {a,b}" $
equalT empty01
(enum ["a", "b"] `And` enum ["a", "b"])
(Tag "a" `Pair` Tag "b")
(Tag "b" `Pair` Tag "a"),
testEq "0=1 ⊢ ('a, 'b) = ('b, 'a) : " $
equalT empty01
Nat
(Tag "a" `Pair` Tag "b")
(Tag "b" `Pair` Tag "a")
],
todo "pair elim",
todo "enum types",
todo "enum",
todo "enum elim",
"elim closure" :- [ "elim closure" :- [
testEq "#0{a} = a" $ testEq "#0{a} = a" $
equalE empty (CloE (BV 0) (F "a" ::: id)) (F "a"), equalE empty (CloE (BV 0) (F "a" ::: id)) (F "a"),