Library lattices.Downset
Require Import Classical.
Require Import ClassicalChoice.
Require Import FunctionalExtensionality.
Require Import PropExtensionality.
Require Import coqrel.LogicalRelations.
Require Import structures.Lattice.
Require Import structures.Completion.
Require Import ClassicalChoice.
Require Import FunctionalExtensionality.
Require Import PropExtensionality.
Require Import coqrel.LogicalRelations.
Require Import structures.Lattice.
Require Import structures.Completion.
Interface
Module Sup <: LatticeCategory.
Class Morphism {L M : cdlattice} (f : L → M) :=
mor : ∀ {I} (x : I → L), f (lsup x) = sup i, f (x i).
Lemma mor_join `{Morphism} x y :
f (x || y) = f x || f y.
Local Transparent join.
Lemma mor_ref {L M : cdlattice} (f : L → M) :
Morphism f →
PosetMorphism f.
Lemma id_mor (L : cdlattice) :
Morphism (fun x:L ⇒ x).
Lemma compose_mor {A B C : cdlattice} (g : B → C) (f : A → B) :
Morphism f →
Morphism g →
Morphism (fun a ⇒ g (f a)).
Hint Immediate mor_ref : typeclass_instances.
Lemma mor_bot `{Morphism} :
f bot = bot.
Local Transparent bot.
End Sup.
Construction
Module Downset <: LatticeCompletion Sup.
Record downset {C : poset} :=
{
has : C → Prop;
closed x y : x [= y → has y → has x;
}.
Arguments downset : clear implicits.
(*
Definition F := downset.
*)
Section DOWNSETS.
Context {C : poset}.
Program Definition Fpos : poset :=
{|
poset_carrier := downset C;
ref x y := ∀ c, has x c → has y c;
|}.
Program Definition F : cdlattice :=
{|
cdl_poset := Fpos;
lsup I x := {| has c := ∃ i, has (x i) c |};
linf I x := {| has c := ∀ i, has (x i) c |};
|}.
sup is downward closed.
inf is downward closed.
Distributivity.
Program Definition emb (c : C) : F :=
{|
has x := x [= c;
|}.
Lemma emb_mor (c1 c2 : C) :
emb c1 [= emb c2 ↔ c1 [= c2.
Lemma emb_join_dense :
∀ x, x = sup {c : C | emb c [= x}, emb c.
Lemma emb_join_prime {I} c (x : I → F) :
emb c [= lsup x ↔ ∃ i, emb c [= x i.
Context {L: cdlattice}.
Definition ext (f : C → L) (x : F) : L :=
sup {c : C | emb c [= x}, f c.
Context {f : C → L} `{Hf : !PosetMorphism f}.
Instance ext_mor :
Sup.Morphism (ext f).
Lemma ext_ana :
(∀ x, ext f (emb x) = f x).
Lemma ext_unique (g : F → L) `{Hg : !Sup.Morphism g} :
(∀ x, g (emb x) = f x) → ∀ x, g x = ext f x.
These are not required to implement the interface but can be
useful when using the concrete implementation directly.