diff options
author | Helmut Grohne <helmut@subdivi.de> | 2019-03-31 21:14:50 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2019-03-31 21:14:50 +0200 |
commit | 4d2b9ba79a5a35ad63ee941f0681697cf017dfd0 (patch) | |
tree | e2b8519ce63b03b470d970f8338048bdaac5597f | |
parent | 25d4df9182c92ef26979566f06c7c9f17746f0fb (diff) | |
download | bidiragda-4d2b9ba79a5a35ad63ee941f0681697cf017dfd0.tar.gz |
replace FinMap.lemma-lookupM-empty with Data.Vec.Properties.lookup-replicate
-rw-r--r-- | FinMap.agda | 10 | ||||
-rw-r--r-- | Precond.agda | 6 |
2 files changed, 6 insertions, 10 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)) diff --git a/Precond.agda b/Precond.agda index 98ba7a6..8eec6da 100644 --- a/Precond.agda +++ b/Precond.agda @@ -15,7 +15,7 @@ import Data.Maybe.Categorical open Category.Monad.RawMonad {Level.zero} Data.Maybe.Categorical.monad using (_>>=_) open Category.Functor.RawFunctor {Level.zero} Data.Maybe.Categorical.functor using (_<$>_) open import Data.Vec using (Vec ; [] ; _∷_ ; map ; lookup ; toList) -open import Data.Vec.Properties using (map-cong ; map-∘ ; tabulate-∘) +open import Data.Vec.Properties using (map-cong ; map-∘ ; tabulate-∘ ; lookup-replicate) import Data.List.All open import Data.List.Any using (here ; there) open import Data.List.Membership.Setoid using (_∉_) @@ -28,7 +28,7 @@ open P.≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎) open import Relation.Nullary using (yes ; no) open import Structures using (IsFunctor ; module Shaped ; Shaped) -open import FinMap using (FinMapMaybe ; lookupM ; union ; fromFunc ; empty ; insert ; lemma-lookupM-empty ; delete-many ; lemma-tabulate-∘ ; delete ; lemma-lookupM-delete ; lemma-lookupM-fromFunc ; reshape ; lemma-reshape-id) +open import FinMap using (FinMapMaybe ; lookupM ; union ; fromFunc ; empty ; insert ; delete-many ; lemma-tabulate-∘ ; delete ; lemma-lookupM-delete ; lemma-lookupM-fromFunc ; reshape ; lemma-reshape-id) import CheckInsert open CheckInsert (P.decSetoid deq) using (checkInsert ; lemma-checkInsert-new ; lemma-lookupM-checkInsert-other) import BFF @@ -103,7 +103,7 @@ data All-different {A : Set} : List A → Set where different-∷ : {x : A} {xs : List A} → _∉_ (P.setoid A) x xs → All-different xs → All-different (x ∷ xs) lemma-∉-lookupM-assoc : {m n : ℕ} → (i : Fin n) → (is : Vec (Fin n) m) → (xs : Vec Carrier m) → {h : FinMapMaybe n Carrier} → assoc is xs ≡ just h → _∉_ (P.setoid (Fin n)) i (toList is) → lookupM i h ≡ nothing -lemma-∉-lookupM-assoc i [] [] P.refl i∉is = lemma-lookupM-empty i +lemma-∉-lookupM-assoc i [] [] P.refl i∉is = lookup-replicate i nothing lemma-∉-lookupM-assoc i (i' ∷ is') (x' ∷ xs') ph i∉is with assoc is' xs' | inspect (assoc is') xs' lemma-∉-lookupM-assoc i (i' ∷ is') (x' ∷ xs') () i∉is | nothing | [ ph' ] lemma-∉-lookupM-assoc i (i' ∷ is') (x' ∷ xs') {h} ph i∉is | just h' | [ ph' ] = begin |