index Var.Compare by compare

i may go back on this if it's too annoying
This commit is contained in:
rhiannon morris 2023-01-10 00:08:47 +01:00
parent f405aeb7f9
commit ef8b8b0da3
2 changed files with 17 additions and 14 deletions

View file

@ -172,34 +172,34 @@ isLT (VS i) (VS j) with (isLT i j)
public export
data Compare : (i, j : Var n) -> Type where
IsLT : (lt : i `LT` j) -> Compare i j
IsEQ : Compare i i
IsGT : (gt : i `GT` j) -> Compare i j
data Compare : (i, j : Var n) -> Ordering -> Type where
IsLT : (lt : i `LT` j) -> Compare i j LT
IsEQ : Compare i i EQ
IsGT : (gt : i `GT` j) -> Compare i j GT
%name Compare cmp
export
compareS : Compare i j -> Compare (VS i) (VS j)
compareS : Compare i j o -> Compare (VS i) (VS j) o
compareS (IsLT lt) = IsLT (LTS lt)
compareS IsEQ = IsEQ
compareS (IsGT gt) = IsGT (LTS gt)
export
compareP : (i, j : Var n) -> Compare i j
compareP : (i, j : Var n) -> Compare i j (compare i j)
compareP VZ VZ = IsEQ
compareP VZ (VS j) = IsLT LTZ
compareP (VS i) VZ = IsGT LTZ
compareP (VS i) (VS j) = compareS $ compareP i j
export
0 compareSelf : (c : Compare i i) -> c = IsEQ
0 compareSelf : Compare i i o -> o = EQ
compareSelf (IsLT lt) = absurd lt
compareSelf IsEQ = Refl
compareSelf (IsGT gt) = absurd gt
export
0 comparePSelf : (i : Var n) -> compareP i i = IsEQ
comparePSelf i = compareSelf {}
0 comparePSelf : (i : Var n) -> Compare i i EQ
comparePSelf i = rewrite sym $ compareNatDiag i.nat in compareP i i
public export