summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2019-03-31 21:23:11 +0200
committerHelmut Grohne <helmut@subdivi.de>2019-03-31 21:23:11 +0200
commit50f61bef184194fc48dd1415800830d032495f51 (patch)
tree0d5b30b9a1e491d8554c96be2c98a8103e6fd737
parent4d2b9ba79a5a35ad63ee941f0681697cf017dfd0 (diff)
downloadbidiragda-50f61bef184194fc48dd1415800830d032495f51.tar.gz
FinMap.lemma-tabulate-∘ is also known as Data.Vec.Properties.tabulate-cong
-rw-r--r--FinMap.agda8
-rw-r--r--Precond.agda8
2 files changed, 6 insertions, 10 deletions
diff --git a/FinMap.agda b/FinMap.agda
index 1ae4c39..b069162 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)
+open import Data.Vec.Properties using (lookup∘update ; lookup∘update′ ; lookup-replicate ; tabulate-cong)
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-tabulate-∘ : {n : ℕ} {A : Set} → {f g : Fin n → A} → f ≗ g → tabulate f ≡ tabulate g
-lemma-tabulate-∘ {zero} {_} {f} {g} f≗g = P.refl
-lemma-tabulate-∘ {suc n} {_} {f} {g} f≗g = P.cong₂ _∷_ (f≗g zero) (lemma-tabulate-∘ (f≗g ∘ suc))
-
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
@@ -134,7 +130,7 @@ lemma-reshape-id [] = P.refl
lemma-reshape-id (x ∷ xs) = P.cong (_∷_ x) (lemma-reshape-id xs)
lemma-disjoint-union : {n m : ℕ} {A : Set} → (f : Fin n → A) → (t : Vec (Fin n) m) → union (restrict f t) (delete-many t (fromFunc f)) ≡ fromFunc f
-lemma-disjoint-union {n} f t = lemma-tabulate-∘ inner
+lemma-disjoint-union {n} f t = tabulate-cong inner
where inner : (x : Fin n) → maybe′ just (lookupM x (delete-many t (fromFunc f))) (lookupM x (restrict f t)) ≡ just (f x)
inner x with is-∈ _≟_ x t
inner x | yes-∈ x∈t = P.cong (maybe′ just (lookupM x (delete-many t (fromFunc f)))) (lemma-lookupM-restrict-∈ x f t x∈t)
diff --git a/Precond.agda b/Precond.agda
index 8eec6da..293f44d 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)
+open import Data.Vec.Properties using (map-cong ; map-∘ ; tabulate-∘ ; lookup-replicate ; tabulate-cong)
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 ; 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 ; 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
@@ -43,7 +43,7 @@ lemma-maybe-just a (just x) = P.refl
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 = _ , (lemma-tabulate-∘ (λ f → begin
+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) ⟩
maybe′ just (just (g f)) (lookupM f h)
@@ -51,7 +51,7 @@ lemma-union-delete-fromFunc {is = []} {h = h} {g = g} p = _ , (lemma-tabulate-âˆ
just (maybe′ id (g f) (lookupM f h)) ∎))
lemma-union-delete-fromFunc {n = n} {is = i ∷ is} {h = h} {g = g} (Data.List.All._∷_ (x , px) ps) = _ , (begin
union h (delete i (delete-many is (fromFunc g)))
- ≡⟨ lemma-tabulate-∘ inner ⟩
+ ≡⟨ tabulate-cong inner ⟩
union h (delete-many is (fromFunc g))
≡⟨ proj₂ (lemma-union-delete-fromFunc ps) ⟩
_ ∎)