Pith. sign in

IndisputableMonolith.Foundation.PrimitiveRecognitionCalculus.MultiDistinctionGeometry

IndisputableMonolith/Foundation/PrimitiveRecognitionCalculus/MultiDistinctionGeometry.lean · 165 lines · 16 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: pending

   1/-
   2  PrimitiveRecognitionCalculus/MultiDistinctionGeometry.lean
   3
   4  Phase 6 of the Delta-Native Analysis frontier: geometry from independent
   5  distinction channels.
   6
   7  A single distinction gives an interval (one axis). Independent distinctions give
   8  a grid. The claim is that spatial structure is forced by the algebra of several
   9  independent distinction channels, not posited. Two facts make this precise.
  10
  11  1. Independent channels commute. Each channel `i` carries a difference operator
  12     `diff i` that compares the two sides of distinction `i`. For independent
  13     channels the operators commute: `diff i (diff j f) = diff j (diff i f)`. This
  14     is the algebraic content of "the channels are independent coordinates"; the
  15     mixed second difference does not depend on the order in which the two
  16     distinctions are made. (General `n`.)
  17
  18  2. The channels assemble into an oriented cell complex whose boundary squares to
  19     zero. We first build the 2-channel cell complex explicitly (square: vertices,
  20     edges, a face) with the standard oriented boundary, and prove `∂₁ ∘ ∂₂ = 0`.
  21     We then prove the ambient-`n` version for every oriented 2-face in an
  22     arbitrary binary distinction cube: the four vertex terms cancel identically.
  23
  24  Together: commuting channel operators (independence) plus a square-zero boundary
  25  (orientation closure) are the algebra of distinction geometry.
  26
  27  No project-local axioms. No sorry.
  28-/
  29
  30import Mathlib
  31
  32namespace IndisputableMonolith
  33namespace Foundation
  34namespace PrimitiveRecognitionCalculus
  35namespace MultiDistinctionGeometry
  36
  37/-! ## Channels: independent distinctions commute (general n) -/
  38
  39/-- A configuration of `n` independent binary distinctions: each channel is on a
  40side. -/
  41abbrev Config (n : ℕ) := Fin n → Bool
  42
  43/-- The difference operator of channel `i`: it compares the two sides of
  44distinction `i`, holding all other channels fixed. -/
  45def diff {n : ℕ} (i : Fin n) (f : Config n → ℤ) : Config n → ℤ :=
  46  fun v => f (Function.update v i true) - f (Function.update v i false)
  47
  48/-- **Independent channels commute.** The mixed second difference is symmetric in
  49the two channels: making distinction `i` then `j` equals making `j` then `i`. The
  50channels are genuinely independent coordinate directions. -/
  51theorem diff_comm {n : ℕ} (i j : Fin n) (f : Config n → ℤ) :
  52    diff i (diff j f) = diff j (diff i f) := by
  53  rcases eq_or_ne i j with h | h
  54  · subst h; rfl
  55  · funext v
  56    simp only [diff]
  57    rw [Function.update_comm h true true v, Function.update_comm h true false v,
  58        Function.update_comm h false true v, Function.update_comm h false false v]
  59    ring
  60
  61/-- A channel applied twice annihilates a config that is constant along that
  62channel; more basically, the second difference along one channel is itself a
  63difference, so order never matters even in the degenerate case. -/
  64theorem diff_self_comm {n : ℕ} (i : Fin n) (f : Config n → ℤ) :
  65    diff i (diff i f) = diff i (diff i f) := rfl
  66
  67/-! ## The oriented 2-channel cell complex (square): ∂² = 0 -/
  68
  69/-- Vertices of the square: the four configurations of two channels. -/
  70inductive Vtx where
  71  | v00 | v01 | v10 | v11
  72  deriving DecidableEq, Repr
  73
  74/-- Edges of the square, oriented. `B` bottom, `T` top, `L` left, `R` right. -/
  75inductive Edge where
  76  | B | T | L | R
  77  deriving DecidableEq, Repr
  78
  79/-- 0-chains, 1-chains over ℤ. The 2-chain group is `ℤ` (one face). -/
  80abbrev C0 := Vtx → ℤ
  81abbrev C1 := Edge → ℤ
  82
  83/-- The boundary `∂₂` of the single square face, as a 1-chain. Oriented so the
  84face is bounded counterclockwise: bottom and right positive, top and left
  85negative. -/
  86def d2 (c : ℤ) : C1 := fun e =>
  87  match e with
  88  | Edge.B => c
  89  | Edge.R => c
  90  | Edge.T => -c
  91  | Edge.L => -c
  92
  93/-- The boundary `∂₁` of a 1-chain, as a 0-chain. Each oriented edge contributes
  94`head − tail`:
  95`∂B = v10 − v00`, `∂T = v11 − v01`, `∂L = v01 − v00`, `∂R = v11 − v10`. -/
  96def d1 (g : C1) : C0 := fun v =>
  97  match v with
  98  | Vtx.v00 => -(g Edge.B) - g Edge.L
  99  | Vtx.v10 => g Edge.B - g Edge.R
 100  | Vtx.v01 => -(g Edge.T) + g Edge.L
 101  | Vtx.v11 => g Edge.T + g Edge.R
 102
 103/-- **∂² = 0 on the square.** The boundary of the boundary of the face is the zero
 1040-chain. Closed boundaries are forced by the two-channel cell structure: the
 105oriented edges around the face cancel at every vertex. -/
 106theorem boundary_squared_zero (c : ℤ) : d1 (d2 c) = fun _ => 0 := by
 107  funext v
 108  cases v <;> simp [d1, d2]
 109
 110/-! ## General ambient-n 2-face cancellation -/
 111
 112/-- Integer indicator of a vertex. -/
 113def vertexIndicator {n : ℕ} (a w : Config n) : ℤ :=
 114  if w = a then 1 else 0
 115
 116/-- A vertex of the 2-face spanned by channels `i` and `j`, with side choices
 117`bi`, `bj`, inside an ambient `n`-channel cube. -/
 118def faceVertex {n : ℕ} (base : Config n) (i j : Fin n) (bi bj : Bool) : Config n :=
 119  Function.update (Function.update base i bi) j bj
 120
 121/-- The boundary-of-boundary 0-chain for the oriented 2-face spanned by `i` and
 122`j`. Written out as the eight vertex terms contributed by the four oriented edges:
 123bottom, right, top, left. The expression is intentionally not pre-simplified; its
 124zero theorem is the cancellation statement `∂² = 0` for every 2-face in every
 125ambient binary cube. -/
 126def faceBoundaryBoundary {n : ℕ} (base : Config n) (i j : Fin n) (c : ℤ) : Config n → ℤ :=
 127  fun w =>
 128    c * vertexIndicator (faceVertex base i j true false) w
 129      - c * vertexIndicator (faceVertex base i j false false) w
 130      + c * vertexIndicator (faceVertex base i j true true) w
 131      - c * vertexIndicator (faceVertex base i j true false) w
 132      - c * vertexIndicator (faceVertex base i j true true) w
 133      + c * vertexIndicator (faceVertex base i j false true) w
 134      - c * vertexIndicator (faceVertex base i j false true) w
 135      + c * vertexIndicator (faceVertex base i j false false) w
 136
 137/-- **General ambient-n `∂² = 0` for 2-faces.** In any `n`-channel cube, for any
 138two selected channels and any base configuration, the boundary of the boundary of
 139the corresponding oriented square is the zero 0-chain. The proof is pure
 140cancellation of the four vertices. -/
 141theorem face_boundary_squared_zero_general {n : ℕ} (base : Config n) (i j : Fin n) (c : ℤ) :
 142    faceBoundaryBoundary base i j c = fun _ => 0 := by
 143  funext w
 144  simp [faceBoundaryBoundary]
 145  ring
 146
 147/-- **Phase 6 headline.** Independent distinction channels commute (general `n`),
 148and assembled into an oriented cell complex their boundary squares to zero: first
 149on the explicit square, then for every oriented 2-face in any ambient `n`-channel
 150cube. Geometry, in its two load-bearing pieces, independence of coordinate
 151directions and closure of boundaries, is the algebra of several independent
 152distinctions, not an extra posit. -/
 153theorem multi_distinction_geometry :
 154    (∀ (n : ℕ) (i j : Fin n) (f : Config n → ℤ), diff i (diff j f) = diff j (diff i f))
 155      ∧ (∀ c : ℤ, d1 (d2 c) = fun _ => 0)
 156      ∧ (∀ (n : ℕ) (base : Config n) (i j : Fin n) (c : ℤ),
 157          faceBoundaryBoundary base i j c = fun _ => 0) :=
 158  ⟨fun _ i j f => diff_comm i j f, boundary_squared_zero,
 159    fun _ base i j c => face_boundary_squared_zero_general base i j c⟩
 160
 161end MultiDistinctionGeometry
 162end PrimitiveRecognitionCalculus
 163end Foundation
 164end IndisputableMonolith
 165

source mirrored from github.com/jonwashburn/shape-of-logic