Debian Codegraph @

src/Data/List/Relation/Binary/Sublist/Propositional/Slice.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Slices in the propositional sublist category.
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Data.List.Relation.Binary.Sublist.Propositional.Slice
10 {a} {A : Set a} where
11
12 open import Data.List.Base using (List)
13 open import Data.List.Relation.Binary.Sublist.Propositional
14 using (_⊆_; UpperBound; ⊆-trans; ∷ₙ-ub; _∷ʳ_; _∷ₗ-ub_; _∷_; _∷ᵣ-ub_;
15 _,_∷-ub_; ⊆-upper-bound; [])
16 open import Relation.Binary.PropositionalEquality.Core
17 using (_≡_; refl; cong)
18
19 ------------------------------------------------------------------------
20 -- A Union where the triangles commute is a
21 -- Cospan in the slice category (_ ⊆ zs).
22
23 record IsCospan {xs ys zs : List A} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} (u : UpperBound τ₁ τ₂) : Set a where
24 field
25 tri₁ : ⊆-trans (UpperBound.inj₁ u) (UpperBound.sub u) ≡ τ₁
26 tri₂ : ⊆-trans (UpperBound.inj₂ u) (UpperBound.sub u) ≡ τ₂
27
28 record Cospan {xs ys zs : List A} (τ₁ : xs ⊆ zs) (τ₂ : ys ⊆ zs) : Set a where
29 field
30 upperBound : UpperBound τ₁ τ₂
31 isCospan : IsCospan upperBound
32
33 open UpperBound upperBound public
34 open IsCospan isCospan public
35
36 open IsCospan
37 open Cospan
38
39 module _
40 {x : A} {xs ys zs : List A} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs}
41 {u : UpperBound τ₁ τ₂} (c : IsCospan u) where
42 open UpperBound u
43 open IsCospan c
44
45 ∷ₙ-cospan : IsCospan (∷ₙ-ub u)
46 ∷ₙ-cospan = record
47 { tri₁ = cong (x ∷ʳ_) (c .tri₁)
48 ; tri₂ = cong (x ∷ʳ_) (c .tri₂)
49 }
50
51 ∷ₗ-cospan : IsCospan (refl {x = x} ∷ₗ-ub u)
52 ∷ₗ-cospan = record
53 { tri₁ = cong (refl ∷_) (c .tri₁)
54 ; tri₂ = cong (x ∷ʳ_) (c .tri₂)
55 }
56
57 ∷ᵣ-cospan : IsCospan (refl {x = x} ∷ᵣ-ub u)
58 ∷ᵣ-cospan = record
59 { tri₁ = cong (x ∷ʳ_) (c .tri₁)
60 ; tri₂ = cong (refl ∷_) (c .tri₂)
61 }
62
63 ∷-cospan : IsCospan (refl {x = x} , refl {x = x} ∷-ub u)
64 ∷-cospan = record
65 { tri₁ = cong (refl ∷_) (c .tri₁)
66 ; tri₂ = cong (refl ∷_) (c .tri₂)
67 }
68
69 ⊆-upper-bound-is-cospan : ∀ {xs ys zs : List A} (τ₁ : xs ⊆ zs) (τ₂ : ys ⊆ zs) →
70 IsCospan (⊆-upper-bound τ₁ τ₂)
71 ⊆-upper-bound-is-cospan [] [] = record { tri₁ = refl ; tri₂ = refl }
72 ⊆-upper-bound-is-cospan (z ∷ʳ τ₁) (.z ∷ʳ τ₂) = ∷ₙ-cospan (⊆-upper-bound-is-cospan τ₁ τ₂)
73 ⊆-upper-bound-is-cospan (z ∷ʳ τ₁) (refl ∷ τ₂) = ∷ᵣ-cospan (⊆-upper-bound-is-cospan τ₁ τ₂)
74 ⊆-upper-bound-is-cospan (refl ∷ τ₁) (z ∷ʳ τ₂) = ∷ₗ-cospan (⊆-upper-bound-is-cospan τ₁ τ₂)
75 ⊆-upper-bound-is-cospan (refl ∷ τ₁) (refl ∷ τ₂) = ∷-cospan (⊆-upper-bound-is-cospan τ₁ τ₂)
76
77 ⊆-upper-bound-cospan : ∀ {xs ys zs : List A} (τ₁ : xs ⊆ zs) (τ₂ : ys ⊆ zs) →
78 Cospan τ₁ τ₂
79 ⊆-upper-bound-cospan τ₁ τ₂ = record
80 { upperBound = ⊆-upper-bound τ₁ τ₂
81 ; isCospan = ⊆-upper-bound-is-cospan τ₁ τ₂
82 }