summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <grohne@cs.uni-bonn.de>2014-02-17 11:04:51 +0100
committerHelmut Grohne <grohne@cs.uni-bonn.de>2014-02-17 11:17:01 +0100
commit1561b1288b93c1353972d08e91f02101b2ccebfc (patch)
treed0c1e18521af040efffaf9019a8287a369ed1000
parent248dc87e7c282a56bcc13fc28701a572288bc3ec (diff)
parentce4bbcc0c06b088a10881fcd66da5422571e7995 (diff)
downloadbidiragda-1561b1288b93c1353972d08e91f02101b2ccebfc.tar.gz
Merge branch feature-partial-getlen into master
It allows defining get functions that are only defined for some vector lengths. It retains backwards compatibility with the previous state via a VecVec compatibility module. The biggest benefit is that now standard library functions such as tail, take and drop can be passed to bff. Conflicts: heavy BFF.agda (imports, bff type clash) Bidir.agda (imports, heavy bff type clash in theorem-{1,2} and lemma-get-mapMV) Generic.agda (imports) Precond.agda (imports, bff type clash in assoc-enough)
-rw-r--r--BFF.agda28
-rw-r--r--Bidir.agda43
-rw-r--r--FreeTheorems.agda19
-rw-r--r--Generic.agda10
-rw-r--r--GetTypes.agda33
-rw-r--r--Precond.agda23
6 files changed, 109 insertions, 47 deletions
diff --git a/BFF.agda b/BFF.agda
index 56ba359..6943f0d 100644
--- a/BFF.agda
+++ b/BFF.agda
@@ -11,15 +11,15 @@ open Category.Functor.RawFunctor {Level.zero} Data.Maybe.functor using (_<$>_)
open import Data.List using (List ; [] ; _∷_ ; map ; length)
open import Data.Vec using (Vec ; toList ; fromList ; tabulate ; allFin) renaming (lookup to lookupV ; map to mapV ; [] to []V ; _∷_ to _∷V_)
open import Function using (id ; _∘_ ; flip)
-open import Relation.Binary using (DecSetoid ; module DecSetoid)
+open import Relation.Binary using (Setoid ; DecSetoid ; module DecSetoid)
open import FinMap
-open import Generic using (mapMV)
+open import Generic using (mapMV ; ≡-to-Π)
import CheckInsert
-import GetTypes
+open import GetTypes using (VecVec-to-PartialVecVec)
-module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where
- open GetTypes.VecVec public using (Get)
+module PartialVecBFF (A : DecSetoid ℓ₀ ℓ₀) where
+ open GetTypes.PartialVecVec public using (Get)
open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq)
open CheckInsert A
@@ -36,12 +36,22 @@ module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where
denumerate : {n : ℕ} → Vec Carrier n → Fin n → Carrier
denumerate = flip lookupV
- bff : (G : Get) → {n : ℕ} → (m : ℕ) → Vec Carrier n → Vec Carrier (Get.getlen G m) → Maybe (Vec Carrier m)
- bff G m s v = let s′ = enumerate s
+ bff : (G : Get) → {i : Get.|I| G} → (j : Get.|I| G) → Vec Carrier (Get.|gl₁| G i) → Vec Carrier (Get.|gl₂| G j) → Maybe (Vec Carrier (Get.|gl₁| G j))
+ bff G i s v = let s′ = enumerate s
t′ = Get.get G s′
g = fromFunc (denumerate s)
g′ = delete-many t′ g
- t = enumeratel m
+ t = enumeratel (Get.|gl₁| G i)
h = assoc (Get.get G t) v
- h′ = (flip union (reshape g′ m)) <$> h
+ h′ = (flip union (reshape g′ (Get.|gl₁| G i))) <$> h
in h′ >>= flip mapMV t ∘ flip lookupM
+
+module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where
+ open GetTypes.VecVec public using (Get)
+ open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq)
+ open CheckInsert A
+
+ open PartialVecBFF A public using (assoc ; enumerate ; denumerate)
+
+ bff : (G : Get) → {n : ℕ} → (m : ℕ) → Vec Carrier n → Vec Carrier (Get.getlen G m) → Maybe (Vec Carrier m)
+ bff G = PartialVecBFF.bff A (VecVec-to-PartialVecVec G)
diff --git a/Bidir.agda b/Bidir.agda
index fe3768d..5ee536f 100644
--- a/Bidir.agda
+++ b/Bidir.agda
@@ -25,13 +25,13 @@ open import Relation.Binary using (Setoid ; module Setoid ; module DecSetoid)
import Relation.Binary.EqReasoning as EqR
import GetTypes
-open GetTypes.VecVec using (Get ; module Get)
+open GetTypes.PartialVecVec using (Get ; module Get)
open import Generic using (mapMV ; mapMV-cong ; mapMV-purity ; sequenceV ; sequence-map ; VecISetoid)
open import FinMap
import CheckInsert
open CheckInsert A
import BFF
-open BFF.VecBFF A using (assoc ; enumerate ; enumeratel ; denumerate ; bff)
+open BFF.PartialVecBFF A using (assoc ; enumerate ; enumeratel ; denumerate ; bff)
open Setoid using () renaming (_≈_ to _∋_≈_)
open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq)
@@ -125,19 +125,19 @@ lemma-map-denumerate-enumerate (a ∷ as) = cong (_∷_ a) (begin
as ∎)
where open ≡-Reasoning
-theorem-1 : (G : Get) → {m : ℕ} → (s : Vec Carrier m) → bff G m s (Get.get G s) ≡ just s
-theorem-1 G {m} s = begin
- bff G m s (get s)
- ≡⟨ cong (bff G m s ∘ get) (sym (lemma-map-denumerate-enumerate s)) ⟩
- bff G m s (get (map (denumerate s) (enumerate s)))
- ≡⟨ cong (bff G m s) (free-theorem (denumerate s) (enumerate s)) ⟩
- bff G m s (map (denumerate s) (get (enumerate s)))
+theorem-1 : (G : Get) → {i : Get.|I| G} → (s : Vec Carrier (Get.|gl₁| G i)) → bff G i s (Get.get G s) ≡ just s
+theorem-1 G {i} s = begin
+ bff G i s (get s)
+ ≡⟨ cong (bff G i s ∘ get) (sym (lemma-map-denumerate-enumerate s)) ⟩
+ bff G i s (get (map (denumerate s) (enumerate s)))
+ ≡⟨ cong (bff G i s) (free-theorem (denumerate s) (enumerate s)) ⟩
+ bff G i s (map (denumerate s) (get (enumerate s)))
≡⟨ refl ⟩
(h′↦r ∘ h↦h′) (assoc (get (enumerate s)) (map (denumerate s) (get (enumerate s))))
≡⟨ cong (h′↦r ∘ h↦h′) (lemma-1 (denumerate s) (get (enumerate s))) ⟩
(h′↦r ∘ h↦h′ ∘ just) (restrict (denumerate s) (toList (get (enumerate s))))
≡⟨ refl ⟩
- (h′↦r ∘ just) (union (restrict (denumerate s) (toList (get (enumerate s)))) (reshape (delete-many (get (enumerate s)) (fromFunc (denumerate s))) m))
+ (h′↦r ∘ just) (union (restrict (denumerate s) (toList (get (enumerate s)))) (reshape (delete-many (get (enumerate s)) (fromFunc (denumerate s))) (Get.|gl₁| G i)))
≡⟨ cong (h′↦r ∘ Maybe.just ∘ union (restrict (denumerate s) (toList (get (enumerate s))))) (lemma-reshape-id (delete-many (get (enumerate s)) (fromFunc (denumerate s)))) ⟩
(h′↦r ∘ just) (union (restrict (denumerate s) (toList (get (enumerate s)))) (delete-many (get (enumerate s)) (fromFunc (denumerate s))))
≡⟨ cong (h′↦r ∘ just) (lemma-disjoint-union (denumerate s) (get (enumerate s))) ⟩
@@ -152,7 +152,7 @@ theorem-1 G {m} s = begin
just s ∎
where open ≡-Reasoning
open Get G
- h↦h′ = _<$>_ (flip union (reshape (delete-many (get (enumerate s)) (fromFunc (denumerate s))) m))
+ h↦h′ = _<$>_ (flip union (reshape (delete-many (get (enumerate s)) (fromFunc (denumerate s))) (Get.|gl₁| G i)))
h′↦r = flip _>>=_ (flip mapMV (enumerate s) ∘ flip lookupM)
@@ -189,9 +189,8 @@ lemma-mapM-successful (x ∷ xs) () | just y | nothing | _
lemma-mapM-successful (x ∷ xs) p | just y | just ys | [ p′ ] with lemma-mapM-successful xs p′
lemma-mapM-successful (x ∷ xs) p | just y | just ys | [ p′ ] | w , pw = y ∷ w , cong (_∷_ (just y)) pw
-
-lemma-get-mapMV : {A B : Set} {f : A → Maybe B} {n : ℕ} {v : Vec A n} {r : Vec B n} → mapMV f v ≡ just r → (get : Get) → Get.get get <$> mapMV f v ≡ mapMV f (Get.get get v)
-lemma-get-mapMV {f = f} {v = v} p G = begin
+lemma-get-mapMV : {A B : Set} {f : A → Maybe B} → (G : Get) → {i : Get.|I| G} {v : Vec A (Get.|gl₁| G i)} {r : Vec B (Get.|gl₁| G i)} → mapMV f v ≡ just r → Get.get G <$> mapMV f v ≡ mapMV f (Get.get G v)
+lemma-get-mapMV {f = f} G {v = v} p = begin
get <$> mapMV f v
≡⟨ cong (_<$>_ get) (sym (sequence-map f v)) ⟩
get <$> (sequenceV (map f v))
@@ -222,16 +221,16 @@ sequence-cong {S} {m₁ = just x ∷ xs} {m₂ = just y ∷ ys} (VecEq._∷-cong
sequence-cong {S} {m₁ = just x ∷ xs} {m₂ = just y ∷ ys} (VecEq._∷-cong_ (just x≈y) xs≈ys) | nothing | nothing | nothing = Setoid.refl (MaybeSetoid (VecISetoid S at _))
sequence-cong {S} (VecEq._∷-cong_ nothing xs≈ys) = Setoid.refl (MaybeSetoid (VecISetoid S at _))
-theorem-2 : (G : Get) → {m : ℕ} → (n : ℕ) → (s : Vec Carrier m) → (v : Vec Carrier (Get.getlen G n)) → (u : Vec Carrier n) → bff G n s v ≡ just u → VecISetoid A.setoid at _ ∋ Get.get G u ≈ v
-theorem-2 G n s v u p with (lemma->>=-just ((flip union (reshape (delete-many (Get.get G (enumerate s)) (fromFunc (denumerate s))) n)) <$> (assoc (Get.get G (enumeratel n)) v)) p)
-theorem-2 G n s v u p | h′ , ph′ with (lemma-<$>-just (assoc (Get.get G (enumeratel n)) v) ph′)
-theorem-2 G n s v u p | h′ , ph′ | h , ph = drop-just (begin⟨ MaybeSetoid (VecISetoid A.setoid at _) ⟩
+theorem-2 : (G : Get) → {i : Get.|I| G} → (j : Get.|I| G) → (s : Vec Carrier (Get.|gl₁| G i)) → (v : Vec Carrier (Get.|gl₂| G j)) → (u : Vec Carrier (Get.|gl₁| G j)) → bff G j s v ≡ just u → VecISetoid A.setoid at _ ∋ Get.get G u ≈ v
+theorem-2 G j s v u p with (lemma->>=-just ((flip union (reshape (delete-many (Get.get G (enumerate s)) (fromFunc (denumerate s))) (Get.|gl₁| G j))) <$> (assoc (Get.get G (enumeratel (Get.|gl₁| G j))) v)) p)
+theorem-2 G j s v u p | h′ , ph′ with (lemma-<$>-just (assoc (Get.get G (enumeratel (Get.|gl₁| G j))) v) ph′)
+theorem-2 G j s v u p | h′ , ph′ | h , ph = drop-just (begin⟨ MaybeSetoid (VecISetoid A.setoid at _) ⟩
get <$> (just u)
≡⟨ cong (_<$>_ get) (sym p) ⟩
- get <$> (bff G n s v)
+ get <$> (bff G j s v)
≡⟨ cong (_<$>_ get ∘ flip _>>=_ h′↦r ∘ _<$>_ h↦h′) ph ⟩
get <$> mapMV (flip lookupM (h↦h′ h)) t
- ≡⟨ lemma-get-mapMV (trans (cong (flip _>>=_ h′↦r ∘ _<$>_ h↦h′) (sym ph)) p) G ⟩
+ ≡⟨ lemma-get-mapMV G (trans (cong (flip _>>=_ h′↦r ∘ _<$>_ h↦h′) (sym ph)) p) ⟩
mapMV (flip lookupM (h↦h′ h)) (get t)
≡⟨ sym (sequence-map (flip lookupM (h↦h′ h)) (get t)) ⟩
sequenceV (map (flip lookupM (h↦h′ h)) (get t))
@@ -246,6 +245,6 @@ theorem-2 G n s v u p | h′ , ph′ | h , ph = drop-just (begin⟨ MaybeSetoid
s′ = enumerate s
g = fromFunc (denumerate s)
g′ = delete-many (get s′) g
- t = enumeratel n
- h↦h′ = flip union (reshape g′ n)
+ t = enumeratel (Get.|gl₁| G j)
+ h↦h′ = flip union (reshape g′ (Get.|gl₁| G j))
h′↦r = flip mapMV t ∘ flip lookupM
diff --git a/FreeTheorems.agda b/FreeTheorems.agda
index 2695491..d4eb174 100644
--- a/FreeTheorems.agda
+++ b/FreeTheorems.agda
@@ -1,10 +1,15 @@
module FreeTheorems where
+open import Level using () renaming (zero to ℓ₀)
open import Data.Nat using (ℕ)
open import Data.List using (List ; map)
open import Data.Vec using (Vec) renaming (map to mapV)
open import Function using (_∘_)
-open import Relation.Binary.PropositionalEquality using (_≗_)
+open import Function.Equality using (_⟶_ ; _⟨$⟩_)
+open import Function.Injection using (module Injection) renaming (Injection to _↪_)
+open import Relation.Binary.PropositionalEquality using (_≗_ ; cong) renaming (setoid to EqSetoid)
+open import Relation.Binary using (Setoid)
+open Injection using (to)
import GetTypes
@@ -31,3 +36,15 @@ module VecVec where
assume-get : {getlen : ℕ → ℕ} → (get : get-type getlen) → Get
assume-get {getlen} get = record { getlen = getlen; get = get; free-theorem = free-theorem get }
+
+module PartialVecVec where
+ get-type : {I : Setoid ℓ₀ ℓ₀} → (I ↪ (EqSetoid ℕ)) → (I ⟶ (EqSetoid ℕ)) → Set₁
+ get-type {I} gl₁ gl₂ = {A : Set} {i : Setoid.Carrier I} → Vec A (to gl₁ ⟨$⟩ i) → Vec A (gl₂ ⟨$⟩ i)
+
+ open GetTypes.PartialVecVec public
+
+ postulate
+ free-theorem : {I : Setoid ℓ₀ ℓ₀} → (gl₁ : I ↪ (EqSetoid ℕ)) → (gl₂ : I ⟶ (EqSetoid ℕ)) (get : get-type gl₁ gl₂) → {α β : Set} → (f : α → β) → {i : Setoid.Carrier I} → get {_} {i} ∘ mapV f ≗ mapV f ∘ get
+
+ assume-get : {I : Setoid ℓ₀ ℓ₀} → (gl₁ : I ↪ (EqSetoid ℕ)) → (gl₂ : I ⟶ (EqSetoid ℕ)) (get : get-type gl₁ gl₂) → Get
+ assume-get {I} gl₁ gl₂ get = record { I = I; gl₁ = gl₁; gl₂ = gl₂; get = get; free-theorem = free-theorem gl₁ gl₂ get }
diff --git a/Generic.agda b/Generic.agda
index b29f47d..c458483 100644
--- a/Generic.agda
+++ b/Generic.agda
@@ -9,16 +9,20 @@ open import Data.Product using (_×_ ; _,_)
open import Data.Vec using (Vec ; toList ; fromList ; map) renaming ([] to []V ; _∷_ to _∷V_)
open import Data.Vec.Equality using () renaming (module Equality to VecEq)
open import Function using (_∘_ ; id ; flip)
+open import Function.Equality using (_⟶_)
open import Level using () renaming (zero to ℓ₀)
open import Relation.Binary using (Setoid ; module Setoid)
open import Relation.Binary.Core using (_≡_ ; refl)
open import Relation.Binary.Indexed using (_at_) renaming (Setoid to ISetoid)
-open import Relation.Binary.PropositionalEquality using (_≗_ ; cong ; subst ; trans ; cong₂) renaming (setoid to PropEq)
+open import Relation.Binary.PropositionalEquality using (_≗_ ; cong ; subst ; trans ; cong₂) renaming (setoid to EqSetoid)
open Setoid using () renaming (_≈_ to _∋_≈_)
open Category.Functor.RawFunctor {Level.zero} Data.Maybe.functor using (_<$>_)
open Category.Monad.RawMonad {Level.zero} Data.Maybe.monad using (_>>=_)
+≡-to-Π : {A B : Set} → (A → B) → EqSetoid A ⟶ EqSetoid B
+≡-to-Π f = record { _⟨$⟩_ = f; cong = cong f }
+
just-injective : {A : Set} → {x y : A} → Maybe.just x ≡ Maybe.just y → x ≡ y
just-injective refl = refl
@@ -38,11 +42,11 @@ mapMV-purity : {A B : Set} {n : ℕ} → (f : A → B) → (v : Vec A n) → map
mapMV-purity f []V = refl
mapMV-purity f (x ∷V xs) = cong (_<$>_ (_∷V_ (f x))) (mapMV-purity f xs)
-maybeEq-from-≡ : {A : Set} {a b : Maybe A} → a ≡ b → MaybeEq (PropEq A) ∋ a ≈ b
+maybeEq-from-≡ : {A : Set} {a b : Maybe A} → a ≡ b → MaybeEq (EqSetoid A) ∋ a ≈ b
maybeEq-from-≡ {a = just x} {b = .(just x)} refl = just refl
maybeEq-from-≡ {a = nothing} {b = .nothing} refl = nothing
-maybeEq-to-≡ : {A : Set} {a b : Maybe A} → MaybeEq (PropEq A) ∋ a ≈ b → a ≡ b
+maybeEq-to-≡ : {A : Set} {a b : Maybe A} → MaybeEq (EqSetoid A) ∋ a ≈ b → a ≡ b
maybeEq-to-≡ (just refl) = refl
maybeEq-to-≡ nothing = refl
diff --git a/GetTypes.agda b/GetTypes.agda
index 99675f9..eb72cea 100644
--- a/GetTypes.agda
+++ b/GetTypes.agda
@@ -1,10 +1,17 @@
module GetTypes where
+open import Level using () renaming (zero to ℓ₀)
open import Data.Nat using (ℕ)
open import Data.List using (List ; map)
open import Data.Vec using (Vec) renaming (map to mapV)
open import Function using (_∘_)
-open import Relation.Binary.PropositionalEquality using (_≗_)
+open import Function.Equality using (_⟶_ ; _⟨$⟩_)
+open import Function.Injection using (module Injection) renaming (Injection to _↪_ ; id to id↪)
+open import Relation.Binary.PropositionalEquality using (_≗_) renaming (setoid to EqSetoid)
+open import Relation.Binary using (Setoid)
+open Injection using (to)
+
+open import Generic using (≡-to-Π)
module ListList where
record Get : Set₁ where
@@ -18,3 +25,27 @@ module VecVec where
getlen : ℕ → ℕ
get : {A : Set} {n : ℕ} → Vec A n → Vec A (getlen n)
free-theorem : {α β : Set} (f : α → β) {n : ℕ} → get {_} {n} ∘ mapV f ≗ mapV f ∘ get
+
+module PartialVecVec where
+ record Get : Set₁ where
+ field
+ I : Setoid ℓ₀ ℓ₀
+ gl₁ : I ↪ EqSetoid ℕ
+ gl₂ : I ⟶ EqSetoid ℕ
+
+ |I| = Setoid.Carrier I
+ |gl₁| = _⟨$⟩_ (to gl₁)
+ |gl₂| = _⟨$⟩_ gl₂
+
+ field
+ get : {A : Set} {i : |I|} → Vec A (|gl₁| i) → Vec A (|gl₂| i)
+ free-theorem : {α β : Set} → (f : α → β) → {i : |I|} → get {_} {i} ∘ mapV f ≗ mapV f ∘ get
+
+VecVec-to-PartialVecVec : VecVec.Get → PartialVecVec.Get
+VecVec-to-PartialVecVec G = record
+ { I = EqSetoid ℕ
+ ; gl₁ = id↪
+ ; gl₂ = ≡-to-Π getlen
+ ; get = get
+ ; free-theorem = free-theorem
+ } where open VecVec.Get G
diff --git a/Precond.agda b/Precond.agda
index 9dd077e..bc619dc 100644
--- a/Precond.agda
+++ b/Precond.agda
@@ -6,7 +6,7 @@ open import Data.Nat using (ℕ)
open import Data.Fin using (Fin ; zero ; suc)
open import Data.Fin.Props using (_≟_)
open import Data.List using (List ; [] ; _∷_)
-import Level
+open import Level using () renaming (zero to ℓ₀)
import Category.Monad
import Category.Functor
open import Data.Maybe using (Maybe ; nothing ; just ; maybe′)
@@ -20,6 +20,7 @@ open Data.List.Any.Membership-≡ using (_∉_)
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 using (refl ; cong ; inspect ; [_] ; sym ; decSetoid)
open Relation.Binary.PropositionalEquality.≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎)
open import Relation.Nullary using (yes ; no)
@@ -32,8 +33,8 @@ import BFF
import Bidir
open Bidir (decSetoid deq) using (_in-domain-of_ ; lemma-assoc-domain ; lemma-just-sequence)
import GetTypes
-open GetTypes.VecVec using (Get ; module Get)
-open BFF.VecBFF (decSetoid deq) using (assoc ; enumerate ; denumerate ; bff ; enumeratel)
+open GetTypes.PartialVecVec using (Get ; module Get)
+open BFF.PartialVecBFF (decSetoid deq) using (assoc ; enumerate ; denumerate ; bff ; enumeratel)
lemma-maybe-just : {A : Set} → (a : A) → (ma : Maybe A) → maybe′ Maybe.just (just a) ma ≡ Maybe.just (maybe′ id a ma)
lemma-maybe-just a (just x) = refl
@@ -67,13 +68,13 @@ lemma-union-delete-fromFunc {n = n} {is = i ∷ is} {h = h} {g = g} (Data.List.A
maybe′ just (lookupM i (delete-many is (fromFunc g))) (lookup i h) ∎
inner f | no f≢i = cong (flip (maybe′ just) (lookup f h)) (lemma-lookupM-delete (delete-many is (fromFunc g)) f≢i)
-assoc-enough : (G : Get) → {m : ℕ} → (s : Vec Carrier m) → (v : Vec Carrier (Get.getlen G m)) → ∃ (λ h → assoc (Get.get G (enumeratel m)) v ≡ just h) → ∃ λ u → bff G m s v ≡ just u
-assoc-enough G {m} s v (h , p) = _ , (begin
- bff G m s v
- ≡⟨ cong (flip _>>=_ (flip mapMV t ∘ flip lookupM) ∘ _<$>_ (flip union (reshape g′ m))) p ⟩
- mapMV (flip lookupM (union h (reshape g′ m))) t
- ≡⟨ sym (sequence-map (flip lookupM (union h (reshape g′ m))) t) ⟩
- sequenceV (map (flip lookupM (union h (reshape g′ m))) t)
+assoc-enough : (G : Get) → {i : Get.|I| G} → (s : Vec Carrier (Get.|gl₁| G i)) → (v : Vec Carrier (Get.|gl₂| G i)) → ∃ (λ h → assoc (Get.get G (enumerate s)) v ≡ just h) → ∃ λ u → bff G i s v ≡ just u
+assoc-enough G {i} s v (h , p) = _ , (begin
+ bff G i s v
+ ≡⟨ cong (flip _>>=_ (flip mapMV t ∘ flip lookupM) ∘ _<$>_ (flip union (reshape g′ (Get.|gl₁| G i)))) p ⟩
+ mapMV (flip lookupM (union h (reshape g′ (Get.|gl₁| G i)))) t
+ ≡⟨ sym (sequence-map (flip lookupM (union h (reshape g′ (Get.|gl₁| G i)))) t) ⟩
+ sequenceV (map (flip lookupM (union h (reshape g′ (Get.|gl₁| G i)))) t)
≡⟨ cong (sequenceV ∘ flip map t ∘ flip lookupM ∘ union h) (lemma-reshape-id g′) ⟩
sequenceV (map (flip lookupM (union h g′)) t)
≡⟨ cong (sequenceV ∘ flip map t ∘ flip lookupM) (proj₂ wp) ⟩
@@ -88,7 +89,7 @@ assoc-enough G {m} s v (h , p) = _ , (begin
s′ = enumerate s
g = fromFunc (denumerate s)
g′ = delete-many (get s′) g
- t = enumeratel m
+ t = enumeratel (Get.|gl₁| G i)
wp = lemma-union-delete-fromFunc (lemma-assoc-domain (get t) v h p)
data All-different {A : Set} : List A → Set where