summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2019-03-31 21:47:21 +0200
committerHelmut Grohne <helmut@subdivi.de>2019-03-31 21:47:21 +0200
commit121094635514bf07bb91d6b7d16a45674c74f34e (patch)
treec7f9c952c05774fd78d9c25e615b0a4da26d6846
parent50f61bef184194fc48dd1415800830d032495f51 (diff)
downloadbidiragda-121094635514bf07bb91d6b7d16a45674c74f34e.tar.gz
FinMap.lemma-lookupM-fromFunc is almost Data.Vec.Properties.lookup∘tabulate
-rw-r--r--Bidir.agda2
-rw-r--r--FinMap.agda8
-rw-r--r--Precond.agda8
3 files changed, 7 insertions, 11 deletions
diff --git a/Bidir.agda b/Bidir.agda
index cbe693c..5587d20 100644
--- a/Bidir.agda
+++ b/Bidir.agda
@@ -130,7 +130,7 @@ theorem-1 G {i} s = begin
h′↦r (fromFunc f)
≡⟨ P.refl ⟩
fmapS (flip lookupM (fromFunc f)) t
- ≡⟨ IsFunctor.cong (Shaped.isFunctor SourceShapeT (gl₁ i)) (lemma-lookupM-fromFunc f) t ⟩
+ ≡⟨ IsFunctor.cong (Shaped.isFunctor SourceShapeT (gl₁ i)) (lookup∘tabulate (just ∘ f)) t ⟩
fmapS (Maybe.just ∘ f) t
≡⟨ IsFunctor.composition (Shaped.isFunctor SourceShapeT (gl₁ i)) just f t ⟩
fmapS just (fmapS f t)
diff --git a/FinMap.agda b/FinMap.agda
index b069162..459ec7e 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′ ; lookup-replicate ; tabulate-cong)
+open import Data.Vec.Properties using (lookup∘update ; lookup∘update′ ; lookup-replicate ; tabulate-cong ; lookup∘tabulate)
open import Data.Product using (_×_ ; _,_)
open import Data.List.All as All using (All)
import Data.List.All.Properties as AllP
@@ -109,10 +109,6 @@ 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))
-lemma-lookupM-fromFunc : {n : ℕ} {A : Set} → (f : Fin n → A) → flip lookupM (fromFunc f) ≗ Maybe.just ∘ f
-lemma-lookupM-fromFunc f zero = P.refl
-lemma-lookupM-fromFunc f (suc i) = lemma-lookupM-fromFunc (f ∘ suc) i
-
lemma-lookupM-delete : {n : ℕ} {A : Set} {i j : Fin n} → (f : FinMapMaybe n A) → i ≢ j → lookupM i (delete j f) ≡ lookupM i f
lemma-lookupM-delete {i = zero} {j = zero} (_ ∷ _) p = contradiction P.refl p
lemma-lookupM-delete {i = zero} {j = suc j} (_ ∷ _) p = P.refl
@@ -138,7 +134,7 @@ lemma-disjoint-union {n} f t = tabulate-cong inner
maybe′ just (lookupM x (delete-many t (fromFunc f))) (lookupM x (restrict f t))
≡⟨ P.cong₂ (maybe′ just) (lemma-lookupM-delete-many (fromFunc f) x t x∉t) (lemma-lookupM-restrict-∉ x f t x∉t) ⟩
maybe′ just (lookupM x (fromFunc f)) nothing
- ≡⟨ lemma-lookupM-fromFunc f x ⟩
+ ≡⟨ P.cong (flip (maybe′ just) nothing) (lookup∘tabulate (just ∘ f) x) ⟩
just (f x) ∎
lemma-exchange-maps : {n m : ℕ} → {A : Set} → {h h′ : FinMapMaybe n A} → {P : Fin n → Set} → (∀ j → P j → lookupM j h ≡ lookupM j h′) → {is : Vec (Fin n) m} → All P (toList is) → mapV (flip lookupM h) is ≡ mapV (flip lookupM h′) is
diff --git a/Precond.agda b/Precond.agda
index 293f44d..3fccfe8 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-∘ ; lookup-replicate ; tabulate-cong)
+open import Data.Vec.Properties using (map-cong ; map-∘ ; tabulate-∘ ; lookup-replicate ; tabulate-cong ; lookup∘tabulate)
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 ; delete-many ; delete ; lemma-lookupM-delete ; lemma-lookupM-fromFunc ; reshape ; lemma-reshape-id)
+open import FinMap using (FinMapMaybe ; lookupM ; union ; fromFunc ; empty ; insert ; delete-many ; delete ; lemma-lookupM-delete ; reshape ; lemma-reshape-id)
import CheckInsert
open CheckInsert (P.decSetoid deq) using (checkInsert ; lemma-checkInsert-new ; lemma-lookupM-checkInsert-other)
import BFF
@@ -45,7 +45,7 @@ lemma-maybe-just a nothing = P.refl
lemma-union-delete-fromFunc : {m n : ℕ} {A : Set} {is : Vec (Fin n) m} {h : FinMapMaybe n A} {g : Fin n → A} → is in-domain-of h → ∃ λ v → union h (delete-many is (fromFunc g)) ≡ fromFunc v
lemma-union-delete-fromFunc {is = []} {h = h} {g = g} p = _ , (tabulate-cong (λ f → begin
maybe′ just (lookupM f (fromFunc g)) (lookupM f h)
- ≡⟨ P.cong (flip (maybe′ just) (lookupM f h)) (lemma-lookupM-fromFunc g f) ⟩
+ ≡⟨ P.cong (flip (maybe′ just) (lookupM f h)) (lookup∘tabulate (just ∘ g) f) ⟩
maybe′ just (just (g f)) (lookupM f h)
≡⟨ lemma-maybe-just (g f) (lookupM f h) ⟩
just (maybe′ id (g f) (lookupM f h)) ∎))
@@ -88,7 +88,7 @@ module _ (G : Get) where
fmapS (flip lookupM (union h g′)) t
≡⟨ P.cong ((λ f → fmapS f t) ∘ flip lookupM) (proj₂ wp) ⟩
fmapS (flip lookupM (fromFunc (proj₁ wp))) t
- ≡⟨ IsFunctor.cong (Shaped.isFunctor SourceShapeT (gl₁ i)) (lemma-lookupM-fromFunc (proj₁ wp)) t ⟩
+ ≡⟨ IsFunctor.cong (Shaped.isFunctor SourceShapeT (gl₁ i)) (lookup∘tabulate (just ∘ proj₁ wp)) t ⟩
fmapS (Maybe.just ∘ proj₁ wp) t
≡⟨ IsFunctor.composition (Shaped.isFunctor SourceShapeT (gl₁ i)) just (proj₁ wp) t ⟩
fmapS Maybe.just (fmapS (proj₁ wp) t) ∎) ⟩ _ ∎)