IdrisDoc: Data.Fin.Extra

Data.Fin.Extra

data FractionView : (n : Nat) -> (d : Nat) -> Type

A view of Nat as a quotient of some number and a finite remainder.

Fraction : (n : Nat) -> (d : Nat) -> {auto ok : GT d 0} -> (q : Nat) -> (r : Fin d) -> (q * d + finToNat r = n) -> FractionView n d
divMod : (n : Nat) -> (d : Nat) -> {auto ok : GT d 0} -> FractionView n d

Converts Nat to the fractional view with a non-zero divisor.

doubleInvFinSame : (m : Fin n) -> invFin (invFin m) = m

Proof that double inversion of Fin n gives the original.

elemSmallerThanBound : (n : Fin m) -> LT (finToNat n) m

Proof that an element n of Fin m , when converted to Nat is smaller than the bound m.

finToNatLastIsBound : finToNat last = n

Proof that application of finToNat the last element of Fin S n gives n.

finToNatWeakenNeutral : finToNat (weaken n) = finToNat n

Proof that an element n of Fin m , when converted to Nat is smaller than the bound m.

invFin : Fin n -> Fin n

Enumerate elements of Fin n backwards.

invLastIsFZ : invFin last = FZ

Proof that an inverse of the last element of Fin (S n) in FZ.

invWeakenIsSucc : (m : Fin n) -> invFin (weaken m) = FS (invFin m)

Proof that an inverse of a weakened element of Fin n is a successive of an inverse of an original element.

strengthen' : (m : Fin (S n)) -> Either (m = last) (m' : Fin n ** finToNat m = finToNat m')

Either tightens the bound on a Fin or proves that it's the last.

strengthenLastIsLeft : strengthen last = Left last

Proof that it's not possible to strengthen the last element of Fin n.

strengthenNotLastIsRight : (m : Fin (S n)) -> strengthen (invFin (FS m)) = Right (invFin m)

Proof that it's possible to strengthen an inverse of a succesive element of Fin n.

strengthenWeakenNeutral : (n : Fin m) -> strengthen (weaken n) = Right n

Proof that it's possible to strengthen a weakened element of Fin m.