summaryrefslogtreecommitdiff
path: root/Precond.agda
diff options
context:
space:
mode:
authorHelmut Grohne <grohne@cs.uni-bonn.de>2014-04-03 08:57:34 +0200
committerHelmut Grohne <grohne@cs.uni-bonn.de>2014-04-03 08:57:34 +0200
commit9d97d3c3cb339b3e78257d19e383df4d3f5bcc74 (patch)
tree5ecf0303a025cc930292223779013d39cd4432af /Precond.agda
parent0041fbe99eab12df177e877bd5fe8d2f6fce9b0d (diff)
parent20ff2bd915d116223e1ea9eda60647c60de98725 (diff)
downloadbidiragda-9d97d3c3cb339b3e78257d19e383df4d3f5bcc74.tar.gz
Merge branch feature-shaped into master
Generalizing both Vecs in the type of get to instances of Shaped. Thus allowing trees and other data structures to be used.
Diffstat (limited to 'Precond.agda')
-rw-r--r--Precond.agda43
1 files changed, 22 insertions, 21 deletions
diff --git a/Precond.agda b/Precond.agda
index a76fddc..85c955c 100644
--- a/Precond.agda
+++ b/Precond.agda
@@ -25,6 +25,7 @@ open import Relation.Binary.PropositionalEquality using (refl ; cong ; inspect ;
open Relation.Binary.PropositionalEquality.≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎)
open import Relation.Nullary using (yes ; no)
+open import Structures using (IsFunctor ; Shaped)
open import FinMap using (FinMapMaybe ; lookupM ; union ; fromFunc ; empty ; insert ; lemma-lookupM-empty ; delete-many ; lemma-tabulate-∘ ; delete ; lemma-lookupM-delete ; lemma-lookupM-fromFunc ; reshape ; lemma-reshape-id)
import CheckInsert
open CheckInsert (decSetoid deq) using (checkInsert ; lemma-checkInsert-new ; lemma-lookupM-checkInsert-other)
@@ -32,8 +33,8 @@ import BFF
import Bidir
open Bidir (decSetoid deq) using (_in-domain-of_ ; lemma-assoc-domain)
import GetTypes
-open GetTypes.PartialVecVec using (Get ; module Get)
-open BFF.PartialVecBFF (decSetoid deq) using (assoc ; enumerate ; denumerate ; bff ; enumeratel)
+open GetTypes.PartialShapeShape using (Get ; module Get)
+open BFF.PartialShapeBFF (decSetoid deq) using (assoc ; enumerate ; denumerate ; bff)
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
@@ -62,32 +63,32 @@ 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) → {i : Get.|I| G} → (j : Get.|I| G) → (s : Vec Carrier (Get.|gl₁| G i)) → (v : Vec Carrier (Get.|gl₂| G j)) → ∃ (λ h → assoc (Get.get G (enumeratel (Get.|gl₁| G j))) v ≡ just h) → ∃ λ u → bff G j s v ≡ just u
-assoc-enough G {i} j s v (h , p) = _ , cong (_<$>_ (flip map t ∘ flip lookupM) ∘ _<$>_ (flip union (reshape g′ (|gl₁| j)))) p
+assoc-enough : (G : Get) → {i : Get.|I| G} → (j : Get.|I| G) → (s : Get.SourceContainer G Carrier (Get.|gl₁| G i)) → (v : Get.ViewContainer G Carrier (Get.|gl₂| G j)) → ∃ (λ h → assoc (Shaped.content (Get.ViewShapeT G) (Get.get G (enumerate (Get.SourceShapeT G) (Get.|gl₁| G j)))) (Shaped.content (Get.ViewShapeT G) v) ≡ just h) → ∃ λ u → bff G j s v ≡ just u
+assoc-enough G {i} j s v (h , p) = _ , cong (_<$>_ ((λ f → fmapS f t) ∘ flip lookupM) ∘ _<$>_ (flip union (reshape g′ (Shaped.arity SourceShapeT (|gl₁| j))))) p
where open Get G
- g′ = delete-many (get (enumerate s)) (fromFunc (denumerate s))
- t = enumeratel (|gl₁| j)
+ g′ = delete-many (Shaped.content ViewShapeT (get (enumerate SourceShapeT (|gl₁| i)))) (fromFunc (denumerate SourceShapeT s))
+ t = enumerate SourceShapeT (|gl₁| j)
-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 (enumeratel (Get.|gl₁| G i))) v ≡ just h) → ∃ λ u → bff G i s v ≡ just (map just u)
+assoc-enough′ : (G : Get) → {i : Get.|I| G} → (s : Get.SourceContainer G Carrier (Get.|gl₁| G i)) → (v : Get.ViewContainer G Carrier (Get.|gl₂| G i)) → ∃ (λ h → assoc (Shaped.content (Get.ViewShapeT G) (Get.get G (enumerate (Get.SourceShapeT G) (Get.|gl₁| G i)))) (Shaped.content (Get.ViewShapeT G) v) ≡ just h) → ∃ λ u → bff G i s v ≡ just (Get.fmapS G just u)
assoc-enough′ G {i} s v (h , p) = _ , (begin
bff G i s v
≡⟨ proj₂ (assoc-enough G i s v (h , p)) ⟩
- just (map (flip lookupM (union h (reshape g′ (|gl₁| i)))) t)
+ just (fmapS (flip lookupM (union h (reshape g′ (Shaped.arity SourceShapeT (|gl₁| i))))) t)
≡⟨ cong just (begin _
- ≡⟨ cong (flip map t ∘ flip lookupM ∘ union h) (lemma-reshape-id g′) ⟩
- map (flip lookupM (union h g′)) t
- ≡⟨ cong (flip map t ∘ flip lookupM) (proj₂ wp) ⟩
- map (flip lookupM (fromFunc (proj₁ wp))) t
- ≡⟨ map-cong (lemma-lookupM-fromFunc (proj₁ wp)) t ⟩
- map (Maybe.just ∘ proj₁ wp) t
- ≡⟨ map-∘ just (proj₁ wp) t ⟩
- map Maybe.just (map (proj₁ wp) t) ∎) ⟩ _ ∎)
+ ≡⟨ cong ((λ f → fmapS f t) ∘ flip lookupM ∘ union h) (lemma-reshape-id g′) ⟩
+ fmapS (flip lookupM (union h g′)) t
+ ≡⟨ 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 ⟩
+ 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 open Get G
- s′ = enumerate s
- g = fromFunc (denumerate s)
- g′ = delete-many (get s′) g
- t = enumeratel (Get.|gl₁| G i)
- wp = lemma-union-delete-fromFunc (lemma-assoc-domain (get t) v h p)
+ s′ = enumerate SourceShapeT (|gl₁| i)
+ g = fromFunc (denumerate SourceShapeT s)
+ g′ = delete-many (Shaped.content ViewShapeT (get s′)) g
+ t = enumerate SourceShapeT (|gl₁| i)
+ wp = lemma-union-delete-fromFunc (lemma-assoc-domain (Shaped.content ViewShapeT (get t)) (Shaped.content ViewShapeT v) h p)
data All-different {A : Set} : List A → Set where
different-[] : All-different []