@@ -20,7 +20,7 @@ open import Function.Base using (flip; id; _∘_)
20
20
open import Function.Bundles using (_↔_; mk↔ₛ′)
21
21
open import Level using (Level)
22
22
open import Relation.Binary.PropositionalEquality.Core
23
- using (_≡_; refl; cong; resp)
23
+ using (_≡_; refl; trans; cong; resp)
24
24
open import Relation.Unary using (Pred; _⊆_)
25
25
26
26
private
@@ -42,7 +42,8 @@ private
42
42
43
43
find-∈ : (x∈xs : x ∈ xs) → find x∈xs ≡ (x , x∈xs , refl)
44
44
find-∈ (here refl) = refl
45
- find-∈ (there x∈xs) rewrite find-∈ x∈xs = refl
45
+ find-∈ (there x∈xs)
46
+ = cong (λ where (x , x∈xs , eq) → x , there x∈xs , eq) (find-∈ x∈xs)
46
47
47
48
------------------------------------------------------------------------
48
49
-- Lemmas relating map and find.
@@ -59,22 +60,24 @@ module _ {P : Pred A p} where
59
60
let x , x∈xs , px = find p in
60
61
find (Any.map f p) ≡ (x , x∈xs , f px)
61
62
find∘map (here p) f = refl
62
- find∘map (there p) f rewrite find∘map p f = refl
63
+ find∘map (there p) f
64
+ = cong (λ where (x , x∈xs , eq) → x , there x∈xs , eq) (find∘map p f)
63
65
64
66
------------------------------------------------------------------------
65
67
-- Any can be expressed using _∈_
66
68
67
69
module _ {P : Pred A p} where
68
70
69
71
∃∈-Any : (∃ λ x → x ∈ xs × P x) → Any P xs
70
- ∃∈-Any (x , x∈xs , px) = lose {P = P} x∈xs px
72
+ ∃∈-Any (x , x∈xs , px) = lose x∈xs px
71
73
72
74
∃∈-Any∘find : (p : Any P xs) → ∃∈-Any (find p) ≡ p
73
75
∃∈-Any∘find p = map∘find p refl
74
76
75
77
find∘∃∈-Any : (p : ∃ λ x → x ∈ xs × P x) → find (∃∈-Any p) ≡ p
76
78
find∘∃∈-Any p@(x , x∈xs , px)
77
- rewrite find∘map x∈xs (flip (resp P) px) | find-∈ x∈xs = refl
79
+ = trans (find∘map x∈xs (flip (resp P) px))
80
+ (cong (λ (x , x∈xs , eq) → x , x∈xs , resp P eq px) (find-∈ x∈xs))
78
81
79
82
Any↔ : (∃ λ x → x ∈ xs × P x) ↔ Any P xs
80
83
Any↔ = mk↔ₛ′ ∃∈-Any find ∃∈-Any∘find find∘∃∈-Any
0 commit comments