diff options
author | Helmut Grohne <helmut@subdivi.de> | 2012-01-21 12:22:34 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2012-01-21 12:22:34 +0100 |
commit | a511dceb455975ded324c14c10f3cb6f85b95c3d (patch) | |
tree | 65f43cf86169346550e69635ab6d692b3f6a79ea /Bidir.agda | |
parent | 6e458b738fd75fccac1c605091bfcf7486001533 (diff) | |
download | bidiragda-a511dceb455975ded324c14c10f3cb6f85b95c3d.tar.gz |
rewrite generate using zip and fromAscList
This way matches the usage in lemma-1 more closely since zip actually is
something similar to assoc.
Diffstat (limited to 'Bidir.agda')
-rw-r--r-- | Bidir.agda | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -25,6 +25,10 @@ module FinMap where empty : {A : Set} {n : ℕ} → FinMapMaybe n A empty = replicate nothing + fromAscList : {A : Set} {n : ℕ} → List (Fin n × A) → FinMapMaybe n A + fromAscList [] = empty + fromAscList ((f , a) ∷ xs) = insert f a (fromAscList xs) + FinMap : ℕ → Set → Set FinMap n A = Vec A n @@ -52,8 +56,7 @@ assoc eq (i ∷ is) (b ∷ bs) = maybe′ (checkInsert eq i b) nothing (assoc eq assoc _ _ _ = nothing generate : {A : Set} {n : ℕ} → (Fin n → A) → List (Fin n) → FinMapMaybe n A -generate f [] = empty -generate f (n ∷ ns) = insert n (f n) (generate f ns) +generate f is = fromAscList (zip is (map f is)) lemma-1 : {τ : Set} {n : ℕ} → (eq : (x y : τ) → Dec (x ≡ y)) → (f : Fin n → τ) → (is : List (Fin n)) → assoc eq is (map f is) ≡ just (generate f is) lemma-1 eq f [] = refl |