diff options
Diffstat (limited to 'Precond.agda')
-rw-r--r-- | Precond.agda | 36 |
1 files changed, 20 insertions, 16 deletions
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 |