represent ℕ constants directly

instead of as huge `succ (succ (succ ⋯))` terms
This commit is contained in:
rhiannon morris 2023-11-02 20:01:34 +01:00
parent fa7f82ae5a
commit 0514fff481
18 changed files with 104 additions and 115 deletions

View file

@ -486,11 +486,11 @@ tests = "equality & subtyping" :- [
testEq "caseω 4 return of {0 ⇒ 0; succ n ⇒ n} = 3" $
equalT empty
(^NAT)
(E $ ^CaseNat Any Zero (^Ann (^makeNat 4) (^NAT))
(E $ ^CaseNat Any Zero (^Ann (^Nat 4) (^NAT))
(SN $ ^NAT)
(^Zero)
(SY [< "n", ^BN Unused] $ ^BVT 1))
(^makeNat 3)
(^Nat 3)
],
todo "pair types",

View file

@ -284,12 +284,10 @@ tests = "parser" :- [
"naturals" :- [
parseMatch term "" `(NAT _),
parseMatch term "Nat" `(NAT _),
parseMatch term "zero" `(Zero _),
parseMatch term "zero" `(Nat 0 _),
parseMatch term "succ n" `(Succ (V "n" {}) _),
parseMatch term "3"
`(Succ (Succ (Succ (Zero _) _) _) _),
parseMatch term "succ (succ 1)"
`(Succ (Succ (Succ (Zero _) _) _) _),
parseMatch term "3" `(Nat 3 _),
parseMatch term "succ (succ 1)" `(Succ (Succ (Nat 1 _) _) _),
parseFails term "succ succ 5",
parseFails term "succ"
],
@ -299,12 +297,9 @@ tests = "parser" :- [
`(BOX (PQ One _) (NAT _) _),
parseMatch term "[ω. × ]"
`(BOX (PQ Any _) (Sig (Unused _) (NAT _) (NAT _) _) _),
parseMatch term "[a]"
`(Box (V "a" {}) _),
parseMatch term "[0]"
`(Box (Zero _) _),
parseMatch term "[1]"
`(Box (Succ (Zero _) _) _)
parseMatch term "[a]" `(Box (V "a" {}) _),
parseMatch term "[0]" `(Box (Nat 0 _) _),
parseMatch term "[1]" `(Box (Nat 1 _) _)
],
"coe" :- [
@ -389,13 +384,13 @@ tests = "parser" :- [
(CaseNat (V "a" {}) (PV "n'" _, PQ Zero _, Unused _, V "b" {}) _) _),
parseMatch term "caseω n return of { succ _, 1.ih ⇒ ih; zero ⇒ 0; }"
`(Case (PQ Any _) (V "n" {}) (Unused _, NAT _)
(CaseNat (Zero _) (Unused _, PQ One _, PV "ih" _, V "ih" {}) _) _),
(CaseNat (Nat 0 _) (Unused _, PQ One _, PV "ih" _, V "ih" {}) _) _),
parseMatch term "caseω n return of { succ _, ω.ih ⇒ ih; zero ⇒ 0; }"
`(Case (PQ Any _) (V "n" {}) (Unused _, NAT _)
(CaseNat (Zero _) (Unused _, PQ Any _, PV "ih" _, V "ih" {}) _) _),
(CaseNat (Nat 0 _) (Unused _, PQ Any _, PV "ih" _, V "ih" {}) _) _),
parseMatch term "caseω n return of { succ _, ih ⇒ ih; zero ⇒ 0; }"
`(Case (PQ Any _) (V "n" {}) (Unused _, NAT _)
(CaseNat (Zero _) (Unused _, PQ One _, PV "ih" _, V "ih" {}) _) _),
(CaseNat (Nat 0 _) (Unused _, PQ One _, PV "ih" _, V "ih" {}) _) _),
parseFails term "caseω n return A of { zero ⇒ a }",
parseFails term "caseω n return of { succ ⇒ 5 }"
],