Debian Codegraph @

src/Algebra/Lattice/Morphism/LatticeMonomorphism.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Consequences of a monomorphism between lattice-like structures
5 ------------------------------------------------------------------------
6
7 -- See Data.Nat.Binary.Properties for examples of how this and similar
8 -- modules can be used to easily translate properties between types.
9
10 {-# OPTIONS --cubical-compatible --safe #-}
11
12 open import Algebra.Lattice
13 using (RawLattice; IsLattice; IsDistributiveLattice; isDistributiveLatticeʳʲᵐ)
14 open import Algebra.Lattice.Morphism.Structures using (IsLatticeMonomorphism)
15
16 module Algebra.Lattice.Morphism.LatticeMonomorphism
17 {a b ℓ₁ ℓ₂} {L₁ : RawLattice a ℓ₁} {L₂ : RawLattice b ℓ₂} {⟦_⟧}
18 (isLatticeMonomorphism : IsLatticeMonomorphism L₁ L₂ ⟦_⟧)
19 where
20
21 open import Algebra using (Absorptive; _Absorbs_; _DistributesOverʳ_)
22 import Algebra.Morphism.MagmaMonomorphism as MagmaMonomorphisms
23 import Algebra.Lattice.Properties.Lattice as LatticeProperties
24 open import Data.Product.Base using (_,_; map)
25 open import Relation.Binary.Bundles using (Setoid)
26 import Relation.Binary.Morphism.RelMonomorphism as RelMonomorphisms
27 import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
28
29 open IsLatticeMonomorphism isLatticeMonomorphism
30 open RawLattice L₁ renaming (_≈_ to _≈₁_; _∨_ to _∨_; _∧_ to _∧_)
31 open RawLattice L₂ renaming (_≈_ to _≈₂_; _∨_ to _⊔_; _∧_ to _⊓_)
32
33 ------------------------------------------------------------------------
34 -- Re-export all properties of magma monomorphisms
35
36 open MagmaMonomorphisms ∨-isMagmaMonomorphism public
37 using () renaming
38 ( cong to ∨-cong
39 ; assoc to ∨-assoc
40 ; comm to ∨-comm
41 ; idem to ∨-idem
42 ; sel to ∨-sel
43 ; cancelˡ to ∨-cancelˡ
44 ; cancelʳ to ∨-cancelʳ
45 ; cancel to ∨-cancel
46 )
47
48 open MagmaMonomorphisms ∧-isMagmaMonomorphism public
49 using () renaming
50 ( cong to ∧-cong
51 ; assoc to ∧-assoc
52 ; comm to ∧-comm
53 ; idem to ∧-idem
54 ; sel to ∧-sel
55 ; cancelˡ to ∧-cancelˡ
56 ; cancelʳ to ∧-cancelʳ
57 ; cancel to ∧-cancel
58 )
59
60 ------------------------------------------------------------------------
61 -- Lattice-specific properties
62
63 module _ (⊔-⊓-isLattice : IsLattice _≈₂_ _⊔_ _⊓_) where
64
65 open IsLattice ⊔-⊓-isLattice using (isEquivalence) renaming
66 ( ∨-congˡ to ⊔-congˡ
67 ; ∨-congʳ to ⊔-congʳ
68 ; ∧-cong to ⊓-cong
69 ; ∧-congˡ to ⊓-congˡ
70 ; ∨-absorbs-∧ to ⊔-absorbs-⊓
71 ; ∧-absorbs-∨ to ⊓-absorbs-⊔
72 )
73
74 setoid : Setoid b ℓ₂
75 setoid = record { isEquivalence = isEquivalence }
76
77 open ≈-Reasoning setoid
78
79 ∨-absorbs-∧ : _Absorbs_ _≈₁_ _∨_ _∧_
80 ∨-absorbs-∧ x y = injective (begin
81 ⟦ x ∨ x ∧ y ⟧ ≈⟨ ∨-homo x (x ∧ y) ⟩
82 ⟦ x ⟧ ⊔ ⟦ x ∧ y ⟧ ≈⟨ ⊔-congˡ (∧-homo x y) ⟩
83 ⟦ x ⟧ ⊔ ⟦ x ⟧ ⊓ ⟦ y ⟧ ≈⟨ ⊔-absorbs-⊓ ⟦ x ⟧ ⟦ y ⟧ ⟩
84 ⟦ x ⟧ ∎)
85
86 ∧-absorbs-∨ : _Absorbs_ _≈₁_ _∧_ _∨_
87 ∧-absorbs-∨ x y = injective (begin
88 ⟦ x ∧ (x ∨ y) ⟧ ≈⟨ ∧-homo x (x ∨ y) ⟩
89 ⟦ x ⟧ ⊓ ⟦ x ∨ y ⟧ ≈⟨ ⊓-congˡ (∨-homo x y) ⟩
90 ⟦ x ⟧ ⊓ (⟦ x ⟧ ⊔ ⟦ y ⟧) ≈⟨ ⊓-absorbs-⊔ ⟦ x ⟧ ⟦ y ⟧ ⟩
91 ⟦ x ⟧ ∎)
92
93 absorptive : Absorptive _≈₁_ _∨_ _∧_
94 absorptive = ∨-absorbs-∧ , ∧-absorbs-∨
95
96 distribʳ : _DistributesOverʳ_ _≈₂_ _⊔_ _⊓_ → _DistributesOverʳ_ _≈₁_ _∨_ _∧_
97 distribʳ distribʳ x y z = injective (begin
98 ⟦ y ∧ z ∨ x ⟧ ≈⟨ ∨-homo (y ∧ z) x ⟩
99 ⟦ y ∧ z ⟧ ⊔ ⟦ x ⟧ ≈⟨ ⊔-congʳ (∧-homo y z) ⟩
100 ⟦ y ⟧ ⊓ ⟦ z ⟧ ⊔ ⟦ x ⟧ ≈⟨ distribʳ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ ⟩
101 (⟦ y ⟧ ⊔ ⟦ x ⟧) ⊓ (⟦ z ⟧ ⊔ ⟦ x ⟧) ≈⟨ ⊓-cong (∨-homo y x) (∨-homo z x) ⟨
102 ⟦ y ∨ x ⟧ ⊓ ⟦ z ∨ x ⟧ ≈⟨ ∧-homo (y ∨ x) (z ∨ x) ⟨
103 ⟦ (y ∨ x) ∧ (z ∨ x) ⟧ ∎)
104
105 isLattice : IsLattice _≈₂_ _⊔_ _⊓_ → IsLattice _≈₁_ _∨_ _∧_
106 isLattice isLattice = record
107 { isEquivalence = RelMonomorphisms.isEquivalence isRelMonomorphism L.isEquivalence
108 ; ∨-comm = ∨-comm LP.∨-isMagma L.∨-comm
109 ; ∨-assoc = ∨-assoc LP.∨-isMagma L.∨-assoc
110 ; ∨-cong = ∨-cong LP.∨-isMagma
111 ; ∧-comm = ∧-comm LP.∧-isMagma L.∧-comm
112 ; ∧-assoc = ∧-assoc LP.∧-isMagma L.∧-assoc
113 ; ∧-cong = ∧-cong LP.∧-isMagma
114 ; absorptive = absorptive isLattice
115 } where
116 module L = IsLattice isLattice
117 module LP = LatticeProperties (record { isLattice = isLattice })
118
119 isDistributiveLattice : IsDistributiveLattice _≈₂_ _⊔_ _⊓_ →
120 IsDistributiveLattice _≈₁_ _∨_ _∧_
121 isDistributiveLattice isDL = isDistributiveLatticeʳʲᵐ (record
122 { isLattice = isLattice L.isLattice
123 ; ∨-distribʳ-∧ = distribʳ L.isLattice L.∨-distribʳ-∧
124 }) where module L = IsDistributiveLattice isDL