Skip to content

Commit

Permalink
[ more ] missing results
Browse files Browse the repository at this point in the history
  • Loading branch information
gallais committed Oct 13, 2023
1 parent 166f20a commit 585f8e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions libs/base/Data/Vect.idr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ Biinjective Vect.(::) where
-- Indexing into vectors
--------------------------------------------------------------------------------

export
invertVectZ : (xs : Vect Z a) -> xs === []
invertVectZ [] = Refl


||| All but the first element of the vector
|||
||| ```idris example
Expand All @@ -67,6 +72,10 @@ public export
head : Vect (S len) elem -> elem
head (x::_) = x

export
invertVectS : (xs : Vect (S n) a) -> xs === head xs :: tail xs
invertVectS (_ :: _) = Refl

||| The last element of the vector
|||
||| ```idris example
Expand Down
12 changes: 11 additions & 1 deletion libs/base/Data/Vect/Quantifiers.idr
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ namespace All
forgetRememberId [] = Refl
forgetRememberId (x :: xs) = cong (x ::) (forgetRememberId xs)

public export
castAllConst : {0 xs, ys : Vect n a} -> All (const ty) xs -> All (const ty) ys
castAllConst [] = rewrite invertVectZ ys in []
castAllConst (x :: xs) = rewrite invertVectS ys in x :: castAllConst xs

export
rememberForgetId : (vs : All (const ty) xs) ->
castAllConst (remember (forget vs)) === vs
rememberForgetId [] = Refl
rememberForgetId (x :: xs) = cong (x ::) (rememberForgetId xs)

export
zipPropertyWith : (f : {0 x : a} -> p x -> q x -> r x) ->
All p xs -> All q xs -> All r xs
Expand Down Expand Up @@ -232,4 +243,3 @@ namespace All
drop' 0 ys = rewrite minusZeroRight k in ys
drop' (S k) [] = []
drop' (S k) (y :: ys) = drop' k ys

0 comments on commit 585f8e1

Please sign in to comment.