Delete more LLM-generated comments from the migration
This commit is contained in:
@@ -1,25 +1,7 @@
|
||||
/-
|
||||
Port of `Lattice/AboveBelow.agda`: the flat lattice obtained by adjoining a
|
||||
top and bottom element to an (unordered, decidable-equality) type.
|
||||
|
||||
With propositional equality the `_≈_` data type and its equivalence/decidability
|
||||
proofs disappear (`deriving DecidableEq`). The lattice itself cannot be lifted:
|
||||
mathlib has no "flat lattice on a discrete type". The `Lattice` instance is
|
||||
built with `Lattice.mk'`, which — exactly like the Agda module — consumes the
|
||||
two semilattices (comm/assoc, idempotence derived) plus the absorption laws,
|
||||
and defines `a ≤ b ↔ a ⊔ b = b` (Agda's `_≼_`).
|
||||
|
||||
The Agda module's `Plain x` submodule (the witness `x` seeds the longest chain
|
||||
`⊥ ≺ [x] ≺ ⊤`) becomes `plainFixedHeight x`; the boundedness proof `isLongest`
|
||||
is restated through a rank function since chains are mathlib `LTSeries` rather
|
||||
than a pattern-matchable inductive (the `¬-Chain-⊤`-style case analysis lives
|
||||
in `rank_strictMono`).
|
||||
-/
|
||||
import Spa.Lattice
|
||||
|
||||
namespace Spa
|
||||
|
||||
/-- Agda: `AboveBelow` with constructors `⊥`, `⊤`, `[_]`. -/
|
||||
inductive AboveBelow (α : Type*) where
|
||||
| bot
|
||||
| top
|
||||
@@ -28,7 +10,6 @@ inductive AboveBelow (α : Type*) where
|
||||
|
||||
namespace AboveBelow
|
||||
|
||||
/-- Agda: the `Showable` instance. -/
|
||||
instance {α : Type*} [ToString α] : ToString (AboveBelow α) where
|
||||
toString
|
||||
| bot => "⊥"
|
||||
@@ -53,9 +34,6 @@ instance : Min (AboveBelow α) where
|
||||
| mk _, bot => bot
|
||||
| mk x, top => mk x
|
||||
|
||||
/-! Agda: `⊥⊔x≡x`, `⊤⊔x≡⊤`, `x⊔⊥≡x`, `x⊔⊤≡⊤`, and the `[x]⊔[y]` reductions
|
||||
(`x≈y⇒[x]⊔[y]≡[x]` / `x̷≈y⇒[x]⊔[y]≡⊤` are the two branches of `mk_sup_mk`). -/
|
||||
|
||||
@[simp] theorem bot_sup (x : AboveBelow α) : bot ⊔ x = x := rfl
|
||||
@[simp] theorem top_sup (x : AboveBelow α) : top ⊔ x = top := rfl
|
||||
@[simp] theorem sup_bot (x : AboveBelow α) : x ⊔ bot = x := by cases x <;> rfl
|
||||
@@ -70,46 +48,38 @@ instance : Min (AboveBelow α) where
|
||||
@[simp] theorem mk_inf_mk (x y : α) :
|
||||
(mk x ⊓ mk y : AboveBelow α) = if x = y then mk x else bot := rfl
|
||||
|
||||
/-- Agda: `⊔-comm`. -/
|
||||
protected theorem sup_comm (a b : AboveBelow α) : a ⊔ b = b ⊔ a := by
|
||||
rcases a with _ | _ | x <;> rcases b with _ | _ | y <;> simp only
|
||||
[bot_sup, sup_bot, top_sup, sup_top, mk_sup_mk]
|
||||
split_ifs with h₁ h₂ h₂ <;> simp_all
|
||||
|
||||
/-- Agda: `⊔-assoc`. -/
|
||||
protected theorem sup_assoc (a b c : AboveBelow α) : a ⊔ b ⊔ c = a ⊔ (b ⊔ c) := by
|
||||
rcases a with _ | _ | x <;> rcases b with _ | _ | y <;> rcases c with _ | _ | z <;>
|
||||
simp only [bot_sup, sup_bot, top_sup, sup_top, mk_sup_mk]
|
||||
split_ifs <;> simp_all
|
||||
|
||||
/-- Agda: `⊓-comm`. -/
|
||||
protected theorem inf_comm (a b : AboveBelow α) : a ⊓ b = b ⊓ a := by
|
||||
rcases a with _ | _ | x <;> rcases b with _ | _ | y <;> simp only
|
||||
[bot_inf, inf_bot, top_inf, inf_top, mk_inf_mk]
|
||||
split_ifs with h₁ h₂ h₂ <;> simp_all
|
||||
|
||||
/-- Agda: `⊓-assoc`. -/
|
||||
protected theorem inf_assoc (a b c : AboveBelow α) : a ⊓ b ⊓ c = a ⊓ (b ⊓ c) := by
|
||||
rcases a with _ | _ | x <;> rcases b with _ | _ | y <;> rcases c with _ | _ | z <;>
|
||||
simp only [bot_inf, inf_bot, top_inf, inf_top, mk_inf_mk]
|
||||
split_ifs <;> simp_all
|
||||
|
||||
/-- Agda: `absorb-⊔-⊓`. -/
|
||||
protected theorem sup_inf_self (a b : AboveBelow α) : a ⊔ a ⊓ b = a := by
|
||||
rcases a with _ | _ | x <;> rcases b with _ | _ | y <;>
|
||||
simp only [bot_sup, sup_bot, top_sup, sup_top, mk_sup_mk,
|
||||
bot_inf, inf_bot, top_inf, inf_top, mk_inf_mk] <;>
|
||||
try (split_ifs <;> simp_all)
|
||||
|
||||
/-- Agda: `absorb-⊓-⊔`. -/
|
||||
protected theorem inf_sup_self (a b : AboveBelow α) : a ⊓ (a ⊔ b) = a := by
|
||||
rcases a with _ | _ | x <;> rcases b with _ | _ | y <;>
|
||||
simp only [bot_sup, sup_bot, top_sup, sup_top, mk_sup_mk,
|
||||
bot_inf, inf_bot, top_inf, inf_top, mk_inf_mk] <;>
|
||||
try (split_ifs <;> simp_all)
|
||||
|
||||
/-- Agda: `isLattice` (via the two semilattices + absorption, like the Agda
|
||||
record; `Lattice.mk'` derives idempotence and sets `a ≤ b ↔ a ⊔ b = b`). -/
|
||||
instance : Lattice (AboveBelow α) :=
|
||||
Lattice.mk' AboveBelow.sup_comm AboveBelow.sup_assoc
|
||||
AboveBelow.inf_comm AboveBelow.inf_assoc
|
||||
@@ -117,11 +87,9 @@ instance : Lattice (AboveBelow α) :=
|
||||
|
||||
theorem le_iff {a b : AboveBelow α} : a ≤ b ↔ a ⊔ b = b := sup_eq_right.symm
|
||||
|
||||
/-- Agda: `⊥≺[x]` (the `≤` part; `⊥` is least). -/
|
||||
theorem bot_le' (a : AboveBelow α) : (bot : AboveBelow α) ≤ a :=
|
||||
le_iff.mpr (bot_sup a)
|
||||
|
||||
/-- Agda: `[x]≺⊤` (the `≤` part; `⊤` is greatest). -/
|
||||
theorem le_top' (a : AboveBelow α) : a ≤ (top : AboveBelow α) :=
|
||||
le_iff.mpr (sup_top a)
|
||||
|
||||
@@ -134,9 +102,6 @@ theorem mk_lt_top (x : α) : (mk x : AboveBelow α) < top :=
|
||||
theorem bot_lt_top : (bot : AboveBelow α) < top :=
|
||||
lt_of_le_of_ne (bot_le' _) (by simp)
|
||||
|
||||
/-- The order of the flat lattice, by cases (used to discharge the
|
||||
monotonicity obligations that were `postulate`d in `Analysis/Sign.agda` and
|
||||
`Analysis/Constant.agda`). -/
|
||||
theorem le_cases {a b : AboveBelow α} (h : a ≤ b) :
|
||||
a = bot ∨ b = top ∨ a = b := by
|
||||
have hsup := le_iff.mp h
|
||||
@@ -183,18 +148,12 @@ theorem monotone₂_of_strict {β γ : Type*} [DecidableEq β] [DecidableEq γ]
|
||||
· rw [htopr x hx]; exact le_top' _
|
||||
· exact le_rfl
|
||||
|
||||
/-! ### Interpretations of flat lattices
|
||||
|
||||
The `⟦⟧-⊔-∨` / `⟦⟧-⊓-∧` proofs of `Analysis/Sign.agda` and
|
||||
`Analysis/Constant.agda` are the same case analysis; only the meaning of the
|
||||
plain elements differs. Factored here, they need just `P ⊥ ↦ False`,
|
||||
`P ⊤ ↦ True`, and (for `⊓`) disjointness of distinct plain elements. -/
|
||||
/-! ### Interpretations of flat lattices -/
|
||||
|
||||
section Interp
|
||||
|
||||
variable {V : Type*} {P : AboveBelow α → V → Prop}
|
||||
|
||||
/-- Agda: `⟦⟧ᵍ-⊔ᵍ-∨` / `⟦⟧ᶜ-⊔ᶜ-∨`, generalized. -/
|
||||
theorem interp_sup_of (hbot : ∀ v, ¬P bot v) (htop : ∀ v, P top v)
|
||||
{s₁ s₂ : AboveBelow α} (v : V) (h : P s₁ v ∨ P s₂ v) : P (s₁ ⊔ s₂) v := by
|
||||
rcases s₁ with _ | _ | x
|
||||
@@ -208,7 +167,6 @@ theorem interp_sup_of (hbot : ∀ v, ¬P bot v) (htop : ∀ v, P top v)
|
||||
· next heq => subst heq; exact h.elim id id
|
||||
· exact htop v
|
||||
|
||||
/-- Agda: `⟦⟧ᵍ-⊓ᵍ-∧` / `⟦⟧ᶜ-⊓ᶜ-∧`, generalized. -/
|
||||
theorem interp_inf_of
|
||||
(hdisj : ∀ {x y : α}, x ≠ y → ∀ v, ¬(P (mk x) v ∧ P (mk y) v))
|
||||
{s₁ s₂ : AboveBelow α} (v : V) (h : P s₁ v ∧ P s₂ v) : P (s₁ ⊓ s₂) v := by
|
||||
@@ -258,17 +216,12 @@ theorem rank_strictMono : StrictMono (rank : AboveBelow α → ℕ) := by
|
||||
· simp [rank]
|
||||
· exact absurd hab (not_mk_lt_mk x y)
|
||||
|
||||
/-- Agda: `isLongest` — no chain is longer than 2. -/
|
||||
theorem boundedChains : BoundedChains (AboveBelow α) 2 := fun c => by
|
||||
have h := LTSeries.head_add_length_le_nat (c.map rank rank_strictMono)
|
||||
rw [LTSeries.head_map, LTSeries.last_map, LTSeries.map_length] at h
|
||||
have h2 : rank c.last ≤ 2 := by cases c.last <;> simp [rank]
|
||||
omega
|
||||
|
||||
/-- Agda: `Plain.longestChain`/`Plain.fixedHeight` and
|
||||
`Plain.isFiniteHeightLattice`/`Plain.finiteHeightLattice` — the witness
|
||||
(`default`, playing the role of the Agda module parameter `x`) seeds the chain
|
||||
`⊥ ≺ [x] ≺ ⊤` of length 2. -/
|
||||
instance [Inhabited α] : FiniteHeightLattice (AboveBelow α) where
|
||||
bot := bot
|
||||
top := top
|
||||
|
||||
Reference in New Issue
Block a user