summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2020-08-01 09:05:13 +0200
committerHelmut Grohne <helmut@subdivi.de>2020-08-01 09:05:13 +0200
commit85865ec3c7c3e3a458dc233d4c28e4db97191f3d (patch)
tree0a14606aecf7bc228f0ddd9d9af78bf37650188f
parent6ce567bf63a61bce4ccf71e3ec402d94d1da2fb1 (diff)
downloadbidiragda-85865ec3c7c3e3a458dc233d4c28e4db97191f3d.tar.gz
individually open ≡-Reasoning
_≡⟨_⟩_ will be turned into a syntax, so it cannot be imported in future. Avoid doing so now by opening it where needed.
-rw-r--r--FinMap.agda28
-rw-r--r--Precond.agda36
2 files changed, 35 insertions, 29 deletions
diff --git a/FinMap.agda b/FinMap.agda
index 051014c..1241252 100644
--- a/FinMap.agda
+++ b/FinMap.agda
@@ -19,8 +19,7 @@ open import Function.Surjection using (module Surjection)
open import Relation.Nullary using (yes ; no)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary.Core using (Decidable)
-open import Relation.Binary.PropositionalEquality as P using (_≡_ ; _≢_ ; _≗_)
-open P.≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎)
+open import Relation.Binary.PropositionalEquality as P using (_≡_ ; _≢_ ; _≗_ ; module ≡-Reasoning)
_∈_ : {A : Set} {n : ℕ} → A → Vec A n → Set
_∈_ {A} x xs = Data.List.Membership.Setoid._∈_ (P.setoid A) x (toList xs)
@@ -82,17 +81,19 @@ lemma-lookupM-restrict : {A : Set} {n m : ℕ} → (i : Fin n) → (f : Fin n
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)
- ≡⟨ P.sym (lookup∘update i (restrict f is) (just (f i))) ⟩
- lookupM i (insert i (f i) (restrict f is))
- ≡⟨ p ⟩
- just a ∎)
+ just (f i)
+ ≡⟨ P.sym (lookup∘update i (restrict f is) (just (f i))) ⟩
+ lookupM i (insert i (f i) (restrict f is))
+ ≡⟨ p ⟩
+ just a ∎)
+ where open ≡-Reasoning
lemma-lookupM-restrict i f (i' ∷ is) {a} p | no i≢i' = lemma-lookupM-restrict i f is (begin
- lookupM i (restrict f is)
- ≡⟨ P.sym (lookup∘update′ i≢i' (restrict f is) (just (f i'))) ⟩
- lookupM i (insert i' (f i') (restrict f is))
- ≡⟨ p ⟩
- just a ∎)
+ lookupM i (restrict f is)
+ ≡⟨ P.sym (lookup∘update′ i≢i' (restrict f is) (just (f i'))) ⟩
+ lookupM i (insert i' (f i') (restrict f is))
+ ≡⟨ p ⟩
+ just a ∎)
+ where open ≡-Reasoning
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) ≡ just (f i)
lemma-lookupM-restrict-∈ i f [] ()
lemma-lookupM-restrict-∈ i f (j ∷ js) p with i ≟ j
@@ -120,7 +121,8 @@ 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 = 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)
+ where open ≡-Reasoning
+ 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)
inner x | no-∉ x∉t = begin
diff --git a/Precond.agda b/Precond.agda
index 9d21022..623c99f 100644
--- a/Precond.agda
+++ b/Precond.agda
@@ -23,8 +23,7 @@ open import Data.Maybe using (just)
open import Data.Product using (∃ ; _,_ ; proj₁ ; proj₂)
open import Function using (flip ; _∘_ ; id)
open import Relation.Binary using (Setoid)
-open import Relation.Binary.PropositionalEquality as P using (inspect ; [_])
-open P.≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎)
+open import Relation.Binary.PropositionalEquality as P using (inspect ; [_] ; module ≡-Reasoning)
open import Relation.Nullary using (yes ; no)
open import Structures using (IsFunctor ; module Shaped ; Shaped)
@@ -49,13 +48,15 @@ lemma-union-delete-fromFunc {is = []} h {g = g} p = _ , (tabulate-cong (λ 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)) ∎))
+ where open ≡-Reasoning
lemma-union-delete-fromFunc {n = n} {is = i ∷ is} h {g = g} (Data.List.All._∷_ (x , px) ps) = _ , (begin
union h (delete i (delete-many is (fromFunc g)))
≡⟨ tabulate-cong inner ⟩
union h (delete-many is (fromFunc g))
≡⟨ proj₂ (lemma-union-delete-fromFunc h ps) ⟩
_ ∎)
- where inner : (f : Fin n) → maybe′ just (lookupM f (delete i (delete-many is (fromFunc g)))) (lookup h f) ≡ maybe′ just (lookupM f (delete-many is (fromFunc g))) (lookup h f)
+ where open ≡-Reasoning
+ inner : (f : Fin n) → maybe′ just (lookupM f (delete i (delete-many is (fromFunc g)))) (lookup h f) ≡ maybe′ just (lookupM f (delete-many is (fromFunc g))) (lookup h f)
inner f with f ≟ i
inner .i | yes P.refl = begin
maybe′ just (lookupM i (delete i (delete-many is (fromFunc g)))) (lookup h i)
@@ -92,7 +93,8 @@ module _ (G : Get) where
fmapS (Maybe.just ∘ proj₁ wp) t
≡⟨ IsFunctor.composition (Shaped.isFunctor SourceShapeT (gl₁ i)) just (proj₁ wp) t ⟩
fmapS Maybe.just (fmapS (proj₁ wp) t) ∎) ⟩ _ ∎)
- where s′ = enumerate SourceShapeT (gl₁ i)
+ where open ≡-Reasoning
+ s′ = enumerate SourceShapeT (gl₁ i)
g = fromFunc (denumerate SourceShapeT s)
g′ = delete-many (contentV (get s′)) g
t = enumerate SourceShapeT (gl₁ i)
@@ -107,20 +109,22 @@ lemma-∉-lookupM-assoc i [] [] P.refl i∉is = lookup-replicate
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
- lookupM i h
- ≡⟨ lemma-lookupM-checkInsert-other i i' (i∉is ∘ here) x' h' ph ⟩
- lookupM i h'
- ≡⟨ lemma-∉-lookupM-assoc i is' xs' ph' (i∉is ∘ there) ⟩
- nothing ∎
+ lookupM i h
+ ≡⟨ lemma-lookupM-checkInsert-other i i' (i∉is ∘ here) x' h' ph ⟩
+ lookupM i h'
+ ≡⟨ lemma-∉-lookupM-assoc i is' xs' ph' (i∉is ∘ there) ⟩
+ nothing ∎
+ where open ≡-Reasoning
different-assoc : {m n : ℕ} → (u : Vec (Fin n) m) → (v : Vec Carrier m) → All-different (toList u) → ∃ λ h → assoc u v ≡ just h
different-assoc [] [] p = empty , P.refl
different-assoc (u ∷ us) (v ∷ vs) (different-∷ u∉us diff-us) with different-assoc us vs diff-us
different-assoc (u ∷ us) (v ∷ vs) (different-∷ u∉us diff-us) | h , p' = insert u v h , (begin
- assoc (u ∷ us) (v ∷ vs)
- ≡⟨ P.refl ⟩
- (assoc us vs >>= checkInsert u v)
- ≡⟨ P.cong (flip _>>=_ (checkInsert u v)) p' ⟩
- checkInsert u v h
- ≡⟨ lemma-checkInsert-new u v h (lemma-∉-lookupM-assoc u us vs p' u∉us) ⟩
- just (insert u v h) ∎)
+ assoc (u ∷ us) (v ∷ vs)
+ ≡⟨ P.refl ⟩
+ (assoc us vs >>= checkInsert u v)
+ ≡⟨ P.cong (flip _>>=_ (checkInsert u v)) p' ⟩
+ checkInsert u v h
+ ≡⟨ lemma-checkInsert-new u v h (lemma-∉-lookupM-assoc u us vs p' u∉us) ⟩
+ just (insert u v h) ∎)
+ where open ≡-Reasoning