Skip to content

Commit b429588

Browse files
authored
[ refactor ] Move Data.List.Relation.Unary.All.Properties.all⊆concat to Data.List.Relation.Binary.Sublist.Setoid.Properties (#2524)
* refactor: prepare for code migration * refactor: move code as is * refactor: add new lemmas to `Setoid` and `Propositional` * refactor: use new lemmas * refactor: localise appeals to `SetoidMembership`; pull lemma back to `SetoidProperties` * refactor: pull `all⊆concat` back to `Setoid.Properties` * refactor: tidy up * refactor: tidy up * refactor: tidy up * refactor: tidy up * refactor: make proof `rewrite`-free * oops: uncommitted file save * tighten `import`s
1 parent 255f8a8 commit b429588

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,14 @@ Additions to existing modules
342342
⊆⇒⊆ₛ : (S : Setoid a ℓ) → as ⊆ bs → as (SetoidSublist.⊆ S) bs
343343
```
344344

345-
* In `Data.List.Relation.Unary.All.Properties`:
345+
* In `Data.List.Relation.Binary.Sublist.Setoid.Properties`:
346346
```agda
347+
concat⁺ : Sublist _⊆_ ass bss → concat ass ⊆ concat bss
347348
all⊆concat : (xss : List (List A)) → All (Sublist._⊆ concat xss) xss
349+
```
350+
351+
* In `Data.List.Relation.Unary.All.Properties`:
352+
```agda
348353
all⇒dropWhile≡[] : (P? : Decidable P) → All P xs → dropWhile P? xs ≡ []
349354
all⇒takeWhile≗id : (P? : Decidable P) → All P xs → takeWhile P? xs ≡ xs
350355
```

src/Data/List/Relation/Binary/Sublist/Setoid/Properties.agda

+33-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ module Data.List.Relation.Binary.Sublist.Setoid.Properties
1313
{c ℓ} (S : Setoid c ℓ) where
1414

1515
open import Data.List.Base hiding (_∷ʳ_)
16+
open import Data.List.Properties using (++-identityʳ)
1617
open import Data.List.Relation.Unary.Any using (Any)
18+
open import Data.List.Relation.Unary.All using (All; tabulateₛ)
1719
import Data.Maybe.Relation.Unary.All as Maybe
1820
open import Data.Nat.Base using (ℕ; _≤_; _≥_)
1921
import Data.Nat.Properties as ℕ
@@ -22,28 +24,32 @@ open import Function.Base
2224
open import Function.Bundles using (_⇔_; _⤖_)
2325
open import Level
2426
open import Relation.Binary.Definitions using () renaming (Decidable to Decidable₂)
25-
open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_; refl; cong; cong₂)
27+
open import Relation.Binary.PropositionalEquality.Core as ≡
28+
using (_≡_; refl; sym; cong; cong₂)
2629
open import Relation.Binary.Structures using (IsDecTotalOrder)
2730
open import Relation.Unary using (Pred; Decidable; Universal; Irrelevant)
2831
open import Relation.Nullary.Negation using (¬_)
2932
open import Relation.Nullary.Decidable using (¬?; yes; no)
3033

3134
import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality
3235
import Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist
36+
import Data.List.Relation.Binary.Sublist.Heterogeneous
37+
as Hetero
3338
import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties
3439
as HeteroProperties
3540
import Data.List.Membership.Setoid as SetoidMembership
3641

3742
open Setoid S using (_≈_; trans) renaming (Carrier to A; refl to ≈-refl)
38-
open SetoidEquality S using (_≋_; ≋-refl)
43+
open SetoidEquality S using (_≋_; ≋-refl; ≋-reflexive; ≋-setoid)
3944
open SetoidSublist S hiding (map)
40-
open SetoidMembership S using (_∈_)
45+
4146

4247
private
4348
variable
4449
p q r s t : Level
4550
a b x y : A
4651
as bs cs ds xs ys : List A
52+
xss yss : List (List A)
4753
P : Pred A p
4854
Q : Pred A q
4955
m n :
@@ -175,6 +181,28 @@ module _ where
175181
++⁻ : length as ≡ length bs as ++ cs ⊆ bs ++ ds cs ⊆ ds
176182
++⁻ = HeteroProperties.++⁻
177183

184+
------------------------------------------------------------------------
185+
-- concat
186+
187+
module _ where
188+
189+
concat⁺ : Hetero.Sublist _⊆_ xss yss
190+
concat xss ⊆ concat yss
191+
concat⁺ = HeteroProperties.concat⁺
192+
193+
open SetoidMembership ≋-setoid using (_∈_)
194+
open SetoidSublist ≋-setoid
195+
using ()
196+
renaming (map to map-≋; from∈ to from∈-≋)
197+
198+
xs∈xss⇒xs⊆concat[xss] : xs ∈ xss xs ⊆ concat xss
199+
xs∈xss⇒xs⊆concat[xss] {xs = xs} xs∈xss
200+
= ⊆-trans (⊆-reflexive (≋-reflexive (sym (++-identityʳ xs))))
201+
(concat⁺ (map-≋ ⊆-reflexive (from∈-≋ xs∈xss)))
202+
203+
all⊆concat : (xss : List (List A)) All (_⊆ concat xss) xss
204+
all⊆concat _ = tabulateₛ ≋-setoid xs∈xss⇒xs⊆concat[xss]
205+
178206
------------------------------------------------------------------------
179207
-- take
180208

@@ -306,6 +334,8 @@ module _ where
306334

307335
module _ where
308336

337+
open SetoidMembership S using (_∈_)
338+
309339
to∈-injective : {p q : [ x ] ⊆ xs} to∈ p ≡ to∈ q p ≡ q
310340
to∈-injective = HeteroProperties.toAny-injective
311341

src/Data/List/Relation/Unary/All/Properties.agda

+1-9
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ import Data.List.Membership.Setoid as SetoidMembership
2020
import Data.List.Properties as List
2121
import Data.List.Relation.Binary.Equality.Setoid as ≋
2222
open import Data.List.Relation.Binary.Pointwise.Base using (Pointwise; []; _∷_)
23-
import Data.List.Relation.Binary.Sublist.Propositional as Sublist
24-
import Data.List.Relation.Binary.Sublist.Propositional.Properties
25-
as Sublist
2623
import Data.List.Relation.Binary.Subset.Propositional as Subset
2724
open import Data.List.Relation.Unary.All as All using
2825
( All; []; _∷_; lookup; updateAt
@@ -49,7 +46,7 @@ open import Relation.Nullary.Negation.Core using (¬_; contradiction)
4946
open import Relation.Nullary.Decidable
5047
using (Dec; does; yes; no; _because_; ¬?; decidable-stable; dec-true)
5148
open import Relation.Unary
52-
using (Decidable; Pred; ∁; _∩_; _⟨×⟩_) renaming (_⊆_ to _⋐_)
49+
using (Decidable; Pred; ∁; _⟨×⟩_) renaming (_⊆_ to _⋐_)
5350
open import Relation.Unary.Properties using (∁?)
5451

5552
private
@@ -388,11 +385,6 @@ concat⁻ : ∀ {xss} → All P (concat xss) → All (All P) xss
388385
concat⁻ {xss = []} [] = []
389386
concat⁻ {xss = xs ∷ xss} pxs = ++⁻ˡ xs pxs ∷ concat⁻ (++⁻ʳ xs pxs)
390387

391-
all⊆concat : (xss : List (List A)) All (Sublist._⊆ concat xss) xss
392-
all⊆concat [] = []
393-
all⊆concat (xs ∷ xss) =
394-
Sublist.++⁺ʳ (concat xss) Sublist.⊆-refl ∷ All.map (Sublist.++⁺ˡ xs) (all⊆concat xss)
395-
396388
------------------------------------------------------------------------
397389
-- snoc
398390

0 commit comments

Comments
 (0)