summaryrefslogtreecommitdiff
path: root/Precond.agda
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 /Precond.agda
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)
Diffstat (limited to 'Precond.agda')
-rw-r--r--Precond.agda23
1 files changed, 12 insertions, 11 deletions
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