- data AtIndex : a -> List a -> Nat -> Type
@AtIndex witnesses the fact that a natural number encodes a membership proof.
It is meant to be used as a runtime-irrelevant gadget to guarantee that the
natural number is indeed a valid index.
Totality: total
Constructors:
- Z : AtIndex a (a :: as) 0
- S : AtIndex a as n -> AtIndex a (b :: as) (S n)
- interface Member : a -> List a -> Type
If the equality is not decidable, we may instead rely on interface resolution
Parameters: t, ts
Methods:
- isMember' : Subset Nat (AtIndex t ts)
Implementations:
- Member t (t :: ts)
- Member t ts => Member t (u :: ts)
- atIndexUnique : AtIndex a as n -> AtIndex b as n -> a = b
For a given list and a given index, there is only one possible value
stored at that index in that list
Totality: total- find : DecEq a => (x : a) -> (xs : List a) -> Dec (Subset Nat (AtIndex x xs))
Provided that equality is decidable, we can look for the first occurence
of a value inside of a list
Totality: total- inRange : (n : Nat) -> (xs : List a) -> (0 _ : AtIndex x xs n) -> LTE n (length xs)
An AtIndex proof implies that n is less than the length of the list indexed into
Totality: total- inverseS : AtIndex x (y :: xs) (S n) -> AtIndex x xs n
inversion principle for S constructor
Totality: total- inverseZ : AtIndex x (y :: xs) 0 -> x = y
Inversion principle for Z constructor
Totality: total- isMember : (0 t : a) -> (0 ts : List a) -> Member t ts => Subset Nat (AtIndex t ts)
- Totality: total
- isMember' : Member t ts => Subset Nat (AtIndex t ts)
- Totality: total
- lookup : (n : Nat) -> (xs : List a) -> Dec (Subset a (\x => AtIndex x xs n))
Given an index, we can decide whether there is a value corresponding to it
Totality: total- strengthenL : (p : Subset Nat (HasLength xs)) -> lt n (fst p) = True -> AtIndex x (xs ++ ys) n -> AtIndex x xs n
- Totality: total
- strengthenR : (p : Subset Nat (HasLength ws)) -> lte (fst p) n = True -> AtIndex x (ws ++ xs) n -> AtIndex x xs (minus n (fst p))
- Totality: total
- weakenL : (p : Subset Nat (HasLength ws)) -> AtIndex x xs n -> AtIndex x (ws ++ xs) (fst p + n)
- Totality: total
- weakenR : AtIndex x xs n -> AtIndex x (xs ++ ys) n
- Totality: total