index Var.Compare by compare
i may go back on this if it's too annoying
This commit is contained in:
parent
f405aeb7f9
commit
ef8b8b0da3
2 changed files with 17 additions and 14 deletions
|
@ -104,10 +104,10 @@ mutual
|
||||||
|
|
||||||
export %inline
|
export %inline
|
||||||
setVar : (i, j : Var d) -> DimEq' d -> DimEq d
|
setVar : (i, j : Var d) -> DimEq' d -> DimEq d
|
||||||
setVar i j eqs = case compareP i j of
|
setVar i j eqs with (compareP i j) | (compare i.nat j.nat)
|
||||||
IsLT lt => setVar' i j lt eqs
|
setVar i j eqs | IsLT lt | LT = setVar' i j lt eqs
|
||||||
IsEQ => C eqs
|
setVar i i eqs | IsEQ | EQ = C eqs
|
||||||
IsGT gt => setVar' j i gt eqs
|
setVar i j eqs | IsGT gt | GT = setVar' j i gt eqs
|
||||||
|
|
||||||
|
|
||||||
export %inline
|
export %inline
|
||||||
|
@ -166,7 +166,10 @@ export
|
||||||
setSelf p ZeroIsOne = Refl
|
setSelf p ZeroIsOne = Refl
|
||||||
setSelf (K Zero) (C eqs) = Refl
|
setSelf (K Zero) (C eqs) = Refl
|
||||||
setSelf (K One) (C eqs) = Refl
|
setSelf (K One) (C eqs) = Refl
|
||||||
setSelf (B i) (C eqs) = rewrite comparePSelf i in Refl
|
setSelf (B i) (C eqs) with (compareP i i) | (compare i.nat i.nat)
|
||||||
|
_ | IsLT lt | LT = absurd lt
|
||||||
|
_ | IsEQ | EQ = Refl
|
||||||
|
_ | IsGT gt | GT = absurd gt
|
||||||
|
|
||||||
|
|
||||||
-- [todo] "well formed" dimeqs
|
-- [todo] "well formed" dimeqs
|
||||||
|
|
|
@ -172,34 +172,34 @@ isLT (VS i) (VS j) with (isLT i j)
|
||||||
|
|
||||||
|
|
||||||
public export
|
public export
|
||||||
data Compare : (i, j : Var n) -> Type where
|
data Compare : (i, j : Var n) -> Ordering -> Type where
|
||||||
IsLT : (lt : i `LT` j) -> Compare i j
|
IsLT : (lt : i `LT` j) -> Compare i j LT
|
||||||
IsEQ : Compare i i
|
IsEQ : Compare i i EQ
|
||||||
IsGT : (gt : i `GT` j) -> Compare i j
|
IsGT : (gt : i `GT` j) -> Compare i j GT
|
||||||
%name Compare cmp
|
%name Compare cmp
|
||||||
|
|
||||||
export
|
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 (IsLT lt) = IsLT (LTS lt)
|
||||||
compareS IsEQ = IsEQ
|
compareS IsEQ = IsEQ
|
||||||
compareS (IsGT gt) = IsGT (LTS gt)
|
compareS (IsGT gt) = IsGT (LTS gt)
|
||||||
|
|
||||||
export
|
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 VZ = IsEQ
|
||||||
compareP VZ (VS j) = IsLT LTZ
|
compareP VZ (VS j) = IsLT LTZ
|
||||||
compareP (VS i) VZ = IsGT LTZ
|
compareP (VS i) VZ = IsGT LTZ
|
||||||
compareP (VS i) (VS j) = compareS $ compareP i j
|
compareP (VS i) (VS j) = compareS $ compareP i j
|
||||||
|
|
||||||
export
|
export
|
||||||
0 compareSelf : (c : Compare i i) -> c = IsEQ
|
0 compareSelf : Compare i i o -> o = EQ
|
||||||
compareSelf (IsLT lt) = absurd lt
|
compareSelf (IsLT lt) = absurd lt
|
||||||
compareSelf IsEQ = Refl
|
compareSelf IsEQ = Refl
|
||||||
compareSelf (IsGT gt) = absurd gt
|
compareSelf (IsGT gt) = absurd gt
|
||||||
|
|
||||||
export
|
export
|
||||||
0 comparePSelf : (i : Var n) -> compareP i i = IsEQ
|
0 comparePSelf : (i : Var n) -> Compare i i EQ
|
||||||
comparePSelf i = compareSelf {}
|
comparePSelf i = rewrite sym $ compareNatDiag i.nat in compareP i i
|
||||||
|
|
||||||
|
|
||||||
public export
|
public export
|
||||||
|
|
Loading…
Reference in a new issue