| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Some derivable properties of lattices |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Algebra.Lattice.Bundles using (Lattice; Semilattice) |
| 10 |
|
| 11 |
module Algebra.Lattice.Properties.Lattice |
| 12 |
{l₁ l₂} (L : Lattice l₁ l₂) where |
| 13 |
|
| 14 |
import Algebra.Lattice.Properties.Semilattice as SemilatticeProperties |
| 15 |
open import Data.Product.Base using (_,_; swap) |
| 16 |
open Lattice L |
| 17 |
open import Algebra.Definitions _≈_ using (Idempotent; Congruent₂) |
| 18 |
open import Algebra.Structures _≈_ using (IsMagma; IsSemigroup; IsBand) |
| 19 |
open import Algebra.Lattice.Structures _≈_ using (IsLattice; IsSemilattice) |
| 20 |
open import Function.Base |
| 21 |
open import Relation.Binary.Reasoning.Setoid setoid |
| 22 |
open import Relation.Binary.Bundles using (Poset) |
| 23 |
import Relation.Binary.Lattice as R |
| 24 |
|
| 25 |
------------------------------------------------------------------------ |
| 26 |
-- _∧_ is a semilattice |
| 27 |
|
| 28 |
∧-idem : Idempotent _∧_ |
| 29 |
∧-idem x = begin |
| 30 |
x ∧ x ≈⟨ ∧-congˡ (∨-absorbs-∧ _ _) ⟨ |
| 31 |
x ∧ (x ∨ x ∧ x) ≈⟨ ∧-absorbs-∨ _ _ ⟩ |
| 32 |
x ∎ |
| 33 |
|
| 34 |
∧-isMagma : IsMagma _∧_ |
| 35 |
∧-isMagma = record |
| 36 |
{ isEquivalence = isEquivalence |
| 37 |
; ∙-cong = ∧-cong |
| 38 |
} |
| 39 |
|
| 40 |
∧-isSemigroup : IsSemigroup _∧_ |
| 41 |
∧-isSemigroup = record |
| 42 |
{ isMagma = ∧-isMagma |
| 43 |
; assoc = ∧-assoc |
| 44 |
} |
| 45 |
|
| 46 |
∧-isBand : IsBand _∧_ |
| 47 |
∧-isBand = record |
| 48 |
{ isSemigroup = ∧-isSemigroup |
| 49 |
; idem = ∧-idem |
| 50 |
} |
| 51 |
|
| 52 |
∧-isSemilattice : IsSemilattice _∧_ |
| 53 |
∧-isSemilattice = record |
| 54 |
{ isBand = ∧-isBand |
| 55 |
; comm = ∧-comm |
| 56 |
} |
| 57 |
|
| 58 |
∧-semilattice : Semilattice l₁ l₂ |
| 59 |
∧-semilattice = record |
| 60 |
{ isSemilattice = ∧-isSemilattice |
| 61 |
} |
| 62 |
|
| 63 |
open SemilatticeProperties ∧-semilattice public |
| 64 |
using |
| 65 |
( ∧-isOrderTheoreticMeetSemilattice |
| 66 |
; ∧-isOrderTheoreticJoinSemilattice |
| 67 |
; ∧-orderTheoreticMeetSemilattice |
| 68 |
; ∧-orderTheoreticJoinSemilattice |
| 69 |
) |
| 70 |
|
| 71 |
------------------------------------------------------------------------ |
| 72 |
-- _∨_ is a semilattice |
| 73 |
|
| 74 |
∨-idem : Idempotent _∨_ |
| 75 |
∨-idem x = begin |
| 76 |
x ∨ x ≈⟨ ∨-congˡ (∧-idem _) ⟨ |
| 77 |
x ∨ x ∧ x ≈⟨ ∨-absorbs-∧ _ _ ⟩ |
| 78 |
x ∎ |
| 79 |
|
| 80 |
∨-isMagma : IsMagma _∨_ |
| 81 |
∨-isMagma = record |
| 82 |
{ isEquivalence = isEquivalence |
| 83 |
; ∙-cong = ∨-cong |
| 84 |
} |
| 85 |
|
| 86 |
∨-isSemigroup : IsSemigroup _∨_ |
| 87 |
∨-isSemigroup = record |
| 88 |
{ isMagma = ∨-isMagma |
| 89 |
; assoc = ∨-assoc |
| 90 |
} |
| 91 |
|
| 92 |
∨-isBand : IsBand _∨_ |
| 93 |
∨-isBand = record |
| 94 |
{ isSemigroup = ∨-isSemigroup |
| 95 |
; idem = ∨-idem |
| 96 |
} |
| 97 |
|
| 98 |
∨-isSemilattice : IsSemilattice _∨_ |
| 99 |
∨-isSemilattice = record |
| 100 |
{ isBand = ∨-isBand |
| 101 |
; comm = ∨-comm |
| 102 |
} |
| 103 |
|
| 104 |
∨-semilattice : Semilattice l₁ l₂ |
| 105 |
∨-semilattice = record |
| 106 |
{ isSemilattice = ∨-isSemilattice |
| 107 |
} |
| 108 |
|
| 109 |
open SemilatticeProperties ∨-semilattice public |
| 110 |
using () |
| 111 |
renaming |
| 112 |
( ∧-isOrderTheoreticMeetSemilattice to ∨-isOrderTheoreticMeetSemilattice |
| 113 |
; ∧-isOrderTheoreticJoinSemilattice to ∨-isOrderTheoreticJoinSemilattice |
| 114 |
; ∧-orderTheoreticMeetSemilattice to ∨-orderTheoreticMeetSemilattice |
| 115 |
; ∧-orderTheoreticJoinSemilattice to ∨-orderTheoreticJoinSemilattice |
| 116 |
) |
| 117 |
|
| 118 |
------------------------------------------------------------------------ |
| 119 |
-- The dual construction is also a lattice. |
| 120 |
|
| 121 |
∧-∨-isLattice : IsLattice _∧_ _∨_ |
| 122 |
∧-∨-isLattice = record |
| 123 |
{ isEquivalence = isEquivalence |
| 124 |
; ∨-comm = ∧-comm |
| 125 |
; ∨-assoc = ∧-assoc |
| 126 |
; ∨-cong = ∧-cong |
| 127 |
; ∧-comm = ∨-comm |
| 128 |
; ∧-assoc = ∨-assoc |
| 129 |
; ∧-cong = ∨-cong |
| 130 |
; absorptive = swap absorptive |
| 131 |
} |
| 132 |
|
| 133 |
∧-∨-lattice : Lattice _ _ |
| 134 |
∧-∨-lattice = record |
| 135 |
{ isLattice = ∧-∨-isLattice |
| 136 |
} |
| 137 |
|
| 138 |
------------------------------------------------------------------------ |
| 139 |
-- Every algebraic lattice can be turned into an order-theoretic one. |
| 140 |
|
| 141 |
open SemilatticeProperties ∧-semilattice public using (poset) |
| 142 |
open Poset poset using (_≤_; isPartialOrder) |
| 143 |
|
| 144 |
∨-∧-isOrderTheoreticLattice : R.IsLattice _≈_ _≤_ _∨_ _∧_ |
| 145 |
∨-∧-isOrderTheoreticLattice = record |
| 146 |
{ isPartialOrder = isPartialOrder |
| 147 |
; supremum = supremum |
| 148 |
; infimum = infimum |
| 149 |
} |
| 150 |
where |
| 151 |
open R.MeetSemilattice ∧-orderTheoreticMeetSemilattice using (infimum) |
| 152 |
open R.JoinSemilattice ∨-orderTheoreticJoinSemilattice using (x≤x∨y; y≤x∨y; ∨-least) |
| 153 |
renaming (_≤_ to _≤′_) |
| 154 |
|
| 155 |
-- An alternative but equivalent interpretation of the order _≤_. |
| 156 |
|
| 157 |
sound : ∀ {x y} → x ≤′ y → x ≤ y |
| 158 |
sound {x} {y} y≈y∨x = sym $ begin |
| 159 |
x ∧ y ≈⟨ ∧-congˡ y≈y∨x ⟩ |
| 160 |
x ∧ (y ∨ x) ≈⟨ ∧-congˡ (∨-comm y x) ⟩ |
| 161 |
x ∧ (x ∨ y) ≈⟨ ∧-absorbs-∨ x y ⟩ |
| 162 |
x ∎ |
| 163 |
|
| 164 |
complete : ∀ {x y} → x ≤ y → x ≤′ y |
| 165 |
complete {x} {y} x≈x∧y = sym $ begin |
| 166 |
y ∨ x ≈⟨ ∨-congˡ x≈x∧y ⟩ |
| 167 |
y ∨ (x ∧ y) ≈⟨ ∨-congˡ (∧-comm x y) ⟩ |
| 168 |
y ∨ (y ∧ x) ≈⟨ ∨-absorbs-∧ y x ⟩ |
| 169 |
y ∎ |
| 170 |
|
| 171 |
supremum : R.Supremum _≤_ _∨_ |
| 172 |
supremum x y = |
| 173 |
sound (x≤x∨y x y) , |
| 174 |
sound (y≤x∨y x y) , |
| 175 |
λ z x≤z y≤z → sound (∨-least (complete x≤z) (complete y≤z)) |
| 176 |
|
| 177 |
∨-∧-orderTheoreticLattice : R.Lattice _ _ _ |
| 178 |
∨-∧-orderTheoreticLattice = record |
| 179 |
{ isLattice = ∨-∧-isOrderTheoreticLattice |
| 180 |
} |