Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ refactor ] Move Data.List.Relation.Unary.All.Properties.all⊆concat to Data.List.Relation.Binary.Sublist.Setoid.Properties #2524

Merged
merged 14 commits into from
Dec 29, 2024
Merged
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,14 @@ Additions to existing modules
⊆⇒⊆ₛ : (S : Setoid a ℓ) → as ⊆ bs → as (SetoidSublist.⊆ S) bs
```

* In `Data.List.Relation.Unary.All.Properties`:
* In `Data.List.Relation.Binary.Sublist.Setoid.Properties`:
```agda
concat⁺ : Sublist _⊆_ ass bss → concat ass ⊆ concat bss
all⊆concat : (xss : List (List A)) → All (Sublist._⊆ concat xss) xss
```

* In `Data.List.Relation.Unary.All.Properties`:
```agda
all⇒dropWhile≡[] : (P? : Decidable P) → All P xs → dropWhile P? xs ≡ []
all⇒takeWhile≗id : (P? : Decidable P) → All P xs → takeWhile P? xs ≡ xs
```
Expand Down
34 changes: 32 additions & 2 deletions src/Data/List/Relation/Binary/Sublist/Setoid/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module Data.List.Relation.Binary.Sublist.Setoid.Properties
{c ℓ} (S : Setoid c ℓ) where

open import Data.List.Base hiding (_∷ʳ_)
open import Data.List.Properties using (++-identityʳ)
open import Data.List.Relation.Unary.Any using (Any)
open import Data.List.Relation.Unary.All using (All; tabulateₛ)
import Data.Maybe.Relation.Unary.All as Maybe
open import Data.Nat.Base using (ℕ; _≤_; _≥_)
import Data.Nat.Properties as ℕ
Expand All @@ -30,20 +32,23 @@ open import Relation.Nullary.Decidable using (¬?; yes; no)

import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality
import Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist
import Data.List.Relation.Binary.Sublist.Heterogeneous
as Hetero
import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties
as HeteroProperties
import Data.List.Membership.Setoid as SetoidMembership

open Setoid S using (_≈_; trans) renaming (Carrier to A; refl to ≈-refl)
open SetoidEquality S using (_≋_; ≋-refl)
open SetoidEquality S using (_≋_; ≋-refl; ≋-setoid)
open SetoidSublist S hiding (map)
open SetoidMembership S using (_∈_)


private
variable
p q r s t : Level
a b x y : A
as bs cs ds xs ys : List A
xss yss : List (List A)
P : Pred A p
Q : Pred A q
m n : ℕ
Expand Down Expand Up @@ -175,6 +180,29 @@ module _ where
++⁻ : length as ≡ length bs → as ++ cs ⊆ bs ++ ds → cs ⊆ ds
++⁻ = HeteroProperties.++⁻

------------------------------------------------------------------------
-- concat

module _ where

concat⁺ : Hetero.Sublist _⊆_ xss yss →
concat xss ⊆ concat yss
concat⁺ = HeteroProperties.concat⁺

open SetoidMembership ≋-setoid using (_∈_)
open SetoidSublist ≋-setoid
using ()
renaming (map to map-≋; from∈ to from∈-≋)

xs∈xss⇒xs⊆concat[xss] : xs ∈ xss → xs ⊆ concat xss
xs∈xss⇒xs⊆concat[xss] {xs = xs} xs∈xss
with prf ← concat⁺ (map-≋ ⊆-reflexive (from∈-≋ xs∈xss))
rewrite ++-identityʳ xs
= prf

all⊆concat : (xss : List (List A)) → All (_⊆ concat xss) xss
all⊆concat _ = tabulateₛ ≋-setoid xs∈xss⇒xs⊆concat[xss]

------------------------------------------------------------------------
-- take

Expand Down Expand Up @@ -306,6 +334,8 @@ module _ where

module _ where

open SetoidMembership S using (_∈_)

to∈-injective : ∀ {p q : [ x ] ⊆ xs} → to∈ p ≡ to∈ q → p ≡ q
to∈-injective = HeteroProperties.toAny-injective

Expand Down
8 changes: 0 additions & 8 deletions src/Data/List/Relation/Unary/All/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import Data.List.Membership.Setoid as SetoidMembership
import Data.List.Properties as List
import Data.List.Relation.Binary.Equality.Setoid as ≋
open import Data.List.Relation.Binary.Pointwise.Base using (Pointwise; []; _∷_)
import Data.List.Relation.Binary.Sublist.Propositional as Sublist
import Data.List.Relation.Binary.Sublist.Propositional.Properties
as Sublist
import Data.List.Relation.Binary.Subset.Propositional as Subset
open import Data.List.Relation.Unary.All as All using
( All; []; _∷_; lookup; updateAt
Expand Down Expand Up @@ -388,11 +385,6 @@ concat⁻ : ∀ {xss} → All P (concat xss) → All (All P) xss
concat⁻ {xss = []} [] = []
concat⁻ {xss = xs ∷ xss} pxs = ++⁻ˡ xs pxs ∷ concat⁻ (++⁻ʳ xs pxs)

all⊆concat : (xss : List (List A)) → All (Sublist._⊆ concat xss) xss
all⊆concat [] = []
all⊆concat (xs ∷ xss) =
Sublist.++⁺ʳ (concat xss) Sublist.⊆-refl ∷ All.map (Sublist.++⁺ˡ xs) (all⊆concat xss)
MatthewDaggitt marked this conversation as resolved.
Show resolved Hide resolved

------------------------------------------------------------------------
-- snoc

Expand Down
Loading