Theory Order_Lattice_Props_Loc
section ‹Locale-Based Duality›
theory Order_Lattice_Props_Loc
imports Main
begin
unbundle lattice_syntax
text ‹This section explores order and lattice duality based on locales. Used within the context of a class or locale,
this is very effective, though more opaque than the previous approach. Outside of such a context, however, it apparently
cannot be used for dualising theorems. Examples are properties of functions between orderings or lattices.›
definition Fix :: "('a ⇒ 'a) ⇒ 'a set" where
"Fix f = {x. f x = x}"
context ord
begin
definition min_set :: "'a set ⇒ 'a set" where
"min_set X = {y ∈ X. ∀x ∈ X. x ≤ y ⟶ x = y}"
definition max_set :: "'a set ⇒ 'a set" where
"max_set X = {x ∈ X. ∀y ∈ X. x ≤ y ⟶ x = y}"
definition directed :: "'a set ⇒ bool" where
"directed X = (∀Y. finite Y ∧ Y ⊆ X ⟶ (∃x ∈ X. ∀y ∈ Y. y ≤ x))"
definition filtered :: "'a set ⇒ bool" where
"filtered X = (∀Y. finite Y ∧ Y ⊆ X ⟶ (∃x ∈ X. ∀y ∈ Y. x ≤ y))"
definition downset_set :: "'a set ⇒ 'a set" ("⇓") where
"⇓X = {y. ∃x ∈ X. y ≤ x}"
definition upset_set :: "'a set ⇒ 'a set" ("⇑") where
"⇑X = {y. ∃x ∈ X. x ≤ y}"
definition downset :: "'a ⇒ 'a set" ("↓") where
"↓ = ⇓ ∘ (λx. {x})"
definition upset :: "'a ⇒ 'a set" ("↑") where
"↑ = ⇑ ∘ (λx. {x})"
definition downsets :: "'a set set" where
"downsets = Fix ⇓"
definition upsets :: "'a set set" where
"upsets = Fix ⇑"
abbreviation "downset_setp X ≡ X ∈ downsets"
abbreviation "upset_setp X ≡ X ∈ upsets"
definition ideals :: "'a set set" where
"ideals = {X. X ≠ {} ∧ downset_setp X ∧ directed X}"
definition filters :: "'a set set" where
"filters = {X. X ≠ {} ∧ upset_setp X ∧ filtered X}"
abbreviation "idealp X ≡ X ∈ ideals"
abbreviation "filterp X ≡ X ∈ filters"
end
abbreviation Sup_pres :: "('a::Sup ⇒ 'b::Sup) ⇒ bool" where
"Sup_pres f ≡ f ∘ Sup = Sup ∘ (`) f"
abbreviation Inf_pres :: "('a::Inf ⇒ 'b::Inf) ⇒ bool" where
"Inf_pres f ≡ f ∘ Inf = Inf ∘ (`) f"
abbreviation sup_pres :: "('a::sup ⇒ 'b::sup) ⇒ bool" where
"sup_pres f ≡ (∀x y. f (x ⊔ y) = f x ⊔ f y)"
abbreviation inf_pres :: "('a::inf ⇒ 'b::inf) ⇒ bool" where
"inf_pres f ≡ (∀x y. f (x ⊓ y) = f x ⊓ f y)"
abbreviation bot_pres :: "('a::bot ⇒ 'b::bot) ⇒ bool" where
"bot_pres f ≡ f ⊥ = ⊥"
abbreviation top_pres :: "('a::top ⇒ 'b::top) ⇒ bool" where
"top_pres f ≡ f ⊤ = ⊤"
abbreviation Sup_dual :: "('a::Sup ⇒ 'b::Inf) ⇒ bool" where
"Sup_dual f ≡ f ∘ Sup = Inf ∘ (`) f"
abbreviation Inf_dual :: "('a::Inf ⇒ 'b::Sup) ⇒ bool" where
"Inf_dual f ≡ f ∘ Inf = Sup ∘ (`) f"
abbreviation sup_dual :: "('a::sup ⇒ 'b::inf) ⇒ bool" where
"sup_dual f ≡ (∀x y. f (x ⊔ y) = f x ⊓ f y)"
abbreviation inf_dual :: "('a::inf ⇒ 'b::sup) ⇒ bool" where
"inf_dual f ≡ (∀x y. f (x ⊓ y) = f x ⊔ f y)"
abbreviation bot_dual :: "('a::bot ⇒ 'b::top) ⇒ bool" where
"bot_dual f ≡ f ⊥ = ⊤"
abbreviation top_dual :: "('a::top ⇒ 'b::bot) ⇒ bool" where
"top_dual f ≡ f ⊤ = ⊥"
subsection ‹Duality via Locales›
sublocale ord ⊆ dual_ord: ord "(≥)" "(>)"
rewrites dual_max_set: "max_set = dual_ord.min_set"
and dual_filtered: "filtered = dual_ord.directed"
and dual_upset_set: "upset_set = dual_ord.downset_set"
and dual_upset: "upset = dual_ord.downset"
and dual_upsets: "upsets = dual_ord.downsets"
and dual_filters: "filters = dual_ord.ideals"
apply unfold_locales
unfolding max_set_def ord.min_set_def fun_eq_iff apply blast
unfolding filtered_def ord.directed_def apply simp
unfolding upset_set_def ord.downset_set_def apply simp
apply (simp add: ord.downset_def ord.downset_set_def ord.upset_def ord.upset_set_def)
unfolding upsets_def ord.downsets_def apply (metis ord.downset_set_def upset_set_def)
unfolding filters_def ord.ideals_def Fix_def ord.downsets_def upsets_def ord.downset_set_def upset_set_def ord.directed_def filtered_def
by simp
sublocale preorder ⊆ dual_preorder: preorder "(≥)" "(>)"
apply unfold_locales
apply (simp add: less_le_not_le)
apply simp
using order_trans by blast
sublocale order ⊆ dual_order: order "(≥)" "(>)"
by (unfold_locales, simp)
sublocale lattice ⊆ dual_lattice: lattice sup "(≥)" "(>)" inf
by (unfold_locales, simp_all)
sublocale bounded_lattice ⊆ dual_bounded_lattice: bounded_lattice sup "(≥)" "(>)" inf ⊤ ⊥
by (unfold_locales, simp_all)
sublocale boolean_algebra ⊆ dual_boolean_algebra: boolean_algebra "λx y. x ⊔ -y" uminus sup "(≥)" "(>)" inf ⊤ ⊥
by (unfold_locales, simp_all add: inf_sup_distrib1)