@@ -19,7 +19,7 @@ open import Function.Base using (_∘′_)
1919open import Level using (Level; _⊔_; Lift)
2020open import Relation.Nullary.Reflects using (invert)
2121open import Relation.Nullary.Decidable.Core
22- open import Relation.Unary as U using (Pred)
22+ open import Relation.Unary as Unary using (Pred)
2323open import Relation.Binary.Core using (Rel)
2424open import Relation.Nary using (∀[_]; _⇒_; ∁; Decidable)
2525open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong)
@@ -30,37 +30,40 @@ private
3030 a b p q r s : Level
3131 A : Set a
3232 B : Set b
33+ P : Pred A p
34+ Q : Pred A q
35+ R : Rel A r
36+ xs ys : List# A R
37+
3338
3439------------------------------------------------------------------------
3540-- NonEmpty
3641
37- module _ {R : Rel A r} {P : Pred A p} where
38-
39- Any⇒NonEmpty : {xs : List# A R} → Any P xs → NonEmpty xs
40- Any⇒NonEmpty {xs = cons x xs pr} p = cons x xs pr
42+ Any⇒NonEmpty : Any P xs → NonEmpty xs
43+ Any⇒NonEmpty {xs = cons x xs pr} p = cons x xs pr
4144
4245------------------------------------------------------------------------
4346-- Correspondence between Any and All
4447
45- module _ {R : Rel A r} {P : Pred A p} {Q : Pred A q} (P⇒¬Q : ∀[ P ⇒ ∁ Q ]) where
48+ module _ (P⇒¬Q : ∀[ P ⇒ ∁ Q ]) where
4649
47- Any⇒¬All : {xs : List# A R} → Any P xs → ¬ (All Q xs)
50+ Any⇒¬All : Any P xs → ¬ (All Q xs)
4851 Any⇒¬All (here p) (q ∷ _) = P⇒¬Q p q
4952 Any⇒¬All (there ps) (_ ∷ qs) = Any⇒¬All ps qs
5053
51- All⇒¬Any : {xs : List# A R} → All P xs → ¬ (Any Q xs)
54+ All⇒¬Any : All P xs → ¬ (Any Q xs)
5255 All⇒¬Any (p ∷ _) (here q) = P⇒¬Q p q
5356 All⇒¬Any (_ ∷ ps) (there qs) = All⇒¬Any ps qs
5457
55- module _ {R : Rel A r} {P : Pred A p} (P? : Decidable P) where
58+ module _ (P? : Decidable P) where
5659
57- ¬All⇒Any : {xs : List# A R} → ¬ (All P xs) → Any (∁ P) xs
60+ ¬All⇒Any : ¬ (All P xs) → Any (∁ P) xs
5861 ¬All⇒Any {xs = []} ¬ps = contradiction [] ¬ps
5962 ¬All⇒Any {xs = x ∷# xs} ¬ps with P? x
6063 ... | true because [p] = there (¬All⇒Any (¬ps ∘′ (invert [p] ∷_)))
6164 ... | false because [¬p] = here (invert [¬p])
6265
63- ¬Any⇒All : {xs : List# A R} → ¬ (Any P xs) → All (∁ P) xs
66+ ¬Any⇒All : ¬ (Any P xs) → All (∁ P) xs
6467 ¬Any⇒All {xs = []} ¬ps = []
6568 ¬Any⇒All {xs = x ∷# xs} ¬ps with P? x
6669 ... | true because [p] = contradiction (here (invert [p])) ¬ps
@@ -69,30 +72,23 @@ module _ {R : Rel A r} {P : Pred A p} (P? : Decidable P) where
6972------------------------------------------------------------------------
7073-- remove
7174
72- module _ {R : Rel A r} {P : Pred A p} where
73-
74- length-remove : {xs : List# A R} (k : Any P xs) →
75- length xs ≡ suc (length (xs ─ k))
76- length-remove (here _) = refl
77- length-remove (there p) = cong suc (length-remove p)
75+ length-remove : (k : Any P xs) → length xs ≡ suc (length (xs ─ k))
76+ length-remove (here _) = refl
77+ length-remove (there p) = cong suc (length-remove p)
7878
7979------------------------------------------------------------------------
8080-- append
8181
82- module _ {R : Rel A r} {P : Pred A p} where
83-
84- append⁺ˡ : {xs ys : List# A R} {ps : All (_# ys) xs} →
85- Any P xs → Any P (append xs ys ps)
86- append⁺ˡ (here px) = here px
87- append⁺ˡ (there p) = there (append⁺ˡ p)
82+ append⁺ˡ : {ps : All (_# ys) xs} → Any P xs → Any P (append xs ys ps)
83+ append⁺ˡ (here px) = here px
84+ append⁺ˡ (there p) = there (append⁺ˡ p)
8885
89- append⁺ʳ : {xs ys : List# A R} {ps : All (_# ys) xs} →
90- Any P ys → Any P (append xs ys ps)
91- append⁺ʳ {xs = []} p = p
92- append⁺ʳ {xs = x ∷# xs} p = there (append⁺ʳ p)
86+ append⁺ʳ : {ps : All (_# ys) xs} → Any P ys → Any P (append xs ys ps)
87+ append⁺ʳ {xs = []} p = p
88+ append⁺ʳ {xs = x ∷# xs} p = there (append⁺ʳ p)
9389
94- append⁻ : ∀ xs {ys : List# A R} {ps : All (_# ys) xs} →
95- Any P (append xs ys ps) → Any P xs ⊎ Any P ys
96- append⁻ [] p = inj₂ p
97- append⁻ (x ∷# xs) (here px) = inj₁ (here px)
98- append⁻ (x ∷# xs) (there p) = Sum.map₁ there (append⁻ xs p)
90+ append⁻ : ∀ xs {ps : All (_# ys) xs} →
91+ Any P (append xs ys ps) → Any P xs ⊎ Any P ys
92+ append⁻ [] p = inj₂ p
93+ append⁻ (x ∷# xs) (here px) = inj₁ (here px)
94+ append⁻ (x ∷# xs) (there p) = Sum.map₁ there (append⁻ xs p)
0 commit comments