diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-01-14 13:13:00 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-01-14 13:13:00 +0100 |
commit | 9c2be74a5369c1bdb737a67c7c508cb50c62bd83 (patch) | |
tree | 4b2972936dc6377e2df28b6da3b3485a50296813 | |
parent | a01871259837d6e36c580338f6d29ea0b154ed04 (diff) | |
download | bidiragda-9c2be74a5369c1bdb737a67c7c508cb50c62bd83.tar.gz |
define a more useful version of lemma-just\==nnothing
If one had a parameter of type just x \== nothing it could be simply
refuted by case splitting. So the cases where lemma-just\==nnothing was
used always employed trans to combine two results. The new version takes
both results instead.
-rw-r--r-- | Bidir.agda | 4 | ||||
-rw-r--r-- | CheckInsert.agda | 2 | ||||
-rw-r--r-- | FinMap.agda | 6 |
3 files changed, 6 insertions, 6 deletions
@@ -53,7 +53,7 @@ lemma-lookupM-assoc i is x xs h p | just h' = apply-checkInsertProof i x h' r lookupM i (insert i x h') ≡⟨ lemma-lookupM-insert i x h' ⟩ just x ∎ - ; wrong = λ x' x≢x' lookupM≡justx' → lemma-just≢nothing (trans (sym p) (lemma-checkInsert-wrong i x h' x' x≢x' lookupM≡justx')) + ; wrong = λ x' x≢x' lookupM≡justx' → lemma-just≢nothing p (lemma-checkInsert-wrong i x h' x' x≢x' lookupM≡justx') } lemma-∉-lookupM-assoc : {m n : ℕ} → (i : Fin n) → (is : Vec (Fin n) m) → (xs : Vec Carrier m) → (h : FinMapMaybe n Carrier) → assoc is xs ≡ just h → (i ∉ toList is) → lookupM i h ≡ nothing @@ -83,7 +83,7 @@ lemma-assoc-domain (i' ∷ is') (x' ∷ xs') h ph | just h' | [ ph' ] = apply-ch (Data.List.All.map (λ {i} p → proj₁ p , lemma-lookupM-checkInsert i i' (proj₁ p) x' h' h (proj₂ p) ph) (lemma-assoc-domain is' xs' h' ph')) - ; wrong = λ x'' x'≢x'' lookupM-i'-h'≡just-x'' → lemma-just≢nothing (trans (sym ph) (lemma-checkInsert-wrong i' x' h' x'' x'≢x'' lookupM-i'-h'≡just-x'')) + ; wrong = λ x'' x'≢x'' lookupM-i'-h'≡just-x'' → lemma-just≢nothing ph (lemma-checkInsert-wrong i' x' h' x'' x'≢x'' lookupM-i'-h'≡just-x'') } lemma-map-lookupM-insert : {m n : ℕ} → (i : Fin n) → (is : Vec (Fin n) m) → (x : Carrier) → (h : FinMapMaybe n Carrier) → i ∉ (toList is) → map (flip lookupM (insert i x h)) is ≡ map (flip lookupM h) is diff --git a/CheckInsert.agda b/CheckInsert.agda index 4083720..dd752be 100644 --- a/CheckInsert.agda +++ b/CheckInsert.agda @@ -74,7 +74,7 @@ lemma-checkInsert-restrict f i is = apply-checkInsertProof i (f i) (restrict f i lemma-lookupM-checkInsert : {n : ℕ} → (i j : Fin n) → (x y : Carrier) → (h h' : FinMapMaybe n Carrier) → lookupM i h ≡ just x → checkInsert j y h ≡ just h' → lookupM i h' ≡ just x lemma-lookupM-checkInsert i j x y h h' pl ph' with lookupM j h | inspect (lookupM j) h lemma-lookupM-checkInsert i j x y h .(insert j y h) pl refl | nothing | pl' with i ≟ j -lemma-lookupM-checkInsert i .i x y h .(insert i y h) pl refl | nothing | [ pl' ] | yes refl = lemma-just≢nothing (trans (sym pl) pl') +lemma-lookupM-checkInsert i .i x y h .(insert i y h) pl refl | nothing | [ pl' ] | yes refl = lemma-just≢nothing pl pl' lemma-lookupM-checkInsert i j x y h .(insert j y h) pl refl | nothing | pl' | no ¬p = begin lookupM i (insert j y h) ≡⟨ sym (lemma-lookupM-insert-other i j y h ¬p) ⟩ diff --git a/FinMap.agda b/FinMap.agda index 2b50920..8b4103b 100644 --- a/FinMap.agda +++ b/FinMap.agda @@ -46,8 +46,8 @@ union m1 m2 = fromFunc (λ f → maybe′ id (lookup f m2) (lookupM f m1)) restrict : {A : Set} {n : ℕ} → (Fin n → A) → List (Fin n) → FinMapMaybe n A restrict f is = fromAscList (zip is (map f is)) -lemma-just≢nothing : {A Whatever : Set} {a : A} → _≡_ {_} {Maybe A} (just a) nothing → Whatever -lemma-just≢nothing () +lemma-just≢nothing : {A Whatever : Set} {a : A} {ma : Maybe A} → ma ≡ just a → ma ≡ nothing → Whatever +lemma-just≢nothing refl () lemma-insert-same : {τ : Set} {n : ℕ} → (m : FinMapMaybe n τ) → (f : Fin n) → (a : τ) → lookupM f m ≡ just a → m ≡ insert f a m lemma-insert-same [] () a p @@ -72,7 +72,7 @@ just-injective : {A : Set} → {x y : A} → _≡_ {_} {Maybe A} (just x) (just just-injective refl = refl lemma-lookupM-restrict : {A : Set} {n : ℕ} → (i : Fin n) → (f : Fin n → A) → (is : List (Fin n)) → (a : A) → lookupM i (restrict f is) ≡ just a → f i ≡ a -lemma-lookupM-restrict i f [] a p = lemma-just≢nothing (trans (sym p) (lemma-lookupM-empty i)) +lemma-lookupM-restrict i f [] a p = lemma-just≢nothing p (lemma-lookupM-empty i) lemma-lookupM-restrict i f (i' ∷ is) a p with i ≟ i' lemma-lookupM-restrict i f (.i ∷ is) a p | yes refl = just-injective (begin just (f i) |