Lean migration cleanup: collapse FixedHeight struct into FiniteHeightLattice typeclass
The fable-based migration left a two-layer design (a standalone `FixedHeight α h` struct, height carried as a type index, plus a `FiniteHeightLattice` wrapper). This collapses it to the single `FiniteHeightLattice` typeclass (height as a plain field, `⊥`/`⊤` via `extends Bot`/`Top`), and fixes the fallout so the whole project builds again (`lake build` green). - Lattice: repair `FixedHeight.bot_le` (compute the `▸` motive via a forward `rw`, drop the leftover `fh.length_longestChain`) and the `bot_le` alias. - Isomorphism: transport rewritten directly onto `FiniteHeightLattice`, taking the source as an instance argument. - Lattice/Prod, AboveBelow: `FixedHeight`-producing def + wrapper instance collapsed into one `FiniteHeightLattice` instance. `head`/`last` proofs use term-mode `congrArg` to bridge the `Bot`/`Top` defeq through the under-construction instance projection (where `rw`+`rfl` cannot). - Lattice/IterProd: `fixedHeight` recursion now yields a `FiniteHeightLattice` (no height index, so the `.cast (by ring)` reassociations vanish); `bot_fixedHeight` reprojected onto the def's own `.bot`. - Lattice/FiniteMap: `fixedHeight`/`bot_contains_bots` go through transport with the IterProd instance resolved by typeclass search; `punitFixedHeight` replaced by the `PUnit` instance. - Analysis/Forward/Lattices: `botV` uses `⊥` instead of the deleted `FiniteHeightLattice.bot` accessor. - Analysis/Sign: `num` case used unimported `ring`; the goal is a pure ℕ→ℤ cast identity, closed with `norm_cast`. Also fixes the missing `show` in `AboveBelow.monotone₂_of_strict` that left un-beta-reduced redexes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,12 +13,11 @@ Correspondence:
|
||||
isLattice/lattice ↦ instance Spa.IterProd.instLattice
|
||||
fixedHeight,
|
||||
isFiniteHeightLattice,
|
||||
finiteHeightLattice ↦ Spa.IterProd.fixedHeight (+ FiniteHeightLattice instance)
|
||||
finiteHeightLattice ↦ Spa.IterProd.fixedHeight (+ instFiniteHeight instance)
|
||||
⊥-built ↦ Spa.IterProd.bot_fixedHeight
|
||||
-/
|
||||
import Spa.Lattice.Prod
|
||||
import Spa.Lattice.Unit
|
||||
import Mathlib.Tactic.Ring
|
||||
|
||||
namespace Spa
|
||||
|
||||
@@ -51,25 +50,21 @@ def build (a : A) (b : B) : (k : ℕ) → IterProd A B k
|
||||
|
||||
variable [Lattice A] [Lattice B]
|
||||
|
||||
/-- Agda: `fixedHeight` (the `isFiniteHeightIfSupported` recursion). -/
|
||||
def fixedHeight {hA hB : ℕ} (fhA : FixedHeight A hA) (fhB : FixedHeight B hB) :
|
||||
(k : ℕ) → FixedHeight (IterProd A B k) (k * hA + hB)
|
||||
| 0 => fhB.cast (by ring)
|
||||
| k + 1 => (fhA.prod (fixedHeight fhA fhB k)).cast (by ring)
|
||||
def fixedHeight [FiniteHeightLattice A] [FiniteHeightLattice B] :
|
||||
∀ k, FiniteHeightLattice (IterProd A B k)
|
||||
| 0 => inferInstanceAs (FiniteHeightLattice B)
|
||||
| k + 1 => @Spa.prod A (IterProd A B k) _ (instLattice k) _ (fixedHeight k)
|
||||
|
||||
/-- Agda: `⊥-built` — the bottom of the iterated product is built from the
|
||||
component bottoms. -/
|
||||
theorem bot_fixedHeight {hA hB : ℕ} (fhA : FixedHeight A hA) (fhB : FixedHeight B hB) :
|
||||
∀ k, (fixedHeight fhA fhB k).bot = build fhA.bot fhB.bot k
|
||||
instance instFiniteHeight [FiniteHeightLattice A] [FiniteHeightLattice B] (k : ℕ) :
|
||||
FiniteHeightLattice (IterProd A B k) := fixedHeight k
|
||||
|
||||
theorem bot_fixedHeight [FiniteHeightLattice A] [FiniteHeightLattice B] :
|
||||
∀ k, (fixedHeight (A := A) (B := B) k).bot = build (⊥ : A) (⊥ : B) k
|
||||
| 0 => rfl
|
||||
| k + 1 => by
|
||||
show (fhA.bot, (fixedHeight fhA fhB k).bot) = (fhA.bot, build fhA.bot fhB.bot k)
|
||||
rw [bot_fixedHeight fhA fhB k]
|
||||
|
||||
instance [IA : FiniteHeightLattice A] [IB : FiniteHeightLattice B] (k : ℕ) :
|
||||
FiniteHeightLattice (IterProd A B k) where
|
||||
height := k * IA.height + IB.height
|
||||
fixedHeight := fixedHeight IA.fixedHeight IB.fixedHeight k
|
||||
show ((⊥ : A), (fixedHeight (A := A) (B := B) k).bot)
|
||||
= ((⊥ : A), build (⊥ : A) (⊥ : B) k)
|
||||
rw [bot_fixedHeight k]
|
||||
|
||||
end IterProd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user