summaryrefslogtreecommitdiff
path: root/FinMap.agda
diff options
context:
space:
mode:
Diffstat (limited to 'FinMap.agda')
-rw-r--r--FinMap.agda10
1 files changed, 3 insertions, 7 deletions
diff --git a/FinMap.agda b/FinMap.agda
index df422c3..1ae4c39 100644
--- a/FinMap.agda
+++ b/FinMap.agda
@@ -6,7 +6,7 @@ open import Data.Maybe using (Maybe ; just ; nothing ; maybe′)
open import Data.Fin using (Fin ; zero ; suc)
open import Data.Fin.Properties using (_≟_)
open import Data.Vec using (Vec ; [] ; _∷_ ; _[_]≔_ ; replicate ; tabulate ; foldr ; zip ; toList) renaming (lookup to lookupVec ; map to mapV)
-open import Data.Vec.Properties using (lookup∘update ; lookup∘update′)
+open import Data.Vec.Properties using (lookup∘update ; lookup∘update′ ; lookup-replicate)
open import Data.Product using (_×_ ; _,_)
open import Data.List.All as All using (All)
import Data.List.All.Properties as AllP
@@ -79,12 +79,8 @@ lemma-insert-same [] () p
lemma-insert-same {suc n} (x ∷ xs) zero p = P.cong (flip _∷_ xs) p
lemma-insert-same (x ∷ xs) (suc i) p = P.cong (_∷_ x) (lemma-insert-same xs i p)
-lemma-lookupM-empty : {A : Set} {n : ℕ} → (i : Fin n) → lookupM {A} i empty ≡ nothing
-lemma-lookupM-empty zero = P.refl
-lemma-lookupM-empty (suc i) = lemma-lookupM-empty i
-
lemma-lookupM-restrict : {A : Set} {n m : ℕ} → (i : Fin n) → (f : Fin n → A) → (is : Vec (Fin n) m) → {a : A} → lookupM i (restrict f is) ≡ just a → f i ≡ a
-lemma-lookupM-restrict i f [] p = contradiction (P.trans (P.sym p) (lemma-lookupM-empty i)) (λ ())
+lemma-lookupM-restrict i f [] p = contradiction (P.trans (P.sym p) (lookup-replicate i nothing)) (λ ())
lemma-lookupM-restrict i f (i' ∷ is) p with i ≟ i'
lemma-lookupM-restrict i f (.i ∷ is) {a} p | yes P.refl = just-injective (begin
just (f i)
@@ -108,7 +104,7 @@ lemma-lookupM-restrict-∈ i f (j ∷ js) (Any.there p) | no i≢j =
(lemma-lookupM-restrict-∈ i f js p)
lemma-lookupM-restrict-∉ : {A : Set} {n m : ℕ} → (i : Fin n) → (f : Fin n → A) → (js : Vec (Fin n) m) → i ∉ js → lookupM i (restrict f js) ≡ nothing
-lemma-lookupM-restrict-∉ i f [] i∉[] = lemma-lookupM-empty i
+lemma-lookupM-restrict-∉ i f [] i∉[] = lookup-replicate i nothing
lemma-lookupM-restrict-∉ i f (j ∷ js) i∉jjs =
P.trans (lookup∘update′ (All.head i∉jjs) (restrict f js) (just (f j)))
(lemma-lookupM-restrict-∉ i f js (All.tail i∉jjs))