unfold definitions in equality checking, plus cleanup

This commit is contained in:
rhiannon morris 2022-08-23 05:43:23 +02:00
parent 44778825c2
commit 8a55cc9581
4 changed files with 137 additions and 81 deletions

View file

@ -5,30 +5,45 @@ import Quox.Pretty
import TAP
export
ToInfo Equal.Error where
ToInfo Error where
toInfo (NotInScope x) =
[("type", "NotInScope"),
("name", show x)]
toInfo (ExpectedTYPE t) =
[("type", "ExpectedTYPE"),
("got", prettyStr True t)]
toInfo (ExpectedPi t) =
[("type", "ExpectedPi"),
("got", prettyStr True t)]
toInfo (BadUniverse k l) =
[("type", "BadUniverse"),
("low", show k),
("high", show l)]
toInfo (ClashT mode s t) =
[("clash", "term"),
[("type", "ClashT"),
("mode", show mode),
("left", prettyStr True s),
("right", prettyStr True t)]
toInfo (ClashU mode k l) =
[("clash", "universe"),
[("type", "ClashU"),
("mode", show mode),
("left", prettyStr True k),
("right", prettyStr True l)]
toInfo (ClashQ pi rh) =
[("clash", "quantity"),
[("type", "ClashQ"),
("left", prettyStr True pi),
("right", prettyStr True rh)]
M = Either Equal.Error
M = ReaderT Definitions (Either Error)
testEq : String -> Lazy (M ()) -> Test
testEq = test
parameters (label : String) (act : Lazy (M ()))
{default empty globals : Definitions}
testEq : Test
testEq = test label $ runReaderT globals act
testNeq : String -> Lazy (M ()) -> Test
testNeq label = testThrows label $ const True
testNeq : Test
testNeq = testThrows label (const True) $ runReaderT globals act
subT : {default 0 d, n : Nat} -> Term d n -> Term d n -> M ()
@ -144,11 +159,22 @@ tests = "equality & subtyping" :- [
todo "term d-closure",
"free var" :- [
"free var" :-
let au_bu = fromList
[("A", MkDef Any (TYPE (U 1)) (TYPE (U 0))),
("B", MkDef Any (TYPE (U 1)) (TYPE (U 0)))]
au_ba = fromList
[("A", MkDef Any (TYPE (U 1)) (TYPE (U 0))),
("B", MkDef Any (TYPE (U 1)) (FT "A"))]
in [
testEq "A ≡ A" $
equalE (F "A") (F "A"),
testNeq "A ≢ B" $
equalE (F "A") (F "B"),
testEq "A ≔ ★₀, B ≔ ★₀ ⊢ A ≡ B" {globals = au_bu} $
equalE (F "A") (F "B"),
testEq "A ≔ ★₀, B ≔ A ⊢ A ≡ B" {globals = au_ba} $
equalE (F "A") (F "B"),
testEq "A <: A" $
subE (F "A") (F "A"),
testNeq "A ≮: B" $