diff options
Diffstat (limited to 'Precond.agda')
-rw-r--r-- | Precond.agda | 23 |
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 |