| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Documentation for subset relations over `List`s |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
open import Data.List.Base using (List; _∷_; []) |
| 8 |
open import Data.List.Membership.Propositional.Properties |
| 9 |
using (∈-++⁺ˡ; ∈-insert) |
| 10 |
open import Data.List.Relation.Binary.Subset.Propositional using (_⊆_) |
| 11 |
open import Data.List.Relation.Unary.Any using (here; there) |
| 12 |
open import Relation.Binary.PropositionalEquality using (refl) |
| 13 |
|
| 14 |
module README.Data.List.Relation.Binary.Subset where |
| 15 |
|
| 16 |
------------------------------------------------------------------------ |
| 17 |
-- Subset Relation |
| 18 |
|
| 19 |
-- The Subset relation is a wrapper over `Any` and so is parameterized |
| 20 |
-- over an equality relation. Thus to use the subset relation we must |
| 21 |
-- tell Agda which equality relation to use. |
| 22 |
|
| 23 |
-- Decidable equality over Strings |
| 24 |
open import Data.String.Base using (String) |
| 25 |
open import Data.String.Properties using (_≟_) |
| 26 |
|
| 27 |
-- Open the decidable membership module using Decidable ≡ over Strings |
| 28 |
open import Data.List.Membership.DecPropositional _≟_ |
| 29 |
|
| 30 |
|
| 31 |
-- Simple cases are inductive proofs |
| 32 |
|
| 33 |
lem₁ : ∀ {xs : List String} → xs ⊆ xs |
| 34 |
lem₁ p = p |
| 35 |
|
| 36 |
lem₂ : "A" ∷ [] ⊆ "B" ∷ "A" ∷ [] |
| 37 |
lem₂ p = there p |
| 38 |
|
| 39 |
-- Or directly use the definition of subsets |
| 40 |
|
| 41 |
lem₃₀ : "E" ∷ "S" ∷ "B" ∷ [] ⊆ "S" ∷ "U" ∷ "B" ∷ "S" ∷ "E" ∷ "T" ∷ [] |
| 42 |
lem₃₀ (here refl) = there (there (there (there (here refl)))) -- "E" |
| 43 |
lem₃₀ (there (here refl)) = here refl -- "S" |
| 44 |
lem₃₀ (there (there (here refl))) = there (there (here refl)) -- "B" |
| 45 |
|
| 46 |
-- Or use proofs from `Data.List.Membership.Propositional.Properties` |
| 47 |
|
| 48 |
lem₄ : "A" ∷ [] ⊆ "B" ∷ "A" ∷ "C" ∷ [] |
| 49 |
lem₄ p = ∈-++⁺ˡ (there p) |
| 50 |
|
| 51 |
lem₅ : "B" ∷ "S" ∷ "E" ∷ [] ⊆ "S" ∷ "U" ∷ "B" ∷ "S" ∷ "E" ∷ "T" ∷ [] |
| 52 |
lem₅ p = ∈-++⁺ˡ (there (there p)) |
| 53 |
|
| 54 |
lem₃₁ : "E" ∷ "S" ∷ "B" ∷ [] ⊆ "S" ∷ "U" ∷ "B" ∷ "S" ∷ "E" ∷ "T" ∷ [] |
| 55 |
lem₃₁ (here refl) = ∈-insert ("S" ∷ "U" ∷ "B" ∷ "S" ∷ []) |
| 56 |
lem₃₁ (there (here refl)) = here refl |
| 57 |
lem₃₁ (there (there (here refl))) = ∈-insert ("S" ∷ "U" ∷ []) |