diff options
author | Greg Brown <greg.brown01@ed.ac.uk> | 2023-06-30 20:45:33 +0100 |
---|---|---|
committer | Greg Brown <greg.brown01@ed.ac.uk> | 2023-06-30 20:45:33 +0100 |
commit | 8c529393421843a7ccad041d2f29fa90b46bf6b6 (patch) | |
tree | f7b31388e5ca5831ef84f9c9a6809a4eb77fa66b /src/Data/Vect/Properties/Insert.idr | |
parent | 621f6221048213dc4d359581197988050af99d0d (diff) |
Define zippers and prove no cycles exist.
Diffstat (limited to 'src/Data/Vect/Properties/Insert.idr')
-rw-r--r-- | src/Data/Vect/Properties/Insert.idr | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Data/Vect/Properties/Insert.idr b/src/Data/Vect/Properties/Insert.idr new file mode 100644 index 0000000..28393b1 --- /dev/null +++ b/src/Data/Vect/Properties/Insert.idr @@ -0,0 +1,26 @@ +module Data.Vect.Properties.Insert + +import Data.Vect + +export +mapInsertAt : + (0 f : a -> b) -> + (i : Fin (S n)) -> + (0 x : a) -> + (xs : Vect n a) -> + map f (insertAt i x xs) = insertAt i (f x) (map f xs) +mapInsertAt f FZ x xs = Refl +mapInsertAt f (FS i) x (y :: xs) = cong (f y ::) $ mapInsertAt f i x xs + +export +indexInsertAt : (i : Fin (S n)) -> (0 x : a) -> (xs : Vect n a) -> index i (insertAt i x xs) = x +indexInsertAt FZ x xs = Refl +indexInsertAt (FS i) x (y :: xs) = indexInsertAt i x xs + +export +insertAtIndex : + (i : Fin (S n)) -> + (xs : Vect (S n) a) -> + insertAt i (index i xs) (deleteAt i xs) = xs +insertAtIndex FZ (x :: xs) = Refl +insertAtIndex (FS i) (x :: xs@(_ :: _)) = cong (x ::) $ insertAtIndex i xs |