Add a Lattice instance for natural numbers.
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
c6dddb177e
commit
bac68b95f1
23
Lattice.agda
23
Lattice.agda
|
@ -154,6 +154,27 @@ private module NatInstances where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private
|
||||||
|
minmax-absorb : {x y : ℕ} → x ⊓ (x ⊔ y) ≡ x
|
||||||
|
minmax-absorb {x} {y} = ≤-antisym x⊓x⊔y≤x (helper x⊓x≤x⊓x⊔y (⊓-idem x))
|
||||||
|
where
|
||||||
|
x⊓x⊔y≤x = min-bound₁ {x} {x ⊔ y} {x ⊓ (x ⊔ y)} refl
|
||||||
|
x⊓x≤x⊓x⊔y = ⊓-mono-≤ {x} {x} ≤-refl (max-bound₁ {x} {y} {x ⊔ y} refl)
|
||||||
|
|
||||||
|
-- >:(
|
||||||
|
helper : x ⊓ x ≤ x ⊓ (x ⊔ y) → x ⊓ x ≡ x → x ≤ x ⊓ (x ⊔ y)
|
||||||
|
helper x⊓x≤x⊓x⊔y x⊓x≡x rewrite x⊓x≡x = x⊓x≤x⊓x⊔y
|
||||||
|
|
||||||
|
maxmin-absorb : {x y : ℕ} → x ⊔ (x ⊓ y) ≡ x
|
||||||
|
maxmin-absorb {x} {y} = ≤-antisym (helper x⊔x⊓y≤x⊔x (⊔-idem x)) x≤x⊔x⊓y
|
||||||
|
where
|
||||||
|
x≤x⊔x⊓y = max-bound₁ {x} {x ⊓ y} {x ⊔ (x ⊓ y)} refl
|
||||||
|
x⊔x⊓y≤x⊔x = ⊔-mono-≤ {x} {x} ≤-refl (min-bound₁ {x} {y} {x ⊓ y} refl)
|
||||||
|
|
||||||
|
-- >:(
|
||||||
|
helper : x ⊔ (x ⊓ y) ≤ x ⊔ x → x ⊔ x ≡ x → x ⊔ (x ⊓ y) ≤ x
|
||||||
|
helper x⊔x⊓y≤x⊔x x⊔x≡x rewrite x⊔x≡x = x⊔x⊓y≤x⊔x
|
||||||
|
|
||||||
NatLattice : Lattice ℕ
|
NatLattice : Lattice ℕ
|
||||||
NatLattice = record
|
NatLattice = record
|
||||||
{ _≼_ = _≤_
|
{ _≼_ = _≤_
|
||||||
|
@ -162,5 +183,7 @@ private module NatInstances where
|
||||||
; isLattice = record
|
; isLattice = record
|
||||||
{ joinSemilattice = Semilattice.isSemilattice NatMaxSemilattice
|
{ joinSemilattice = Semilattice.isSemilattice NatMaxSemilattice
|
||||||
; meetSemilattice = Semilattice.isSemilattice NatMinSemilattice
|
; meetSemilattice = Semilattice.isSemilattice NatMinSemilattice
|
||||||
|
; absorb-⊔-⊓ = λ x y → maxmin-absorb {x} {y}
|
||||||
|
; absorb-⊓-⊔ = λ x y → minmax-absorb {x} {y}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user