diff --git a/lean/ComparatorChallenges/PartitionConsistency.lean b/lean/ComparatorChallenges/PartitionConsistency.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0164000be29492237dbac6486670f7f33d09f21 --- /dev/null +++ b/lean/ComparatorChallenges/PartitionConsistency.lean @@ -0,0 +1,324 @@ +import Mathlib + +namespace OAI + +namespace PartitionConsistency + +/-- Pure first-order membership syntax with equality. `n` variables are in scope. +A quantifier binds the last variable in its body. There are no atoms/urelements, +function symbols, constants, semantic predicates, or mathematical assumptions +in this syntax. -/ +inductive Formula : ℕ → Type where + | bot {n} : Formula n + | mem {n} (x y : Fin n) : Formula n + | equal {n} (x y : Fin n) : Formula n + | imp {n} (p q : Formula n) : Formula n + | conj {n} (p q : Formula n) : Formula n + | disj {n} (p q : Formula n) : Formula n + | all {n} (p : Formula (n + 1)) : Formula n + | ex {n} (p : Formula (n + 1)) : Formula n + +namespace Formula + +abbrev neg {n} (p : Formula n) : Formula n := p.imp .bot +abbrev iff {n} (p q : Formula n) : Formula n := (p.imp q).conj (q.imp p) + +/-- Under a binder, a renaming leaves the newly bound variable bound. -/ +def liftRen {n m} (r : Fin n → Fin m) : Fin (n + 1) → Fin (m + 1) := + Fin.lastCases (Fin.last m) (fun i => (r i).castSucc) + +/-- Capture-avoiding renaming; in this relational language all terms are variables. -/ +def rename {n m} (r : Fin n → Fin m) : Formula n → Formula m + | .bot => .bot + | .mem x y => .mem (r x) (r y) + | .equal x y => .equal (r x) (r y) + | .imp p q => .imp (rename r p) (rename r q) + | .conj p q => .conj (rename r p) (rename r q) + | .disj p q => .disj (rename r p) (rename r q) + | .all p => .all (rename (liftRen r) p) + | .ex p => .ex (rename (liftRen r) p) + +abbrev raise {n} (p : Formula n) : Formula (n + 1) := rename Fin.castSucc p + +/-- Substitution of a variable term for the variable just quantified. -/ +def instantiate {n} (p : Formula (n + 1)) (x : Fin n) : Formula n := + rename (Fin.lastCases x id) p + +/-- Universal closure of all the free variables. -/ +def close : {n : ℕ} → Formula n → Formula 0 + | 0, p => p + | _ + 1, p => close (.all p) + +end Formula + +abbrev Sentence := Formula 0 +abbrev Theory := Set Sentence + +/-- Classical first-order natural deduction with equality. Hypotheses may be an +infinite theory, but a derivation is a finite inductive proof. The `allI` and +`exE` rules use a fresh last variable, and shift all assumptions to avoid +capture. We allow finitely many free variables in proofs of closed sentences. -/ +inductive Derives : {n : ℕ} → Set (Formula n) → Formula n → Prop where + | hyp {n} {Γ : Set (Formula n)} {p} : p ∈ Γ → Derives Γ p + | weaken {n} {Γ Δ : Set (Formula n)} {p} : + Γ ⊆ Δ → Derives Γ p → Derives Δ p + | impI {n} {Γ : Set (Formula n)} {p q} : + Derives (insert p Γ) q → Derives Γ (.imp p q) + | impE {n} {Γ : Set (Formula n)} {p q} : + Derives Γ (.imp p q) → Derives Γ p → Derives Γ q + | botE {n} {Γ : Set (Formula n)} {p} : Derives Γ .bot → Derives Γ p + | classical {n} {Γ : Set (Formula n)} {p} : + Derives (insert p.neg Γ) .bot → Derives Γ p + | conjI {n} {Γ : Set (Formula n)} {p q} : + Derives Γ p → Derives Γ q → Derives Γ (.conj p q) + | conjL {n} {Γ : Set (Formula n)} {p q} : + Derives Γ (.conj p q) → Derives Γ p + | conjR {n} {Γ : Set (Formula n)} {p q} : + Derives Γ (.conj p q) → Derives Γ q + | disjL {n} {Γ : Set (Formula n)} {p q} : + Derives Γ p → Derives Γ (.disj p q) + | disjR {n} {Γ : Set (Formula n)} {p q} : + Derives Γ q → Derives Γ (.disj p q) + | disjE {n} {Γ : Set (Formula n)} {p q r} : + Derives Γ (.disj p q) → Derives (insert p Γ) r → + Derives (insert q Γ) r → Derives Γ r + | allI {n} {Γ : Set (Formula n)} {p : Formula (n + 1)} : + Derives (Formula.raise '' Γ) p → Derives Γ (.all p) + | allE {n} {Γ : Set (Formula n)} {p : Formula (n + 1)} (t : Fin n) : + Derives Γ (.all p) → Derives Γ (p.instantiate t) + | exI {n} {Γ : Set (Formula n)} {p : Formula (n + 1)} (t : Fin n) : + Derives Γ (p.instantiate t) → Derives Γ (.ex p) + | exE {n} {Γ : Set (Formula n)} {p : Formula (n + 1)} {q : Formula n} : + Derives Γ (.ex p) → Derives (insert p (Formula.raise '' Γ)) q.raise → + Derives Γ q + | eqRefl {n} {Γ : Set (Formula n)} (t : Fin n) : Derives Γ (.equal t t) + | eqSubst {n} {Γ : Set (Formula n)} {s t : Fin n} (p : Formula (n + 1)) : + Derives Γ (.equal s t) → Derives Γ (p.instantiate s) → + Derives Γ (p.instantiate t) + | rename {n m} {Γ : Set (Formula n)} {p : Formula n} (r : Fin n → Fin m) : + Derives Γ p → Derives (Formula.rename r '' Γ) (Formula.rename r p) + +/-- Sentences are usable as open hypotheses with any finite supply of variables. -/ +def Theory.at (T : Theory) (n : ℕ) : Set (Formula n) := + Formula.rename Fin.elim0 '' T + +/-- Ordinary syntactic consistency: there is no finite natural-deduction proof +of falsity from the theory, with any finite supply of free variables. -/ +def Consistent (T : Theory) : Prop := ∀ n, ¬ Derives (T.at n) .bot + +namespace SetLanguage +open Formula + +/-! All abbreviations in this namespace expand to formulas of the pure language +of equality and membership. Functions are sets of Kuratowski pairs *inside the +structure*. In particular, no quantification over external Lean functions is +used in PP, Choice, or ordinal-indexed Choice. -/ + +/-- `a ⊆ b`. -/ +def subset {n} (a b : Fin n) : Formula n := + rename ![a, b] (Formula.all ((Formula.mem 2 0).imp (Formula.mem 2 1)) : Formula 2) + +/-- `a = ∅`. -/ +def empty {n} (a : Fin n) : Formula n := + rename ![a] (Formula.all (Formula.mem 1 0).neg : Formula 1) + +/-- `a ≠ ∅`, stated as existence of a member. -/ +def nonempty {n} (a : Fin n) : Formula n := + rename ![a] (Formula.ex (Formula.mem 1 0) : Formula 1) + +/-- `p = {x,y}`. -/ +def unorderedPair {n} (p x y : Fin n) : Formula n := + rename ![p, x, y] + (Formula.all ((Formula.mem 3 0).iff ((Formula.equal 3 1).disj (Formula.equal 3 2))) : Formula 3) + +/-- `b = a ∪ {a}`. -/ +def successor {n} (b a : Fin n) : Formula n := + rename ![b, a] + (Formula.all ((Formula.mem 2 0).iff ((Formula.mem 2 1).disj (Formula.equal 2 1))) : Formula 2) + +/-- Kuratowski ordered pair: `p = {{x},{x,y}}`. -/ +def orderedPair {n} (p x y : Fin n) : Formula n := + rename ![p, x, y] + (Formula.ex (Formula.ex ((unorderedPair 3 1 1).conj + ((unorderedPair 4 1 2).conj (unorderedPair 0 3 4)))) : Formula 3) + +/-- The internal graph relation `⟨x,y⟩ ∈ f`. -/ +def edge {n} (f x y : Fin n) : Formula n := + rename ![f, x, y] + (Formula.ex ((Formula.mem 3 0).conj (orderedPair 3 1 2)) : Formula 3) + +/-- `f` is a set graph of a function whose domain is exactly `d`. +The first conjunct excludes non-pairs and graph entries outside the domain; +the second conjunct asserts totality and single-valuedness. -/ +def functionOn {n} (f d : Fin n) : Formula n := + rename ![f, d] + ((Formula.all ((Formula.mem 2 0).imp + (Formula.ex (Formula.ex ((Formula.mem 3 1).conj (orderedPair 2 3 4)))))).conj + (Formula.all ((Formula.mem 2 1).imp + (Formula.ex ((edge 0 2 3).conj (Formula.all ((edge 0 2 4).imp (Formula.equal 4 3))))))) : Formula 2) + +/-- Internal set function `f : d → r`. -/ +def mapsTo {n} (f d r : Fin n) : Formula n := + rename ![f, d, r] + ((functionOn 0 1).conj + (Formula.all (Formula.all ((Formula.mem 3 1).imp ((edge 0 3 4).imp (Formula.mem 4 2))))) : Formula 3) + +/-- Internal set surjection `f : d ↠ r`. -/ +def surjection {n} (f d r : Fin n) : Formula n := + rename ![f, d, r] + ((mapsTo 0 1 2).conj + (Formula.all ((Formula.mem 3 2).imp (Formula.ex ((Formula.mem 4 1).conj (edge 0 4 3))))) : Formula 3) + +/-- Internal set injection `f : d ↪ r`. -/ +def injection {n} (f d r : Fin n) : Formula n := + rename ![f, d, r] + ((mapsTo 0 1 2).conj + (Formula.all (Formula.all (.all + ((Formula.mem 3 1).imp ((Formula.mem 4 1).imp + (((edge 0 3 5).conj (edge 0 4 5)).imp (Formula.equal 3 4))))))) : Formula 3) + +/-- Transitivity of a set (not transitivity of the external structure). -/ +def transitiveSet {n} (a : Fin n) : Formula n := + rename ![a] + (Formula.all (Formula.all ((Formula.mem 1 0).imp ((Formula.mem 2 1).imp (Formula.mem 2 0)))) : Formula 1) + +/-- Membership is an internal strict linear order on `a`. -/ +def membershipLinear {n} (a : Fin n) : Formula n := + rename ![a] + ((Formula.all ((Formula.mem 1 0).imp (Formula.mem 1 1).neg)).conj + ((Formula.all (Formula.all (Formula.all ((Formula.mem 1 0).imp ((Formula.mem 2 0).imp ((Formula.mem 3 0).imp + (((Formula.mem 1 2).conj (Formula.mem 2 3)).imp (Formula.mem 1 3)))))))).conj + (Formula.all (Formula.all ((Formula.mem 1 0).imp ((Formula.mem 2 0).imp + ((Formula.equal 1 2).disj ((Formula.mem 1 2).disj (Formula.mem 2 1)))))))) : Formula 1) + +/-- Every nonempty internal subset of `a` has a membership-minimal element. +This does NOT assert external well-foundedness of the relation. -/ +def membershipWellFounded {n} (a : Fin n) : Formula n := + rename ![a] + (Formula.all (((subset 1 0).conj (nonempty 1)).imp + (Formula.ex ((Formula.mem 2 1).conj (Formula.all ((Formula.mem 3 1).imp (Formula.mem 3 2).neg))))) : Formula 1) + +/-- A von Neumann ordinal: a transitive set internally wellordered by membership. -/ +def ordinal {n} (a : Fin n) : Formula n := + (transitiveSet a).conj ((membershipLinear a).conj (membershipWellFounded a)) + +/-- A choice function on the set `A` of nonempty sets. -/ +def choiceOn {n} (c A : Fin n) : Formula n := + rename ![c, A] + ((functionOn 0 1).conj + (Formula.all ((Formula.mem 2 1).imp (Formula.ex ((edge 0 2 3).conj (Formula.mem 3 2))))) : Formula 2) + +/-- A graph `F` coding a family of nonempty sets indexed by ordinal `η`. -/ +def nonemptyFamily {n} (F η : Fin n) : Formula n := + rename ![F, η] + ((functionOn 0 1).conj + (Formula.all (Formula.all ((Formula.mem 2 1).imp ((edge 0 2 3).imp (nonempty 3))))) : Formula 2) + +/-- `c(ξ) ∈ F(ξ)` for every `ξ ∈ η`, with `c` an internal function. -/ +def choiceForFamily {n} (c η F : Fin n) : Formula n := + rename ![c, η, F] + ((functionOn 0 1).conj + (Formula.all (Formula.all ((Formula.mem 3 1).imp ((edge 2 3 4).imp + (Formula.ex ((edge 0 3 5).conj (Formula.mem 5 4))))))) : Formula 3) + +/-- The Partition Principle. The reverse injection is not required to be a +section of the original surjection. Both `X` and `Y` range over all sets. -/ +def PP : Sentence := + Formula.all (Formula.all ((Formula.ex (surjection 2 0 1)).imp (Formula.ex (injection 2 1 0)))) + +/-- Ordinary Choice for every set of nonempty sets. -/ +def AC : Sentence := + Formula.all ((Formula.all ((Formula.mem 1 0).imp (nonempty 1))).imp (Formula.ex (choiceOn 1 0))) + +/-- Choice for every ordinal-indexed family of nonempty sets, including ordinals +which may fail to be well founded from outside a model. -/ +def ACwo : Sentence := + Formula.all ((ordinal 0).imp + (Formula.all ((nonemptyFamily 1 0).imp (Formula.ex (choiceForFamily 2 0 1))))) + +/-! Full pure-set ZF, not a finite fragment and not ZFA. -/ + +def extensionality : Sentence := + Formula.all (Formula.all ((Formula.all ((Formula.mem 2 0).iff (Formula.mem 2 1))).imp (Formula.equal 0 1))) + +def emptySet : Sentence := Formula.ex (empty 0) + +def pairing : Sentence := Formula.all (Formula.all (Formula.ex (unorderedPair 2 0 1))) + +def union : Sentence := + Formula.all (Formula.ex (Formula.all ((Formula.mem 2 1).iff (Formula.ex ((Formula.mem 3 0).conj (Formula.mem 2 3)))))) + +def powerSet : Sentence := Formula.all (Formula.ex (Formula.all ((Formula.mem 2 1).iff (subset 2 0)))) + +def infinity : Sentence := + Formula.ex ((Formula.ex ((Formula.mem 1 0).conj (empty 1))).conj + (Formula.all ((Formula.mem 1 0).imp (Formula.ex ((Formula.mem 2 0).conj (successor 2 1)))))) + +def foundation : Sentence := + Formula.all ((nonempty 0).imp + (Formula.ex ((Formula.mem 1 0).conj (Formula.all ((Formula.mem 2 1).imp (Formula.mem 2 0).neg))))) + +/-- The instance of Separation for an entirely arbitrary formula `p(params,x)`. +All parameters are universally closed. Neither the quantifier complexity of +`p` nor the number of parameters is bounded. -/ +def separation {n} (p : Formula (n + 1)) : Sentence := + let A : Fin (n + 3) := (Fin.last n).castSucc.castSucc + let B : Fin (n + 3) := (Fin.last (n + 1)).castSucc + let x : Fin (n + 3) := Fin.last (n + 2) + let r : Fin (n + 1) → Fin (n + 3) := + Fin.lastCases x (fun i => i.castSucc.castSucc.castSucc) + close (Formula.all (Formula.ex (Formula.all ((Formula.mem x B).iff ((Formula.mem x A).conj (rename r p)))))) + +/-- Substitution into a binary formula with `n` additional parameters. -/ +def relation {n m} (p : Formula (n + 2)) (params : Fin n → Fin m) (x y : Fin m) : + Formula m := + rename (Fin.lastCases y (Fin.lastCases x params)) p + +/-- The instance of Replacement for an entirely arbitrary formula +`p(params,x,y)`: if it is single-valued and total on `A`, its image is a set. +As with Separation, the parameters are all universally closed. -/ +def replacement {n} (p : Formula (n + 2)) : Sentence := + let unique : Formula (n + 3) := + Formula.all ((relation p (fun i => i.castSucc.castSucc.castSucc.castSucc) + (Fin.last (n + 1)).castSucc.castSucc (Fin.last (n + 3))).imp + (Formula.equal (Fin.last (n + 3)) (Fin.last (n + 2)).castSucc)) + let totalFunctional : Formula (n + 1) := + Formula.all ((Formula.mem (Fin.last (n + 1)) (Fin.last n).castSucc).imp + (Formula.ex ((relation p (fun i => i.castSucc.castSucc.castSucc) + (Fin.last (n + 1)).castSucc (Fin.last (n + 2))).conj unique))) + let image : Formula (n + 1) := + Formula.ex (Formula.all ((Formula.mem (Fin.last (n + 2)) (Fin.last (n + 1)).castSucc).iff + (Formula.ex ((Formula.mem (Fin.last (n + 3)) (Fin.last n).castSucc.castSucc.castSucc).conj + (relation p (fun i => i.castSucc.castSucc.castSucc.castSucc) + (Fin.last (n + 3)) (Fin.last (n + 2)).castSucc))))) + close (Formula.all (totalFunctional.imp image)) + +/-- Exactly the axioms and all schema instances of pure first-order ZF. -/ +inductive IsZFAxiom : Sentence → Prop where + | extensionality : IsZFAxiom extensionality + | emptySet : IsZFAxiom emptySet + | pairing : IsZFAxiom pairing + | union : IsZFAxiom union + | powerSet : IsZFAxiom powerSet + | infinity : IsZFAxiom infinity + | foundation : IsZFAxiom foundation + | separation {n} (p : Formula (n + 1)) : IsZFAxiom (separation p) + | replacement {n} (p : Formula (n + 2)) : IsZFAxiom (replacement p) + +/-- Zermelo–Fraenkel set theory, without Choice. -/ +def ZF : Theory := {p | IsZFAxiom p} + +/-- ZF with the Partition Principle, ordinal-indexed Choice and failure of Choice. -/ +def targetTheory : Theory := ZF ∪ {PP, ACwo, AC.neg} + +end SetLanguage + +/-- Relative consistency of ZF with the Partition Principle, ordinal-indexed +Choice and failure of Choice. -/ +theorem main_consistency : + Consistent SetLanguage.ZF → Consistent SetLanguage.targetTheory := by + sorry + +end PartitionConsistency + +end OAI diff --git a/lean/ComparatorChallenges/PartitionPrinciple.json b/lean/ComparatorChallenges/PartitionPrinciple.json new file mode 100644 index 0000000000000000000000000000000000000000..c280139691ba247c85ac7f2f9d027e6187c974be --- /dev/null +++ b/lean/ComparatorChallenges/PartitionPrinciple.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PartitionPrinciple", + "solution_module": "OAI.SetTheory.PartitionPrinciple.Main", + "theorem_names": [ + "OAI.PartitionPilot.Forcing.TransitiveGround.exists_model_partitionPrinciple_without_choice" + ], + "definition_names": [], + "enable_nanoda": false, + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ] +} diff --git a/lean/ComparatorChallenges/PartitionPrinciple.lean b/lean/ComparatorChallenges/PartitionPrinciple.lean new file mode 100644 index 0000000000000000000000000000000000000000..e551315f882d35ba66f9f24bd67f27ce30cfd2f5 --- /dev/null +++ b/lean/ComparatorChallenges/PartitionPrinciple.lean @@ -0,0 +1,277 @@ +import Mathlib + +namespace OAI + +namespace PartitionPilot.Forcing + +universe u + +inductive SetFormula : Nat → Type + | equal {n} : Fin n → Fin n → SetFormula n + | mem {n} : Fin n → Fin n → SetFormula n + | neg {n} : SetFormula n → SetFormula n + | conj {n} : SetFormula n → SetFormula n → SetFormula n + | all {n} : SetFormula (n + 1) → SetFormula n + +namespace SetFormula + +def extend {A : Type u} {n : Nat} (x : A) (env : Fin n → A) : Fin (n + 1) → A := + Fin.cases x env + +def Realize (U : Set ZFSet.{u}) : {n : Nat} → SetFormula n → (Fin n → ZFSet.{u}) → Prop + | _, .equal i j, env => env i = env j + | _, .mem i j, env => env i ∈ env j + | _, .neg φ, env => ¬ Realize U φ env + | _, .conj φ ψ, env => Realize U φ env ∧ Realize U ψ env + | _, .all φ, env => ∀ x ∈ U, Realize U φ (extend x env) + +def ex {n : Nat} (φ : SetFormula (n + 1)) : SetFormula n := .neg (.all (.neg φ)) + +def disj {n : Nat} (φ ψ : SetFormula n) : SetFormula n := .neg (.conj (.neg φ) (.neg ψ)) + +def imp {n : Nat} (φ ψ : SetFormula n) : SetFormula n := .neg (.conj φ (.neg ψ)) + +end SetFormula + +inductive BoundedFormula : Nat → Type + | equal {n} : Fin n → Fin n → BoundedFormula n + | mem {n} : Fin n → Fin n → BoundedFormula n + | neg {n} : BoundedFormula n → BoundedFormula n + | conj {n} : BoundedFormula n → BoundedFormula n → BoundedFormula n + | allMem {n} : Fin n → BoundedFormula (n + 1) → BoundedFormula n + +namespace BoundedFormula + +open SetFormula + +def imp {n} (φ ψ : BoundedFormula n) : BoundedFormula n := .neg (.conj φ (.neg ψ)) + +def disj {n} (φ ψ : BoundedFormula n) : BoundedFormula n := .neg (.conj (.neg φ) (.neg ψ)) + +def exMem {n} (b : Fin n) (φ : BoundedFormula (n + 1)) : BoundedFormula n := + .neg (.allMem b (.neg φ)) + +def toFormula : {n : Nat} → BoundedFormula n → SetFormula n + | _, .equal i j => .equal i j + | _, .mem i j => .mem i j + | _, .neg φ => .neg φ.toFormula + | _, .conj φ ψ => .conj φ.toFormula ψ.toFormula + | _, .allMem b φ => .all (SetFormula.imp (.mem 0 b.succ) φ.toFormula) + +def singletonFormula {n} (z x : Fin n) : BoundedFormula n := + .conj (.mem x z) (.allMem z (.equal 0 x.succ)) + +def unorderedPairFormula {n} (z x y : Fin n) : BoundedFormula n := + .conj (.mem x z) (.conj (.mem y z) (.allMem z (disj (.equal 0 x.succ) (.equal 0 y.succ)))) + +def orderedPairFormula {n} (z x y : Fin n) : BoundedFormula n := + exMem z (.conj (singletonFormula 0 x.succ) + (exMem z.succ (.conj (unorderedPairFormula 0 x.succ.succ y.succ.succ) + (unorderedPairFormula z.succ.succ 1 0)))) + +def pairMembershipFormula {n} (x y r : Fin n) : BoundedFormula n := + exMem r (orderedPairFormula 0 x.succ y.succ) + +def relationBetweenFormula {n} (a b f : Fin n) : BoundedFormula n := + .allMem f (exMem a.succ (exMem b.succ.succ (orderedPairFormula 2 1 0))) + +def functionFormula {n} (a b f : Fin n) : BoundedFormula n := + .conj (relationBetweenFormula a b f) + (.allMem a (exMem b.succ (.conj (pairMembershipFormula 1 0 f.succ.succ) + (.allMem b.succ.succ (imp (pairMembershipFormula 2 0 f.succ.succ.succ) (.equal 0 1)))))) + +def nonemptyFormula {n} (x : Fin n) : BoundedFormula n := exMem x (.equal 0 0) + +def choiceFunctionFormula {n} (a f : Fin n) : BoundedFormula n := + .conj (.allMem f (exMem a.succ (exMem 0 (orderedPairFormula 2 1 0)))) + (.allMem a (exMem 0 (.conj (pairMembershipFormula 1 0 f.succ.succ) + (.allMem 1 (imp (pairMembershipFormula 2 0 f.succ.succ.succ) (.equal 0 1)))))) + +end BoundedFormula + +structure TransitiveGround where + sets : Set ZFSet.{u} + transitive : ∀ {x y}, x ∈ sets → y ∈ x → y ∈ sets + +structure InjectionCode (D N f : ZFSet.{u}) : Prop where + function : ZFSet.IsFunc D N f + injective : ∀ x y z, ZFSet.pair x z ∈ f → ZFSet.pair y z ∈ f → x = y + +namespace TransitiveGround + +open SetFormula + +variable (M : TransitiveGround.{u}) + +def groundEmbeddable (D N : ZFSet.{u}) : Prop := ∃ f ∈ M.sets, InjectionCode D N f + +end TransitiveGround + +def setTransitive (x : ZFSet.{u}) : Prop := ∀ y ∈ x, ∀ z ∈ y, z ∈ x + +def ordinalSetProperty (x : ZFSet.{u}) : Prop := + setTransitive x ∧ ∀ y ∈ x, setTransitive y + +namespace TransitiveGround + +open SetFormula + +variable (M : TransitiveGround.{u}) + +noncomputable def groundPower (B : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun p => p ∈ M.sets) (ZFSet.powerset B) + +end TransitiveGround + +def GroundBelow (M : TransitiveGround.{u}) (A K : ZFSet.{u}) : Prop := + ∃ β ∈ K, M.groundEmbeddable A β + +def GroundCardinal (M : TransitiveGround.{u}) (κ : ZFSet.{u}) : Prop := + ordinalSetProperty κ ∧ ∀ β ∈ κ, ¬ M.groundEmbeddable κ β + +def CofinalFunctionCode (α K f : ZFSet.{u}) : Prop := + ZFSet.IsFunc α K f ∧ ∀ β ∈ K, ∃ x ∈ α, ∃ y ∈ K, + ZFSet.pair x y ∈ f ∧ (β = y ∨ β ∈ y) + +def GroundCofinalRegular (M : TransitiveGround.{u}) (K : ZFSet.{u}) : Prop := + ∀ α ∈ K, ∀ f ∈ M.sets, ¬ CofinalFunctionCode α K f + +def GroundCardinalStrongLimit (M : TransitiveGround.{u}) (K : ZFSet.{u}) : Prop := + ∀ κ ∈ K, GroundCardinal M κ → GroundBelow M (M.groundPower κ) K + +def GroundStandardInaccessible (M : TransitiveGround.{u}) (K : ZFSet.{u}) : Prop := + GroundCardinal M K ∧ ¬ M.groundEmbeddable K ZFSet.omega ∧ + GroundCofinalRegular M K ∧ GroundCardinalStrongLimit M K + +namespace SetFormula + +def extensionality : SetFormula 0 := + .all (.all (imp + (.all (.conj (imp (.mem 0 2) (.mem 0 1)) (imp (.mem 0 1) (.mem 0 2)))) + (.equal 1 0))) + +def foundation : SetFormula 0 := + .all (imp (ex (.mem 0 1)) + (ex (.conj (.mem 0 1) (.all (.neg (.conj (.mem 0 2) (.mem 0 1))))))) + +def emptySet : SetFormula 0 := ex (.all (.neg (.mem 0 1))) + +def pairing : SetFormula 0 := + .all (.all (ex (.all (.conj + (imp (.mem 0 1) (disj (.equal 0 3) (.equal 0 2))) + (imp (disj (.equal 0 3) (.equal 0 2)) (.mem 0 1)))))) + +def union : SetFormula 0 := + .all (ex (.all (.conj + (imp (.mem 0 1) (ex (.conj (.mem 0 3) (.mem 1 0)))) + (imp (ex (.conj (.mem 0 3) (.mem 1 0))) (.mem 0 1))))) + +def powerSet : SetFormula 0 := + .all (ex (.all (.conj + (imp (.mem 0 1) (.all (imp (.mem 0 1) (.mem 0 3)))) + (imp (.all (imp (.mem 0 1) (.mem 0 3))) (.mem 0 1))))) + +def SeparationSchema (U : Set ZFSet.{u}) : Prop := + ∀ {n} (φ : SetFormula (n + 1)) (params : Fin n → ZFSet.{u}), + (∀ i, params i ∈ U) → ∀ x ∈ U, ∃ y ∈ U, + ∀ z ∈ U, z ∈ y ↔ z ∈ x ∧ Realize U φ (extend z params) + +def CollectionSchema (U : Set ZFSet.{u}) : Prop := + ∀ {n} (φ : SetFormula (n + 2)) (params : Fin n → ZFSet.{u}), + (∀ i, params i ∈ U) → ∀ a ∈ U, + (∀ x ∈ U, x ∈ a → ∃ y ∈ U, Realize U φ (extend x (extend y params))) → + ∃ b ∈ U, ∀ x ∈ U, x ∈ a → + ∃ y ∈ U, y ∈ b ∧ Realize U φ (extend x (extend y params)) + +def emptySetFormula {n : Nat} (x : Fin n) : SetFormula n := .all (.neg (.mem 0 x.succ)) + +def successorFormula {n : Nat} (y x : Fin n) : SetFormula n := + .all (.conj (imp (.mem 0 y.succ) (disj (.equal 0 x.succ) (.mem 0 x.succ))) + (imp (disj (.equal 0 x.succ) (.mem 0 x.succ)) (.mem 0 y.succ))) + +def infinity : SetFormula 0 := + ex (.conj (ex (.conj (.mem 0 1) (emptySetFormula 0))) + (.all (imp (.mem 0 1) (ex (.conj (.mem 0 2) (successorFormula 0 1)))))) + +def choice : SetFormula 0 := + .all (imp (BoundedFormula.allMem 0 (BoundedFormula.nonemptyFormula 0)).toFormula + (ex (BoundedFormula.choiceFunctionFormula 1 0).toFormula)) + +def ReplacementSchema (U : Set ZFSet.{u}) : Prop := + ∀ {n} (φ : SetFormula (n + 2)) (params : Fin n → ZFSet.{u}), + (∀ i, params i ∈ U) → ∀ A ∈ U, + (∀ x ∈ U, x ∈ A → ∃ y ∈ U, Realize U φ (extend x (extend y params)) ∧ + ∀ z ∈ U, Realize U φ (extend x (extend z params)) → z = y) → + ∃ B ∈ U, ∀ y ∈ U, y ∈ B ↔ ∃ x ∈ U, x ∈ A ∧ Realize U φ (extend x (extend y params)) + +def finiteZFAxioms : SetFormula 0 := + .conj extensionality (.conj foundation (.conj emptySet + (.conj pairing (.conj SetFormula.union (.conj powerSet infinity))))) + +def ZFRealization (U : Set ZFSet.{u}) : Prop := + Realize U finiteZFAxioms Fin.elim0 ∧ SeparationSchema U ∧ ReplacementSchema U + +end SetFormula + +namespace BoundedFormula + +open SetFormula + +def injectionFormula {n} (d c f : Fin n) : BoundedFormula n := + .conj (functionFormula d c f) (.allMem d (.allMem d.succ (.allMem c.succ.succ + (imp (.conj (pairMembershipFormula 2 0 f.succ.succ.succ) + (pairMembershipFormula 1 0 f.succ.succ.succ)) (.equal 2 1))))) + +end BoundedFormula + +namespace SetFormula + +def hasInjectionFormula {n} (d c : Fin n) : SetFormula n := + ex (BoundedFormula.injectionFormula d.succ c.succ 0).toFormula + +end SetFormula + +namespace BoundedFormula + +open SetFormula + +def surjectionFormula {n : Nat} (a b f : Fin n) : BoundedFormula n := + .conj (functionFormula a b f) + (.allMem b (exMem a.succ (pairMembershipFormula 0 1 f.succ.succ))) + +end BoundedFormula + +namespace SetFormula + +def partitionPrinciple : SetFormula 0 := + .all (.all (.all (imp (BoundedFormula.surjectionFormula (n := 3) 2 1 0).toFormula + (hasInjectionFormula (n := 3) 1 2)))) + +end SetFormula + +end PartitionPilot.Forcing + +namespace PartitionPilot.Forcing.TransitiveGround + +open SetFormula + +universe u + +variable (M : TransitiveGround.{u}) + +theorem exists_model_partitionPrinciple_without_choice + (pairing : Realize M.sets SetFormula.pairing Fin.elim0) + (unions : Realize M.sets SetFormula.union Fin.elim0) + (powers : Realize M.sets powerSet Fin.elim0) (separation : SeparationSchema M.sets) + (collection : CollectionSchema M.sets) (infinite : Realize M.sets infinity Fin.elim0) + (choice : Realize M.sets SetFormula.choice Fin.elim0) + (small : M.sets.Countable) + {K : ZFSet.{u}} (hK : K ∈ M.sets) (standard : GroundStandardInaccessible M K) : + ∃ N : TransitiveGround.{u}, M.sets ⊆ N.sets ∧ ZFRealization N.sets ∧ + Realize N.sets partitionPrinciple Fin.elim0 ∧ + ¬ Realize N.sets SetFormula.choice Fin.elim0 := by + sorry + +end PartitionPilot.Forcing.TransitiveGround + +end OAI diff --git a/lean/ComparatorChallenges/PattersonFirstMoment.json b/lean/ComparatorChallenges/PattersonFirstMoment.json new file mode 100644 index 0000000000000000000000000000000000000000..56b93df0b9fa46cea32eff3776124addbce4d87c --- /dev/null +++ b/lean/ComparatorChallenges/PattersonFirstMoment.json @@ -0,0 +1,16 @@ +{ + "challenge_module": "ComparatorChallenges.PattersonFirstMoment", + "solution_module": "OAI.NumberTheory.CubicMoment.Theta.CubicThetaMains", + "theorem_names": [ + "OAI.CubicFirstMoment.patterson_firstMoment", + "OAI.CubicFirstMoment.patterson_angularComparison", + "OAI.CubicFirstMoment.patterson_angularCancellation" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PattersonFirstMoment.lean b/lean/ComparatorChallenges/PattersonFirstMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ff9710eda593d43ff80dce2ab69ec254d015832 --- /dev/null +++ b/lean/ComparatorChallenges/PattersonFirstMoment.lean @@ -0,0 +1,99 @@ +import Mathlib + +namespace OAI + +/-! Primary Eisenstein elements, residue characters, Gauss sums and first-moment target definitions. -/ + +section + +noncomputable section +open scoped BigOperators +open Module +attribute [local instance] Classical.propDecidable + +namespace CubicFirstMoment + +def omega : ℂ := Complex.exp (2 * (Real.pi : ℂ) * Complex.I / 3) + +def eisensteinRing : Subalgebra ℤ ℂ := Algebra.adjoin ℤ {omega} +abbrev Eisenstein := eisensteinRing + +def omegaE : Eisenstein := + ⟨omega, Algebra.subset_adjoin (Set.mem_singleton omega)⟩ + +def norm (a : Eisenstein) : ℝ := Complex.normSq (a : ℂ) + +def normNat (a : Eisenstein) : ℕ := ⌊norm a⌋₊ + +def primary (a : Eisenstein) : Prop := (3 : Eisenstein) ∣ a - 1 + +def primaryPrime (a : Eisenstein) : Prop := primary a ∧ Prime a + +def modulus (a : Eisenstein) : Ideal Eisenstein := Ideal.span {a} + +abbrev Residues (a : Eisenstein) := Eisenstein ⧸ modulus a + +def residueRepresentative (a : Eisenstein) (v : Residues a) : Eisenstein := + Classical.choose (Ideal.Quotient.mk_surjective v) + +def cubicSymbolAtPrime (p v : Eisenstein) : ℂ := + if IsUnit (Ideal.Quotient.mk (modulus p) v) then + if h : ∃ j : Fin 3, + Ideal.Quotient.mk (modulus p) (v ^ ((normNat p - 1) / 3)) = + Ideal.Quotient.mk (modulus p) (omegaE ^ (j : ℕ)) then + omega ^ ((Classical.choose h : Fin 3) : ℕ) + else 0 + else 0 + +def additivePhase (p v : Eisenstein) : ℂ := + let z : ℂ := (v : ℂ) / (p : ℂ) + Complex.exp (2 * (Real.pi : ℂ) * Complex.I * (z + star z)) + +def gaussAtPrime (p : Eisenstein) : ℂ := + (Real.sqrt (norm p) : ℂ)⁻¹ * + ∑' v : Residues p, + cubicSymbolAtPrime p (residueRepresentative p v) * + additivePhase p (residueRepresentative p v) + +def cStar : ℝ := (2 * Real.pi) ^ (2 / 3 : ℝ) / (3 * Real.Gamma (2 / 3)) + +def primeCutoffSum (f : Eisenstein → ℂ) (X : ℝ) : ℂ := + ∑' p : Eisenstein, if primaryPrime p ∧ norm p ≤ X then f p else 0 + +def firstMomentScale (X : ℝ) : ℝ := X ^ (5 / 6 : ℝ) / Real.log X + +def FirstMomentStatement : Prop := + Asymptotics.IsLittleO Filter.atTop + (fun X : ℝ => primeCutoffSum gaussAtPrime X - + (((6 / 5 : ℝ) * cStar * firstMomentScale X : ℝ) : ℂ)) + firstMomentScale + +def theta (ℓ : ℤ) (a : Eisenstein) : ℂ := ((a : ℂ) / (‖(a : ℂ)‖ : ℂ)) ^ ℓ + +def AngularComparisonStatement : Prop := + ∀ ℓ : ℤ, Asymptotics.IsLittleO Filter.atTop + (primeCutoffSum (fun p => theta ℓ p * + (gaussAtPrime p - ((cStar * norm p ^ (-1 / 6 : ℝ) : ℝ) : ℂ)))) + firstMomentScale + +def AngularCancellationStatement : Prop := + ∀ ℓ : ℤ, ℓ ≠ 0 → Asymptotics.IsLittleO Filter.atTop + (primeCutoffSum (fun p => theta ℓ p * gaussAtPrime p)) firstMomentScale + +/-- The sharp first moment over all primary Eisenstein primes. -/ +theorem patterson_firstMoment : FirstMomentStatement := by + sorry + +/-- Model comparison in every fixed integer angular mode. -/ +theorem patterson_angularComparison : AngularComparisonStatement := by + sorry + +/-- Cancellation at the first-moment scale for each nonzero angular mode. -/ +theorem patterson_angularCancellation : AngularCancellationStatement := by + sorry + +end CubicFirstMoment +end +end + +end OAI diff --git a/lean/ComparatorChallenges/PerceptronFreeEnergy.json b/lean/ComparatorChallenges/PerceptronFreeEnergy.json new file mode 100644 index 0000000000000000000000000000000000000000..c25886ed2ea74a10813757dc99d38f03cc8a301d --- /dev/null +++ b/lean/ComparatorChallenges/PerceptronFreeEnergy.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PerceptronFreeEnergy", + "solution_module": "OAI.Probability.Perceptron.Main", + "theorem_names": [ + "OAI.SphericalPerceptronFreeEnergy.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PerceptronFreeEnergy.lean b/lean/ComparatorChallenges/PerceptronFreeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..408c1b65ee5ce32896101e6892cfae34b0e50596 --- /dev/null +++ b/lean/ComparatorChallenges/PerceptronFreeEnergy.lean @@ -0,0 +1,111 @@ +import Mathlib + +namespace OAI + +noncomputable section +open MeasureTheory ProbabilityTheory Filter Set +open scoped ENNReal NNReal Topology BigOperators BoundedContinuousFunction + +namespace SphericalPerceptronFreeEnergy + +abbrev Time := unitInterval +abbrev BrownianPath := C(ℝ≥0, ℝ) + +instance : MeasurableSpace BrownianPath := borel BrownianPath +instance : BorelSpace BrownianPath := ⟨rfl⟩ + +abbrev Spin (N : ℕ) := EuclideanSpace ℝ (Fin N) + +def patternCount (α : ℝ) (N : ℕ) : ℕ := ⌊α * (N : ℝ)⌋₊ +abbrev Patterns (α : ℝ) (N : ℕ) := Fin (patternCount α N) → Fin N → ℝ + +def patternLaw (α : ℝ) (N : ℕ) : Measure (Patterns α N) := + Measure.pi fun _ => Measure.pi fun _ => gaussianReal 0 1 + +def unitSphereLaw (N : ℕ) : Measure (Metric.sphere (0 : Spin N) 1) := + let s := (volume : Measure (Spin N)).toSphere + (s Set.univ)⁻¹ • s + +def sphereLaw (N : ℕ) : Measure (Spin N) := + (unitSphereLaw N).map fun x => Real.sqrt (N : ℝ) • x.val + +def patternField {α : ℝ} {N : ℕ} (g : Patterns α N) + (a : Fin (patternCount α N)) (x : Spin N) : ℝ := + (∑ i : Fin N, g a i * x i) / Real.sqrt (N : ℝ) + +def hamiltonian (α : ℝ) (φ : ℝ →ᵇ ℝ) (N : ℕ) (g : Patterns α N) + (x : Spin N) : ℝ := + ∑ a : Fin (patternCount α N), φ (patternField g a x) + +def pressure (α β : ℝ) (φ : ℝ →ᵇ ℝ) (N : ℕ) (g : Patterns α N) : ℝ := + Real.log (∫ x, Real.exp (β * hamiltonian α φ N g x) ∂sphereLaw N) / (N : ℝ) + +def expectedPressure (α β : ℝ) (φ : ℝ →ᵇ ℝ) (N : ℕ) : ℝ := + ∫ g, pressure α β φ N g ∂patternLaw α N + +structure Trial where + toFun : Time → ℝ + monotone : Monotone toFun + measurable : Measurable toFun + nonneg : ∀ t, 0 ≤ toFun t + le_one : ∀ t, toFun t ≤ 1 + +instance : CoeFun Trial (fun _ => Time → ℝ) := ⟨Trial.toFun⟩ + +def timeLaw : Measure Time := Measure.comap Subtype.val volume + +def tailIntegral (m : Trial) (t : Time) : ℝ := + ∫ s in Set.Ici t, m s ∂timeLaw + +def entropy (m : Trial) : ℝ≥0∞ := + (∫⁻ t, (ENNReal.ofReal (tailIntegral m t))⁻¹ - + (ENNReal.ofReal (1 - (t : ℝ)))⁻¹ ∂timeLaw) / 2 + +def brownianEval (t : ℝ≥0) (ω : BrownianPath) : ℝ := ω t + +@[instance_reducible] def nullSigma (P : Measure BrownianPath) : MeasurableSpace BrownianPath := + MeasurableSpace.generateFrom {s | P s = 0} + +@[instance_reducible] def usualBrownianSigma (P : Measure BrownianPath) (t : Time) : + MeasurableSpace BrownianPath := + ⨅ s : {s : ℝ≥0 // (t : ℝ) < s}, + (⨆ r : {r : ℝ≥0 // r ≤ s.val}, + MeasurableSpace.comap (brownianEval r.val) (borel ℝ)) ⊔ nullSigma P + +def Progressive (P : Measure BrownianPath) (v : Time → BrownianPath → ℝ) : Prop := + ∀ t : Time, + @Measurable (Set.Iic t × BrownianPath) ℝ + (MeasurableSpace.prod inferInstance (usualBrownianSigma P t)) (borel ℝ) + (fun p => v p.1.val p.2) + +def controlCost (P : Measure BrownianPath) (m : Trial) + (v : Time → BrownianPath → ℝ) : ℝ≥0∞ := + ∫⁻ ω, ∫⁻ t, ENNReal.ofReal (m t * v t ω ^ 2) ∂timeLaw ∂P + +def controlPayoff (P : Measure BrownianPath) (f : ℝ →ᵇ ℝ) (m : Trial) + (v : Time → BrownianPath → ℝ) : ℝ := + (∫ ω, f (brownianEval 1 ω + ∫ t, m t * v t ω ∂timeLaw) ∂P) - + (controlCost P m v).toReal / 2 + +def controlValue (P : Measure BrownianPath) (f : ℝ →ᵇ ℝ) (m : Trial) : ℝ := + sSup {a | ∃ v : Time → BrownianPath → ℝ, + Progressive P v ∧ controlCost P m v < ∞ ∧ a = controlPayoff P f m v} + +def variationalValue (P : Measure BrownianPath) (α β : ℝ) (φ : ℝ →ᵇ ℝ) : EReal := + ⨅ m : Trial, ((α * controlValue P (β • φ) m : ℝ) : EReal) + (entropy m).toEReal + +theorem main (P : Measure BrownianPath) [IsProbabilityMeasure P] + (hB : IsBrownianReal brownianEval P) + (α β : ℝ) (hα : 0 < α) (hβ : 0 < β) (φ : ℝ →ᵇ ℝ) : + ∃ p : ℝ, variationalValue P α β φ = (p : EReal) ∧ + Tendsto (fun N : ℕ => expectedPressure α β φ (N + 1)) atTop (𝓝 p) ∧ + ∀ ε : ℝ, 0 < ε → + Tendsto (fun N : ℕ => patternLaw α (N + 1) + {g | ε < |pressure α β φ (N + 1) g - p|}) atTop (𝓝 0) := by + sorry + +end SphericalPerceptronFreeEnergy + +end + +end OAI diff --git a/lean/ComparatorChallenges/PerfectCompleteness.json b/lean/ComparatorChallenges/PerfectCompleteness.json new file mode 100644 index 0000000000000000000000000000000000000000..c8a63fa00611be828228a68dc728f703cca66754 --- /dev/null +++ b/lean/ComparatorChallenges/PerfectCompleteness.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PerfectCompleteness", + "solution_module": "OAI.Computability.PerfectCompleteness.Main", + "theorem_names": [ + "OAI.PerfectCompleteness.Theorem11.exists_reduction" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PerfectCompleteness.lean b/lean/ComparatorChallenges/PerfectCompleteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6ce53557019808040aaee908d802fbeeb63b166 --- /dev/null +++ b/lean/ComparatorChallenges/PerfectCompleteness.lean @@ -0,0 +1,185 @@ +import Mathlib + +namespace OAI + +namespace UniqueGamesTheorem.Foundations.Complexity + +def encodeWord (n : Nat) : List Bool := List.replicate n true ++ [false] + +def encodeWords : List Nat → List Bool + | [] => [] + | n :: ns => encodeWord n ++ encodeWords ns + +end UniqueGamesTheorem.Foundations.Complexity + +namespace UniqueGamesTheorem.Foundations.Complexity.MachineFiniteAlphabet + +open Turing + +def FiniteAlphabet (M : FinTM2) : Prop := ∀ k, Finite (M.Γ k) + +end UniqueGamesTheorem.Foundations.Complexity.MachineFiniteAlphabet + +namespace PerfectCompleteness.BinaryFormula + +structure Literal where + name : Nat + positive : Bool + deriving DecidableEq + +def Literal.eval (literal : Literal) (assignment : Nat → Bool) : Bool := + if literal.positive then assignment literal.name else !(assignment literal.name) + +abbrev Clause := Vector Literal 3 + +def Clause.eval (clause : Clause) (assignment : Nat → Bool) : Bool := + (clause[0].eval assignment || clause[1].eval assignment) || clause[2].eval assignment + +structure Formula where + clauses : List Clause + +def Formula.Satisfiable (F : Formula) : Prop := + ∃ assignment : Nat → Bool, ∀ clause ∈ F.clauses, clause.eval assignment = true + +end PerfectCompleteness.BinaryFormula + +namespace PerfectCompleteness.BinaryEncoding + +open PerfectCompleteness.BinaryFormula + +def bitsValue : List Bool → Nat + | [] => 0 + | b :: bits => Nat.bit b (bitsValue bits) + +def parseFrame : List Bool → Option (List Bool × List Bool) + | false :: rest => some ([], rest) + | true :: b :: rest => do + let (bits, trailing) ← parseFrame rest + return (b :: bits, trailing) + | _ => none + +def parseName (input : List Bool) : Option (Nat × List Bool) := do + let (digits, rest) ← parseFrame input + let name := bitsValue digits + if digits = name.bits then some (name, rest) else none + +def parseLiteral : List Bool → Option (Literal × List Bool) + | sign :: input => do + let (name, rest) ← parseName input + return (⟨name, sign⟩, rest) + | [] => none + +def parseClause (input : List Bool) : Option (Clause × List Bool) := do + let (a, input) ← parseLiteral input + let (b, input) ← parseLiteral input + let (c, rest) ← parseLiteral input + return (#v[a, b, c], rest) + +def parseClauses : Nat → List Bool → Option (List Clause × List Bool) + | 0, _ => none + | _ + 1, false :: rest => some ([], rest) + | fuel + 1, true :: input => do + let (clause, input) ← parseClause input + let (clauses, rest) ← parseClauses fuel input + return (clause :: clauses, rest) + | _ + 1, [] => none + +def decodeFormula (input : List Bool) : Option Formula := do + let (clauses, rest) ← parseClauses (input.length + 1) input + if rest = [] then some ⟨clauses⟩ else none + +end PerfectCompleteness.BinaryEncoding + +namespace PerfectCompleteness.BinaryLanguage + +def language (input : List Bool) : Prop := + ∃ formula, BinaryEncoding.decodeFormula input = some formula ∧ formula.Satisfiable + +end PerfectCompleteness.BinaryLanguage + +namespace PerfectCompleteness + +structure ProjectionTable (q : Nat) where + images : Vector (Fin q) (2 * q) + exactlyTwo : ∀ b : Fin q, + ((List.finRange (2 * q)).filter (fun a => decide (images[a] = b))).length = 2 + +structure Edge (leftVertices rightVertices q : Nat) where + left : Fin leftVertices + right : Fin rightVertices + projection : ProjectionTable q + +structure Instance (q : Nat) where + leftVertices : Nat + rightVertices : Nat + edges : List (Edge leftVertices rightVertices q) + nonempty : edges ≠ [] + +abbrev Labeling {q : Nat} (G : Instance q) := + (Fin G.leftVertices → Fin (2 * q)) × (Fin G.rightVertices → Fin q) + +def Edge.satisfied {l r q : Nat} (e : Edge l r q) + (a : Fin l → Fin (2 * q)) (b : Fin r → Fin q) : Bool := + decide (e.projection.images[a e.left] = b e.right) + +def countSatisfied {l r q : Nat} (a : Fin l → Fin (2 * q)) + (b : Fin r → Fin q) : List (Edge l r q) → Nat + | [] => 0 + | e :: es => (if e.satisfied a b then 1 else 0) + countSatisfied a b es + +end PerfectCompleteness + +namespace PerfectCompleteness.Instance + +def maxSatisfied {q : Nat} (G : Instance q) : Nat := + Finset.univ.sup (fun s : Labeling G => countSatisfied s.1 s.2 G.edges) + +noncomputable def value {q : Nat} (G : Instance q) : ℝ := + (G.maxSatisfied : ℝ) / G.edges.length + +end PerfectCompleteness.Instance + +namespace PerfectCompleteness.Encoding + +open UniqueGamesTheorem.Foundations.Complexity + +def tableWords {q : Nat} (table : ProjectionTable q) : List Nat := + table.images.toList.map Fin.val + +def edgeWords {l r q : Nat} (edge : Edge l r q) : List Nat := + [edge.left.val, edge.right.val] ++ tableWords edge.projection + +def gameWords {q : Nat} (game : Instance q) : List Nat := + [game.leftVertices, game.rightVertices, q, game.edges.length] ++ + game.edges.flatMap edgeWords + +def gameBits {q : Nat} (game : Instance q) : List Bool := + encodeWords (gameWords game) + +end PerfectCompleteness.Encoding + +namespace PerfectCompleteness + +open Turing UniqueGamesTheorem.Foundations.Complexity + +structure BinaryGapReduction (δ : ℚ) where + alphabet : Nat + alphabet_ge_two : 2 ≤ alphabet + construct : List Bool → Instance alphabet + computation : TM2ComputableInPolyTime (id : List Bool → List Bool) + Encoding.gameBits construct + finiteAlphabet : MachineFiniteAlphabet.FiniteAlphabet computation.tm + completeness : ∀ input, BinaryLanguage.language input → (construct input).value = 1 + soundness : ∀ input, ¬BinaryLanguage.language input → (construct input).value ≤ (δ : ℝ) + +end PerfectCompleteness + +namespace PerfectCompleteness.Theorem11 + +theorem exists_reduction (δ : ℚ) (positive : 0 < δ) (less_than_one : δ < 1) : + Nonempty (PerfectCompleteness.BinaryGapReduction δ) := by + sorry + +end PerfectCompleteness.Theorem11 + +end OAI diff --git a/lean/ComparatorChallenges/PeriodicGroup.json b/lean/ComparatorChallenges/PeriodicGroup.json new file mode 100644 index 0000000000000000000000000000000000000000..1dcbfe6db0fdcb67a65181b5b0f143f3fc8174e6 --- /dev/null +++ b/lean/ComparatorChallenges/PeriodicGroup.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PeriodicGroup", + "solution_module": "OAI.GroupTheory.PeriodicGroups.Main", + "theorem_names": [ + "OAI.SourceBurnside.thm_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PeriodicGroup.lean b/lean/ComparatorChallenges/PeriodicGroup.lean new file mode 100644 index 0000000000000000000000000000000000000000..7656ab1dcbfc8aefbd95c1c68a2d9a97f8f58fd9 --- /dev/null +++ b/lean/ComparatorChallenges/PeriodicGroup.lean @@ -0,0 +1,56 @@ +import Mathlib + +namespace OAI + +universe u + +namespace SourceBurnside + +structure Root (n : ℕ) where + row : Fin n + col : Fin n + ne : row ≠ col + deriving DecidableEq + +abbrev Generator (n : ℕ) (R : Type u) := Root n × R + +def bracket {G : Type u} [Group G] (x y : G) : G := x * y * x⁻¹ * y⁻¹ + +def letter {n : ℕ} {R : Type u} (p : Root n) (a : R) : + FreeGroup (Generator n R) := FreeGroup.of (p, a) + +inductive SteinbergRel (n : ℕ) (R : Type u) [Ring R] : + FreeGroup (Generator n R) → Prop + | add (p : Root n) (a b : R) : + SteinbergRel n R (letter p (a + b) * (letter p a * letter p b)⁻¹) + | commute (p q : Root n) (h₁ : p.col ≠ q.row) (h₂ : p.row ≠ q.col) (a b : R) : + SteinbergRel n R (bracket (letter p a) (letter q b)) + | mul (i j k : Fin n) (hij : i ≠ j) (hjk : j ≠ k) (hik : i ≠ k) (a b : R) : + SteinbergRel n R + (bracket (letter ⟨i, j, hij⟩ a) (letter ⟨j, k, hjk⟩ b) * + (letter ⟨i, k, hik⟩ (a * b))⁻¹) + +def Steinberg (n : ℕ) (R : Type u) [Ring R] := + PresentedGroup {r | SteinbergRel n R r} + deriving Group + +def Periodic (G : Type u) [Group G] : Prop := ∀ g : G, ∃ m : ℕ, 0 < m ∧ g ^ m = 1 + +def MainStatement : Prop := + ∃ (R : Type) (_ : Ring R) (_ : Algebra (ZMod 2) R), + Infinite (Steinberg 12 R) ∧ Group.IsFinitelyPresented (Steinberg 12 R) ∧ + Periodic (Steinberg 12 R) + +def BurnsideStatement : Prop := + ∃ (G : Type) (_ : Group G), Infinite G ∧ Group.IsFinitelyPresented G ∧ Periodic G + +end SourceBurnside + +namespace SourceBurnside + +theorem thm_main : MainStatement ∧ BurnsideStatement := by + sorry + +end SourceBurnside + +end OAI diff --git a/lean/ComparatorChallenges/PeriodicTilingThree.json b/lean/ComparatorChallenges/PeriodicTilingThree.json new file mode 100644 index 0000000000000000000000000000000000000000..493068b9b0425bd3a2852ce3e0ce2c0c98acc189 --- /dev/null +++ b/lean/ComparatorChallenges/PeriodicTilingThree.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PeriodicTilingThree", + "solution_module": "OAI.Geometry.PeriodicTiling.Main", + "theorem_names": [ + "OAI.PeriodicTilingThree.periodic_tiling_counterexample_and_minimality" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PeriodicTilingThree.lean b/lean/ComparatorChallenges/PeriodicTilingThree.lean new file mode 100644 index 0000000000000000000000000000000000000000..9eb75b99b57afe0f7a9e24035095d9c9015acb52 --- /dev/null +++ b/lean/ComparatorChallenges/PeriodicTilingThree.lean @@ -0,0 +1,66 @@ +import Mathlib + +namespace OAI + +noncomputable section + +universe u + +namespace PeriodicTilingThree + +abbrev Lattice (d : ℕ) := Fin d → ℤ + +variable {G : Type u} [AddCommGroup G] + +def Tiles (F : Finset G) (A : Set G) : Prop := + Function.Bijective (fun p : ↥F × A => (p.1 : G) + (p.2 : G)) + +def Period (A : Set G) (v : G) : Prop := + ∀ x : G, x + v ∈ A ↔ x ∈ A + +def FullyPeriodic (A : Set G) : Prop := + ∃ P : AddSubgroup G, P.FiniteIndex ∧ ∀ v ∈ P, Period A v + +open MeasureTheory + +abbrev Space (d : ℕ) := Fin d → ℝ + +def castLattice {d : ℕ} : Lattice d →+ Space d where + toFun z i := (z i : ℝ) + map_zero' := by ext i; simp + map_add' z w := by ext i; simp + +def unitCube (d : ℕ) : Set (Space d) := Set.Icc 0 1 + +def Thickening {d : ℕ} (F : Finset (Lattice d)) : Set (Space d) := + {x | ∃ z ∈ F, x - castLattice z ∈ unitCube d} + +def AETiles {d : ℕ} (Ω A : Set (Space d)) : Prop := + ∀ᵐ x ∂volume, ∃! a : A, x - (a : Space d) ∈ Ω + +def latticeOfBasis {d : ℕ} (b : Module.Basis (Fin d) ℝ (Space d)) : + AddSubgroup (Space d) := (Submodule.span ℤ (Set.range b)).toAddSubgroup + +def EuclideanFullyPeriodic {d : ℕ} (A : Set (Space d)) : Prop := + ∃ b : Module.Basis (Fin d) ℝ (Space d), ∀ v ∈ latticeOfBasis b, Period A v + +def HasTileWithoutPeriodicComplement (d : ℕ) : Prop := + ∃ T : Finset (Lattice d), T.Nonempty ∧ + (∃ A : Set (Lattice d), Tiles T A) ∧ + ∀ A : Set (Lattice d), Tiles T A → ¬ FullyPeriodic A + +theorem periodic_tiling_counterexample_and_minimality : + (∃ T : Finset (Lattice 3), T.Nonempty ∧ + (∃ A : Set (Lattice 3), Tiles T A) ∧ + (∀ A : Set (Lattice 3), Tiles T A → ¬ FullyPeriodic A) ∧ + (∃ A : Set (Space 3), AETiles (Thickening T) A) ∧ + (∀ A : Set (Space 3), + AETiles (Thickening T) A → ¬ EuclideanFullyPeriodic A)) ∧ + IsLeast {d : ℕ | HasTileWithoutPeriodicComplement d} 3 := by + sorry + +end PeriodicTilingThree + +end + +end OAI diff --git a/lean/ComparatorChallenges/PermanentCubic.json b/lean/ComparatorChallenges/PermanentCubic.json new file mode 100644 index 0000000000000000000000000000000000000000..886f958a1936a33af285e91a4507724002760416 --- /dev/null +++ b/lean/ComparatorChallenges/PermanentCubic.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PermanentCubic", + "solution_module": "OAI.Algebra.Determinantal.Main", + "theorem_names": [ + "OAI.PermanentBorder.permanent_cubic_lower_bounds" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PermanentCubic.lean b/lean/ComparatorChallenges/PermanentCubic.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5b566f18fe7a7789ffc42f1eb00fcc1735d2f87 --- /dev/null +++ b/lean/ComparatorChallenges/PermanentCubic.lean @@ -0,0 +1,42 @@ +import Mathlib + +namespace OAI + +namespace PermanentBorder + +open Filter +open scoped Topology + +abbrev Variables (m : ℕ) := Fin m × Fin m +abbrev Poly (σ : Type*) := MvPolynomial σ ℂ + +noncomputable def permanentPolynomial (m : ℕ) : Poly (Variables m) := + ∑ τ : Equiv.Perm (Fin m), ∏ i : Fin m, MvPolynomial.X (i, τ i) + +noncomputable def affineMatrixPolynomial {σ : Type*} [Fintype σ] (n : ℕ) + (A₀ : Matrix (Fin n) (Fin n) ℂ) + (A : σ → Matrix (Fin n) (Fin n) ℂ) : Poly σ := + Matrix.det (fun i j => MvPolynomial.C (A₀ i j) + + ∑ v : σ, MvPolynomial.C (A v i j) * MvPolynomial.X v) + +def HasBorderDeterminant {σ : Type*} [Fintype σ] (n : ℕ) (p : Poly σ) : Prop := + 0 < n ∧ ∃ (A₀ : ℕ → Matrix (Fin n) (Fin n) ℂ) + (A : ℕ → σ → Matrix (Fin n) (Fin n) ℂ), + ∀ d : σ →₀ ℕ, Tendsto + (fun j => (affineMatrixPolynomial n (A₀ j) (A j)).coeff d) + atTop (𝓝 (p.coeff d)) + +def HasExactDeterminant {σ : Type*} [Fintype σ] (n : ℕ) (p : Poly σ) : Prop := + 0 < n ∧ ∃ (A₀ : Matrix (Fin n) (Fin n) ℂ) + (A : σ → Matrix (Fin n) (Fin n) ℂ), affineMatrixPolynomial n A₀ A = p + +theorem permanent_cubic_lower_bounds : + (∀ (m n : ℕ), 1408 ≤ m → HasBorderDeterminant n (permanentPolynomial m) → + (m : ℝ)^3 / (5529600 * Real.exp 1) ≤ (n : ℝ)) ∧ + (∀ (m n : ℕ), 1408 ≤ m → HasExactDeterminant n (permanentPolynomial m) → + (m : ℝ)^3 / (5529600 * Real.exp 1) ≤ (n : ℝ)) := by + sorry + +end PermanentBorder + +end OAI diff --git a/lean/ComparatorChallenges/PettyProjectionVolume.json b/lean/ComparatorChallenges/PettyProjectionVolume.json new file mode 100644 index 0000000000000000000000000000000000000000..0c8e4f11c04b90920715aa3f6c6fd04d08411147 --- /dev/null +++ b/lean/ComparatorChallenges/PettyProjectionVolume.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PettyProjectionVolume", + "solution_module": "OAI.Geometry.ProjectionBodies.Main", + "theorem_names": [ + "OAI.PettyProjection.petty_projection_volume" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PettyProjectionVolume.lean b/lean/ComparatorChallenges/PettyProjectionVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..680a631459c84863752d24ea9ad899e069de69f8 --- /dev/null +++ b/lean/ComparatorChallenges/PettyProjectionVolume.lean @@ -0,0 +1,54 @@ +import Mathlib + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped RealInnerProductSpace + +namespace PettyProjection + +abbrev Space (n : ℕ) := EuclideanSpace ℝ (Fin n) + +def IsConvexBody {n : ℕ} (K : Set (Space n)) : Prop := + IsCompact K ∧ Convex ℝ K ∧ (interior K).Nonempty + +def unitBall (n : ℕ) : Set (Space n) := Metric.closedBall 0 1 + +def kappa (n : ℕ) : ℝ := volume.real (unitBall n) + +def perpendicular {n : ℕ} (u : Space n) : Submodule ℝ (Space n) := + (Submodule.span ℝ {u})ᗮ + +/-- Volume in the induced Euclidean structure on the orthogonal hyperplane. -/ +def shadowVolume {n : ℕ} (K : Set (Space n)) (u : Space n) : ℝ := + (volume : Measure (perpendicular u)).real + ((perpendicular u).orthogonalProjectionOnto '' K) + +/-- The body with support function equal to the volumes of orthogonal shadows, +expressed as its defining intersection of supporting half-spaces. -/ +def projectionBody {n : ℕ} (K : Set (Space n)) : Set (Space n) := + {x | ∀ u : Space n, ‖u‖ = 1 → ⟪u, x⟫ ≤ shadowVolume K u} + +def projectionRatio {n : ℕ} (K : Set (Space n)) : ℝ := + volume.real (projectionBody K) / volume.real K ^ (n - 1) + +def pettyConstant (n : ℕ) : ℝ := + kappa (n - 1) ^ n * kappa n ^ (2 - (n : ℤ)) + +def IsEllipsoid {n : ℕ} (K : Set (Space n)) : Prop := + ∃ (a : Space n) (T : Space n ≃ₗ[ℝ] Space n), + K = (fun x => a + T x) '' unitBall n + +/-- The exact unrestricted inequality and its global equality characterization. +-/ +theorem petty_projection_volume (n : ℕ) (hn : 4 ≤ n) + (K : Set (Space n)) (hK : IsConvexBody K) : + pettyConstant n ≤ projectionRatio K ∧ + (projectionRatio K = pettyConstant n ↔ IsEllipsoid K) := by + sorry + +end PettyProjection +end + +end OAI diff --git a/lean/ComparatorChallenges/PiExponent.json b/lean/ComparatorChallenges/PiExponent.json new file mode 100644 index 0000000000000000000000000000000000000000..de39cf2b2955b45355ee07e63446f380f7d231f6 --- /dev/null +++ b/lean/ComparatorChallenges/PiExponent.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PiExponent", + "solution_module": "OAI.NumberTheory.PiExponent.Main", + "theorem_names": [ + "OAI.PiExponent.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PiExponent.lean b/lean/ComparatorChallenges/PiExponent.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf78c83492e3f7aa3ab922b13d0b4151e7f601c3 --- /dev/null +++ b/lean/ComparatorChallenges/PiExponent.lean @@ -0,0 +1,19 @@ +import Mathlib + +namespace OAI + +namespace PiExponent + +theorem main : + (∀ ν : ℝ, 2 < ν → ∃ Q : ℤ, 2 ≤ Q ∧ + ∀ p q : ℤ, Q ≤ q → + (q : ℝ) ^ (-ν) ≤ |Real.pi - (p : ℝ) / (q : ℝ)|) ∧ + sSup {ν : ℝ | 0 < ν ∧ + Set.Infinite {r : ℚ | 2 ≤ r.den ∧ + 0 < |Real.pi - (r : ℝ)| ∧ + |Real.pi - (r : ℝ)| < (r.den : ℝ) ^ (-ν)}} = 2 := by + sorry + +end PiExponent + +end OAI diff --git a/lean/ComparatorChallenges/PinchedKahler.json b/lean/ComparatorChallenges/PinchedKahler.json new file mode 100644 index 0000000000000000000000000000000000000000..c98598a0b814306ca34c3a2f1708f2603f681354 --- /dev/null +++ b/lean/ComparatorChallenges/PinchedKahler.json @@ -0,0 +1,16 @@ +{ + "challenge_module": "ComparatorChallenges.PinchedKahler", + "solution_module": "OAI.Geometry.Kahler.Main", + "theorem_names": [ + "OAI.PinchedHartogs.main_theorem", + "OAI.PinchedHartogs.controlled_potential", + "OAI.PinchedHartogs.metric_transfer" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PinchedKahler.lean b/lean/ComparatorChallenges/PinchedKahler.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f55474744633082b995669e1fa7669ea1e7d49e --- /dev/null +++ b/lean/ComparatorChallenges/PinchedKahler.lean @@ -0,0 +1,159 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open Set Filter Topology +open scoped ContDiff + +namespace PinchedHartogs + +abbrev Base := EuclideanSpace ℂ (Fin 2) +abbrev Ambient := Base × ℂ +abbrev Target := Fin 3 → ℂ + +def ball : Set Base := {z | ‖z‖ < 1} + +def hartogs (φ : Base → ℝ) : Set Ambient := + {p | p.1 ∈ ball ∧ Real.exp (φ p.1) * ‖p.2‖ ^ 2 < 1} + +def noMinorant (φ : Base → ℝ) : Prop := + ¬ ∃ (H : Base → ℂ) (C : ℝ), AnalyticOnNhd ℂ H ball ∧ + ∀ z ∈ ball, (H z).re ≤ C + 4 * Real.log (1 / (1 - ‖z‖)) + φ z + +def coordVector (j : Fin 3) : Ambient := + ![(EuclideanSpace.single 0 1, 0), (EuclideanSpace.single 1 1, 0), (0, 1)] j + +def jacobian (F : Ambient → Target) (p : Ambient) : Matrix (Fin 3) (Fin 3) ℂ := + fun i j ↦ (fderiv ℂ F p (coordVector j)) i + +open scoped Matrix.Norms.Elementwise + +abbrev CMatrix := Matrix (Fin 3) (Fin 3) ℂ +abbrev CurvatureTensor := Fin 3 → Fin 3 → Fin 3 → Fin 3 → ℂ + +def coordinates (u : Ambient) : Fin 3 → ℂ := ![u.1 0, u.1 1, u.2] + +def dz (f : Ambient → ℂ) (p : Ambient) (j : Fin 3) : ℂ := + (fderiv ℝ f p (coordVector j) - Complex.I * fderiv ℝ f p (Complex.I • coordVector j)) / 2 + +def dbar (f : Ambient → ℂ) (p : Ambient) (j : Fin 3) : ℂ := + (fderiv ℝ f p (coordVector j) + Complex.I * fderiv ℝ f p (Complex.I • coordVector j)) / 2 + +def hermitianValue (h : CMatrix) (u v : Ambient) : ℂ := + ∑ i, ∑ j, h i j * coordinates u i * star (coordinates v j) + +def realArea (h : CMatrix) (u v : Ambient) : ℝ := + (hermitianValue h u u).re * (hermitianValue h v v).re - (hermitianValue h u v).re ^ 2 + +def tensorValue (R : CurvatureTensor) (u v w y : Ambient) : ℂ := + ∑ a, ∑ b, ∑ c, ∑ d, + R a b c d * coordinates u a * star (coordinates v b) * coordinates w c * star (coordinates y d) + +def curvature (g : Ambient → CMatrix) (p : Ambient) : CurvatureTensor := fun a b c d ↦ + -dbar (fun q ↦ dz (fun r ↦ g r c d) q a) p b + + ∑ e, ∑ k, (g p)⁻¹ e k * dz (fun q ↦ g q c e) p a * dbar (fun q ↦ g q k d) p b + +def sectional (g : Ambient → CMatrix) (p u v : Ambient) : ℝ := + ((tensorValue (curvature g p) u u v v).re - (tensorValue (curvature g p) u v u v).re) / + (2 * realArea (g p) u v) + +def IsKahlerMetric (M : Set Ambient) (g : Ambient → CMatrix) : Prop := + ContDiffOn ℝ ∞ g M ∧ + (∀ p ∈ M, ∀ i j, g p i j = star (g p j i)) ∧ + (∀ p ∈ M, ∀ u : Ambient, u ≠ 0 → 0 < (hermitianValue (g p) u u).re) ∧ + (∀ p ∈ M, ∀ i j k, dz (fun q ↦ g q k j) p i = dz (fun q ↦ g q i j) p k) + +def christoffel (g : Ambient → CMatrix) (p : Ambient) (k a c : Fin 3) : ℂ := + ∑ e, (g p)⁻¹ e k * dz (fun q ↦ g q c e) p a + +def GeodesicallyComplete (M : Set Ambient) (g : Ambient → CMatrix) : Prop := + ∀ p ∈ M, ∀ v : Ambient, ∃ γ : ℝ → Ambient, + ContDiff ℝ ∞ γ ∧ (∀ t, γ t ∈ M) ∧ γ 0 = p ∧ deriv γ 0 = v ∧ + ∀ t k, coordinates (deriv (deriv γ) t) k + + ∑ a, ∑ c, christoffel g (γ t) k a c * coordinates (deriv γ t) a * + coordinates (deriv γ t) c = 0 + +def IsNegativelyPinched (M : Set Ambient) (g : Ambient → CMatrix) (A B : ℝ) : Prop := + 0 < A ∧ A ≤ B ∧ ∀ p ∈ M, ∀ u v : Ambient, LinearIndependent ℝ ![u, v] → + -B ≤ sectional g p u v ∧ sectional g p u v ≤ -A + +def NoBoundedCoordinates (M : Set Ambient) : Prop := + ∀ F : Ambient → Target, AnalyticOnNhd ℂ F M → + (∃ B : ℝ, ∀ p ∈ M, ∀ i, ‖F p i‖ ≤ B) → + ¬ ∀ p ∈ M, (jacobian F p).det ≠ 0 + +def BiholomorphicToBoundedDomain (M : Set Ambient) : Prop := + ∃ N : Set Ambient, IsOpen N ∧ Bornology.IsBounded N ∧ + ∃ F G : Ambient → Ambient, AnalyticOnNhd ℂ F M ∧ AnalyticOnNhd ℂ G N ∧ + MapsTo F M N ∧ MapsTo G N M ∧ (∀ p ∈ M, G (F p) = p) ∧ (∀ q ∈ N, F (G q) = q) + +def MainTheorem : Prop := + ∃ (M : Set Ambient) (g : Ambient → CMatrix) (A B : ℝ), + IsOpen M ∧ M.Nonempty ∧ ContractibleSpace M ∧ IsKahlerMetric M g ∧ + GeodesicallyComplete M g ∧ IsNegativelyPinched M g A B ∧ + NoBoundedCoordinates M ∧ ¬ BiholomorphicToBoundedDomain M + +def psi (z : Base) : ℝ := -Real.log (1 - ‖z‖ ^ 2) +def metricPotential (φ : Base → ℝ) (lam : ℝ) (p : Ambient) : ℝ := + lam * psi p.1 - Real.log (1 - Real.exp (φ p.1) * ‖p.2‖ ^ 2) + +def complexHessian (f : Ambient → ℝ) (p : Ambient) : CMatrix := + fun i j ↦ dz (fun q ↦ dbar (fun r ↦ (f r : ℂ)) q j) p i + +def hartogsMetric (φ : Base → ℝ) (lam : ℝ) : Ambient → CMatrix := + complexHessian (metricPotential φ lam) + +def dzBase (f : Base → ℂ) (z : Base) (i : Fin 2) : ℂ := + (fderiv ℝ f z (EuclideanSpace.single i 1) - + Complex.I * fderiv ℝ f z (Complex.I • EuclideanSpace.single i 1)) / 2 + +def dbarBase (f : Base → ℂ) (z : Base) (i : Fin 2) : ℂ := + (fderiv ℝ f z (EuclideanSpace.single i 1) + + Complex.I * fderiv ℝ f z (Complex.I • EuclideanSpace.single i 1)) / 2 + +def baseHessian (φ : Base → ℝ) (z : Base) : Matrix (Fin 2) (Fin 2) ℂ := + fun i j ↦ dzBase (fun q ↦ dbarBase (fun r ↦ (φ r : ℂ)) q j) z i + +def centeredChart (r : ℝ) (U : Base ≃ₗᵢ[ℂ] Base) (ζ : Base) : Base := + U (WithLp.toLp 2 ![((r : ℂ) + ζ 0) / (1 + (r : ℂ) * ζ 0), + ((Real.sqrt (1 - r ^ 2) : ℝ) : ℂ) * ζ 1 / (1 + (r : ℂ) * ζ 0)]) + +def ChartControl (φ : Base → ℝ) (c C : ℝ) : Prop := + ∀ r : ℝ, 0 ≤ r → r < 1 → ∀ U : Base ≃ₗᵢ[ℂ] Base, ∀ v : Base, + c * ‖v‖ ^ 2 ≤ (∑ i, ∑ j, baseHessian (φ ∘ centeredChart r U) 0 i j * v i * star (v j)).re ∧ + (∑ i, ∑ j, baseHessian (φ ∘ centeredChart r U) 0 i j * v i * star (v j)).re ≤ C * ‖v‖ ^ 2 + +def ChartJets (φ : Base → ℝ) (C : ℝ) : Prop := + ∀ r : ℝ, 0 ≤ r → r < 1 → ∀ U : Base ≃ₗᵢ[ℂ] Base, ∀ i j k l : Fin 2, + ‖dzBase (fun z ↦ baseHessian (φ ∘ centeredChart r U) z i j) 0 k‖ + + ‖dbarBase (fun z ↦ baseHessian (φ ∘ centeredChart r U) z i j) 0 l‖ + + ‖dzBase (fun z ↦ dbarBase (fun q ↦ baseHessian (φ ∘ centeredChart r U) q i j) z l) 0 k‖ ≤ C + +def ControlledPotential : Prop := + ∃ φ : Base → ℝ, ∃ C : ℝ, ContDiffOn ℝ ∞ φ ball ∧ + ChartControl φ 1 C ∧ ChartJets φ C ∧ noMinorant φ + +def MetricTransfer : Prop := + ∀ c C : ℝ, 0 < c → c ≤ C → ∃ lam0 : ℝ, 0 < lam0 ∧ + ∀ φ : Base → ℝ, ContDiffOn ℝ ∞ φ ball → ChartControl φ c C → ChartJets φ C → + ∀ lam : ℝ, lam0 ≤ lam → ContractibleSpace (hartogs φ) ∧ + IsKahlerMetric (hartogs φ) (hartogsMetric φ lam) ∧ + GeodesicallyComplete (hartogs φ) (hartogsMetric φ lam) ∧ + ∃ A B : ℝ, IsNegativelyPinched (hartogs φ) (hartogsMetric φ lam) A B + +theorem main_theorem : MainTheorem := by + sorry + +theorem controlled_potential : ControlledPotential := by + sorry + +theorem metric_transfer : MetricTransfer := by + sorry + +end PinchedHartogs + +end + +end OAI diff --git a/lean/ComparatorChallenges/PinnedDistances.json b/lean/ComparatorChallenges/PinnedDistances.json new file mode 100644 index 0000000000000000000000000000000000000000..d813c8063702368cb97058d3dd77055176a9a764 --- /dev/null +++ b/lean/ComparatorChallenges/PinnedDistances.json @@ -0,0 +1,13 @@ +{ + "challenge_module": "ComparatorChallenges.PinnedDistances", + "solution_module": "OAI.Geometry.PinnedDistances.Main", + "theorem_names": [ + "OAI.WeakPinned.main" + ], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PinnedDistances.lean b/lean/ComparatorChallenges/PinnedDistances.lean new file mode 100644 index 0000000000000000000000000000000000000000..b21ebbe370ea1424d956a10613471e9ff4c5a8fd --- /dev/null +++ b/lean/ComparatorChallenges/PinnedDistances.lean @@ -0,0 +1,36 @@ +import Mathlib + +namespace OAI + +noncomputable section +open Filter +open scoped Topology + +namespace WeakPinned +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +def distanceFiber (P : Finset Plane) (x y : Plane) : Finset Plane := + (P.erase x).filter (fun z => dist z x = dist y x) + +def k (P : Finset Plane) (x y : Plane) : ℕ := + (distanceFiber P x y).card + +def richPairs (P : Finset Plane) (s : ℝ) : Finset (Plane × Plane) := + (P ×ˢ P).filter (fun xy => xy.1 ≠ xy.2 ∧ + (P.card : ℝ) ^ s ≤ (k P xy.1 xy.2 : ℝ)) + +def pairFraction (P : Finset Plane) (s : ℝ) : ℝ := + (richPairs P s).card / ((P.card : ℝ) * ((P.card : ℝ) - 1)) + +def F (n : ℕ) (s : ℝ) : ℝ := + if 2 ≤ n then sSup {a : ℝ | ∃ P : Finset Plane, P.card = n ∧ a = pairFraction P s} + else 0 + +theorem main (s : ℝ) (hs : 0 F n s) atTop (𝓝 0) := by + sorry + +end WeakPinned + +end + +end OAI diff --git a/lean/ComparatorChallenges/PlanarAndersonSpectrum.json b/lean/ComparatorChallenges/PlanarAndersonSpectrum.json new file mode 100644 index 0000000000000000000000000000000000000000..76020286d5aad5bec182ab2195de815d398cda53 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarAndersonSpectrum.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlanarAndersonSpectrum", + "definition_names": [], + "enable_nanoda": false, + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "solution_module": "OAI.MathematicalPhysics.PlanarAnderson.Spectrum", + "theorem_names": [ + "OAI.PlanarAnderson.anderson_spectrum_ae" + ] +} diff --git a/lean/ComparatorChallenges/PlanarAndersonSpectrum.lean b/lean/ComparatorChallenges/PlanarAndersonSpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..aac6e079c38b70768c57c325ea97467682e19697 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarAndersonSpectrum.lean @@ -0,0 +1,35 @@ +import Mathlib + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped ENNReal + +namespace PlanarAnderson + +abbrev Site := ℤ × ℤ +abbrev Configuration := Site → ℝ +abbrev Hilbert := lp (fun _ : Site => ℂ) 2 + +def disorderLaw (h : ℝ) : Measure Configuration := + Measure.infinitePi (fun _ : Site => ProbabilityTheory.cond volume (Set.Icc (-h) h)) + +def IsAndersonOperator (v : Configuration) (H : Hilbert →L[ℂ] Hilbert) : Prop := + ∀ (u : Hilbert) (x : Site), + (H u) x = u (x.1 + 1, x.2) + u (x.1 - 1, x.2) + + u (x.1, x.2 + 1) + u (x.1, x.2 - 1) + (v x : ℂ) * u x + +def spectralInterval (h : ℝ) : Set ℂ := + {z | z.im = 0 ∧ -4 - h ≤ z.re ∧ z.re ≤ 4 + h} + +theorem anderson_spectrum_ae {h : ℝ} (hh : 0 < h) : + ∀ᵐ v ∂disorderLaw h, ∃ H : Hilbert →L[ℂ] Hilbert, + IsAndersonOperator v H ∧ IsSelfAdjoint H ∧ spectrum ℂ H = spectralInterval h := by + sorry + +end PlanarAnderson + +end + +end OAI diff --git a/lean/ComparatorChallenges/PlanarFalconer.json b/lean/ComparatorChallenges/PlanarFalconer.json new file mode 100644 index 0000000000000000000000000000000000000000..f4d121eb9ac0f5dea4afc9fc38825b3463bd80a9 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarFalconer.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlanarFalconer", + "solution_module": "OAI.MeasureTheory.Falconer.Main", + "theorem_names": [ + "OAI.PlanarFalconer.mainTarget_proved" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Classical.choice", + "Quot.sound" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PlanarFalconer.lean b/lean/ComparatorChallenges/PlanarFalconer.lean new file mode 100644 index 0000000000000000000000000000000000000000..56a7d65c687b851e93055b9776d6623a6e266aac --- /dev/null +++ b/lean/ComparatorChallenges/PlanarFalconer.lean @@ -0,0 +1,25 @@ +import Mathlib + +namespace OAI + +namespace PlanarFalconer +open MeasureTheory Set + +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +def distanceSet (E : Set Plane) : Set ℝ := + {r | ∃ x ∈ E, ∃ y ∈ E, dist x y = r} + +def MainTarget : Prop := + ∀ E : Set Plane, IsCompact E → 1 < dimH E → 0 < volume (distanceSet E) + +end PlanarFalconer + +namespace PlanarFalconer + +theorem mainTarget_proved : MainTarget := by + sorry + +end PlanarFalconer + +end OAI diff --git a/lean/ComparatorChallenges/PlanarFirstPassage.json b/lean/ComparatorChallenges/PlanarFirstPassage.json new file mode 100644 index 0000000000000000000000000000000000000000..8d47a2039f683ef4edf2b683a206606e84812f8b --- /dev/null +++ b/lean/ComparatorChallenges/PlanarFirstPassage.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlanarFirstPassage", + "solution_module": "OAI.Probability.FirstPassage.BoundaryCurve", + "theorem_names": [ + "OAI.PlanarFPP.manuscriptMain" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PlanarFirstPassage.lean b/lean/ComparatorChallenges/PlanarFirstPassage.lean new file mode 100644 index 0000000000000000000000000000000000000000..747a40dc3b5058a23c5f0a1eafe6fe25bd6c4def --- /dev/null +++ b/lean/ComparatorChallenges/PlanarFirstPassage.lean @@ -0,0 +1,102 @@ +import Mathlib.Algebra.BigOperators.Group.List.Basic +import Mathlib.Algebra.Group.Prod +import Mathlib.Analysis.Calculus.ContDiff.Defs +import Mathlib.Analysis.Calculus.Deriv.Basic +import Mathlib.Analysis.Calculus.FDeriv.Basic +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Analysis.LocallyConvex.WithSeminorms +import Mathlib.Probability.Distributions.Exponential +import Mathlib.Probability.Independence.Basic + +namespace OAI + +namespace PlanarFPP + +open Set MeasureTheory ProbabilityTheory Filter +open scoped Topology + +abbrev Vertex := ℤ × ℤ + +abbrev Edge := Vertex × Bool + +inductive Step where + | east | west | north | south + deriving DecidableEq + +def Step.delta : Step → Vertex + | .east => (1, 0) + | .west => (-1, 0) + | .north => (0, 1) + | .south => (0, -1) + +def Step.edge (p : Vertex) : Step → Edge + | .east => (p, false) + | .west => (p + (-1, 0), false) + | .north => (p, true) + | .south => (p + (0, -1), true) + +def displacement (ds : List Step) : Vertex := (ds.map Step.delta).sum + +def pathCost (τ : Edge → ℝ) (p : Vertex) : List Step → ℝ + | [] => 0 + | d :: ds => τ (d.edge p) + pathCost τ (p + d.delta) ds + +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +noncomputable def latticeFloor (v : Plane) : Vertex := (⌊v 0⌋, ⌊v 1⌋) + +noncomputable def passageTime (τ : Edge → ℝ) (p q : Vertex) : ℝ := + sInf {t | ∃ ds : List Step, p + displacement ds = q ∧ pathCost τ p ds = t} + +structure TimeConstantNorm (μ : Plane → ℝ) : Prop where + nonneg : ∀ v, 0 ≤ μ v + zero_iff : ∀ v, μ v = 0 ↔ v = 0 + triangle : ∀ v w, μ (v + w) ≤ μ v + μ w + homogeneous : ∀ (a : ℝ) v, μ (a • v) = |a| * μ v + +structure ExponentialEnvironment {Ω : Type*} [MeasurableSpace Ω] + (P : Measure Ω) (τ : Edge → Ω → ℝ) : Prop where + probability : IsProbabilityMeasure P + measurable : ∀ e, Measurable (τ e) + independent : iIndepFun τ P + marginal : ∀ e, Measure.map (τ e) P = expMeasure 1 + +def IsTimeConstant {Ω : Type*} [MeasurableSpace Ω] + (P : Measure Ω) (τ : Edge → Ω → ℝ) (μ : Plane → ℝ) : Prop := + ∀ v : Plane, ∀ᵐ ω ∂P, + Tendsto (fun t : ℝ => passageTime (fun e => τ e ω) (0, 0) + (latticeFloor (t • v)) / t) atTop (𝓝 (μ v)) + +def DifferentiableAwayFromOrigin (μ : Plane → ℝ) : Prop := + ∀ v : Plane, v ≠ 0 → ∃ ℓ : Plane →L[ℝ] ℝ, HasFDerivAt μ ℓ v + +def UniqueNormalizedSupports (μ : Plane → ℝ) : Prop := + ∀ v : Plane, μ v = 1 → ∃! ℓ : Plane →L[ℝ] ℝ, + ℓ v = 1 ∧ ∀ w, ℓ w ≤ μ w + +def C1UnitSphere (μ : Plane → ℝ) : Prop := + ∀ v : Plane, μ v = 1 → ∃ U : Set Plane, IsOpen U ∧ v ∈ U ∧ + ∃ g : Plane → ℝ, ContDiffOn ℝ 1 g U ∧ + (∀ w ∈ U, μ w = 1 ↔ g w = 0) ∧ + ∀ w ∈ U, g w = 0 → ∃ ℓ : Plane →L[ℝ] ℝ, + HasFDerivAt g ℓ w ∧ ℓ ≠ 0 + +def HasC1CurveChart (S : Set Plane) (v : Plane) : Prop := + ∃ U : Set Plane, IsOpen U ∧ v ∈ U ∧ v ∈ S ∧ ∃ γ : ℝ → Plane, ∃ θ : Plane → ℝ, + ContDiff ℝ 1 γ ∧ ContinuousOn θ U ∧ + (∀ t, γ t ∈ S ∩ U) ∧ (∀ t, θ (γ t)=t) ∧ + (∀ z ∈ S ∩ U, γ (θ z)=z) ∧ + (∀ t, ∃ d : Plane, HasDerivAt γ d t ∧ d ≠ 0) + +theorem manuscriptMain (Ω : Type) [MeasurableSpace Ω] (P : Measure Ω) (τ : Edge → Ω → ℝ) + (henv : ExponentialEnvironment P τ) : + ∃ μ : Plane → ℝ, TimeConstantNorm μ ∧ IsTimeConstant P τ μ ∧ + DifferentiableAwayFromOrigin μ ∧ UniqueNormalizedSupports μ ∧ C1UnitSphere μ ∧ + (∀ v ∈ frontier {z | μ z ≤ 1}, ∃! L : Set Plane, + ∃ g : Plane →L[ℝ] ℝ, g ≠ 0 ∧ (∀ z, μ z ≤ 1 → g z ≤ g v) ∧ L={z | g z=g v}) ∧ + (∀ v ∈ frontier {z | μ z ≤ 1}, HasC1CurveChart (frontier {z | μ z ≤ 1}) v) := by + sorry + +end PlanarFPP + +end OAI diff --git a/lean/ComparatorChallenges/PlanarL1.json b/lean/ComparatorChallenges/PlanarL1.json new file mode 100644 index 0000000000000000000000000000000000000000..7f18a29b2df2cc67bc14cbadae6a87940dbf9804 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarL1.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlanarL1", + "solution_module": "OAI.Combinatorics.PlanarL1.Embedding", + "theorem_names": [ + "OAI.PlanarL1.planar_graph_metrics_embed_L1" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PlanarL1.lean b/lean/ComparatorChallenges/PlanarL1.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b93c85ebad6b2f9efbeb62cfe1dfc5f61cc8bd9 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarL1.lean @@ -0,0 +1,51 @@ +import Mathlib + +namespace OAI + +namespace PlanarL1 + +/-- A topological drawing by simple plane arcs, with injective vertex placement, +no vertex in an edge interior, and disjoint interiors for distinct unoriented edges. -/ +def IsPlanar {V : Type} (G : SimpleGraph V) : Prop := + ∃ (point : V → ℝ × ℝ) (arc : ∀ u v : V, G.Adj u v → C(unitInterval, ℝ × ℝ)), + Function.Injective point ∧ + (∀ u v h, (arc u v h) 0 = point u ∧ (arc u v h) 1 = point v) ∧ + (∀ u v h, Function.Injective (arc u v h)) ∧ + (∀ u v h (t : unitInterval) w, 0 < (t : ℝ) → (t : ℝ) < 1 → + (arc u v h) t ≠ point w) ∧ + (∀ u v h x y k (s t : unitInterval), + 0 < (s : ℝ) → (s : ℝ) < 1 → 0 < (t : ℝ) → (t : ℝ) < 1 → + (arc u v h) s = (arc x y k) t → + (u = x ∧ v = y) ∨ (u = y ∧ v = x)) + +/-- The sum of edge lengths along a finite graph walk. -/ +def walkLength {V : Type} {G : SimpleGraph V} (length : V → V → ℝ) + {u v : V} : G.Walk u v → ℝ + | .nil => 0 + | @SimpleGraph.Walk.cons _ _ u w _ _ p => length u w + walkLength length p + +/-- The infimum of lengths of actual walks between the two vertices. -/ +noncomputable def graphDistance {V : Type} (G : SimpleGraph V) + (length : V → V → ℝ) (u v : V) : ℝ := + sInf (Set.range (fun p : G.Walk u v => walkLength length p)) + +/-- One universal distortion bound for finite connected planar graphs with +arbitrary symmetric positive edge lengths, realized in a real `L¹` space. -/ +def MainStatement : Prop := + ∃ C : ℝ, 1 ≤ C ∧ + ∀ (n : ℕ) (G : SimpleGraph (Fin n)) (length : Fin n → Fin n → ℝ), + G.Connected → IsPlanar G → + (∀ u v, length u v = length v u) → + (∀ u v, G.Adj u v → 0 < length u v) → + ∃ (Ω : Type) (measurable : MeasurableSpace Ω) + (μ : @MeasureTheory.Measure Ω measurable) + (f : Fin n → @MeasureTheory.Lp Ω ℝ measurable _ 1 μ), + ∀ x y, graphDistance G length x y ≤ ‖f x - f y‖ ∧ + ‖f x - f y‖ ≤ C * graphDistance G length x y + +theorem planar_graph_metrics_embed_L1 : MainStatement := by + sorry + +end PlanarL1 + +end OAI diff --git a/lean/ComparatorChallenges/PlanarPacking.json b/lean/ComparatorChallenges/PlanarPacking.json new file mode 100644 index 0000000000000000000000000000000000000000..f1575ad9294afa3c93c5507bbb0e3089c9f84d39 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarPacking.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlanarPacking", + "solution_module": "OAI.Analysis.PlanarPacking.Main", + "theorem_names": [ + "OAI.sharp_fourier_certificate" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PlanarPacking.lean b/lean/ComparatorChallenges/PlanarPacking.lean new file mode 100644 index 0000000000000000000000000000000000000000..661041e8c9c991c54d19a54e1f9040efa7605371 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarPacking.lean @@ -0,0 +1,40 @@ +import Mathlib + +namespace OAI + +/-! +# A sharp Fourier certificate for planar circle packing + +The normalization and Fourier convention are those of +*A sharp Fourier certificate for planar circle packing* (OpenAI, 2026). +-/ + +open MeasureTheory + +namespace SharpPlanar + +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +/-- Radiality of a real function on the Euclidean plane. -/ +def Radial (f : Plane → ℝ) : Prop := + ∀ x y, ‖x‖ = ‖y‖ → f x = f y + +/-- Fourier transformation with kernel `exp (-2πi⟪x, ξ⟫)`. -/ +noncomputable def fourier (f : Plane → ℝ) (ξ : Plane) : ℂ := + ∫ x : Plane, (f x : ℂ) * + Complex.exp (((-2 * Real.pi * inner ℝ x ξ : ℝ) : ℂ) * Complex.I) + +/-- A normalized sharp certificate for disks of radius one half. -/ +def SharpCertificate (f : SchwartzMap Plane ℝ) : Prop := + Radial f ∧ fourier f 0 = 1 ∧ f 0 = 2 / Real.sqrt 3 ∧ + (∀ ξ, (fourier f ξ).im = 0 ∧ 0 ≤ (fourier f ξ).re) ∧ + (∀ x, 1 ≤ ‖x‖ → f x ≤ 0) + +end SharpPlanar + +/-- The sharp Fourier certificate theorem. -/ +theorem sharp_fourier_certificate : + ∃ f : SchwartzMap SharpPlanar.Plane ℝ, SharpPlanar.SharpCertificate f := by + sorry + +end OAI diff --git a/lean/ComparatorChallenges/PlanarUnitDistances.json b/lean/ComparatorChallenges/PlanarUnitDistances.json new file mode 100644 index 0000000000000000000000000000000000000000..6cf673e92784682bce651b4b8842e1cfe5d28d10 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarUnitDistances.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlanarUnitDistances", + "solution_module": "OAI.Geometry.UnitDistances.Main", + "theorem_names": [ + "OAI.PlanarUnitDistances.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PlanarUnitDistances.lean b/lean/ComparatorChallenges/PlanarUnitDistances.lean new file mode 100644 index 0000000000000000000000000000000000000000..92866ae695092215b79a72c636d9687bfe958304 --- /dev/null +++ b/lean/ComparatorChallenges/PlanarUnitDistances.lean @@ -0,0 +1,25 @@ +import Mathlib + +namespace OAI + +namespace PlanarUnitDistances + +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +def IsUnitPair : Sym2 Plane → Prop := + Sym2.lift ⟨fun x y => dist x y = 1, fun x y => by dsimp; rw [dist_comm]⟩ + +noncomputable def unitPairCount (X : Finset Plane) : ℕ := by + classical + exact (X.sym2.filter IsUnitPair).card + +noncomputable def u (n : ℕ) : ℕ := + sSup {m : ℕ | ∃ X : Finset Plane, X.card = n ∧ unitPairCount X = m} + +theorem main : ∃ C β : ℝ, 0 < C ∧ 1 ≤ β ∧ β < (4 : ℝ) / 3 ∧ + ∀ n : ℕ, (u n : ℝ) ≤ C * (n : ℝ) ^ β := by + sorry + +end PlanarUnitDistances + +end OAI diff --git a/lean/ComparatorChallenges/PlaneColoring.json b/lean/ComparatorChallenges/PlaneColoring.json new file mode 100644 index 0000000000000000000000000000000000000000..f7ccb51bddd3231b637085715221a55af27d058e --- /dev/null +++ b/lean/ComparatorChallenges/PlaneColoring.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PlaneColoring", + "solution_module": "OAI.Geometry.PlaneColoring.Main", + "theorem_names": [ + "OAI.Problem160.properColoring_seven" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PlaneColoring.lean b/lean/ComparatorChallenges/PlaneColoring.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c836214b1fbdef0ed72ccd619f20bbeb0b66e80 --- /dev/null +++ b/lean/ComparatorChallenges/PlaneColoring.lean @@ -0,0 +1,21 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem160 + +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +def ProperColoring (k : ℕ) : Prop := + ∃ c : Plane → Fin k, + ∀ x y : Plane, dist x y = 1 → c x ≠ c y + +theorem properColoring_seven : ProperColoring 7 := by sorry + +end Problem160 + +end + +end OAI diff --git a/lean/ComparatorChallenges/PolycyclicRecognition.json b/lean/ComparatorChallenges/PolycyclicRecognition.json new file mode 100644 index 0000000000000000000000000000000000000000..186f1d6f1a9e5d370f337e0b96054bcdc8c9d5f4 --- /dev/null +++ b/lean/ComparatorChallenges/PolycyclicRecognition.json @@ -0,0 +1,16 @@ +{ + "challenge_module": "ComparatorChallenges.PolycyclicRecognition", + "solution_module": "OAI.GroupTheory.PolycyclicRecognition.Recognition", + "theorem_names": [ + "OAI.PolycyclicRecognition.group_recognition", + "OAI.PolycyclicRecognition.main_uniform_bounded_height", + "OAI.PolycyclicRecognition.lattice_recognition" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PolycyclicRecognition.lean b/lean/ComparatorChallenges/PolycyclicRecognition.lean new file mode 100644 index 0000000000000000000000000000000000000000..7010023a67931b9c31128e4938defcba27481da9 --- /dev/null +++ b/lean/ComparatorChallenges/PolycyclicRecognition.lean @@ -0,0 +1,249 @@ +import Mathlib + +namespace OAI + +/-! # Quasi-isometric recognition and uniform bounded height + +A polycyclic group has a finite subnormal series with cyclic factors. The +height quotient below is the quotient of the Lie algebra by the common +kernel of the diagonal adjoint characters. +-/ + +noncomputable section + +namespace ChromaticCyclic + +structure CyclicStep {G : Type*} [Group G] (H K : Subgroup G) : Prop where + le : H ≤ K + normal : (H.subgroupOf K).Normal + cyclic : letI := normal; IsCyclic (K ⧸ H.subgroupOf K) + +structure CyclicSeries {G : Type*} [Group G] (H K : Subgroup G) (n : ℕ) where + group : ℕ → Subgroup G + first : group 0 = H + last : group n = K + step : ∀ i < n, CyclicStep (group i) (group (i + 1)) + +end ChromaticCyclic + +namespace PolycyclicRecognition + +open Module LieAlgebra MeasureTheory +open scoped Manifold NNReal + +section Coarse + +variable {G H J : Type*} [Group G] [Group H] [Group J] + +/-- Uniform control of finite sets of group differences. -/ +def GroupBornologous (f : G → H) : Prop := + ∀ S : Set G, S.Finite → ∃ T : Set H, T.Finite ∧ + ∀ x y, x⁻¹ * y ∈ S → (f x)⁻¹ * f y ∈ T + +/-- Coarse inverse maps with errors contained in fixed finite sets. -/ +structure GroupCoarseEquivalence (G H : Type*) [Group G] [Group H] where + toFun : G → H + invFun : H → G + bornologous_toFun : GroupBornologous toFun + bornologous_invFun : GroupBornologous invFun + left_error : (Set.range fun x => x⁻¹ * invFun (toFun x)).Finite + right_error : (Set.range fun y => y⁻¹ * toFun (invFun y)).Finite + +end Coarse + +section Polycyclic + +open ChromaticCyclic + +variable (G : Type*) [Group G] + +/-- Polycyclicity expressed by an actual cyclic subnormal series. -/ +def IsPolycyclic : Prop := + ∃ n : ℕ, Nonempty (CyclicSeries (⊥ : Subgroup G) ⊤ n) + +/-- Virtual polycyclicity means a polycyclic subgroup of finite index. -/ +def IsVirtuallyPolycyclic : Prop := + ∃ H : Subgroup G, H.FiniteIndex ∧ IsPolycyclic H + +end Polycyclic + +section UniformLattice + +variable {G : Type*} [Group G] + +/-- A uniform lattice is discrete and has a compact fundamental cover. -/ +def IsUniformLattice [TopologicalSpace G] (Λ : Subgroup G) : Prop := + DiscreteTopology Λ ∧ ∃ K : Set G, IsCompact K ∧ + ∀ g : G, ∃ (γ : Λ) (k : G), k ∈ K ∧ (γ : G) * k = g + +end UniformLattice + +/-- A connected simply connected finite-dimensional real solvable Lie group. -/ +structure SimplyConnectedSolvableLieModel where + modelSpace : Type + [normedAddCommGroup : NormedAddCommGroup modelSpace] + [normedSpace : NormedSpace ℝ modelSpace] + [finiteDimensional : FiniteDimensional ℝ modelSpace] + carrier : Type + [topologicalSpace : TopologicalSpace carrier] + [chartedSpace : ChartedSpace modelSpace carrier] + [group : Group carrier] + [lieGroup : LieGroup (𝓘(ℝ, modelSpace)) ⊤ carrier] + [t2Space : T2Space carrier] + [secondCountableTopology : SecondCountableTopology carrier] + [simplyConnectedSpace : SimplyConnectedSpace carrier] + [solvable : Group.IsSolvable carrier] + +attribute [instance] SimplyConnectedSolvableLieModel.normedAddCommGroup + SimplyConnectedSolvableLieModel.normedSpace SimplyConnectedSolvableLieModel.finiteDimensional + SimplyConnectedSolvableLieModel.topologicalSpace SimplyConnectedSolvableLieModel.chartedSpace + SimplyConnectedSolvableLieModel.group SimplyConnectedSolvableLieModel.lieGroup + SimplyConnectedSolvableLieModel.t2Space SimplyConnectedSolvableLieModel.simplyConnectedSpace + SimplyConnectedSolvableLieModel.secondCountableTopology + SimplyConnectedSolvableLieModel.solvable + +/-- A discrete subgroup with a normalized invariant measure on its coset space. -/ +def IsFiniteCovolumeLattice {G : Type} [Group G] [TopologicalSpace G] + (Λ : Subgroup G) : Prop := + letI : MeasurableSpace (G ⧸ Λ) := borel _ + DiscreteTopology Λ ∧ ∃ μ : Measure (G ⧸ Λ), + IsProbabilityMeasure μ ∧ SMulInvariantMeasure G (G ⧸ Λ) μ + +/-- Explicit chains with bounded steps and a linear bound on their length. -/ +structure LinearMetricChains (X : Type*) [PseudoMetricSpace X] where + step : ℝ + step_pos : 0 < step + slope : ℝ + slope_nonneg : 0 ≤ slope + error : ℝ + error_nonneg : 0 ≤ error + chain : ∀ x y : X, ∃ (n : ℕ) (p : ℕ → X), + p 0 = x ∧ p n = y ∧ (n : ℝ) ≤ slope * dist x y + error ∧ + ∀ i < n, dist (p i) (p (i + 1)) ≤ step + +/-- A compatible proper left-invariant metric with large-scale-geodesic chains. -/ +structure ProperChainMetric (G : Type*) [Group G] [TopologicalSpace G] where + metric : MetricSpace G + topology_eq : metric.toUniformSpace.toTopologicalSpace = ‹TopologicalSpace G› + proper : letI := metric; ProperSpace G + leftInvariant : letI := metric; IsIsometricSMul G G + chains : letI := metric; LinearMetricChains G + +/-- The compatible metric retains the original topology definitionally. -/ +abbrev ProperChainMetric.compatibleMetric + {G : Type*} [Group G] [TopologicalSpace G] (d : ProperChainMetric G) : MetricSpace G := + d.metric.replaceTopology d.topology_eq.symm + +section Height + +variable {L I : Type*} [AddCommGroup L] [Module ℝ L] + +/-- The common kernel, including the empty family of characters. -/ +def heightKernel (χ : I → L →ₗ[ℝ] ℝ) : Submodule ℝ L := ⨅ i, (χ i).ker + +/-- The canonical linear height quotient. -/ +abbrev HeightSpace (χ : I → L →ₗ[ℝ] ℝ) := L ⧸ heightKernel χ + +/-- The quotient map defining infinitesimal height. -/ +def heightProjection (χ : I → L →ₗ[ℝ] ℝ) : L →ₗ[ℝ] HeightSpace χ := + (heightKernel χ).mkQ + +end Height + +/-- A simultaneous real upper triangular basis for the adjoint representation. -/ +structure TriangularAdjoint (L : Type*) [LieRing L] [LieAlgebra ℝ L] (n : ℕ) where + basis : Basis (Fin n) ℝ L + upper : ∀ x : L, (LinearMap.toMatrix basis basis (LieAlgebra.ad ℝ L x)).IsUpperTriangular + +namespace TriangularAdjoint + +variable {L : Type*} [LieRing L] [LieAlgebra ℝ L] {n : ℕ} +variable (T : TriangularAdjoint L n) + +/-- The diagonal entries of the adjoint representation. -/ +noncomputable def character (i : Fin n) : L →ₗ[ℝ] ℝ where + toFun x := T.basis.repr ⁅x, T.basis i⁆ i + map_add' x y := by simp [add_lie] + map_smul' r x := (by simp [smul_lie] : _ = r * T.basis.repr ⁅x, T.basis i⁆ i) + +end TriangularAdjoint + +section Exponential + +attribute [local instance 10000] NormedField.toNormedSpace + +variable {E G : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] [TopologicalSpace G] [ChartedSpace E G] [Group G] + [LieGroup (𝓘(ℝ, E)) ⊤ G] + +/-- The exponential is characterized by its one-parameter subgroups and +by their tangent vectors at the identity. -/ +structure IsGroupExponential (Exp : GroupLieAlgebra (𝓘(ℝ, E)) G → G) : Prop where + map_zero : Exp 0 = 1 + map_add_smul : ∀ (v : GroupLieAlgebra (𝓘(ℝ, E)) G) (s t : ℝ), + Exp ((s + t) • v) = Exp (s • v) * Exp (t • v) + hasMFDerivAt_zero : ∀ v : GroupLieAlgebra (𝓘(ℝ, E)) G, + HasMFDerivAt (𝓘(ℝ, ℝ)) (𝓘(ℝ, E)) (fun t : ℝ => Exp (t • v)) 0 + (ContinuousLinearMap.smulRight (ContinuousLinearMap.id ℝ ℝ) v) + +end Exponential + +/-- Unimodularity for the canonical Borel Haar measure of the Lie group. -/ +def ModelIsUnimodular (R : SimplyConnectedSolvableLieModel) : Prop := + letI : IsTopologicalGroup R.carrier := + topologicalGroup_of_lieGroup (𝓘(ℝ, R.modelSpace)) ⊤ + letI : LocallyCompactSpace R.carrier := + Manifold.locallyCompact_of_finiteDimensional (𝓘(ℝ, R.modelSpace)) + letI : MeasurableSpace R.carrier := borel _ + letI : BorelSpace R.carrier := ⟨rfl⟩ + (Measure.haar : Measure R.carrier).IsMulRightInvariant + +/-- The upper, lower, and coarse-surjectivity bounds of a self quasi-isometry. -/ +structure SelfQuasiIsometry (G : Type*) [PseudoMetricSpace G] (K C : ℝ) where + toFun : G → G + upper : ∀ x y, dist (toFun x) (toFun y) ≤ K * dist x y + C + lower : ∀ x y, dist x y ≤ K * dist (toFun x) (toFun y) + K * C + surjective : ∀ y, ∃ x, dist y (toFun x) ≤ C + +/-- Quasi-isometric recognition, including the finite-index uniform-lattice realization. -/ +theorem group_recognition + {P J : Type} [Group P] [Group J] [Group.FG P] [Group.FG J] + (e : GroupCoarseEquivalence P J) (hP : IsVirtuallyPolycyclic P) : + IsVirtuallyPolycyclic J ∧ + ∃ Γ : Subgroup J, Γ.FiniteIndex ∧ + ∃ (S : SimplyConnectedSolvableLieModel) (Λ : Subgroup S.carrier), + IsUniformLattice Λ ∧ Nonempty (Γ ≃* Λ) := by + sorry + +/-- One finite slope group controls the height of every self quasi-isometry. -/ +theorem main_uniform_bounded_height + (R : SimplyConnectedSolvableLieModel) (d : ProperChainMetric R.carrier) + {a : ℕ} (T : TriangularAdjoint (GroupLieAlgebra (𝓘(ℝ, R.modelSpace)) R.carrier) a) + (huni : ModelIsUnimodular R) + {W : Type} [NormedAddCommGroup W] [NormedSpace ℝ W] [FiniteDimensional ℝ W] + (q : HeightSpace T.character ≃ₗ[ℝ] W) + (Exp : GroupLieAlgebra (𝓘(ℝ, R.modelSpace)) R.carrier → R.carrier) + (hExp : IsGroupExponential Exp) (π : R.carrier →* Multiplicative W) + (hπExp : ∀ x, (π (Exp x)).toAdd = q (heightProjection T.character x)) : + letI := d.compatibleMetric + ∃ A : Subgroup (W ≃ₗ[ℝ] W), Set.Finite (A : Set (W ≃ₗ[ℝ] W)) ∧ + ∀ K C : ℝ, 1 ≤ K → 0 ≤ C → ∃ B : ℝ, 0 ≤ B ∧ + ∀ F : SelfQuasiIsometry R.carrier K C, ∃ AF : A, ∀ g, + ‖(π (F.toFun g)).toAdd - ((π (F.toFun 1)).toAdd + AF.val (π g).toAdd)‖ ≤ B := by + sorry + +/-- Finite-covolume lattice recognition, allowing a different ambient Lie group. -/ +theorem lattice_recognition + (S : SimplyConnectedSolvableLieModel) (Λ : Subgroup S.carrier) + (hΛ : IsFiniteCovolumeLattice Λ) + {J : Type} [Group J] [Group.FG J] (e : GroupCoarseEquivalence Λ J) : + ∃ Γ : Subgroup J, Γ.FiniteIndex ∧ + ∃ (R : SimplyConnectedSolvableLieModel) (Δ : Subgroup R.carrier), + IsUniformLattice Δ ∧ Nonempty (Γ ≃* Δ) := by + sorry + +end PolycyclicRecognition + +end + +end OAI diff --git a/lean/ComparatorChallenges/PosteriorReplicas.json b/lean/ComparatorChallenges/PosteriorReplicas.json new file mode 100644 index 0000000000000000000000000000000000000000..c665eebab98f3fe87917c1c462cf1718c14f6463 --- /dev/null +++ b/lean/ComparatorChallenges/PosteriorReplicas.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PosteriorReplicas", + "solution_module": "OAI.Probability.PosteriorReplicas.Main", + "theorem_names": [ + "OAI.PosteriorReplicas.source_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PosteriorReplicas.lean b/lean/ComparatorChallenges/PosteriorReplicas.lean new file mode 100644 index 0000000000000000000000000000000000000000..be840922beb1feff22f51fa3d0c5b1d21f2f2211 --- /dev/null +++ b/lean/ComparatorChallenges/PosteriorReplicas.lean @@ -0,0 +1,455 @@ +import Mathlib + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Set Matrix +open scoped ENNReal NNReal RealInnerProductSpace Classical + +noncomputable section + +namespace PosteriorReplicas + +abbrev Vec (d : ℕ) := EuclideanSpace ℝ (Fin d) +abbrev Rows (d k : ℕ) := Fin k → Vec d +abbrev Labels (k : ℕ) := Fin k → ℝ +abbrev Data (d k : ℕ) := Rows d k × Labels k +abbrev Tuple (d m : ℕ) := Fin (m + 1) → Vec d + +def sphereLaw (d : ℕ) : Measure (Vec d) := + let σ := (volume : Measure (Vec d)).toSphere + ((σ univ)⁻¹ • σ).map Subtype.val + +def gaussianRows (d k : ℕ) : Measure (Rows d k) := + Measure.pi fun _ => stdGaussian (Vec d) + +instance (d k : ℕ) : IsProbabilityMeasure (gaussianRows d k) := by + unfold gaussianRows + infer_instance + +def labels {d k : ℕ} (A : Rows d k) (s : Vec d) : Labels k := + fun i => ⟪A i, s⟫ + +lemma measurable_labels {d k : ℕ} : + Measurable (fun z : Rows d k × Vec d => labels z.1 z.2) := by + unfold labels + fun_prop + +def messageKernel {d k N : ℕ} (κ : Kernel (Data d k) (Fin N)) : + Kernel (Vec d × Rows d k) (Fin N) := + κ.comap (fun z => (z.2, labels z.2 z.1)) (by + unfold labels + fun_prop) + +instance {d k N : ℕ} (κ : Kernel (Data d k) (Fin N)) [IsMarkovKernel κ] : + IsMarkovKernel (messageKernel κ) := by + unfold messageKernel + infer_instance + +def signalMessageLaw {d k N : ℕ} (p : Measure (Vec d)) + (κ : Kernel (Data d k) (Fin N)) : Measure (Vec d × Fin N) := + ((p.prod (gaussianRows d k)) ⊗ₘ messageKernel κ).map + (fun z => (z.1.1, z.2)) + +instance {d k N : ℕ} (p : Measure (Vec d)) [IsProbabilityMeasure p] + (κ : Kernel (Data d k) (Fin N)) [IsMarkovKernel κ] : + IsProbabilityMeasure (signalMessageLaw p κ) := by + unfold signalMessageLaw + infer_instance + +def sideLaw {d N : ℕ} (ℓ : ℕ) (q : Measure (Vec d × Fin N)) : + Measure (Data d ℓ × (Vec d × Fin N)) := + ((gaussianRows d ℓ).prod q).map + (fun z => ((z.1, labels z.1 z.2.1), z.2)) + +instance {d N : ℕ} (ℓ : ℕ) (q : Measure (Vec d × Fin N)) [IsProbabilityMeasure q] : + IsProbabilityMeasure (sideLaw ℓ q) := by + unfold sideLaw + infer_instance + +def messageEntropy {d N : ℕ} (q : Measure (Vec d × Fin N)) : ℝ := + ∑ w : Fin N, -(q.snd.real {w}) * Real.log (q.snd.real {w}) + +def conditionalInformation {d ℓ N : ℕ} [NeZero N] + (μ : Measure (Data d ℓ × (Vec d × Fin N))) [IsFiniteMeasure μ] : ℝ≥0∞ := + klDiv μ (μ.fst ⊗ₘ (μ.condKernel.fst ×ₖ μ.condKernel.snd)) + +def GaussianReplicaBlock : Prop := + ∃ C : ℝ, 0 < C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + let k := 2 * (d / 16) + let t := k + 1 + let ℓ := 4 * k + ∀ (p : Measure (Vec d)) [IsProbabilityMeasure p] + (f : Vec d → ℝ) (L : ℝ), + Measurable f → (∀ x, 0 ≤ f x ∧ f x ≤ L) → + p = (sphereLaw d).withDensity (fun x => ENNReal.ofReal (f x)) → + ∀ (N : ℕ) [NeZero N] (κ : Kernel (Data d k) (Fin N)) [IsMarkovKernel κ], + conditionalInformation (sideLaw ℓ (signalMessageLaw p κ)) ≤ + ENNReal.ofReal (messageEntropy (signalMessageLaw p κ) / (t : ℝ) + + C * (d : ℝ) + C * Real.log (2 + Real.log L)) + +inductive BaseLaw where + | spherical + | gaussian + deriving DecidableEq + +def BaseLaw.measure (base : BaseLaw) (d : ℕ) : Measure (Vec d) := + match base with + | .spherical => sphereLaw d + | .gaussian => stdGaussian (Vec d) + +def rowGram {d k : ℕ} (A : Rows d k) : Matrix (Fin k) (Fin k) ℝ := + fun i j => ⟪A i, A j⟫ + +def liftLabel {d k : ℕ} (A : Rows d k) (y : Labels k) : Vec d := + ∑ i, ((rowGram A)⁻¹ *ᵥ y) i • A i + +def kernelComponent {d k : ℕ} (A : Rows d k) (x : Vec d) : Vec d := + x - liftLabel A (labels A x) + +def baseFiber {d k : ℕ} (base : BaseLaw) (A : Rows d k) (y : Labels k) : + Measure (Vec d) := + match base with + | .gaussian => (stdGaussian (Vec d)).map + (fun x => liftLabel A y + kernelComponent A x) + | .spherical => (stdGaussian (Vec d)).map + (fun x => liftLabel A y + + (Real.sqrt (1 - ‖liftLabel A y‖ ^ 2) / ‖kernelComponent A x‖) • + kernelComponent A x) + +def baseDensity {d k : ℕ} (base : BaseLaw) (A : Rows d k) (y : Labels k) : ℝ≥0∞ := + if LinearIndependent ℝ A then + match base with + | .gaussian => ENNReal.ofReal + ((2 * Real.pi) ^ (-(k : ℝ) / 2) * + Real.exp (-‖liftLabel A y‖ ^ 2 / 2) / Real.sqrt (rowGram A).det) + | .spherical => if ‖liftLabel A y‖ < 1 then ENNReal.ofReal + (Real.Gamma ((d : ℝ) / 2) / + (Real.pi ^ ((k : ℝ) / 2) * Real.Gamma (((d : ℝ) - k) / 2)) * + (1 - ‖liftLabel A y‖ ^ 2) ^ (((d : ℝ) - k - 2) / 2) / + Real.sqrt (rowGram A).det) else 0 + else 0 + +def tiltMass {d k : ℕ} (base : BaseLaw) (f : Vec d → ℝ≥0∞) + (A : Rows d k) (y : Labels k) : ℝ≥0∞ := + ∫⁻ x, f x ∂baseFiber base A y + +def projectedDensity {d k : ℕ} (base : BaseLaw) (f : Vec d → ℝ≥0∞) + (A : Rows d k) (y : Labels k) : ℝ≥0∞ := + baseDensity base A y * tiltMass base f A y + +def tiltedFiber {d k : ℕ} (base : BaseLaw) (f : Vec d → ℝ≥0∞) + (A : Rows d k) (y : Labels k) : Measure (Vec d) := + if tiltMass base f A y = 0 then Measure.dirac 0 + else (tiltMass base f A y)⁻¹ • (baseFiber base A y).withDensity f + +def differences {d m : ℕ} (u : Tuple d m) : Fin m → Vec d := + fun i => u i.succ - u 0 + +def differenceSpan {d m : ℕ} (u : Tuple d m) : Submodule ℝ (Vec d) := + Submodule.span ℝ (Set.range (differences u)) + +def affineVolume {d m : ℕ} (u : Tuple d m) : ℝ := + Real.sqrt (Matrix.gram ℝ (differences u)).det + +def constrainedRows {d m : ℕ} (k : ℕ) (u : Tuple d m) : Measure (Rows d k) := + (gaussianRows d k).map + (fun A i => (differenceSpan u)ᗮ.starProjection (A i)) + +def equalLabelLeft {d k m : ℕ} (base : BaseLaw) (f : Vec d → ℝ≥0∞) + (H : Rows d k × Labels k × Tuple d m → ℝ≥0∞) : ℝ≥0∞ := + ∫⁻ A, ∫⁻ y, (projectedDensity base f A y) ^ (m + 1) * + ∫⁻ u, H (A, y, u) ∂Measure.pi (fun _ : Fin (m + 1) => tiltedFiber base f A y) + ∂volume ∂gaussianRows d k + +def equalLabelRight {d k m : ℕ} (base : BaseLaw) (f : Vec d → ℝ≥0∞) + (H : Rows d k × Labels k × Tuple d m → ℝ≥0∞) : ℝ≥0∞ := + ENNReal.ofReal ((2 * Real.pi) ^ (-(k * m : ℝ) / 2)) * + ∫⁻ u, (ENNReal.ofReal (affineVolume u))⁻¹ ^ k * + ∫⁻ A, H (A, labels A (u 0), u) ∂constrainedRows k u + ∂Measure.pi (fun _ : Fin (m + 1) => (base.measure d).withDensity f) + +def EqualLabelMeasureIdentity : Prop := + ∀ (d k m : ℕ), 1 ≤ k → 1 ≤ m → k + m ≤ d - 2 → + ∀ (base : BaseLaw) (f : Vec d → ℝ≥0∞), Measurable f → + (∃ L : ℝ≥0∞, L ≠ ∞ ∧ ∀ x, f x ≤ L) → + equalLabelLeft (k := k) (m := m) base f (fun _ => 1) < ∞ ∧ + ∀ H : Rows d k × Labels k × Tuple d m → ℝ≥0∞, + Measurable H → equalLabelLeft base f H = equalLabelRight base f H + +def DistanceReplicaBlock : Prop := + ∃ C : ℝ, 0 < C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + ∀ (p : Measure (Vec d)) [IsProbabilityMeasure p] + (f : Vec d → ℝ) (b : ℝ), + 0 ≤ b → Measurable f → (∀ x, 0 ≤ f x ∧ f x ≤ Real.exp b) → + p = (sphereLaw d).withDensity (fun x => ENNReal.ofReal (f x)) → + ∀ (N : ℕ) [NeZero N] (κ : Kernel (Data d (d / 16)) (Fin N)) [IsMarkovKernel κ], + conditionalInformation (sideLaw (d / 2) (signalMessageLaw p κ)) ≤ + ENNReal.ofReal (messageEntropy (signalMessageLaw p κ) / ((d / 8 : ℕ) : ℝ) + + C * ((d : ℝ) + b / (d : ℝ))) + +def SyntheticReplicaBlock : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ d : ℕ, 16 ≤ d → + ∀ (p : Measure (Vec d)) [IsProbabilityMeasure p] + (f : Vec d → ℝ) (L : ℝ), + 1 ≤ L → Measurable f → (∀ x, 0 ≤ f x ∧ f x ≤ L) → + p = (sphereLaw d).withDensity (fun x => ENNReal.ofReal (f x)) → + ∀ (N : ℕ) [NeZero N] (z : Data d (d / 8) → Fin N) (hz : Measurable z), + conditionalInformation + (sideLaw (d / 2) (signalMessageLaw p (Kernel.deterministic z hz))) ≤ + ENNReal.ofReal (Real.log (N : ℝ) / ((d / 8 : ℕ) : ℝ) + + C * ((d : ℝ) + Real.log (1 + Real.log L))) + +def IncidenceReplicaBlock : Prop := + ∃ C : ℝ, 0 < C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + ∀ (p : Measure (Vec d)) [IsProbabilityMeasure p] + (f : Vec d → ℝ) (F : ℝ), + 1 ≤ F → Measurable f → (∀ x, 0 ≤ f x ∧ f x ≤ F) → + p = (sphereLaw d).withDensity (fun x => ENNReal.ofReal (f x)) → + ∀ (N : ℕ) [NeZero N] (κ : Kernel (Data d (d / 16)) (Fin N)) [IsMarkovKernel κ], + conditionalInformation (sideLaw (d / 4) (signalMessageLaw p κ)) ≤ + ENNReal.ofReal (Real.log (N : ℝ) / ((d / 16 : ℕ) : ℝ) + + C * (d : ℝ) + C * Real.log (1 + Real.log F)) + +def labelNorm {k : ℕ} (y : Labels k) : ℝ := ‖WithLp.toLp 2 y‖ + +def ballDensityVersion {d k : ℕ} (ν : Measure (Vec d)) + (A : Rows d k) (y : Labels k) : ℝ≥0∞ := + Filter.liminf (fun n : ℕ => + ((volume : Measure (Labels k)) {v | labelNorm v < (n + 1 : ℝ)⁻¹})⁻¹ * + ν {x | labelNorm (labels A x - y) < (n + 1 : ℝ)⁻¹}) Filter.atTop + +def gaussianDensityVersion {d k : ℕ} (ν : Measure (Vec d)) + (A : Rows d k) (y : Labels k) : ℝ≥0∞ := + Filter.liminf (fun n : ℕ => ∫⁻ x, + ENNReal.ofReal ((2 * Real.pi * ((n + 1 : ℝ)⁻¹)^2) ^ (-(k : ℝ) / 2) * + Real.exp (-(labelNorm (labels A x - y))^2 / (2 * ((n + 1 : ℝ)⁻¹)^2))) ∂ν) + Filter.atTop + +def EqualLabelVersions : Prop := + ∀ (d k m : ℕ), 1 ≤ k → 1 ≤ m → k + m ≤ d - 2 → + ∀ (base : BaseLaw) (f : Vec d → ℝ≥0∞), Measurable f → + (∃ L : ℝ≥0∞, L ≠ ∞ ∧ ∀ x, f x ≤ L) → + let ν := (base.measure d).withDensity f + (Measurable (fun z : Rows d k × Labels k => projectedDensity base f z.1 z.2)) ∧ + (Measurable (fun z : Rows d k × Labels k => ballDensityVersion ν z.1 z.2)) ∧ + (Measurable (fun z : Rows d k × Labels k => gaussianDensityVersion ν z.1 z.2)) ∧ + (∀ A : Rows d k, LinearIndependent ℝ A → + ν.map (labels A) = volume.withDensity (projectedDensity base f A) ∧ + projectedDensity base f A =ᵐ[volume] ballDensityVersion ν A ∧ + projectedDensity base f A =ᵐ[volume] gaussianDensityVersion ν A) ∧ + (∀ᵐ u ∂Measure.pi (fun _ : Fin (m + 1) => ν), + LinearIndependent ℝ (differences u) ∧ + ∀ᵐ A ∂constrainedRows k u, + LinearIndependent ℝ A ∧ + (∀ i, labels A (u i) = labels A (u 0)) ∧ + (base = .spherical → ‖liftLabel A (labels A (u 0))‖ < 1) ∧ + 0 < projectedDensity base f A (labels A (u 0)) ∧ + projectedDensity base f A (labels A (u 0)) ≠ ∞ ∧ + projectedDensity base f A (labels A (u 0)) = + ballDensityVersion ν A (labels A (u 0)) ∧ + projectedDensity base f A (labels A (u 0)) = + gaussianDensityVersion ν A (labels A (u 0))) + +def haarRows (d ℓ : ℕ) : Measure (Rows d ℓ) := + (gaussianRows d ℓ).map (InnerProductSpace.gramSchmidtNormed ℝ) + +def cmi {Z X Y : Type*} [MeasurableSpace Z] [MeasurableSpace X] [MeasurableSpace Y] + [StandardBorelSpace X] [StandardBorelSpace Y] [Nonempty X] [Nonempty Y] + (μ : Measure (Z × (X × Y))) [IsFiniteMeasure μ] : ℝ≥0∞ := + klDiv μ (μ.fst ⊗ₘ (μ.condKernel.fst ×ₖ μ.condKernel.snd)) + +def finiteEntropy {J : Type*} [Fintype J] [MeasurableSpace J] (μ : Measure J) : ℝ := + ∑ j, - μ.real {j} * Real.log (μ.real {j}) + +def stateMessageKernel {d k V W : ℕ} (κ : Kernel (Fin V × Data d k) (Fin W)) : + Kernel ((Vec d × Fin V) × Rows d k) (Fin W) := + κ.comap (fun z => (z.1.2, (z.2, labels z.2 z.1.1))) (by unfold labels; fun_prop) + +instance {d k V W : ℕ} (κ : Kernel (Fin V × Data d k) (Fin W)) [IsMarkovKernel κ] : + IsMarkovKernel (stateMessageKernel κ) := by + unfold stateMessageKernel + infer_instance + +def stateMessageLaw {d k V W : ℕ} (q : Measure (Vec d × Fin V)) + (κ : Kernel (Fin V × Data d k) (Fin W)) : Measure ((Vec d × Fin V) × Fin W) := + (((q.prod (gaussianRows d k)) ⊗ₘ stateMessageKernel κ).map + (fun z => (z.1.1, z.2))) + +instance {d k V W : ℕ} (q : Measure (Vec d × Fin V)) [IsProbabilityMeasure q] + (κ : Kernel (Fin V × Data d k) (Fin W)) [IsMarkovKernel κ] : + IsProbabilityMeasure (stateMessageLaw q κ) := by + unfold stateMessageLaw + infer_instance + +def stateHaarSideLaw {d V W : ℕ} (ℓ : ℕ) + (q : Measure ((Vec d × Fin V) × Fin W)) : + Measure ((Fin V × Data d ℓ) × (Vec d × Fin W)) := + ((haarRows d ℓ).prod q).map + (fun z => ((z.2.1.2, (z.1, labels z.1 z.2.1.1)), (z.2.1.1, z.2.2))) + +instance {d V W : ℕ} (ℓ : ℕ) + (q : Measure ((Vec d × Fin V) × Fin W)) [IsFiniteMeasure q] : + IsFiniteMeasure (stateHaarSideLaw ℓ q) := by + unfold stateHaarSideLaw haarRows + infer_instance + +def terminalConditionalEntropy {d V W : ℕ} + (q : Measure ((Vec d × Fin V) × Fin W)) : ℝ := + finiteEntropy (q.map (fun z => (z.1.2, z.2))) - finiteEntropy (q.map (fun z => z.1.2)) + +def HaarReplicaBlock : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ d : ℕ, 64 ≤ d → + ∀ (V W : ℕ) [NeZero V] [NeZero W] + (q : Measure (Vec d × Fin V)) [IsProbabilityMeasure q], + q.fst = sphereLaw d → + ∀ (κ : Kernel (Fin V × Data d (d / 16)) (Fin W)) [IsMarkovKernel κ], + cmi (stateHaarSideLaw (d / 4) (stateMessageLaw q κ)) ≤ + ENNReal.ofReal (terminalConditionalEntropy (stateMessageLaw q κ) / + ((d / 16 + 1 : ℕ) : ℝ) + C * (d : ℝ) + + Real.log (1 + C * (d : ℝ) + finiteEntropy q.snd) + + C * (finiteEntropy q.snd + Real.log (d : ℝ)) / (d : ℝ)^2) + +end PosteriorReplicas +end +end + +open MeasureTheory ProbabilityTheory Set Filter +open scoped ENNReal NNReal RealInnerProductSpace + +noncomputable section + +universe u + +namespace PosteriorRegression + +abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d) +abbrev UnitSphere (d : ℕ) := Metric.sphere (0 : Vector d) 1 +abbrev State (M : ℕ) := Fin (2 ^ M) +abbrev Samples (d T : ℕ) := Fin T → Vector d + +def uniformSphere (d : ℕ) : Measure (UnitSphere d) := + let σ := (volume : Measure (Vector d)).toSphere + (σ Set.univ)⁻¹ • σ + +def sampleLaw (d T : ℕ) : Measure (Samples d T) := + Measure.pi fun _ => stdGaussian (Vector d) + +def observationReference (d : ℕ) : Measure (Vector d × ℝ) := + (stdGaussian (Vector d)).prod volume + +namespace Learner + +abbrev RunStatus (M : ℕ) := Sum (State M) (ℕ × State M) + +def angularError {d : ℕ} (s ŝ : UnitSphere d) : ℝ := + Real.arccos ⟪ŝ.val, s.val⟫ + +end Learner + +end PosteriorRegression + +open MeasureTheory ProbabilityTheory InformationTheory Set Matrix +open scoped ENNReal NNReal RealInnerProductSpace Classical + +noncomputable section + +namespace PosteriorRegression +abbrev CompletedObservation (d : ℕ) := NullMeasurableSpace (Vector d × ℝ) (observationReference d) +abbrev Destination (M : ℕ) := Bool × State M + +structure CompletedKernelLearner (d M : ℕ) where + initial : Measure (Destination M) + initial_probability : IsProbabilityMeasure initial + transition : ℕ → State M → Kernel (CompletedObservation d) (Destination M) + transition_markov : ∀ t a, IsMarkovKernel (transition t a) + output : ℕ → State M → Measure (UnitSphere d) + output_probability : ∀ t a, IsProbabilityMeasure (output t a) + +attribute [instance] CompletedKernelLearner.initial_probability + CompletedKernelLearner.transition_markov CompletedKernelLearner.output_probability + +namespace CompletedKernelLearner +open Learner +def destStatus {M : ℕ} (n : ℕ) (v : Destination M) : RunStatus M := + if v.1 then Sum.inr (n,v.2) else Sum.inl v.2 + +def finishState {M : ℕ} (T : ℕ) : RunStatus M → ℕ × State M + | .inl a => (T,a) + | .inr done => done + +def stepMeasure {d M T : ℕ} (K : CompletedKernelLearner d M) + (s : UnitSphere d) (x : Samples d T) (i : Fin T) : RunStatus M → Measure (RunStatus M) + | .inr done => Measure.dirac (.inr done) + | .inl a => (K.transition (i.val+1) a (x i,⟪x i,s.val⟫)).map (destStatus (i.val+1)) + +def runMeasure {d M T : ℕ} (K : CompletedKernelLearner d M) + (s : UnitSphere d) (x : Samples d T) : ℕ → Measure (RunStatus M) + | 0 => K.initial.map (destStatus 0) + | n+1 => if hn : n K.output a.1 a.2) + +end CompletedKernelLearner + +structure JointKernelExperiment (d M T : ℕ) (Ω : Type u) [MeasurableSpace Ω] + (ρ : Measure Ω) where + rules : Ω → CompletedKernelLearner d M + outputKernel : Kernel (Ω × (UnitSphere d × Samples d T)) (UnitSphere d) + output_markov : IsMarkovKernel outputKernel + conditional_output : ∀ᵐ ω ∂ρ, ∀ᵐ z ∂((uniformSphere d).prod (sampleLaw d T)), + outputKernel (ω,z) = (rules ω).estimateLaw z.1 z.2 + +attribute [instance] JointKernelExperiment.output_markov + +namespace JointKernelExperiment +open Learner +def law {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] {ρ : Measure Ω} + (E : JointKernelExperiment d M T Ω ρ) : Measure ((Ω × (UnitSphere d × Samples d T)) × UnitSphere d) := + (ρ.prod ((uniformSphere d).prod (sampleLaw d T))) ⊗ₘ E.outputKernel + +def uniformSuccess {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] {ρ : Measure Ω} + (E : JointKernelExperiment d M T Ω ρ) (ε : ℝ) : ℝ≥0∞ := + E.law {z | angularError z.1.2.1 z.2 ≤ ε} + +end JointKernelExperiment + +def KernelSubquadraticMemory : Prop := + ∃ c : ℝ, 0 < c ∧ ∀ M : ℕ → ℕ, + Asymptotics.IsLittleO atTop (fun d => (M d : ℝ)) (fun d => (d : ℝ)^2) → + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ, + 0<ε → ε≤1/10 → + ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ → + ∀ E : JointKernelExperiment d (M d) T Ω ρ, + (2/3 : ℝ≥0∞) ≤ E.uniformSuccess ε → + c * (d : ℝ) * Real.log (1/ε) ≤ (T : ℝ) + +end PosteriorRegression + +namespace PosteriorReplicas + +end PosteriorReplicas +end +end + +namespace PosteriorReplicas + +universe u + +theorem source_main : EqualLabelMeasureIdentity ∧ EqualLabelVersions ∧ + GaussianReplicaBlock ∧ DistanceReplicaBlock ∧ HaarReplicaBlock ∧ + SyntheticReplicaBlock ∧ IncidenceReplicaBlock ∧ + PosteriorRegression.KernelSubquadraticMemory.{u} := by + sorry + +end PosteriorReplicas + +end OAI diff --git a/lean/ComparatorChallenges/PowerFreeValues.json b/lean/ComparatorChallenges/PowerFreeValues.json new file mode 100644 index 0000000000000000000000000000000000000000..84b9f8c3fc3318671f528228d592038f77484e90 --- /dev/null +++ b/lean/ComparatorChallenges/PowerFreeValues.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PowerFreeValues", + "solution_module": "OAI.NumberTheory.PowerFree.Main", + "theorem_names": [ + "OAI.QuarticPowerFree.allDegrees" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PowerFreeValues.lean b/lean/ComparatorChallenges/PowerFreeValues.lean new file mode 100644 index 0000000000000000000000000000000000000000..515e91fe8f60e8b63c74de87a313b34b12054061 --- /dev/null +++ b/lean/ComparatorChallenges/PowerFreeValues.lean @@ -0,0 +1,46 @@ +import Mathlib + +namespace OAI + + + +open Filter Asymptotics +open scoped Topology + +namespace QuarticPowerFree + +def PowerFree (k : ℕ) (a : ℤ) : Prop := + ∀ p : ℕ, p.Prime → ¬ (p : ℤ) ^ k ∣ a + +def rho (f : Polynomial ℤ) (q : ℕ) : ℕ := + ((Finset.range q).filter fun a : ℕ => (q : ℤ) ∣ f.eval (a : ℤ)).card + +noncomputable def count (f : Polynomial ℤ) (k : ℕ) (X : ℝ) : ℕ := by + classical + exact ((Finset.Icc 1 ⌊X⌋₊).filter fun n : ℕ => PowerFree k (f.eval (n : ℤ))).card + +def LocallyAdmissible (f : Polynomial ℤ) (k : ℕ) : Prop := + ∀ p : ℕ, p.Prime → rho f (p ^ k) < p ^ k + +noncomputable def localFactor (f : Polynomial ℤ) (k : ℕ) (p : Nat.Primes) : ℝ := + 1 - (rho f (p.val ^ k) : ℝ) / (p.val : ℝ) ^ k + +noncomputable def densityConstant (f : Polynomial ℤ) (k : ℕ) : ℝ := + ∏' p : Nat.Primes, localFactor f k p + +def DensityStatement (f : Polynomial ℤ) (k : ℕ) : Prop := + Multipliable (localFactor f k) ∧ + 0 < densityConstant f k ∧ + (fun X : ℝ => (count f k X : ℝ) - densityConstant f k * X) =o[atTop] + (fun X : ℝ => X) + +theorem allDegrees (f : Polynomial ℤ) + (hirr : Irreducible (f.map (Int.castRingHom ℚ))) + (hdeglo : 4 ≤ f.natDegree) + (hlocal : LocallyAdmissible f (f.natDegree - 2)) : + DensityStatement f (f.natDegree - 2) := by + sorry + +end QuarticPowerFree + +end OAI diff --git a/lean/ComparatorChallenges/PrimeGaps.json b/lean/ComparatorChallenges/PrimeGaps.json new file mode 100644 index 0000000000000000000000000000000000000000..61c85d17d7d7de2046c04da18fc3054845bafa29 --- /dev/null +++ b/lean/ComparatorChallenges/PrimeGaps.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.PrimeGaps", + "solution_module": "OAI.NumberTheory.PrimeGaps.RatioCorollary", + "theorem_names": [ + "OAI.Problem344.large_gaps_and_ratio_density" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/PrimeGaps.lean b/lean/ComparatorChallenges/PrimeGaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..30450675a284489ec37f1f82004f3980717551c2 --- /dev/null +++ b/lean/ComparatorChallenges/PrimeGaps.lean @@ -0,0 +1,47 @@ +import Mathlib + +namespace OAI + +namespace LargePrimeGaps + +noncomputable def prime (n : ℕ) : ℕ := Nat.nth Nat.Prime (n - 1) + +noncomputable def largeGapIndices (C : ℝ) (N : ℕ) : Finset ℕ := by + classical + exact (Finset.Icc 1 N).filter fun n => + C * Real.log (prime n : ℝ) < (prime (n + 1) : ℝ) - (prime n : ℝ) + +end LargePrimeGaps + +noncomputable section + +namespace Problem344 + +def primeAt (n : ℕ) : ℕ := + Nat.nth Nat.Prime (n - 1) + +def initialCount (A : Set ℕ) (N : ℕ) : ℕ := by + classical + exact ((Finset.Icc 1 N).filter (fun n => n ∈ A)).card + +def lowerAsymptoticDensity (A : Set ℕ) : ℝ := + sSup {d : ℝ | ∃ N0 : ℕ, ∀ N : ℕ, N0 ≤ N → + d ≤ (initialCount A N : ℝ) / (N : ℝ)} + +def ratioIncreaseIndices : Set ℕ := + {n | 1 ≤ n ∧ + (primeAt n : ℝ) / (n : ℝ) < + (primeAt (n + 1) : ℝ) / ((n + 1 : ℕ) : ℝ)} + +theorem large_gaps_and_ratio_density : + (∀ C : ℝ, 0 < C → + ∃ c : ℝ, 0 < c ∧ ∃ N₀ : ℕ, ∀ N : ℕ, N₀ ≤ N → + c * (N : ℝ) ≤ ((LargePrimeGaps.largeGapIndices C N).card : ℝ)) ∧ + 0 < lowerAsymptoticDensity ratioIncreaseIndices := by + sorry + +end Problem344 + +end + +end OAI diff --git a/lean/ComparatorChallenges/ProductBrown.json b/lean/ComparatorChallenges/ProductBrown.json new file mode 100644 index 0000000000000000000000000000000000000000..6e4d55d5fdeec1dde4b79a9de799175c8a7c4b1c --- /dev/null +++ b/lean/ComparatorChallenges/ProductBrown.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ProductBrown", + "solution_module": "OAI.Analysis.BrownMeasure.Main", + "theorem_names": [ + "OAI.FiniteFactor.productBrown" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ProductBrown.lean b/lean/ComparatorChallenges/ProductBrown.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2bbbe9672222d5b4a7db18864d1f8497aec588d --- /dev/null +++ b/lean/ComparatorChallenges/ProductBrown.lean @@ -0,0 +1,757 @@ +import Mathlib + +namespace OAI + +section +noncomputable section +open Polynomial +namespace FiniteFactor + +theorem product_has_low_nonzero_coeff (K : ℕ) (p q : ℂ[X]) + (hp : p.coeff K ≠ 0) (hq : q.coeff K ≠ 0) : + ∃ n ≤ 2 * K, (p * q).coeff n ≠ 0 := by + have hp0 : p ≠ 0 := by intro h; simp [h] at hp + have hq0 : q ≠ 0 := by intro h; simp [h] at hq + refine ⟨(p * q).natTrailingDegree, ?_, + Polynomial.coeff_natTrailingDegree_ne_zero.mpr (mul_ne_zero hp0 hq0)⟩ + rw [Polynomial.natTrailingDegree_mul hp0 hq0] + have ha := Polynomial.natTrailingDegree_le_of_ne_zero hp + have hb := Polynomial.natTrailingDegree_le_of_ne_zero hq + omega + +abbrev Coefficients (K : ℕ) := Fin (2 * K + 1) → ℂ + +noncomputable def coefficientPolynomial {K : ℕ} (a : Coefficients K) : ℂ[X] := + ∑ i : Fin (2 * K + 1), Polynomial.monomial i.val (a i) + +theorem coefficientPolynomial_coeff {K : ℕ} (a : Coefficients K) + (i : Fin (2 * K + 1)) : (coefficientPolynomial a).coeff i.val = a i := by + classical + simp [coefficientPolynomial, Polynomial.finsetSum_coeff, Polynomial.coeff_monomial, + Fin.val_inj] + +noncomputable def productCoefficient {K : ℕ} (a b : Coefficients K) (n : ℕ) : ℂ := + ∑ i : Fin (2 * K + 1), ∑ j : Fin (2 * K + 1), + if i.val + j.val = n then a i * b j else 0 + +theorem productCoefficient_eq {K : ℕ} (a b : Coefficients K) (n : ℕ) : + productCoefficient a b n = + (coefficientPolynomial a * coefficientPolynomial b).coeff n := by + classical + simp only [productCoefficient, coefficientPolynomial, Finset.sum_mul, Finset.mul_sum, + Polynomial.monomial_mul_monomial, Polynomial.finsetSum_coeff, Polynomial.coeff_monomial] + exact Finset.sum_comm + +theorem continuous_productCoefficient (K n : ℕ) : + Continuous (fun ab : Coefficients K × Coefficients K => + productCoefficient ab.1 ab.2 n) := by + classical + unfold productCoefficient + apply continuous_finsetSum + intro i _ + apply continuous_finsetSum + intro j _ + split_ifs <;> fun_prop + +noncomputable def lowCoefficients {K : ℕ} (ab : Coefficients K × Coefficients K) : + Coefficients K := fun n => productCoefficient ab.1 ab.2 n.val + +theorem continuous_lowCoefficients (K : ℕ) : Continuous (@lowCoefficients K) := + continuous_pi fun n => continuous_productCoefficient K n.val + +theorem lowCoefficients_ne_zero {K : ℕ} (ab : Coefficients K × Coefficients K) + (ha : ab.1 ⟨K, by omega⟩ ≠ 0) (hb : ab.2 ⟨K, by omega⟩ ≠ 0) : + lowCoefficients ab ≠ 0 := by + have ha' : (coefficientPolynomial ab.1).coeff K ≠ 0 := by + simpa using (coefficientPolynomial_coeff ab.1 ⟨K, by omega⟩).trans_ne ha + have hb' : (coefficientPolynomial ab.2).coeff K ≠ 0 := by + simpa using (coefficientPolynomial_coeff ab.2 ⟨K, by omega⟩).trans_ne hb + obtain ⟨n, hn, hne⟩ := product_has_low_nonzero_coeff K _ _ ha' hb' + intro h + have hz := congrFun h ⟨n, by omega⟩ + exact hne (by simpa [lowCoefficients, productCoefficient_eq] using hz) + +def admissibleCoefficients (K : ℕ) (D δ : ℝ) : Set (Coefficients K) := + {a | ∀ i, ‖a i‖ ≤ D} ∩ {a | δ ≤ ‖a ⟨K, by omega⟩‖} + +theorem isCompact_admissibleCoefficients (K : ℕ) (D δ : ℝ) : + IsCompact (admissibleCoefficients K D δ) := by + have hc : IsCompact {a : Coefficients K | ∀ i, ‖a i‖ ≤ D} := by + simpa [Set.pi, Metric.mem_closedBall, dist_zero_right] using + (isCompact_pi_infinite fun _ : Fin (2 * K + 1) => + isCompact_closedBall (0 : ℂ) D) + exact hc.inter_right (isClosed_le continuous_const (continuous_apply (⟨K, by omega⟩ : Fin (2 * K + 1))).norm) + +theorem uniform_product_coefficient_bound (K : ℕ) (D δ : ℝ) (hδ : 0 < δ) : + ∃ ε : ℝ, 0 < ε ∧ ∀ a b : Coefficients K, + (∀ i, ‖a i‖ ≤ D) → (∀ i, ‖b i‖ ≤ D) → + δ ≤ ‖a ⟨K, by omega⟩‖ → δ ≤ ‖b ⟨K, by omega⟩‖ → + ∃ n : Fin (2 * K + 1), ε ≤ ‖productCoefficient a b n.val‖ := by + classical + let S := (admissibleCoefficients K D δ).prod (admissibleCoefficients K D δ) + have hc : IsCompact S := (isCompact_admissibleCoefficients K D δ).prod + (isCompact_admissibleCoefficients K D δ) + by_cases hs : S.Nonempty + · obtain ⟨ab, hab, hmin⟩ := hc.exists_isMinOn hs + (continuous_lowCoefficients K).norm.continuousOn + have hpos : 0 < ‖lowCoefficients ab‖ := by + apply norm_pos_iff.mpr + apply lowCoefficients_ne_zero + · exact norm_pos_iff.mp (hδ.trans_le hab.1.2) + · exact norm_pos_iff.mp (hδ.trans_le hab.2.2) + refine ⟨‖lowCoefficients ab‖, hpos, ?_⟩ + intro a b ha hb ha0 hb0 + have hm : ‖lowCoefficients ab‖ ≤ ‖lowCoefficients (a, b)‖ := + hmin ⟨⟨ha, ha0⟩, ⟨hb, hb0⟩⟩ + by_contra hn + push Not at hn + have hlt : ‖lowCoefficients (a, b)‖ < ‖lowCoefficients ab‖ := + (pi_norm_lt_iff hpos).mpr hn + exact (not_lt_of_ge hm) hlt + · refine ⟨1, zero_lt_one, ?_⟩ + intro a b ha hb ha0 hb0 + exact False.elim (hs ⟨(a, b), ⟨⟨ha, ha0⟩, ⟨hb, hb0⟩⟩⟩) + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory +open scoped ENNReal +namespace FiniteFactor + +def unitIntervalMeasure : Measure ℝ := volume.restrict (Set.Ico 0 1) + +instance : IsProbabilityMeasure unitIntervalMeasure := by + constructor + simp [unitIntervalMeasure, Real.volume_Ico] + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory +open scoped ENNReal +namespace FiniteFactor + +def sourceKappa (s : ℕ) : ℝ := 1 / (100*((s : ℝ)+1)) + +end FiniteFactor +end +end + +section +noncomputable section +open Filter Finset +open scoped Topology +namespace FiniteFactor + +def sourceNextCutoff (m : ℕ) : ℕ := Nat.ceil ((m : ℝ)^((3/4 : ℝ)*(m : ℝ))) + +theorem sourceNextCutoff_large (m : ℕ) (hm : 100 ≤ m) : 2*m < sourceNextCutoff m := by + have hmR : (100 : ℝ) ≤ m := by exact_mod_cast hm + have hp : (m : ℝ)^2 ≤ (m : ℝ)^((3/4 : ℝ)*(m : ℝ)) := by + rw [← Real.rpow_natCast] + exact Real.rpow_le_rpow_of_exponent_le (by linarith) (by norm_num; linarith) + have hh := hp.trans (Nat.le_ceil _) + have hh2 : (2 : ℝ)*m < (sourceNextCutoff m : ℝ) := by + change (m : ℝ)^2 ≤ (sourceNextCutoff m : ℝ) at hh + nlinarith + exact_mod_cast hh2 + +theorem exists_source_block_length (R κ L G : ℝ) (hκ : 0 < κ) (hG : 0 < G) : + ∃ m : ℕ, R ≤ (m : ℝ) ∧ 100 ≤ m ∧ κ*(m : ℝ)^(1/40 : ℝ) ≥ L ∧ + G*(sourceNextCutoff m : ℝ) < (m : ℝ)^((4/5 : ℝ)*(m : ℝ)) := by + have ht : Tendsto (fun m : ℕ => (m : ℝ)^(1/40 : ℝ)) atTop atTop := + (tendsto_rpow_atTop (by norm_num)).comp tendsto_natCast_atTop_atTop + obtain ⟨m, hmR, hm100, hmG, hmκ⟩ := + ((tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop R)).and + ((eventually_ge_atTop (100 : ℕ)).and + ((tendsto_natCast_atTop_atTop.eventually (eventually_gt_atTop (2*G))).and + (ht.eventually (eventually_ge_atTop (L/κ)))))).exists + refine ⟨m, hmR, hm100, (div_le_iff₀ hκ).mp hmκ |>.trans_eq (mul_comm _ _), ?_⟩ + have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega) + have hm0 : (0 : ℝ) < m := lt_of_lt_of_le zero_lt_one hm1 + let A : ℝ := (m : ℝ)^((3/4 : ℝ)*(m : ℝ)) + have hApos : 0 < A := Real.rpow_pos_of_pos hm0 _ + have hA1 : 1 ≤ A := Real.one_le_rpow hm1 (by positivity) + have hceil : (sourceNextCutoff m : ℝ) ≤ 2*A := by + have hh := Nat.ceil_lt_add_one hApos.le + change (Nat.ceil A : ℝ) ≤ 2*A + linarith + calc + G*(sourceNextCutoff m : ℝ) ≤ G*(2*A) := mul_le_mul_of_nonneg_left hceil hG.le + _ < (m : ℝ)*A := by nlinarith + _ = (m : ℝ)^((3/4 : ℝ)*(m : ℝ)+1) := by rw [Real.rpow_add hm0, Real.rpow_one]; ring + _ ≤ (m : ℝ)^((4/5 : ℝ)*(m : ℝ)) := + Real.rpow_le_rpow_of_exponent_le hm1 (by + have hh : (100 : ℝ) ≤ m := by exact_mod_cast hm100 + linarith) + +structure SourceStageState where + K : ℕ + G : ℝ + d : ℕ + B : ℝ + previousL : ℝ + K_ge : 1 ≤ K + G_ge : 1 ≤ G + B_nonneg : 0 ≤ B + previousL_ge : 1 ≤ previousL + +def SourceStageState.D (a : SourceStageState) : ℝ := Real.exp (((a.K : ℝ)+1)*a.B) + +structure SourceStageChoice (s : ℕ) (a : SourceStageState) where + ε : ℝ + L : ℝ + Gnext : ℝ + m : ℕ + ε_pos : 0 < ε + polynomial : ∀ u v : Coefficients a.K, + (∀ i, ‖u i‖ ≤ a.D) → (∀ i, ‖v i‖ ≤ a.D) → + 1/((s : ℝ)+1) ≤ ‖u ⟨a.K, by omega⟩‖ → 1/((s : ℝ)+1) ≤ ‖v ⟨a.K, by omega⟩‖ → + ∃ n : Fin (2*a.K+1), ε ≤ ‖productCoefficient u v n.val‖ + L_ge : a.previousL ≤ L + decay : ((2*a.K : ℕ)+1 : ℝ)*3*Real.exp (-L/10000) ≤ ε/((s : ℝ)+1) + Gnext_ge : 1 ≤ Gnext + next_budget : sourceKappa (s+1) * Real.sqrt Gnext ≥ L + m_ge_K : a.K ≤ m + m_ge_pow : 2^(s+1) ≤ m + m_ge_G : 4*a.G ≤ (m : ℝ) + m_ge_100 : 100 ≤ m + previous_size : (a.d : ℝ) ≤ (m : ℝ)/100 + current_budget : sourceKappa s * (m : ℝ)^(1/40 : ℝ) ≥ L + next_gap : Gnext*(sourceNextCutoff m : ℝ) < (m : ℝ)^((4/5 : ℝ)*(m : ℝ)) + +theorem exists_sourceStageChoice (s : ℕ) (a : SourceStageState) : + Nonempty (SourceStageChoice s a) := by + have hs : 0 < (s : ℝ)+1 := by positivity + have hk (j : ℕ) : 0 < sourceKappa j := by unfold sourceKappa; positivity + obtain ⟨ε, hε, hp⟩ := uniform_product_coefficient_bound a.K a.D (1/((s : ℝ)+1)) (by positivity) + let target : ℝ := (ε/((s : ℝ)+1))/(((2*a.K : ℕ)+1 : ℝ)*3) + have ht : 0 < target := by dsimp [target]; positivity + obtain ⟨t, htL, htt⟩ := ((eventually_ge_atTop (a.previousL/10000)).and + (Real.tendsto_exp_neg_atTop_nhds_zero.eventually (gt_mem_nhds ht))).exists + let L : ℝ := 10000*t + have hL : a.previousL ≤ L := by dsimp [L]; linarith + have hLpos : 0 < L := lt_of_lt_of_le (by linarith [a.previousL_ge]) hL + let G : ℝ := (1+L/sourceKappa (s+1))^2 + have hG : 1 ≤ G := by dsimp [G]; nlinarith [div_pos hLpos (hk (s+1))] + have hbudget : L ≤ sourceKappa (s+1)*Real.sqrt G := by + rw [show Real.sqrt G = 1+L/sourceKappa (s+1) by + dsimp [G]; rw [Real.sqrt_sq (by linarith [div_pos hLpos (hk (s+1))])]] + rw [mul_add, mul_one, mul_div_cancel₀ _ (hk (s+1)).ne'] + linarith [hk (s+1)] + let R : ℝ := max (a.K : ℝ) (max ((2^(s+1) : ℕ) : ℝ) (max (4*a.G) (100*(a.d : ℝ)))) + obtain ⟨m, hmR, hm100, hmκ, hmgap⟩ := exists_source_block_length R (sourceKappa s) L G (hk s) (by linarith) + have hmK : (a.K : ℝ) ≤ m := (le_max_left _ _).trans hmR + have hm2 : (((2^(s+1) : ℕ)) : ℝ) ≤ m := (le_max_left _ _).trans ((le_max_right _ _).trans hmR) + have hmG : 4*a.G ≤ (m : ℝ) := (le_max_left _ _).trans + ((le_max_right _ _).trans ((le_max_right _ _).trans hmR)) + have hmd : 100*(a.d : ℝ) ≤ m := (le_max_right _ _).trans + ((le_max_right _ _).trans ((le_max_right _ _).trans hmR)) + refine ⟨⟨ε, L, G, m, hε, hp, hL, ?_, hG, hbudget, + by exact_mod_cast hmK, by exact_mod_cast hm2, hmG, hm100, by linarith, hmκ, hmgap⟩⟩ + have hden : 0 < (((2*a.K : ℕ)+1 : ℝ)*3) := by positivity + have htt' := (lt_div_iff₀ hden).mp htt + have he : -L/10000 = -t := by dsimp [L]; ring + rw [he] + nlinarith + +def selectedSourceStage (s : ℕ) (a : SourceStageState) : SourceStageChoice s a := + Classical.choice (exists_sourceStageChoice s a) + +def SourceStageChoice.C {s : ℕ} {a : SourceStageState} (b : SourceStageChoice s a) : ℝ := + max b.L ((a.K : ℝ)^2) + +def SourceStageChoice.next {s : ℕ} {a : SourceStageState} (b : SourceStageChoice s a) : SourceStageState where + K := sourceNextCutoff b.m + G := b.Gnext + d := a.d+b.m + B := a.B+b.C*(b.m : ℝ) + previousL := b.L + K_ge := by have := sourceNextCutoff_large b.m b.m_ge_100; omega + G_ge := b.Gnext_ge + B_nonneg := add_nonneg a.B_nonneg (mul_nonneg (le_max_of_le_right (sq_nonneg _)) (Nat.cast_nonneg _)) + previousL_ge := a.previousL_ge.trans b.L_ge + +def sourceStageState : ℕ → SourceStageState + | 0 => ⟨100, 1, 0, 0, 1, by norm_num, le_rfl, le_rfl, le_rfl⟩ + | s+1 => (selectedSourceStage s (sourceStageState s)).next + +def sourceStage (s : ℕ) : SourceStageChoice s (sourceStageState s) := + selectedSourceStage s (sourceStageState s) + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter +open scoped ENNReal +namespace FiniteFactor + +def coordinateFloor {ι : Type*} (θ : ι → ℝ) (k : ℤ) (x : ι → ℝ) (i : ι) : ℤ := + Int.floor (x i + (k : ℝ)*θ i) + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter +open scoped ENNReal +namespace FiniteFactor + +def coordinateRotate {ι : Type*} (θ : ι → ℝ) (k : ℤ) (x : ι → ℝ) (i : ι) : ℝ := + Int.fract (x i + (k : ℝ)*θ i) + +def sourceLog {ι : Type*} (θ c : ι → ℝ) (k : ℤ) (x : ι → ℝ) : ℝ := + ∑' i, c i * (coordinateFloor θ k x i : ℝ) + +def sourceCocycle {ι : Type*} (θ c : ι → ℝ) (k : ℤ) (x : ι → ℝ) : ℝ := + Real.exp (-sourceLog θ c k x) + +theorem sourceCocycle_pos {ι : Type*} (θ c : ι → ℝ) (k : ℤ) (x : ι → ℝ) : + 0 < sourceCocycle θ c k x := Real.exp_pos _ + +theorem sourceCocycle_measurable {ι : Type*} [Countable ι] + (θ c : ι → ℝ) (k : ℤ) : + @Measurable (ι → ℝ) ℝ + (@MeasurableSpace.pi ι (fun _ => ℝ) (fun _ => Real.measurableSpace)) + Real.measurableSpace (sourceCocycle θ c k) := by + apply Real.continuous_exp.measurable.comp + apply Measurable.neg + apply Measurable.tsum + intro i + have hm0 : Measurable (fun x : ι → ℝ => x i + (k : ℝ)*θ i) := + (measurable_pi_apply i).add measurable_const + have hm := Int.measurable_floor.comp hm0 + exact measurable_const.mul ((measurable_of_countable (fun z : ℤ => (z : ℝ))).comp hm) + +theorem sourceWeight_le_one {ι : Type*} (θ c : ι → ℝ) + (hθ : ∀ i, 0 ≤ θ i) (hc : ∀ i, 0 ≤ c i) {x : ι → ℝ} + (hx : ∀ i, x i ∈ Set.Ico 0 1) : sourceCocycle θ c 1 x ≤ 1 := by + apply Real.exp_le_one_iff.mpr + apply neg_nonpos.mpr + apply tsum_nonneg + intro i + apply mul_nonneg (hc i) + unfold coordinateFloor + exact_mod_cast Int.floor_nonneg.mpr (show 0 ≤ x i + (1 : ℤ)*θ i by simpa using add_nonneg (hx i).1 (hθ i)) + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter +open scoped ENNReal +namespace FiniteFactor + +abbrev sourceMeasure (ι : Type*) : Measure ((ι → ℝ) × ℤ) := + (Measure.infinitePi (fun _ : ι => unitIntervalMeasure)).prod Measure.count + +abbrev SourceHilbert (ι : Type*) : Type _ := Lp ℂ 2 (sourceMeasure ι) + +def sourceDiagonal {ι : Type*} (θ c : ι → ℝ) (z : (ι → ℝ) × ℤ) : ℂ := + sourceCocycle θ c 1 (coordinateRotate θ z.2 z.1) + +theorem sourceDiagonal_measurable {ι : Type*} [Countable ι] (θ c : ι → ℝ) : + Measurable (sourceDiagonal θ c) := by + apply Complex.measurable_ofReal.comp + apply (sourceCocycle_measurable θ c 1).comp + apply Measurable.of_eval + intro i + unfold coordinateRotate + fun_prop + +theorem sourceDiagonal_norm_le {ι : Type*} (θ c : ι → ℝ) + (hθ : ∀ i, 0 ≤ θ i) (hc : ∀ i, 0 ≤ c i) (z : (ι → ℝ) × ℤ) : + ‖sourceDiagonal θ c z‖ ≤ 1 := by + rw [sourceDiagonal, Complex.norm_real, Real.norm_of_nonneg (sourceCocycle_pos _ _ _ _).le] + apply sourceWeight_le_one θ c hθ hc + intro i + exact ⟨Int.fract_nonneg _, Int.fract_lt_one _⟩ + +theorem sourceDiagonal_memLp {ι : Type*} [Countable ι] (θ c : ι → ℝ) + (hθ : ∀ i, 0 ≤ θ i) (hc : ∀ i, 0 ≤ c i) : + MemLp (sourceDiagonal θ c) ∞ (sourceMeasure ι) := + memLp_top_of_bound (sourceDiagonal_measurable θ c).aestronglyMeasurable 1 + (Eventually.of_forall (sourceDiagonal_norm_le θ c hθ hc)) + +def sourceMultiplication {ι : Type*} [Countable ι] (θ c : ι → ℝ) + (hθ : ∀ i, 0 ≤ θ i) (hc : ∀ i, 0 ≤ c i) : SourceHilbert ι →L[ℂ] SourceHilbert ι := + (ContinuousLinearMap.mul ℂ ℂ).holderL (sourceMeasure ι) ∞ 2 2 + ((sourceDiagonal_memLp θ c hθ hc).toLp (sourceDiagonal θ c)) + +def sourceShiftIndex {ι : Type*} (z : (ι → ℝ) × ℤ) : (ι → ℝ) × ℤ := (z.1, z.2-1) + +theorem sourceShiftIndex_preserving (ι : Type*) : + MeasurePreserving (sourceShiftIndex (ι := ι)) (sourceMeasure ι) (sourceMeasure ι) := by + have hm : Measurable (fun k : ℤ => k-1) := measurable_of_countable _ + have hi : Function.Injective (fun k : ℤ => k-1) := by intro a b h; dsimp at h; omega + have hs : Function.Surjective (fun k : ℤ => k-1) := by intro k; exact ⟨k+1, by dsimp; omega⟩ + have hp : MeasurePreserving (fun k : ℤ => k-1) Measure.count Measure.count := by + refine ⟨hm, ?_⟩ + ext S hS + rw [Measure.map_apply hm hS, Measure.count_apply (hS.preimage hm), Measure.count_apply hS, + ← hi.encard_image, Set.image_preimage_eq S hs] + exact (MeasurePreserving.id _).prod hp + +def sourceShift (ι : Type*) : SourceHilbert ι →L[ℂ] SourceHilbert ι := + (Lp.compMeasurePreservingₗᵢ ℂ sourceShiftIndex (sourceShiftIndex_preserving ι)).toContinuousLinearMap + +def sourceOperator {ι : Type*} [Countable ι] (θ c : ι → ℝ) + (hθ : ∀ i, 0 ≤ θ i) (hc : ∀ i, 0 ≤ c i) : SourceHilbert ι →L[ℂ] SourceHilbert ι := + (sourceShift ι).comp (sourceMultiplication θ c hθ hc) + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter Finset +open scoped Topology ENNReal +namespace FiniteFactor +namespace CouplingParameters + +abbrev BlockCoordinate (m : ℕ → ℕ) := Σ s : ℕ, Fin (m s) + +end CouplingParameters +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter Finset +open scoped Topology ENNReal +namespace FiniteFactor + +def sourceBlockSize (s : ℕ) : ℕ := (sourceStage s).m +abbrev SourceCoordinate := CouplingParameters.BlockCoordinate sourceBlockSize + +def sourceLogWeight (i : SourceCoordinate) : ℝ := (sourceStage i.1).C + +def SourceAngles (θ : SourceCoordinate → ℝ) : Prop := + let realGroup : GroupWithZero ℝ := + (@DivisionRing.toDivisionSemiring ℝ Real.instField.toDivisionRing).toGroupWithZero + let realOrder : LE ℝ := @Preorder.toLE ℝ Real.partialOrder.toPreorder + ∀ i : SourceCoordinate, + let block : ℝ := @Nat.cast ℝ Real.instNatCast (sourceBlockSize i.1) + let cutoff : ℝ := @Nat.cast ℝ Real.instNatCast (sourceStageState i.1).K + let denominator : ℝ := @Mul.mul ℝ Real.instMul block cutoff + let lower : ℝ := + @Div.div ℝ realGroup.toDiv (@One.one ℝ Real.instOne) denominator + let upper : ℝ := + @Div.div ℝ realGroup.toDiv (@Nat.cast ℝ Real.instNatCast 2) denominator + @LE.le ℝ realOrder lower (θ i) ∧ @LE.le ℝ realOrder (θ i) upper + +theorem sourceBlockSize_pos (s : ℕ) : (0 : ℝ) < sourceBlockSize s := by + exact_mod_cast (show 0 < (sourceStage s).m by have := (sourceStage s).m_ge_100; omega) + +theorem sourceCutoff_pos (s : ℕ) : (0 : ℝ) < (sourceStageState s).K := by + exact_mod_cast (show 0 < (sourceStageState s).K by have := (sourceStageState s).K_ge; omega) + +theorem SourceAngles.nonneg {θ : SourceCoordinate → ℝ} (hθ : SourceAngles θ) + (i : SourceCoordinate) : + @LE.le ℝ (@Preorder.toLE ℝ Real.partialOrder.toPreorder) + (@Zero.zero ℝ Real.instZero) (θ i) := + let realGroup : GroupWithZero ℝ := + (@DivisionRing.toDivisionSemiring ℝ Real.instField.toDivisionRing).toGroupWithZero + let realOrder : Preorder ℝ := Real.partialOrder.toPreorder + let realStrict : @PosMulStrictMono ℝ Real.instMul Real.instZero realOrder := + @IsStrictOrderedRing.toPosMulStrictMono ℝ Real.semiring Real.partialOrder + Real.instIsStrictOrderedRing + let realReflect : @PosMulReflectLT ℝ Real.instMul Real.instZero realOrder := + @PosMulMono.toPosMulReflectLT ℝ Real.instMul Real.instZero Real.linearOrder + (@IsOrderedRing.toPosMulMono ℝ Real.semiring Real.partialOrder + Real.instIsOrderedRing) + let block : ℝ := @Nat.cast ℝ Real.instNatCast (sourceBlockSize i.1) + let cutoff : ℝ := @Nat.cast ℝ Real.instNatCast (sourceStageState i.1).K + let denominator : ℝ := @Mul.mul ℝ Real.instMul block cutoff + let lower : ℝ := + @Div.div ℝ realGroup.toDiv (@One.one ℝ Real.instOne) denominator + let upper : ℝ := + @Div.div ℝ realGroup.toDiv (@Nat.cast ℝ Real.instNatCast 2) denominator + let zeroReal : ℝ := @Zero.zero ℝ Real.instZero + @le_trans ℝ realOrder zeroReal lower (θ i) + (@le_of_lt ℝ realOrder zeroReal lower + ((@one_div_pos ℝ realGroup Real.partialOrder realReflect denominator).mpr + (@mul_pos ℝ realGroup.toMulZeroClass (a := block) (b := cutoff) + realOrder realStrict (sourceBlockSize_pos i.1) (sourceCutoff_pos i.1)))) + (@And.left + (@LE.le ℝ realOrder.toLE lower (θ i)) + (@LE.le ℝ realOrder.toLE (θ i) upper) + (hθ i)) + +theorem sourceLogWeight_nonneg (i : SourceCoordinate) : 0 ≤ sourceLogWeight i := + le_max_of_le_right (sq_nonneg _) + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter +open scoped ENNReal +namespace FiniteFactor + +def sourceVacuum : SourceHilbert SourceCoordinate := + @indicatorConstLp ((SourceCoordinate → ℝ) × ℤ) ℂ + (@Prod.instMeasurableSpace (SourceCoordinate → ℝ) ℤ + (@MeasurableSpace.pi SourceCoordinate (fun _ => ℝ) + (fun _ => Real.measurableSpace)) Int.instMeasurableSpace) + (sourceMeasure SourceCoordinate) Complex.instNormedAddCommGroup + (Set.univ ×ˢ {(0 : ℤ)}) + (@Nat.cast ENNReal + (ENNReal.instAddCommMonoidWithOne.toAddMonoidWithOne.toNatCast) + (Nat.succ (Nat.succ Nat.zero))) + (MeasurableSet.univ.prod (measurableSet_singleton (0 : ℤ))) + (letI : IsProbabilityMeasure unitIntervalMeasure := + ⟨(Measure.restrict_apply_univ + (μ := (volume : Measure ℝ)) (Set.Ico (0 : ℝ) 1)).trans + ((Real.volume_Ico (a := 0) (b := 1)).trans + ((congrArg ENNReal.ofReal (sub_zero (1 : ℝ))).trans + ENNReal.ofReal_one))⟩ + let base : Measure (SourceCoordinate → ℝ) := + Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) + let mass_one := + (Measure.prod_prod (μ := base) (ν := (Measure.count : Measure ℤ)) + Set.univ {(0 : ℤ)}).trans + ((congrArg₂ (fun left right : ℝ≥0∞ => left * right) + (measure_univ (μ := base)) + (Measure.count_singleton (0 : ℤ))).trans (one_mul (1 : ℝ≥0∞))) + fun mass_top => ENNReal.one_ne_top (mass_one.symm.trans mass_top)) (1 : ℂ) + +theorem sourceVacuum_norm : ‖sourceVacuum‖ = 1 := by + rw [sourceVacuum,norm_indicatorConstLp (by norm_num) (by norm_num)] + simp [measureReal_def,sourceMeasure,Measure.prod_prod] + +section + +local notation "vacuumMeasurable" => + @Prod.instMeasurableSpace (SourceCoordinate → ℝ) ℤ + (@MeasurableSpace.pi SourceCoordinate (fun _ => ℝ) + (fun _ => Real.measurableSpace)) Int.instMeasurableSpace +local notation "vacuumSemiring" => + Complex.instNormedField.toField.toCommRing.toRing.toSemiring +local notation "vacuumIdentity" => + @RingHom.id ℂ (@Semiring.toNonAssocSemiring ℂ vacuumSemiring) +local notation "vacuumHilbertGroup" => + @MeasureTheory.Lp.instNormedAddCommGroup + ((SourceCoordinate → ℝ) × ℤ) ℂ vacuumMeasurable + (@Nat.cast ENNReal + (ENNReal.instAddCommMonoidWithOne.toAddMonoidWithOne.toNatCast) + (Nat.succ (Nat.succ Nat.zero))) + (sourceMeasure SourceCoordinate) Complex.instNormedAddCommGroup + fact_one_le_two_ennreal +local notation "vacuumHilbertInner" => + @MeasureTheory.L2.innerProductSpace + ((SourceCoordinate → ℝ) × ℤ) ℂ ℂ Complex.instRCLike + vacuumMeasurable (sourceMeasure SourceCoordinate) + Complex.instNormedAddCommGroup (@RCLike.innerProductSpace ℂ Complex.instRCLike) +local notation "vacuumHilbertTopology" => + @UniformSpace.toTopologicalSpace (SourceHilbert SourceCoordinate) + (@PseudoMetricSpace.toUniformSpace (SourceHilbert SourceCoordinate) + (@MetricSpace.toPseudoMetricSpace (SourceHilbert SourceCoordinate) + (@NormedAddCommGroup.toMetricSpace (SourceHilbert SourceCoordinate) vacuumHilbertGroup))) +local notation "vacuumHilbertAddition" => + @AddCommGroup.toAddCommMonoid (SourceHilbert SourceCoordinate) + (@NormedAddCommGroup.toAddCommGroup (SourceHilbert SourceCoordinate) vacuumHilbertGroup) +local notation "vacuumHilbertModule" => + @NormedSpace.toModule ℂ (SourceHilbert SourceCoordinate) + (@DenselyNormedField.toNormedField ℂ + (@RCLike.toDenselyNormedField ℂ Complex.instRCLike)) + (@NormedAddCommGroup.toSeminormedAddCommGroup + (SourceHilbert SourceCoordinate) vacuumHilbertGroup) + (@InnerProductSpace.toNormedSpace ℂ (SourceHilbert SourceCoordinate) Complex.instRCLike + (@NormedAddCommGroup.toSeminormedAddCommGroup + (SourceHilbert SourceCoordinate) vacuumHilbertGroup) + vacuumHilbertInner) + +abbrev sourceVacuumFunctional + (operator : @ContinuousLinearMap ℂ ℂ vacuumSemiring vacuumSemiring vacuumIdentity + (SourceHilbert SourceCoordinate) vacuumHilbertTopology vacuumHilbertAddition + (SourceHilbert SourceCoordinate) vacuumHilbertTopology vacuumHilbertAddition + vacuumHilbertModule vacuumHilbertModule) : ℂ := + @inner ℂ (SourceHilbert SourceCoordinate) + (@InnerProductSpace.toInner ℂ (SourceHilbert SourceCoordinate) Complex.instRCLike + (@NormedAddCommGroup.toSeminormedAddCommGroup + (SourceHilbert SourceCoordinate) vacuumHilbertGroup) + vacuumHilbertInner) sourceVacuum + (@AddHom.toFun (SourceHilbert SourceCoordinate) (SourceHilbert SourceCoordinate) + (vacuumHilbertAddition).toAdd (vacuumHilbertAddition).toAdd + (@LinearMap.toAddHom ℂ ℂ vacuumSemiring vacuumSemiring vacuumIdentity + (SourceHilbert SourceCoordinate) (SourceHilbert SourceCoordinate) + vacuumHilbertAddition vacuumHilbertAddition vacuumHilbertModule vacuumHilbertModule + (@ContinuousLinearMap.toLinearMap ℂ ℂ vacuumSemiring vacuumSemiring vacuumIdentity + (SourceHilbert SourceCoordinate) vacuumHilbertTopology vacuumHilbertAddition + (SourceHilbert SourceCoordinate) vacuumHilbertTopology vacuumHilbertAddition + vacuumHilbertModule vacuumHilbertModule operator)) sourceVacuum) + +end + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter InnerProductSpace +open scoped ComplexInnerProductSpace Topology ENNReal CStarAlgebra +namespace FiniteFactor + +local instance : IsometricContinuousFunctionalCalculus ℝ + (SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate) IsSelfAdjoint := + IsSelfAdjoint.instIsometricContinuousFunctionalCalculus +instance productHilbertNontrivial : Nontrivial (SourceHilbert SourceCoordinate) := by + have hv : sourceVacuum≠0 := by + intro hz + have h := sourceVacuum_norm + rw [hz,norm_zero] at h + norm_num at h + exact ⟨⟨sourceVacuum,0,hv⟩⟩ + +end FiniteFactor +end +end + +section +noncomputable section +open MeasureTheory Filter InnerProductSpace +open scoped ComplexInnerProductSpace Topology +namespace FiniteFactor + +local notation "productMeasurable" => + @Prod.instMeasurableSpace (SourceCoordinate → ℝ) ℤ + (@MeasurableSpace.pi SourceCoordinate (fun _ => ℝ) + (fun _ => Real.measurableSpace)) Int.instMeasurableSpace +local notation "productSemiring" => + Complex.instNormedField.toField.toCommRing.toRing.toSemiring +local notation "productIdentity" => + @RingHom.id ℂ (@Semiring.toNonAssocSemiring ℂ productSemiring) +local notation "productExponent" => + @Nat.cast ENNReal + (ENNReal.instAddCommMonoidWithOne.toAddMonoidWithOne.toNatCast) + (Nat.succ (Nat.succ Nat.zero)) +local notation "productHilbertGroup" => + @MeasureTheory.Lp.instNormedAddCommGroup + ((SourceCoordinate → ℝ) × ℤ) ℂ productMeasurable + productExponent + (sourceMeasure SourceCoordinate) Complex.instNormedAddCommGroup + fact_one_le_two_ennreal +local notation "productHilbertInner" => + @MeasureTheory.L2.innerProductSpace + ((SourceCoordinate → ℝ) × ℤ) ℂ ℂ Complex.instRCLike + productMeasurable (sourceMeasure SourceCoordinate) + Complex.instNormedAddCommGroup (@RCLike.innerProductSpace ℂ Complex.instRCLike) +local notation "productHilbertTopology" => + @UniformSpace.toTopologicalSpace (SourceHilbert SourceCoordinate) + (@PseudoMetricSpace.toUniformSpace (SourceHilbert SourceCoordinate) + (@MetricSpace.toPseudoMetricSpace (SourceHilbert SourceCoordinate) + (@NormedAddCommGroup.toMetricSpace (SourceHilbert SourceCoordinate) productHilbertGroup))) +local notation "productHilbertAddition" => + @AddCommGroup.toAddCommMonoid (SourceHilbert SourceCoordinate) + (@NormedAddCommGroup.toAddCommGroup (SourceHilbert SourceCoordinate) productHilbertGroup) +local notation "productHilbertModule" => + @NormedSpace.toModule ℂ (SourceHilbert SourceCoordinate) + (@DenselyNormedField.toNormedField ℂ + (@RCLike.toDenselyNormedField ℂ Complex.instRCLike)) + (@NormedAddCommGroup.toSeminormedAddCommGroup + (SourceHilbert SourceCoordinate) productHilbertGroup) + (@InnerProductSpace.toNormedSpace ℂ (SourceHilbert SourceCoordinate) Complex.instRCLike + (@NormedAddCommGroup.toSeminormedAddCommGroup + (SourceHilbert SourceCoordinate) productHilbertGroup) + productHilbertInner) + +abbrev ProductOp := + @ContinuousLinearMap ℂ ℂ productSemiring productSemiring productIdentity + (SourceHilbert SourceCoordinate) productHilbertTopology productHilbertAddition + (SourceHilbert SourceCoordinate) productHilbertTopology productHilbertAddition + productHilbertModule productHilbertModule + +section +open MeasureTheory Filter InnerProductSpace +open scoped ComplexInnerProductSpace Topology ENNReal + +local instance : Module ℝ ProductOp := Module.complexToReal ProductOp +local instance : IsometricContinuousFunctionalCalculus ℝ ProductOp IsSelfAdjoint := + IsSelfAdjoint.instIsometricContinuousFunctionalCalculus + +def logarithmCutoff (n : ℕ) : C(ℝ,ℝ) where + toFun t := Real.log (max (Real.exp (-(n:ℝ))) t) + continuous_toFun := (continuous_const.max continuous_id).log + (fun _=>ne_of_gt ((Real.exp_pos _).trans_le (le_max_left _ _))) + +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +def FugledeKadisonDeterminant (τ : ProductOp → ℂ) (T : ProductOp) : ℝ≥0∞ := + let determinant := fun (Hilbert : Type) [NormedAddCommGroup Hilbert] + [InnerProductSpace ℂ Hilbert] [CompleteSpace Hilbert] [Nontrivial Hilbert] + (trace : (Hilbert →L[ℂ] Hilbert) → ℂ) (operator : Hilbert →L[ℂ] Hilbert) => + letI : Module ℝ (Hilbert →L[ℂ] Hilbert) := Module.complexToReal _ + letI : IsometricContinuousFunctionalCalculus ℝ (Hilbert →L[ℂ] Hilbert) + IsSelfAdjoint := IsSelfAdjoint.instIsometricContinuousFunctionalCalculus + ⨅ n : ℕ, ENNReal.ofReal + (Real.exp ((trace (cfc (logarithmCutoff n) (CFC.abs operator))).re)) + let domain := (SourceCoordinate → ℝ) × ℤ + let measurable : MeasurableSpace domain := productMeasurable + let exponent : ℝ≥0∞ := productExponent + let measure : @Measure domain measurable := sourceMeasure SourceCoordinate + let complete := @MeasureTheory.Lp.instCompleteSpace domain measurable exponent measure ℂ + Complex.instNormedAddCommGroup Complex.instCompleteSpace fact_one_le_two_ennreal + @determinant (SourceHilbert SourceCoordinate) productHilbertGroup productHilbertInner + complete productHilbertNontrivial τ T + +end + +section +open MeasureTheory Filter +open scoped ENNReal Topology + +def expLogPotential (μ : Measure ℂ) (z : ℂ) : ℝ≥0∞ := + ⨅ n : ℕ, ENNReal.ofReal (Real.exp (∫ w,logarithmCutoff n ‖z-w‖ ∂μ)) + +def IsBrownMeasure (τ : ProductOp → ℂ) (T : ProductOp) (μ : Measure ℂ) : Prop := + let translate := fun (Hilbert : Type) [NormedAddCommGroup Hilbert] + [NormedSpace ℂ Hilbert] (operator : Hilbert →L[ℂ] Hilbert) (scalar : ℂ) => + operator - algebraMap ℂ (Hilbert →L[ℂ] Hilbert) scalar + IsProbabilityMeasure μ ∧ IsCompact μ.support ∧ + ∀ z : ℂ, FugledeKadisonDeterminant τ + (@translate (SourceHilbert SourceCoordinate) productHilbertGroup + (@InnerProductSpace.toNormedSpace ℂ (SourceHilbert SourceCoordinate) Complex.instRCLike + (@NormedAddCommGroup.toSeminormedAddCommGroup + (SourceHilbert SourceCoordinate) productHilbertGroup) + productHilbertInner) T z) = expLogPotential μ z + +def ProductBrownClaim : Prop := + ∀ (θ : SourceCoordinate → ℝ) (hθ : SourceAngles θ), + IsBrownMeasure sourceVacuumFunctional + (sourceOperator θ sourceLogWeight hθ.nonneg sourceLogWeight_nonneg) (Measure.dirac 0) + +end + +end FiniteFactor +end +end + +namespace FiniteFactor + +/-- The Brown measure of the product weighted shift is the point mass at zero. -/ +theorem productBrown : ProductBrownClaim := by + sorry + +end FiniteFactor + +end OAI diff --git a/lean/ComparatorChallenges/ProjectionCounterexample.json b/lean/ComparatorChallenges/ProjectionCounterexample.json new file mode 100644 index 0000000000000000000000000000000000000000..4c1dc8409e152059847d8f8ba13dacecaded52d2 --- /dev/null +++ b/lean/ComparatorChallenges/ProjectionCounterexample.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ProjectionCounterexample", + "solution_module": "OAI.Geometry.ProjectionBody.Counterexample", + "theorem_names": [ + "OAI.ProjectionCounterexample.universal_simplex_upper_bound_false" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ProjectionCounterexample.lean b/lean/ComparatorChallenges/ProjectionCounterexample.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c8504059ca289b96e9f3a5ec84de35c58d0967a --- /dev/null +++ b/lean/ComparatorChallenges/ProjectionCounterexample.lean @@ -0,0 +1,45 @@ +import Mathlib.Analysis.Convex.Hull +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Analysis.InnerProductSpace.Projection.Basic +import Mathlib.Geometry.Euclidean.Volume.Measure + +namespace OAI + +noncomputable section + +open Set MeasureTheory +open scoped RealInnerProductSpace + +namespace ProjectionCounterexample + +abbrev E (d : ℕ) := EuclideanSpace ℝ (Fin d) + +def simplex (d : ℕ) : Set (E d) := + convexHull ℝ (insert 0 (range fun i : Fin d => EuclideanSpace.single i (1 : ℝ))) + +def IsConvexBody {d : ℕ} (P : Set (E d)) : Prop := + IsCompact P ∧ Convex ℝ P ∧ (interior P).Nonempty + +def project {d : ℕ} (u : E d) : E d →L[ℝ] E d := + (ℝ ∙ u)ᗮ.starProjection + +def projectionVolume {d : ℕ} (P : Set (E d)) (u : E d) : ℝ := + (Measure.euclideanHausdorffMeasure (d - 1) (project u '' P)).toReal + +def projectionBody {d : ℕ} (P : Set (E d)) : Set (E d) := + {x | ∀ u : E d, ‖u‖ = 1 → ⟪u, x⟫ ≤ projectionVolume P u} + +def bodyVolume {d : ℕ} (P : Set (E d)) : ℝ := (volume P).toReal + +def ratio {d : ℕ} (P : Set (E d)) : ℝ := + bodyVolume (projectionBody P) / bodyVolume P ^ (d - 1) + +theorem universal_simplex_upper_bound_false : + ¬ (∀ P : Set (E 20), IsConvexBody P → ratio P ≤ ratio (simplex 20)) := by + sorry + +end ProjectionCounterexample + +end + +end OAI diff --git a/lean/ComparatorChallenges/ProjectionMoments.json b/lean/ComparatorChallenges/ProjectionMoments.json new file mode 100644 index 0000000000000000000000000000000000000000..b04976339edbb4afb9b79fbf2769051203db02f4 --- /dev/null +++ b/lean/ComparatorChallenges/ProjectionMoments.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ProjectionMoments", + "solution_module": "OAI.Probability.ProjectionMoments.Main", + "theorem_names": [ + "OAI.ProjectionMoments.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ProjectionMoments.lean b/lean/ComparatorChallenges/ProjectionMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..3409d69fb128e6ace78dc4e603df8063b984384d --- /dev/null +++ b/lean/ComparatorChallenges/ProjectionMoments.lean @@ -0,0 +1,714 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +universe u + +namespace NoiselessRegression + +section + +abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d) + +abbrev UnitSphere (d : ℕ) := Metric.sphere (0 : Vector d) 1 + +abbrev State (M : ℕ) := Fin (2 ^ M) + +abbrev Samples (d T : ℕ) := Fin T → Vector d + +def uniformSphere (d : ℕ) : Measure (UnitSphere d) := + let σ := (volume : Measure (Vector d)).toSphere + (σ Set.univ)⁻¹ • σ + +def sampleLaw (d T : ℕ) : Measure (Samples d T) := + Measure.pi fun _ => stdGaussian (Vector d) + +def observationReference (d : ℕ) : Measure (Vector d × ℝ) := + (stdGaussian (Vector d)).prod volume + +structure Learner (d M T : ℕ) (Ω : Type u) where + initialChoice : Ω → Bool × State M + transition : ℕ → Ω → State M → (Vector d × ℝ) → Bool × State M + output : ℕ → Ω → State M → UnitSphere d + +namespace Learner + +abbrev RunStatus (M : ℕ) := Sum (State M) (ℕ × State M) + +def start {d M T : ℕ} {Ω : Type u} (L : Learner d M T Ω) (ω : Ω) : + RunStatus M := + let a := L.initialChoice ω + if a.1 then .inr (0, a.2) else .inl a.2 + +def run {d M T : ℕ} {Ω : Type u} (L : Learner d M T Ω) + (s : UnitSphere d) (ω : Ω) (x : Samples d T) : ℕ → RunStatus M + | 0 => L.start ω + | n + 1 => + match L.run s ω x n with + | .inr done => .inr done + | .inl state => + if hn : n < T then + let row := x ⟨n, hn⟩ + let a := L.transition (n + 1) ω state (row, ⟪row, s.val⟫) + if a.1 then .inr (n + 1, a.2) else .inl a.2 + else .inl state + +def terminal {d M T : ℕ} {Ω : Type u} (L : Learner d M T Ω) + (s : UnitSphere d) (ω : Ω) (x : Samples d T) : ℕ × State M := + match L.run s ω x T with + | .inl state => (T, state) + | .inr done => done + +def estimate {d M T : ℕ} {Ω : Type u} (L : Learner d M T Ω) + (s : UnitSphere d) (ω : Ω) (x : Samples d T) : UnitSphere d := + let a := L.terminal s ω x + L.output a.1 ω a.2 + +structure Admissible {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] + (L : Learner d M T Ω) (ρ : Measure Ω) : Prop where + initialChoice : AEMeasurable L.initialChoice ρ + transition : ∀ t a, AEMeasurable (fun z : Ω × (Vector d × ℝ) => + L.transition t z.1 a z.2) (ρ.prod (observationReference d)) + output : ∀ t a, AEMeasurable (fun ω => L.output t ω a) ρ + fixed_experiment : ∀ s, AEMeasurable (fun z : Ω × Samples d T => + L.estimate s z.1 z.2) (ρ.prod (sampleLaw d T)) + uniform_experiment : AEMeasurable + (fun z : UnitSphere d × (Ω × Samples d T) => L.estimate z.1 z.2.1 z.2.2) + ((uniformSphere d).prod (ρ.prod (sampleLaw d T))) + +def angularError {d : ℕ} (s ŝ : UnitSphere d) : ℝ := + Real.arccos ⟪ŝ.val, s.val⟫ + +def uniformSuccess {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] + (L : Learner d M T Ω) (ρ : Measure Ω) (ε : ℝ) : ℝ≥0∞ := + ((uniformSphere d).prod (ρ.prod (sampleLaw d T))) + {z | angularError z.1 (L.estimate z.1 z.2.1 z.2.2) ≤ ε} + +end Learner + +open scoped Topology + +open InnerProductSpace + +section SphereBounds + +open scoped Pointwise + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def sphereLaw : Measure (Metric.sphere (0 : E) 1) := + let σ := (volume : Measure E).toSphere + (σ Set.univ)⁻¹ • σ + +end SphereBounds + +open scoped Pointwise + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def ambientSphereLaw : Measure E := (sphereLaw (E := E)).map Subtype.val + +end + +section + +section + +variable {d M T : ℕ} {Ω : Type u} + +abbrev Learner.TaggedState (M T : ℕ) := Sum (State M) (Fin (T+1) × State M) + +instance Learner.taggedMeasurableSpace : MeasurableSpace (TaggedState M T) := ⊤ + +def Learner.taggedStart (a : Bool × State M) : TaggedState M T := + if a.1 then .inr (⟨0,by omega⟩,a.2) else .inl a.2 + +end + +open MeasureTheory ProbabilityTheory Set Filter + +open scoped ENNReal NNReal RealInnerProductSpace + +variable {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] + +structure Learner.MeasurableRules (L : Learner d M T Ω) : Prop where + initial : Measurable L.initialChoice + transition : ∀ t j, Measurable (fun z : Ω × (Vector d × ℝ) => L.transition t z.1 j z.2) + output : ∀ t j, Measurable (fun ω => L.output t ω j) + +end + +open MeasureTheory ProbabilityTheory Set Filter + +open scoped ENNReal NNReal RealInnerProductSpace + +structure FiniteKernelLearner (d M T : ℕ) where + initial : Measure (Bool × State M) + initial_probability : IsProbabilityMeasure initial + transition : ℕ → State M → (Vector d × ℝ) → Measure (Bool × State M) + transition_probability : ∀ t j obs, IsProbabilityMeasure (transition t j obs) + output : ℕ → State M → Measure (UnitSphere d) + output_probability : ∀ t j, IsProbabilityMeasure (output t j) + +namespace FiniteKernelLearner + +variable {d M T : ℕ} + +structure CompletedRules (K : FiniteKernelLearner d M T) : Prop where + transition : ∀ t j a, AEMeasurable (fun obs => K.transition t j obs {a}) (observationReference d) + +end FiniteKernelLearner + +open MeasureTheory ProbabilityTheory Set Filter unitInterval + +section CoinRun + +variable {J O : Type*} [Fintype J] [MeasurableSpace J] [MeasurableSingletonClass J] + [MeasurableSpace O] + +def kernelRun (P : ℕ → J → O → Measure J) : (n : ℕ) → J → (Fin n → O) → Measure J + | 0, j, _ => Measure.dirac j + | n+1, j, obs => (kernelRun P n j (Fin.init obs)).bind (fun a => P (n+1) a (obs (Fin.last n))) + +end CoinRun + +section + +section + +open Learner + +variable {d M T : ℕ} + +abbrev FiniteKernelLearner.Tape (M T : ℕ) := (Bool × State M) × ((Fin T → I) × I) + +def FiniteKernelLearner.destination (t : ℕ) (h : t ≤ T) (a : Bool × State M) : TaggedState M T := + if a.1 then .inr (⟨t,by omega⟩,a.2) else .inl a.2 + +def FiniteKernelLearner.taggedKernel (K : FiniteKernelLearner d M T) (t : ℕ) : + TaggedState M T → (Vector d × ℝ) → Measure (TaggedState M T) + | .inr a, _ => Measure.dirac (.inr a) + | .inl j, obs => if ht : t ≤ T then (K.transition t j obs).map (destination t ht) + else Measure.dirac (.inl j) + +def FiniteKernelLearner.terminalOutput (K : FiniteKernelLearner d M T) : TaggedState M T → Measure (UnitSphere d) + | .inl j => K.output T j + | .inr (t,j) => K.output t j + +end + +open MeasureTheory ProbabilityTheory Set Filter unitInterval + +open scoped ENNReal NNReal RealInnerProductSpace + +open Learner + +variable {d M T : ℕ} + +abbrev FiniteKernelLearner.Result (d M : ℕ) := (ℕ × State M) × UnitSphere d + +def FiniteKernelLearner.terminalTag : TaggedState M T → ℕ × State M + | .inl j => (T,j) + | .inr (t,j) => (t,j) + +def FiniteKernelLearner.terminalJointOutput (K : FiniteKernelLearner d M T) (j : TaggedState M T) : Measure (Result d M) := + (K.terminalOutput j).map (fun y => (terminalTag j,y)) + +def FiniteKernelLearner.jointExperimentLaw (K : FiniteKernelLearner d M T) (obs : Fin T → (Vector d × ℝ)) : Measure (Result d M) := + K.initial.bind (fun a => (kernelRun K.taggedKernel T (taggedStart a) obs).bind K.terminalJointOutput) + +def FiniteKernelLearner.uniformSuccess (K : FiniteKernelLearner d M T) (ε : ℝ) : ℝ≥0∞ := + ∫⁻ z : UnitSphere d × Samples d T, + K.jointExperimentLaw (fun i => (z.2 i,⟪z.1.val,z.2 i⟫)) + {r | angularError z.1 r.2 ≤ ε} ∂((uniformSphere d).prod (sampleLaw d T)) + +def FiniteKernelLearner.uniformFixedSuccess (K : FiniteKernelLearner d M T) (ε : ℝ) (t : ℕ) : ℝ≥0∞ := + ∫⁻ z : UnitSphere d × Samples d T, + K.jointExperimentLaw (fun i => (z.2 i,⟪z.1.val,z.2 i⟫)) + {r | r.1.1 = t ∧ angularError z.1 r.2 ≤ ε} ∂((uniformSphere d).prod (sampleLaw d T)) + +end + +section + +open MeasureTheory ProbabilityTheory Set Filter + +open scoped ENNReal NNReal RealInnerProductSpace + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Nontrivial E] + +variable {d M T : ℕ} {Ω : Type u} + +def Learner.uniformFixedSuccess [MeasurableSpace Ω] (L : Learner d M T Ω) (ρ : Measure Ω) + (ε : ℝ) (t : ℕ) : ℝ≥0∞ := + ((uniformSphere d).prod (ρ.prod (sampleLaw d T))) + {z | (L.terminal z.1 z.2.1 z.2.2).1 = t ∧ angularError z.1 (L.estimate z.1 z.2.1 z.2.2) ≤ ε} + +end + +section + +variable {d M T : ℕ} + +def FiniteKernelLearner.seededSuccess {Ξ : Type u} [MeasurableSpace Ξ] + (K : Ξ → FiniteKernelLearner d M T) (ρ : Measure Ξ) (ε : ℝ) : ℝ≥0∞ := + ∫⁻ ξ, (K ξ).uniformSuccess ε ∂ρ + +def FiniteKernelLearner.seededFixedSuccess {Ξ : Type u} [MeasurableSpace Ξ] + (K : Ξ → FiniteKernelLearner d M T) (ρ : Measure Ξ) (ε : ℝ) (t : ℕ) : ℝ≥0∞ := + ∫⁻ ξ, (K ξ).uniformFixedSuccess ε t ∂ρ + +def FiniteKernelLearner.FixedQuadraticMemory : Prop := + ∀ A₀ : ℝ, 0 < A₀ → ∃ c : ℝ, 0 < c ∧ ∃ d₀ : ℕ, + ∀ d : ℕ, d₀ ≤ d → ∀ M T : ℕ, (M : ℝ) ≤ A₀ * (d : ℝ)^2 → + ∀ ε : ℝ, 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d M T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + (2/3 : ℝ≥0∞) ≤ seededSuccess K ρ ε → + c*(d:ℝ)*Real.log (1/ε) ≤ (T:ℝ) + +end + +open MeasureTheory ProbabilityTheory Set Filter + +open scoped ENNReal NNReal RealInnerProductSpace + +variable {d M T : ℕ} {Ξ : Type u} [MeasurableSpace Ξ] + +def FiniteKernelLearner.conditionalSuccess (K : FiniteKernelLearner d M T) (ε : ℝ) + (s : UnitSphere d) (x : Samples d T) : ℝ≥0∞ := + K.jointExperimentLaw (fun i => (x i,⟪s.val,x i⟫)) {r | Learner.angularError s r.2 ≤ ε} + +def FiniteKernelLearner.seededPointwiseSuccess (K : Ξ → FiniteKernelLearner d M T) (ρ : Measure Ξ) + (ε : ℝ) (s : UnitSphere d) : ℝ≥0∞ := + ∫⁻ z : Ξ × Samples d T, (K z.1).conditionalSuccess ε s z.2 ∂ρ.prod (sampleLaw d T) + +def FiniteKernelLearner.JointSuccessMeasurable (K : Ξ → FiniteKernelLearner d M T) (ρ : Measure Ξ) (ε : ℝ) : Prop := + AEMeasurable (fun z : UnitSphere d × (Ξ × Samples d T) => + (K z.2.1).conditionalSuccess ε z.1 z.2.2) + ((uniformSphere d).prod (ρ.prod (sampleLaw d T))) + +def FiniteKernelLearner.SubquadraticMemoryWithPointwise : Prop := + ∃ c : ℝ, 0 < c ∧ ∀ M : ℕ → ℕ, + Asymptotics.IsLittleO atTop (fun d => (M d : ℝ)) (fun d => (d:ℝ)^2) → + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d (M d) T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + ((2/3 : ℝ≥0∞) ≤ seededSuccess K ρ ε ∨ + (JointSuccessMeasurable K ρ ε ∧ ∀ s, (2/3 : ℝ≥0∞) ≤ seededPointwiseSuccess K ρ ε s)) → + c*(d:ℝ)*Real.log (1/ε) ≤ (T:ℝ) + +end NoiselessRegression + +namespace ProjectionMoments + +open NoiselessRegression NoiselessRegression.FiniteKernelLearner + +section + +section GaussianGraph + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def vectorSmoothing (ν : Measure E) (m : ℕ) (φ : (Fin m → ℝ) → ℝ≥0∞) + (z : (Fin m → E) × (Fin m → ℝ)) : ℝ≥0∞ := + ∫⁻ t, φ (fun j => z.2 j - ⟪t, z.1 j⟫) ∂ν + +abbrev Label (m : ℕ) := EuclideanSpace ℝ (Fin m) + +def ballKernel (m : ℕ) (η : ℝ) (y : Fin m → ℝ) : ℝ≥0∞ := + (Metric.closedBall (0 : Label m) η).indicator + (fun _ => (volume (Metric.closedBall (0 : Label m) η))⁻¹) (WithLp.toLp 2 y) + +def rowMap {m : ℕ} (A : Fin m → E) : E →L[ℝ] Label m := + (PiLp.continuousLinearEquiv 2 ℝ (fun _ : Fin m => ℝ)).symm.toContinuousLinearMap.comp + (ContinuousLinearMap.pi (fun j => innerSL ℝ (A j))) + +def ballAverage (ν : Measure E) (m : ℕ) (η : ℝ) + (z : (Fin m → E) × Label m) : ℝ≥0∞ := + vectorSmoothing ν m (ballKernel m η) (z.1, WithLp.ofLp z.2) + +def lowerDensity (ν : Measure E) (m : ℕ) (z : (Fin m → E) × Label m) : ℝ≥0∞ := + liminf (fun n : ℕ => ballAverage ν m ((n : ℝ) + 1)⁻¹ z) atTop + +def AllBallMass (ν : Measure E) (K a : ℝ) : Prop := + ∀ b : E, ∀ t : ℝ, 0 < t → ν (Metric.closedBall b t) ≤ ENNReal.ofReal (K * t ^ a) + +end GaussianGraph + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +section Rotations + +variable (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +abbrev Rotation := unitary (E →L[ℝ] E) + +instance rotationMeasurableSpace : MeasurableSpace (Rotation E) := borel (Rotation E) + +instance rotationBorelSpace : BorelSpace (Rotation E) := ⟨rfl⟩ + +instance rotationCompact : CompactSpace (Rotation E) := by + apply isCompact_iff_compactSpace.mp + apply Metric.isCompact_of_isClosed_isBounded isClosed_unitary + apply (Metric.isBounded_closedBall (x := (0 : E →L[ℝ] E)) (r := 1)).subset (s := (unitary (E →L[ℝ] E) : Set (E →L[ℝ] E))) + intro U hU + rw [Metric.mem_closedBall, dist_zero_right] + by_cases h : Subsingleton E + · have := h + simp + · have : Nontrivial E := not_subsingleton_iff_nontrivial.mp h + exact (CStarRing.norm_of_mem_unitary hU).le + +def rotationLaw : Measure (Rotation E) := + ((Measure.haar : Measure (Rotation E)) Set.univ)⁻¹ • Measure.haar + +variable {E} + +variable [MeasurableSpace E] [BorelSpace E] + +def rotateRows {ι : Type*} (O : Rotation E) (v : ι → E) : ι → E := + fun i => (O : E →L[ℝ] E) (v i) + +end Rotations + +section Triangular + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + +def coordinateMap {m : ℕ} (A : Fin m → E) : E →ₗ[ℝ] (Fin m → ℝ) := + (WithLp.linearEquiv 2 ℝ (Fin m → ℝ)) ∘ₗ (rowMap A).toLinearMap + +def coordinateDensity (ν : Measure E) (m : ℕ) (z : (Fin m → E) × (Fin m → ℝ)) : ℝ≥0∞ := + lowerDensity ν m (z.1, WithLp.toLp 2 z.2) + +def frameLaw {m : ℕ} (u : Fin m → E) : Measure (Fin m → E) := + (rotationLaw E).map (fun O => rotateRows O u) + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +def rieszKernel (α : ℝ) (z s : E) : ℝ≥0∞ := (ENNReal.ofReal ‖s-z‖)^(-α) + +def rieszPotential (α : ℝ) (h : E → ℝ≥0∞) : ℝ≥0∞ := + ⨆ z : E, ∫⁻ s, h s*rieszKernel α z s ∂NoiselessRegression.ambientSphereLaw + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace Matrix + +open scoped ENNReal NNReal RealInnerProductSpace Topology MatrixOrder Matrix.Norms.L2Operator + +def mixRows {k : ℕ} (M : Matrix (Fin k) (Fin k) ℝ) (X : Fin k → E) : Fin k → E := + fun i => ∑ j, M i j • X j + +def polarRadial {k : ℕ} (X : Fin k → E) : Matrix (Fin k) (Fin k) ℝ := + CFC.sqrt (Matrix.gram ℝ X) + +def rawPolarRows {k : ℕ} (X : Fin k → E) : Fin k → E := + mixRows (polarRadial X)⁻¹ X + +def polarRows {k : ℕ} (u X : Fin k → E) : Fin k → E := by + classical + exact if LinearIndependent ℝ X then rawPolarRows X else u + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +def unitBallVolume (k : ℕ) : ℝ≥0∞ := (volume : Measure (Label k)) (Metric.closedBall 0 1) + +def unitBallLaw (k : ℕ) : Measure (Label k) := + (unitBallVolume k)⁻¹ • volume.restrict (Metric.closedBall 0 1) + +def normalizedDensity (ν : Measure E) (k : ℕ) (u : Fin k → E) + (z : (Fin k → E) × Label k) : ℝ≥0∞ := + unitBallVolume k * lowerDensity ν k (polarRows u z.1,z.2) + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +def sphereWeightedRestriction (h : E → ℝ≥0∞) (H : Set E) : Measure E := + (NoiselessRegression.ambientSphereLaw.withDensity h).restrict H + +end Triangular + +section + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +variable {E : Type u} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def capMeasure (c : E) (r : ℝ) : Measure E := + (NoiselessRegression.ambientSphereLaw (Metric.closedBall c r))⁻¹ • + NoiselessRegression.ambientSphereLaw.restrict (Metric.closedBall c r) + +structure CapDictionary (c : E) (r α : ℝ) where + I : Type u + countable : Countable I + center : I → E + radius : I → ℝ + center_norm : ∀ i, ‖center i‖ = 1 + radius_pos : ∀ i, 0 < radius i + radius_le : ∀ i, radius i ≤ r + parent : I + parent_center : center parent = c + parent_radius : radius parent = r + proper : ∀ R : ℝ, {i | (r/radius i)^α ≤ R}.Finite + cover : ∀ (s : E), ‖s‖ = 1 → ∀ t : ℝ, 0 < t → t ≤ 1/4 → + ∃ i, 4*r*t ≤ radius i ∧ radius i < 8*r*t ∧ dist s (center i) ≤ radius i/2 + +end + +section + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace Matrix + +open scoped ENNReal NNReal RealInnerProductSpace Topology + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def radialLabel {k : ℕ} (X : Fin k → E) (y : Label k) : Label k := + WithLp.toLp 2 (polarRadial X *ᵥ y.ofLp) + +def capKernelValue {k : ℕ} (K : (Fin k → E) × Label k → ℝ≥0∞) (s : E) : ℝ≥0∞ := + ∫⁻ X, K (X,rowMap X s) ∂Measure.pi (fun _ => stdGaussian E) + +def capReferenceLabel {k : ℕ} (c : E) (r : ℝ) (X : Fin k → E) (z : Label k) : Label k := + rowMap X c + r • radialLabel X z + +def capReference {k : ℕ} (K : (Fin k → E) × Label k → ℝ≥0∞) (c : E) (r : ℝ) : ℝ≥0∞ := + ∫⁻ X, ∫⁻ z, K (X,capReferenceLabel c r X z) ∂unitBallLaw k ∂Measure.pi (fun _ => stdGaussian E) + +end + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def fractionalBlock {J : Type*} [Fintype J] {k : ℕ} + (Q : J → (Fin k → E) × Label k → ℝ≥0∞) (f : J → E → ℝ≥0∞) (s : E) : ℝ≥0∞ := + ∫⁻ X, ∑ j, Q j (X,rowMap X s)*f j s ∂Measure.pi (fun _ => stdGaussian E) + +end + +def IntegratedFrameMoment : Prop := + ∃ C : ℝ, 1 ≤ C ∧ ∀ (d k q : ℕ) (β K R : ℝ) + (ν : Measure (EuclideanSpace ℝ (Fin d))) [IsFiniteMeasure ν] + (z : EuclideanSpace ℝ (Fin d)) (u : Fin k → EuclideanSpace ℝ (Fin d)), + 1 ≤ k → 2 ≤ q → k+q ≤ d → 0 < β → β ≤ d → + 1 ≤ β-k-((q:ℝ)-2) → 0 ≤ K → 0 < R → + ν.support ⊆ Metric.closedBall z R → AllBallMass ν K β → + Orthonormal ℝ u → + (∀ᵐ A ∂frameLaw u, ν.map (coordinateMap A) ≪ (volume : Measure (Fin k → ℝ))) → + Measurable (coordinateDensity ν k) ∧ + (∀ᵐ A ∂frameLaw u, + (volume : Measure (Fin k → ℝ)).withDensity (fun y => coordinateDensity ν k (A,y)) = + ν.map (coordinateMap A)) ∧ + (∀ (A : Fin k → EuclideanSpace ℝ (Fin d)), Orthonormal ℝ A → + ∀ y : Fin k → ℝ, + R < ‖WithLp.toLp 2 (y-coordinateMap A z)‖ → coordinateDensity ν k (A,y) = 0) ∧ + (∫⁻ A, ∫⁻ y : Fin k → ℝ, coordinateDensity ν k (A,y)^q ∂volume ∂frameLaw u) ^ (1/(q:ℝ)) ≤ + ENNReal.ofReal (C^d * (C*Real.sqrt d)^((k:ℝ)*(1-1/(q:ℝ))) * + K * R^(β-(k:ℝ)*(1-1/(q:ℝ)))) + +def NormalizedUnitBallMoment : Prop := + ∀ D : ℝ, 0 < D → + ∃ C_D : ℝ, 0 < C_D ∧ ∀ d : ℕ, 32 ≤ d → + let k := d/16 + let lam : ℝ := ((d:ℝ)-1)/2 + ∀ (ν : Measure (EuclideanSpace ℝ (Fin d))) [IsFiniteMeasure ν] + (u : Fin k → EuclideanSpace ℝ (Fin d)), + ν Set.univ ≤ 1 → ν.support ⊆ Metric.closedBall 0 1 → + AllBallMass ν (D^d) lam → Orthonormal ℝ u → + (∀ᵐ X ∂Measure.pi (fun _ : Fin k => stdGaussian (EuclideanSpace ℝ (Fin d))), + ν.map (rowMap (polarRows u X)) ≪ (volume : Measure (Label k))) → + Measurable (normalizedDensity ν k u) ∧ + (∀ᵐ X ∂Measure.pi (fun _ : Fin k => stdGaussian (EuclideanSpace ℝ (Fin d))), + ((unitBallVolume k)⁻¹ • (volume : Measure (Label k))).withDensity + (fun y => normalizedDensity ν k u (X,y)) = ν.map (rowMap (polarRows u X))) ∧ + (∀ X y, 1 < ‖y‖ → normalizedDensity ν k u (X,y) = 0) ∧ + (∫⁻ X, ∫⁻ y, normalizedDensity ν k u (X,y)^k ∂unitBallLaw k + ∂Measure.pi (fun _ => stdGaussian (EuclideanSpace ℝ (Fin d)))) ≤ + ENNReal.ofReal (Real.exp (C_D*d*k)) + +def AllRadiiSphereMoment : Prop := + ∃ C : ℝ, 1 ≤ C ∧ ∀ d : ℕ, 16 ≤ d → + let k := d/4 + let β : ℝ := (d:ℝ)-1-k + ∀ f : EuclideanSpace ℝ (Fin d) → ℝ≥0∞, + Measurable f → (∀ s, f s ≤ 1) → + ∀ K : ℝ, 0 ≤ K → + AllBallMass (NoiselessRegression.ambientSphereLaw.withDensity f) K β → + ∀ z : EuclideanSpace ℝ (Fin d), ∀ R : ℝ, 0 < R → + ∀ u : Fin k → EuclideanSpace ℝ (Fin d), Orthonormal ℝ u → + let μ := sphereWeightedRestriction f (Metric.closedBall z R) + Measurable (coordinateDensity μ k) ∧ + (∀ A : Fin k → EuclideanSpace ℝ (Fin d), Orthonormal ℝ A → + (volume : Measure (Fin k → ℝ)).withDensity (fun y => coordinateDensity μ k (A,y)) = + μ.map (coordinateMap A)) ∧ + (∀ A : Fin k → EuclideanSpace ℝ (Fin d), Orthonormal ℝ A → + ∀ y : Fin k → ℝ, R < ‖WithLp.toLp 2 (y-coordinateMap A z)‖ → + coordinateDensity μ k (A,y) = 0) ∧ + (∫⁻ A, ∫⁻ y : Fin k → ℝ, coordinateDensity μ k (A,y)^k ∂volume ∂frameLaw u) ^ (1/(k:ℝ)) ≤ + ENNReal.ofReal (C^d*(C*Real.sqrt d)^((k:ℝ)*(1-1/(k:ℝ)))* + K*R^(β-(k:ℝ)*(1-1/(k:ℝ)))) + +def PositiveCapDomination : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ d : ℕ, 32 ≤ d → + let k := d/16 + let α : ℝ := ((d:ℝ)-1)/2 + ∀ (c : EuclideanSpace ℝ (Fin d)), ‖c‖ = 1 → + ∀ r : ℝ, 0 < r → r ≤ 2 → ∀ N : ℕ, + ∀ K : Fin N → (Fin k → EuclideanSpace ℝ (Fin d)) × Label k → ℝ≥0∞, + (∀ j, Measurable (K j)) → (∀ z, ∑ j, K j z ≤ 1) → + (∑ j, capReference (K j) c r) ≤ 1 ∧ + ∀ j, ∃ D : CapDictionary c r α, ∃ a : D.I → ℝ, + (∀ i, 0 ≤ a i) ∧ Summable (fun i => a i*(r/D.radius i)^α) ∧ + (∑' i, a i*(r/D.radius i)^α) ≤ Real.exp (C*d)*(capReference (K j) c r).toReal^(1-1/(k:ℝ)) ∧ + (capMeasure c r).withDensity (capKernelValue (K j)) ≤ + Measure.sum (fun i => ENNReal.ofReal (a i) • capMeasure (D.center i) (D.radius i)) ∧ + (Measure.sum (fun i => ENNReal.ofReal (a i) • capMeasure (D.center i) (D.radius i))) Set.univ < ∞ + +def DeterministicOffsetDensity : Prop := + ∃ C : ℝ, 1 ≤ C ∧ ∀ d : ℕ, 16 ≤ d → + let k := d/8 + let α : ℝ := (d:ℝ)/2 + ∀ h : EuclideanSpace ℝ (Fin d) → ℝ≥0∞, Measurable h → (∀ s, h s ≤ 1) → + ∀ z : EuclideanSpace ℝ (Fin d), ∀ ρ : ℝ, 0 < ρ → + ∀ H : Set (EuclideanSpace ℝ (Fin d)), MeasurableSet H → H ⊆ Metric.closedBall z ρ → + rieszPotential α h < ∞ ∧ + Measurable (lowerDensity (sphereWeightedRestriction h H) k) ∧ + (∀ A : Fin k → EuclideanSpace ℝ (Fin d), LinearIndependent ℝ A → + volume.withDensity (fun y => lowerDensity (sphereWeightedRestriction h H) k (A,y)) = + (sphereWeightedRestriction h H).map (rowMap A)) ∧ + (∀ b : Label k, (∫⁻ A, (lowerDensity (sphereWeightedRestriction h H) k (A,rowMap A z+b))^k + ∂Measure.pi (fun _ => stdGaussian (EuclideanSpace ℝ (Fin d))))^(1/(k:ℝ)) ≤ + ENNReal.ofReal (C^d) * rieszPotential α h * ENNReal.ofReal (ρ^(α-k))) ∧ + (∀ A y, ‖rowMap A‖*ρ < ‖y-rowMap A z‖ → + lowerDensity (sphereWeightedRestriction h H) k (A,y) = 0) + +def AllRadiiBlockBound : Prop := + ∃ C : ℝ, 1 ≤ C ∧ ∀ d : ℕ, 16 ≤ d → + let k := d/4 + let β : ℝ := (d:ℝ)-1-k + ∀ N : ℕ, ∀ f : Fin N → EuclideanSpace ℝ (Fin d) → ℝ≥0∞, + (∀ j, Measurable (f j)) → (∀ j s, f j s ≤ 1) → + ∀ K : ℝ, 0 ≤ K → + (∀ j, AllBallMass (NoiselessRegression.ambientSphereLaw.withDensity (f j)) K β) → + ∀ Q : Fin N → (Fin k → EuclideanSpace ℝ (Fin d)) × Label k → ℝ≥0∞, + (∀ j, Measurable (Q j)) → (∀ z, ∑ j, Q j z ≤ 1) → + AllBallMass (NoiselessRegression.ambientSphereLaw.withDensity (fractionalBlock Q f)) + (C^d*(N:ℝ)^(1/(k:ℝ))*K) β + +def HaarStreamingCost : Prop := + ∃ C : ℝ, 1 ≤ C ∧ ∀ d M T : ℕ, 16 ≤ d → ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d M T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + let k := d/4 + let Nstar : ℝ := ((k:ℝ)+2)*2^M + seededSuccess K ρ ε ≤ ENNReal.ofReal + (C^d*ε^k*(C^d*Nstar^(1/(k:ℝ)))^((T+k-1)/k)) + +def RieszStreamingCost : Prop := + ∃ C₀ : ℝ, 1 ≤ C₀ ∧ ∀ d M T : ℕ, 16 ≤ d → ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d M T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + let q := d/8 + let W : ℝ := ((T:ℝ)+2)*2^M + seededSuccess K ρ ε ≤ ENNReal.ofReal + (C₀^d*ε^((d:ℝ)/2-1)*(1+C₀^d*(1+Real.log (1/ε))*W^(1/(q:ℝ)))^((T+q-1)/q)) + +def CapFixedStoppingCost : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ d M T : ℕ, 32 ≤ d → ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d M T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + ∀ t : ℕ, t ≤ T → + let k := d/16 + let α : ℝ := ((d:ℝ)-1)/2 + seededFixedSuccess K ρ ε t ≤ ENNReal.ofReal + (Real.exp (C*d)*(ε/2)^α*(Real.exp (C*d)*(2:ℝ)^((M:ℝ)/k))^((t+k-1)/k)) + +def CapTotalStoppingCost : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ d M T : ℕ, 32 ≤ d → ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d M T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + let k := d/16 + let α : ℝ := ((d:ℝ)-1)/2 + seededSuccess K ρ ε ≤ ENNReal.ofReal + (((T:ℝ)+1)*Real.exp (C*d)*(ε/2)^α* + (Real.exp (C*d)*(2:ℝ)^((M:ℝ)/k))^((T+k-1)/k)) + +def CapFixedStoppingAsymptotic : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ M : ℕ → ℕ, + Asymptotics.IsLittleO atTop (fun d => (M d:ℝ)) (fun d => (d:ℝ)^2) → + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d (M d) T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + ∀ t : ℕ, t ≤ T → + let k := d/16 + let α : ℝ := ((d:ℝ)-1)/2 + seededFixedSuccess K ρ ε t ≤ ENNReal.ofReal + (Real.exp (C*d*(1+((t+k-1)/k:ℕ)))*(ε/2)^α) + +def CapTotalStoppingAsymptotic : Prop := + ∃ C₁ C₂ : ℝ, 0 < C₁ ∧ 0 < C₂ ∧ ∀ M : ℕ → ℕ, + Asymptotics.IsLittleO atTop (fun d => (M d:ℝ)) (fun d => (d:ℝ)^2) → + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ξ : Type u) [MeasurableSpace Ξ] (ρ : Measure Ξ), IsProbabilityMeasure ρ → + ∀ K : Ξ → FiniteKernelLearner d (M d) T, (∀ᵐ ξ ∂ρ, (K ξ).CompletedRules) → + seededSuccess K ρ ε ≤ ENNReal.ofReal + (((T:ℝ)+1)*Real.exp (C₁*d+C₂*T-(d:ℝ)*Real.log (1/ε)/3)) + +def KernelModelBridge : Prop := + ∀ d M T : ℕ, 3 ≤ d → ∀ K : FiniteKernelLearner d M T, K.CompletedRules → + ∃ (ρ : Measure (Tape M T)) (L : Learner d M T (Tape M T)), + IsProbabilityMeasure ρ ∧ L.MeasurableRules ∧ L.Admissible ρ ∧ + (∀ ε, L.uniformSuccess ρ ε = K.uniformSuccess ε) ∧ + (∀ ε t, L.uniformFixedSuccess ρ ε t = K.uniformFixedSuccess ε t) + +def MainStatement : Prop := + IntegratedFrameMoment ∧ NormalizedUnitBallMoment ∧ AllRadiiSphereMoment ∧ + PositiveCapDomination ∧ DeterministicOffsetDensity ∧ AllRadiiBlockBound ∧ + HaarStreamingCost.{u} ∧ RieszStreamingCost.{u} ∧ CapFixedStoppingCost.{u} ∧ + CapTotalStoppingCost.{u} ∧ CapFixedStoppingAsymptotic.{u} ∧ + CapTotalStoppingAsymptotic.{u} ∧ KernelModelBridge ∧ + NoiselessRegression.FiniteKernelLearner.SubquadraticMemoryWithPointwise.{u} ∧ + NoiselessRegression.FiniteKernelLearner.FixedQuadraticMemory.{u} + +open MeasureTheory ProbabilityTheory Set Filter InnerProductSpace +open scoped ENNReal NNReal RealInnerProductSpace Topology + +theorem main : MainStatement.{u} := by + sorry + +end ProjectionMoments + +end + +end OAI diff --git a/lean/ComparatorChallenges/ProjectionVolume.json b/lean/ComparatorChallenges/ProjectionVolume.json new file mode 100644 index 0000000000000000000000000000000000000000..abee0b7a99518236725a4443144dadca064943fa --- /dev/null +++ b/lean/ComparatorChallenges/ProjectionVolume.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ProjectionVolume", + "solution_module": "OAI.Geometry.ProjectionVolume.ProductCounterexample", + "theorem_names": [ + "OAI.Paper092.product_counterexample" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ProjectionVolume.lean b/lean/ComparatorChallenges/ProjectionVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..ceba0e72f227c9ce3ca10d617f034794bc8d5f34 --- /dev/null +++ b/lean/ComparatorChallenges/ProjectionVolume.lean @@ -0,0 +1,61 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open Set MeasureTheory +open scoped RealInnerProductSpace Pointwise + +namespace Paper092 + +noncomputable def simplexConstant (d : ℕ) : ℝ := + (d + 1) * (d : ℝ) ^ d / d.factorial + +abbrev Euclidean (n : ℕ) := EuclideanSpace ℝ (Fin n) + +def normalHyperplane {n : ℕ} (u : Euclidean n) : Submodule ℝ (Euclidean n) := + (Submodule.span ℝ ({u} : Set (Euclidean n)))ᗮ + +def projectionVolume {n : ℕ} (K : Set (Euclidean n)) (u : Euclidean n) : ENNReal := + (volume : Measure (normalHyperplane u)) + ((normalHyperplane u).orthogonalProjectionOnto '' K) + +def brightness {n : ℕ} (K : Set (Euclidean n)) (u : Euclidean n) : ℝ := + ‖u‖ * (projectionVolume K u).toReal + +def projectionBody {n : ℕ} (K : Set (Euclidean n)) : Set (Euclidean n) := + {y | ∀ u, ⟪u, y⟫ ≤ brightness K u} + +def normalizedProjectionVolume {n : ℕ} (K : Set (Euclidean n)) : ℝ := + (volume (projectionBody K)).toReal / (volume K).toReal ^ (n - 1) + +def standardSimplex (n : ℕ) : Set (Euclidean n) := + convexHull ℝ (insert 0 (Set.range fun i : Fin n => EuclideanSpace.single i (1 : ℝ))) + +def firstBlock (x : Euclidean 20) : Euclidean 10 := + WithLp.toLp 2 (fun i : Fin 10 => x (Fin.castAdd 10 i)) + +def secondBlock (x : Euclidean 20) : Euclidean 10 := + WithLp.toLp 2 (fun i : Fin 10 => x (Fin.natAdd 10 i)) + +def productWitness : Set (Euclidean 20) := + {x | firstBlock x ∈ standardSimplex 10 ∧ secondBlock x ∈ standardSimplex 10} + +theorem product_counterexample : + (IsCompact productWitness ∧ Convex ℝ productWitness ∧ + (interior productWitness).Nonempty) ∧ + normalizedProjectionVolume productWitness / simplexConstant 20 = + (121 * (Nat.choose 20 10 : ℝ)) / (21 * (2 : ℝ) ^ 20) ∧ + normalizedProjectionVolume productWitness / simplexConstant 20 = + (22355476 : ℝ) / 22020096 ∧ + 1 < normalizedProjectionVolume productWitness / simplexConstant 20 ∧ + (volume (projectionBody productWitness)).toReal > + simplexConstant 20 * (volume productWitness).toReal ^ 19 := by + sorry + +end Paper092 + +end + +end OAI diff --git a/lean/ComparatorChallenges/QACParity.json b/lean/ComparatorChallenges/QACParity.json new file mode 100644 index 0000000000000000000000000000000000000000..f9f591355023b027e9c9f1de62c202485854d01d --- /dev/null +++ b/lean/ComparatorChallenges/QACParity.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.QACParity", + "solution_module": "OAI.InformationTheory.QuantumCircuit.Parity", + "theorem_names": [ + "OAI.QAC.parity_lower_bound" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/QACParity.lean b/lean/ComparatorChallenges/QACParity.lean new file mode 100644 index 0000000000000000000000000000000000000000..8befca08a4e620cdc873f06efa0780f6955e1778 --- /dev/null +++ b/lean/ComparatorChallenges/QACParity.lean @@ -0,0 +1,76 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator + +namespace QAC + +abbrev Bit := Fin 2 +abbrev Word (N : ℕ) := Fin N → Bit +abbrev Operator (N : ℕ) := Matrix (Word N) (Word N) ℂ +abbrev QubitOperator := Matrix Bit Bit ℂ + +/-- Tensor product in the computational basis. -/ +def tensorMatrix {N : ℕ} (a : Fin N → QubitOperator) : Operator N := + fun x y => ∏ i, a i (x i) (y i) + +/-- A one-qubit unitary or an unbounded-arity Toffoli gate. -/ +inductive Gate (N : ℕ) where + | local (q : Fin N) (u : Matrix.unitaryGroup Bit ℂ) + | toffoli (controls : Finset (Fin N)) (target : Fin N) (hne : target ∉ controls) + +namespace Gate + +def support {N : ℕ} : Gate N → Finset (Fin N) + | .local q _ => {q} + | .toffoli c t _ => insert t c + +/-- A Toffoli flips its target iff all controls are one. -/ +def toffoliWord {N : ℕ} (c : Finset (Fin N)) (t : Fin N) (x : Word N) : Word N := + if ∀ i ∈ c, x i = 1 then Function.update x t (1 - x t) else x + +def matrix {N : ℕ} : Gate N → Operator N + | .local q u => tensorMatrix fun i => if i = q then (u : QubitOperator) else 1 + | .toffoli c t _ => fun x y => if x = toffoliWord c t y then 1 else 0 + +end Gate + +structure PhysicalLayer (N : ℕ) where + gates : List (Gate N) + disjoint : gates.Pairwise (fun A B => Disjoint A.support B.support) + +def physicalLayerMatrix {N : ℕ} (L : PhysicalLayer N) : Operator N := + (L.gates.map Gate.matrix).prod + +/-- Chronological order: the rightmost matrix acts first. -/ +def physicalCircuitMatrix {N : ℕ} (layers : List (PhysicalLayer N)) : Operator N := + ((layers.map physicalLayerMatrix).reverse).prod + +/-- The computational-basis input with the remaining qubits initialized to zero. -/ +def inputWord {n N : ℕ} (x : Word n) : Word N := + fun i => if h : i.val < n then x ⟨i.val, h⟩ else 0 + +def parity {n : ℕ} (x : Word n) : Bit := ∑ i, x i + +/-- Born probability, summing all final garbage with no cleanliness assumption. -/ +def successProbability {n N : ℕ} (W : Operator N) (out : Fin N) (x : Word n) : ℝ := + ∑ y : Word N, if y out = parity x then Complex.normSq (W y (inputWord x)) else 0 + +/-- The literal measured-output, polynomial-total-qubit parity lower bound. -/ +def ParityStatement : Prop := + ∀ (d : ℕ) (c ε : ℝ), 1 ≤ c → 0 < ε → ε ≤ 1 / 2 → + ∃ n₀ : ℕ, ∀ n ≥ n₀, ∀ N : ℕ, n ≤ N → (N : ℝ) ≤ (n : ℝ) ^ c → + ∀ layers : List (PhysicalLayer N), layers.length ≤ d → + ∀ out : Fin N, ¬ (∀ x : Word n, + 1 / 2 + ε ≤ successProbability (physicalCircuitMatrix layers) out x) + +end QAC + +theorem QAC.parity_lower_bound : QAC.ParityStatement := by + sorry + +end + +end OAI diff --git a/lean/ComparatorChallenges/QuadricBundles.json b/lean/ComparatorChallenges/QuadricBundles.json new file mode 100644 index 0000000000000000000000000000000000000000..60fda5b8c043d927c7a90b3d23be58aa0083bba0 --- /dev/null +++ b/lean/ComparatorChallenges/QuadricBundles.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.QuadricBundles", + "solution_module": "OAI.Geometry.QuadricBundles.Main", + "theorem_names": [ + "OAI.QuadricCounterexample.main_theorem" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/QuadricBundles.lean b/lean/ComparatorChallenges/QuadricBundles.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e56aea69f438c79cb66100f8d02deb4508e95f8 --- /dev/null +++ b/lean/ComparatorChallenges/QuadricBundles.lean @@ -0,0 +1,181 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace QuadricCounterexample + +open Set Filter Topology Metric OnePoint + +open scoped Matrix.Norms.Elementwise ComplexOrder + +abbrev ProjectiveLine := OnePoint ℂ +abbrev QuadricSurface := ProjectiveLine × ProjectiveLine + +def reciprocalP1 (x : ProjectiveLine) : ProjectiveLine := + x.elim (0 : ℂ) (fun z ↦ if z = 0 then ∞ else (z⁻¹ : ℂ)) + +def affineP1 (i : Fin 2) (z : ℂ) : ProjectiveLine := + if i = 0 then reciprocalP1 z else (z : ProjectiveLine) + +def affineQuadric (i : Fin 2 × Fin 2) (z : ℂ × ℂ) : QuadricSurface := + (affineP1 i.1 z.1, affineP1 i.2 z.2) + +def coordP1 (i : Fin 2) (x : ProjectiveLine) : ℂ := + (if i=0 then reciprocalP1 x else x).elim 0 id +def coordQuadric (i : Fin 2 × Fin 2) (x : QuadricSurface) : ℂ × ℂ := + (coordP1 i.1 x.1,coordP1 i.2 x.2) + +def powerP1 (m : ℕ) (x : ProjectiveLine) : ProjectiveLine := + x.elim ∞ (fun z ↦ ((z^m : ℂ) : ProjectiveLine)) +def powerQuadric (m : ℕ) (x : QuadricSurface) : QuadricSurface := + (powerP1 m x.1,powerP1 m x.2) + +abbrev BaseCoordinates := ℂ × ℂ +abbrev FiberCoordinates := Fin 2 → ℂ +abbrev TwoMatrix := Matrix (Fin 2) (Fin 2) ℂ +abbrev BasePolynomial := MvPolynomial (Fin 2) ℂ +def baseEval (p : BasePolynomial) (z : BaseCoordinates) : ℂ := + MvPolynomial.eval ![z.1,z.2] p + +def AlgebraicallyRegularOn (U : Set BaseCoordinates) (f : BaseCoordinates → ℂ) : Prop := + ∀ z ∈ U, ∃ p q : BasePolynomial, baseEval q z ≠ 0 ∧ + ∀ w ∈ U, baseEval q w ≠ 0 → f w=baseEval p w/baseEval q w + +def principalChart (i : Fin 2 × Fin 2) (p : BasePolynomial) : Set QuadricSurface := + {x | x ∈ range (affineQuadric i) ∧ baseEval p (coordQuadric i x) ≠ 0} + +structure AlgebraicRankTwoBundle where + numberOfCharts : ℕ + chart : ℕ → Fin 2 × Fin 2 + equation : ℕ → BasePolynomial + finiteCover : ∀ i, numberOfCharts ≤ i → equation i=0 + covers : ∀ x : QuadricSurface, ∃ i, x ∈ principalChart (chart i) (equation i) + transition : ℕ → ℕ → QuadricSurface → TwoMatrix + transition_self : ∀ i x, x ∈ principalChart (chart i) (equation i) → + transition i i x=1 + transition_mul : ∀ i j k x, + x ∈ principalChart (chart i) (equation i) → + x ∈ principalChart (chart j) (equation j) → + x ∈ principalChart (chart k) (equation k) → + transition i j x * transition j k x=transition i k x + transition_regular : ∀ i j a b, AlgebraicallyRegularOn + {z | baseEval (equation i) z ≠ 0 ∧ + affineQuadric (chart i) z ∈ principalChart (chart j) (equation j)} + (fun z ↦ transition i j (affineQuadric (chart i) z) a b) + +namespace AlgebraicRankTwoBundle + +def domain (V : AlgebraicRankTwoBundle) (i : ℕ) : Set QuadricSurface := + principalChart (V.chart i) (V.equation i) +def coordinateDomain (V : AlgebraicRankTwoBundle) (i : ℕ) : Set BaseCoordinates := + {z | baseEval (V.equation i) z ≠ 0} + +def dualTransition (V : AlgebraicRankTwoBundle) (i j : ℕ) (x : QuadricSurface) : TwoMatrix := + (V.transition j i x).transpose + +end AlgebraicRankTwoBundle + +def hyperplaneTransition (i j : Fin 2) (x : ProjectiveLine) : ℂ := + if i=j then 1 else coordP1 i x +def polarizationTransition (i j : Fin 2 × Fin 2) (x : QuadricSurface) : ℂ := + hyperplaneTransition i.1 j.1 x.1 * hyperplaneTransition i.2 j.2 x.2 + +def IsPowerPullbackTwist (G : AlgebraicRankTwoBundle) (m : ℕ) + (E : AlgebraicRankTwoBundle) : Prop := + E.numberOfCharts=G.numberOfCharts ∧ E.chart=G.chart ∧ + (∀ i, E.equation i = (MvPolynomial.bind₁ fun j ↦ MvPolynomial.X j ^ m) (G.equation i)) ∧ + ∀ i j x, x ∈ E.domain i → x ∈ E.domain j → + E.transition i j x = polarizationTransition (G.chart i) (G.chart j) x • + G.transition i j (powerQuadric m x) + +structure SymmetricSection (V : AlgebraicRankTwoBundle) (n : ℕ) where + coefficient : ℕ → Fin (n+1) → BaseCoordinates → ℂ + regular : ∀ i k, AlgebraicallyRegularOn (V.coordinateDomain i) (coefficient i k) + compatible : ∀ i j x, x ∈ V.domain i → x ∈ V.domain j → ∀ v : FiberCoordinates, + (∑ k : Fin (n+1), coefficient i k (coordQuadric (V.chart i) x) * + ((V.dualTransition i j x).mulVec v 0)^k.val * + ((V.dualTransition i j x).mulVec v 1)^(n-k.val)) = + ∑ k : Fin (n+1), coefficient j k (coordQuadric (V.chart j) x) * v 0^k.val * v 1^(n-k.val) + +def SymmetricSection.value {V : AlgebraicRankTwoBundle} {n : ℕ} + (s : SymmetricSection V n) (i : ℕ) (x : QuadricSurface) (v : FiberCoordinates) : ℂ := + ∑ k : Fin (n+1), s.coefficient i k (coordQuadric (V.chart i) x) * v 0^k.val * v 1^(n-k.val) + +def ProjectiveAlgebraicCone {N : ℕ} (C : Set (Fin N → ℂ)) : Prop := + ∃ equations : Set (MvPolynomial (Fin N) ℂ), + (∀ p ∈ equations, ∃ d : ℕ, p.IsHomogeneous d) ∧ + C = {y | ∀ p ∈ equations, MvPolynomial.eval y p=0} + +def sectionVector {V : AlgebraicRankTwoBundle} {n N : ℕ} + (s : Fin N → SymmetricSection V n) (i : ℕ) (x : QuadricSurface) + (v : FiberCoordinates) : Fin N → ℂ := fun j ↦ (s j).value i x v + +def GivesClosedProjectiveEmbedding {V : AlgebraicRankTwoBundle} {n N : ℕ} + (s : Fin N → SymmetricSection V n) : Prop := + (∀ i x, x ∈ V.domain i → ∀ v : FiberCoordinates, v ≠ 0 → sectionVector s i x v ≠ 0) ∧ + (∀ i j x y, x ∈ V.domain i → y ∈ V.domain j → ∀ v w : FiberCoordinates, + v ≠ 0 → w ≠ 0 → (∃ c : ℂ, c ≠ 0 ∧ sectionVector s i x v = c • sectionVector s j y w) → + x=y ∧ ∃ c : ℂ, c ≠ 0 ∧ v=c • ((V.dualTransition i j x).mulVec w)) ∧ + ProjectiveAlgebraicCone ({0} ∪ {a | ∃ i x, x ∈ V.domain i ∧ + ∃ v : FiberCoordinates, v ≠ 0 ∧ ∃ c : ℂ, c ≠ 0 ∧ a=c • sectionVector s i x v}) ∧ + ∀ i x, x ∈ V.domain i → ∀ v : FiberCoordinates, v ≠ 0 → + ∃ j : Fin N, ∃ b : Fin 2, v b ≠ 0 ∧ sectionVector s i x v j ≠ 0 ∧ + ∃ p q : Fin 3 → MvPolynomial (Fin N) ℂ, + (∀ k, MvPolynomial.eval (fun l ↦ sectionVector s i x v l / sectionVector s i x v j) (q k) ≠ 0) ∧ + ∀ i' x', x' ∈ V.domain i' → ∀ v' : FiberCoordinates, v' ≠ 0 → + sectionVector s i' x' v' j ≠ 0 → + (∀ k, MvPolynomial.eval (fun l ↦ sectionVector s i' x' v' l / sectionVector s i' x' v' j) (q k) ≠ 0) → + x' ∈ V.domain i ∧ ((V.dualTransition i i' x').mulVec v') b ≠ 0 ∧ + (∀ k : Fin 3, + (![ (coordQuadric (V.chart i) x').1, (coordQuadric (V.chart i) x').2, + ((V.dualTransition i i' x').mulVec v') (1-b) / + ((V.dualTransition i i' x').mulVec v') b ] : Fin 3 → ℂ) k = + MvPolynomial.eval (fun l ↦ sectionVector s i' x' v' l / sectionVector s i' x' v' j) (p k) / + MvPolynomial.eval (fun l ↦ sectionVector s i' x' v' l / sectionVector s i' x' v' j) (q k)) + +def IsAmple (V : AlgebraicRankTwoBundle) : Prop := + ∃ n : ℕ, 0 < n ∧ ∃ N : ℕ, ∃ s : Fin N → SymmetricSection V n, + GivesClosedProjectiveEmbedding s + +def holomorphicMetricDerivative (H : BaseCoordinates → TwoMatrix) + (z u : BaseCoordinates) : TwoMatrix := + (1/2 : ℂ) • (fderiv ℝ H z u - Complex.I • fderiv ℝ H z (Complex.I • u)) + +def metricMixedHessian (H : BaseCoordinates → TwoMatrix) + (z u : BaseCoordinates) : TwoMatrix := + (1/4 : ℂ) • ((fderiv ℝ (fun y ↦ fderiv ℝ H y) z u) u + + (fderiv ℝ (fun y ↦ fderiv ℝ H y) z (Complex.I • u)) (Complex.I • u)) + +structure SmoothHermitianMetric (V : AlgebraicRankTwoBundle) where + dualMatrix : ℕ → BaseCoordinates → TwoMatrix + smooth : ∀ i, ContDiffOn ℝ ((⊤ : ℕ∞) : WithTop ℕ∞) (dualMatrix i) (V.coordinateDomain i) + positive : ∀ i z, z ∈ V.coordinateDomain i → (dualMatrix i z).PosDef + compatible : ∀ i j x, x ∈ V.domain i → x ∈ V.domain j → + dualMatrix j (coordQuadric (V.chart j) x) = + (V.dualTransition i j x).conjTranspose * dualMatrix i (coordQuadric (V.chart i) x) * + V.dualTransition i j x + +def SmoothHermitianMetric.StrictlyGriffithsPositive {V : AlgebraicRankTwoBundle} + (h : SmoothHermitianMetric V) : Prop := + ∀ i z, z ∈ V.coordinateDomain i → ∀ u : BaseCoordinates, u ≠ 0 → + (metricMixedHessian (h.dualMatrix i) z u - + (holomorphicMetricDerivative (h.dualMatrix i) z u).conjTranspose * + (h.dualMatrix i z)⁻¹ * holomorphicMetricDerivative (h.dualMatrix i) z u).PosDef + +def SourceMainTheorem : Prop := + ∃ G : AlgebraicRankTwoBundle, ∃ E : ℕ → AlgebraicRankTwoBundle, + (∀ m, 0 < m → IsPowerPullbackTwist G m (E m)) ∧ + (∀ m, 0 < m → IsAmple (E m)) ∧ + ∃ m₀ : ℕ, 0 < m₀ ∧ ∀ m, m₀ ≤ m → + ¬ ∃ h : SmoothHermitianMetric (E m), h.StrictlyGriffithsPositive + +theorem main_theorem : SourceMainTheorem := by + sorry + +end QuadricCounterexample + +end + +end OAI diff --git a/lean/ComparatorChallenges/QuantitativeVanDerWaerden.json b/lean/ComparatorChallenges/QuantitativeVanDerWaerden.json new file mode 100644 index 0000000000000000000000000000000000000000..10b1770000baae70cfe28b4890143ff9960273af --- /dev/null +++ b/lean/ComparatorChallenges/QuantitativeVanDerWaerden.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.QuantitativeVanDerWaerden", + "solution_module": "OAI.Combinatorics.ProgressionColoring.Main", + "theorem_names": [ + "OAI.QuantitativeVanDerWaerden.uniform_lower_bound" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/QuantitativeVanDerWaerden.lean b/lean/ComparatorChallenges/QuantitativeVanDerWaerden.lean new file mode 100644 index 0000000000000000000000000000000000000000..bee3f5a820455ead2a00f8fdc08d4ae5276cba2a --- /dev/null +++ b/lean/ComparatorChallenges/QuantitativeVanDerWaerden.lean @@ -0,0 +1,33 @@ +import Mathlib + +namespace OAI + +universe u + +namespace QuantitativeVanDerWaerden + +def MonoAP {α : Type u} (c : ℕ → α) (k a d : ℕ) : Prop := + ∀ j < k, c (a + j * d) = c a + +def HasMonoAP {α : Type u} (c : ℕ → α) (k N : ℕ) : Prop := + ∃ a d, 0 < d ∧ a + (k - 1) * d < N ∧ MonoAP c k a d + +def IsRamsey (α : Type u) (k N : ℕ) : Prop := + ∀ c : ℕ → α, HasMonoAP c k N + +/-- The least positive Ramsey interval size. Statements about its Ramsey +property require a finiteness proof; no such proof is built into this definition. -/ +noncomputable def W (r k : ℕ) : ℕ := + sInf {N : ℕ | 0 < N ∧ IsRamsey (Fin r) k N} + +open Filter + +/-- An absolute quantitative lower bound, uniform over all color counts. -/ +theorem uniform_lower_bound : + ∃ K : ℕ, ∀ k ≥ K, ∀ r ≥ 2, + (k : ℝ) ^ ((1 / 100000 : ℝ) * k * (Nat.log 2 r : ℝ)) < (W r k : ℝ) := by + sorry + +end QuantitativeVanDerWaerden + +end OAI diff --git a/lean/ComparatorChallenges/QuasiRiemannHypothesis.json b/lean/ComparatorChallenges/QuasiRiemannHypothesis.json new file mode 100644 index 0000000000000000000000000000000000000000..acf552468fc23c1a27d685d33983c58c50040542 --- /dev/null +++ b/lean/ComparatorChallenges/QuasiRiemannHypothesis.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.QuasiRiemannHypothesis", + "solution_module": "OAI.NumberTheory.DirichletL.Nonvanishing", + "theorem_names": [ + "OAI.riemannZeta_ne_zero_of_seven_eighths_lt_re" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/QuasiRiemannHypothesis.lean b/lean/ComparatorChallenges/QuasiRiemannHypothesis.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7d1caf6c579dc9afbf0d2b01f79e5cd2511b028 --- /dev/null +++ b/lean/ComparatorChallenges/QuasiRiemannHypothesis.lean @@ -0,0 +1,9 @@ +import Mathlib + +namespace OAI + +theorem riemannZeta_ne_zero_of_seven_eighths_lt_re + {s : ℂ} (hs : (7 / 8 : ℝ) < s.re) : riemannZeta s ≠ 0 := by + sorry + +end OAI diff --git a/lean/ComparatorChallenges/QuinticLienard.json b/lean/ComparatorChallenges/QuinticLienard.json new file mode 100644 index 0000000000000000000000000000000000000000..89f4500a1b15d5455e81e76f583faf1751db83b1 --- /dev/null +++ b/lean/ComparatorChallenges/QuinticLienard.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.QuinticLienard", + "solution_module": "OAI.Analysis.LienardCycles.Main", + "theorem_names": [ + "OAI.QuinticLienard.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/QuinticLienard.lean b/lean/ComparatorChallenges/QuinticLienard.lean new file mode 100644 index 0000000000000000000000000000000000000000..aaa3712a73aa86b4c6a7a0e0a6007eb62feb135a --- /dev/null +++ b/lean/ComparatorChallenges/QuinticLienard.lean @@ -0,0 +1,46 @@ +import Mathlib + +namespace OAI + +namespace QuinticLienard + +abbrev Plane := ℝ × ℝ + +def vectorField (F : Polynomial ℝ) (z : Plane) : Plane := + (z.2 - F.eval z.1, -z.1) + +def IsSolution (F : Polynomial ℝ) (z : ℝ → Plane) : Prop := + ∀ t : ℝ, HasDerivAt z (vectorField F (z t)) t + +def IsPeriodicOrbit (F : Polynomial ℝ) (C : Set Plane) : Prop := + ∃ (z : ℝ → Plane) (T : ℝ), + IsSolution F z ∧ 0 < T ∧ Function.Periodic z T ∧ + (∃ s t : ℝ, z s ≠ z t) ∧ C = Set.range z + +def IsLimitCycle (F : Polynomial ℝ) (C : Set Plane) : Prop := + IsPeriodicOrbit F C ∧ + ∃ U : Set Plane, IsOpen U ∧ C ⊆ U ∧ + ∀ C' : Set Plane, IsPeriodicOrbit F C' → C' ⊆ U → C' = C + +open scoped Topology NNReal ContDiff Manifold +open Filter Set +open Set Filter Metric MeasureTheory +open scoped Topology NNReal ContDiff +open scoped Topology ENNReal +open Set Filter MeasureTheory +open Set Filter Asymptotics +open Set Filter Metric +open scoped Topology NNReal +open scoped Topology +open scoped Topology ContDiff +open Set Filter +open scoped Topology ContDiff NNReal + +theorem main : + (∀ F : Polynomial ℝ, F.degree ≤ 5 → {C : Set Plane | IsLimitCycle F C}.encard ≤ 2) ∧ + (∃ F : Polynomial ℝ, F.degree ≤ 5 ∧ {C : Set Plane | IsLimitCycle F C}.encard = 2) := by + sorry + +end QuinticLienard + +end OAI diff --git a/lean/ComparatorChallenges/README.md b/lean/ComparatorChallenges/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c1ac131559880e759c28caf79905ba4fe6194eb7 --- /dev/null +++ b/lean/ComparatorChallenges/README.md @@ -0,0 +1,10 @@ +# [Comparator](https://github.com/leanprover/comparator) challenges + +Install `comparator`, `landrun`, and `lean4export`, and make them available on `PATH`. +Then, from `lean/`: + +```sh +lake update +lake exe cache get +lake env comparator ComparatorChallenges/QuasiRiemannHypothesis.json +``` diff --git a/lean/ComparatorChallenges/RadialDensityInterval.json b/lean/ComparatorChallenges/RadialDensityInterval.json new file mode 100644 index 0000000000000000000000000000000000000000..2309d3af26aeeec2f27ba16e6561bb151f9f0d9f --- /dev/null +++ b/lean/ComparatorChallenges/RadialDensityInterval.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RadialDensityInterval", + "solution_module": "OAI.Probability.RadialTransition.DensityInterval", + "theorem_names": [ + "OAI.RadialTransition.densityInterval" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RadialDensityInterval.lean b/lean/ComparatorChallenges/RadialDensityInterval.lean new file mode 100644 index 0000000000000000000000000000000000000000..a97c1f21da4d92225d2bb3edf54061d318447786 --- /dev/null +++ b/lean/ComparatorChallenges/RadialDensityInterval.lean @@ -0,0 +1,72 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open scoped BigOperators NNReal ContDiff ENNReal +open Filter MeasureTheory Set + +namespace RadialTransition + +abbrev Position := EuclideanSpace ℝ (Fin 3) +abbrev Potential := ℝ≥0 → ℝ + +def cube (L : ℝ) : Set Position := + {x | ∀ k : Fin 3, 0 ≤ x k ∧ x k ≤ L} + +def configurationCube (L : ℝ) (N : ℕ) : Set (Fin N → Position) := + {x | ∀ i : Fin N, x i ∈ cube L} + +def energy (φ : Potential) {N : ℕ} (x : Fin N → Position) : ℝ := + ∑ i : Fin N, ∑ j : Fin N with i < j, φ (nndist (x i) (x j)) + +def partition (φ : Potential) (L : ℝ) (N : ℕ) (β : ℝ) : ℝ := + (N.factorial : ℝ)⁻¹ * + ∫ x in configurationCube L N, Real.exp (-β * energy φ x) + +def packingNumber (L : ℝ) : ℕ := + sSup {n : ℕ | ∃ X : Finset Position, X.card = n ∧ + (∀ x ∈ X, x ∈ cube L) ∧ + (∀ x ∈ X, ∀ y ∈ X, x ≠ y → 1 ≤ dist x y)} + +def IsPackingDensity (p : ℝ) : Prop := + Tendsto (fun L : ℝ => (packingNumber L : ℝ) / L ^ 3) atTop (nhds p) + +def IsBoundedPotential (φ : Potential) : Prop := + ∃ M : ℝ, 0 ≤ M ∧ ∀ r : ℝ≥0, |φ r| ≤ M + +def StableWith (φ : Potential) (B : ℝ) : Prop := + ∀ (N : ℕ) (x : Fin N → Position), -(B * N) ≤ energy φ x + +def AlgebraicDecayWith (φ : Potential) (C : ℝ) : Prop := + ∀ r : ℝ≥0, 1 ≤ r → |φ r| ≤ C * (r : ℝ) ^ (-(3 : ℝ) - 1 / 32) + +def IsCanonicalFreeEnergy (φ : Potential) (ρ : ℝ) (f : ℝ → ℝ) : Prop := + ∀ β : ℝ, 0 < β → + Tendsto (fun L : ℝ => + -(Real.log (partition φ L ⌊ρ * L ^ 3⌋₊ β) / (β * L ^ 3))) + atTop (nhds (f β)) + +def StrictTemperatureCorner (f : ℝ → ℝ) (βc : ℝ) : Prop := + ∃ dLeft dRight : ℝ, + HasDerivWithinAt f dLeft (Iic βc) βc ∧ + HasDerivWithinAt f dRight (Ici βc) βc ∧ + dRight < dLeft ∧ ¬DifferentiableAt ℝ f βc + +theorem densityInterval : + ∃ (p : ℝ) (φ : Potential) (B C η βc : ℝ) (f : ℝ → ℝ → ℝ), + 0 < p ∧ IsPackingDensity p ∧ + IsBoundedPotential φ ∧ Continuous φ ∧ + 0 < B ∧ 0 < C ∧ StableWith φ B ∧ AlgebraicDecayWith φ C ∧ + 0 < η ∧ Ioo (5*p/3 - η) (5*p/3 + η) ⊆ Ioi 0 ∧ + βc ∈ Icc (7/8:ℝ) (9/8) ∧ + ∀ ρ ∈ Ioo (5*p/3 - η) (5*p/3 + η), + IsCanonicalFreeEnergy φ ρ (fun β => f β ρ) ∧ + StrictTemperatureCorner (fun β => f β ρ) βc := by + sorry + +end RadialTransition +end + +end OAI diff --git a/lean/ComparatorChallenges/RadialTransition.json b/lean/ComparatorChallenges/RadialTransition.json new file mode 100644 index 0000000000000000000000000000000000000000..6ed1573978a57563159dbacef4ace97c6605ac2b --- /dev/null +++ b/lean/ComparatorChallenges/RadialTransition.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RadialTransition", + "solution_module": "OAI.Probability.RadialTransition.Main", + "theorem_names": [ + "OAI.RadialTransition.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RadialTransition.lean b/lean/ComparatorChallenges/RadialTransition.lean new file mode 100644 index 0000000000000000000000000000000000000000..09f994133923301f8ed387a7238a877ebeeeca58 --- /dev/null +++ b/lean/ComparatorChallenges/RadialTransition.lean @@ -0,0 +1,70 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open scoped BigOperators NNReal +open Filter MeasureTheory Set + +namespace RadialTransition + +abbrev Position := EuclideanSpace ℝ (Fin 3) +abbrev Potential := ℝ≥0 → ℝ + +def cube (L : ℝ) : Set Position := + {x | ∀ k : Fin 3, 0 ≤ x k ∧ x k ≤ L} + +def configurationCube (L : ℝ) (N : ℕ) : Set (Fin N → Position) := + {x | ∀ i : Fin N, x i ∈ cube L} + +def energy (φ : Potential) {N : ℕ} (x : Fin N → Position) : ℝ := + ∑ i : Fin N, ∑ j : Fin N with i < j, φ (nndist (x i) (x j)) + +def partition (φ : Potential) (L : ℝ) (N : ℕ) (β : ℝ) : ℝ := + (N.factorial : ℝ)⁻¹ * + ∫ x in configurationCube L N, Real.exp (-β * energy φ x) + +def packingNumber (L : ℝ) : ℕ := + sSup {n : ℕ | ∃ X : Finset Position, X.card = n ∧ + (∀ x ∈ X, x ∈ cube L) ∧ + (∀ x ∈ X, ∀ y ∈ X, x ≠ y → 1 ≤ dist x y)} + +def IsPackingDensity (p : ℝ) : Prop := + Tendsto (fun L : ℝ => (packingNumber L : ℝ) / L ^ 3) atTop (nhds p) + +def IsBoundedPotential (φ : Potential) : Prop := + ∃ M : ℝ, 0 ≤ M ∧ ∀ r : ℝ≥0, |φ r| ≤ M + +def StableWith (φ : Potential) (B : ℝ) : Prop := + ∀ (N : ℕ) (x : Fin N → Position), -(B * N) ≤ energy φ x + +def AlgebraicDecayWith (φ : Potential) (C : ℝ) : Prop := + ∀ r : ℝ≥0, 1 ≤ r → |φ r| ≤ C * (r : ℝ) ^ (-(3 : ℝ) - 1 / 32) + +def IsCanonicalFreeEnergy (φ : Potential) (ρ : ℝ) (f : ℝ → ℝ) : Prop := + ∀ β : ℝ, 0 < β → + Tendsto (fun L : ℝ => + -(Real.log (partition φ L ⌊ρ * L ^ 3⌋₊ β) / (β * L ^ 3))) + atTop (nhds (f β)) + +def StrictTemperatureCorner (f : ℝ → ℝ) (βc : ℝ) : Prop := + ∃ dLeft dRight : ℝ, + HasDerivWithinAt f dLeft (Iic βc) βc ∧ + HasDerivWithinAt f dRight (Ici βc) βc ∧ + dRight < dLeft ∧ ¬DifferentiableAt ℝ f βc + +theorem main : + ∃ (p : ℝ) (φ : Potential) (B C : ℝ) (f : ℝ → ℝ) (βc : ℝ), + 0 < p ∧ IsPackingDensity p ∧ + IsBoundedPotential φ ∧ Continuous φ ∧ + 0 < B ∧ 0 < C ∧ StableWith φ B ∧ AlgebraicDecayWith φ C ∧ + IsCanonicalFreeEnergy φ (5*p/3) f ∧ + βc ∈ Icc (7/8:ℝ) (9/8) ∧ StrictTemperatureCorner f βc := by + sorry + +end RadialTransition + +end + +end OAI diff --git a/lean/ComparatorChallenges/RamseyFive.json b/lean/ComparatorChallenges/RamseyFive.json new file mode 100644 index 0000000000000000000000000000000000000000..7a2fb30b864b78af93d8e28cc8293cabe4d81a53 --- /dev/null +++ b/lean/ComparatorChallenges/RamseyFive.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RamseyFive", + "solution_module": "OAI.Combinatorics.RamseyFive.Main", + "theorem_names": [ + "OAI.SharpRamseyFive.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RamseyFive.lean b/lean/ComparatorChallenges/RamseyFive.lean new file mode 100644 index 0000000000000000000000000000000000000000..783fa994079892d567045b968487655b9ca20dcc --- /dev/null +++ b/lean/ComparatorChallenges/RamseyFive.lean @@ -0,0 +1,30 @@ +import Mathlib + +namespace OAI + +namespace SharpRamseyFive + +def RamseyProperty (s t n : ℕ) : Prop := + ∀ G : SimpleGraph (Fin n), + (∃ A : Finset (Fin n), G.IsNClique s A) ∨ + (∃ B : Finset (Fin n), G.IsNIndepSet t B) + +noncomputable def ramsey (s t : ℕ) : ℕ := sInf {n : ℕ | RamseyProperty s t n} + +def SharpBounds : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ ε : ℝ, 0 < ε → ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t → + (t : ℝ) ^ 4 / Real.rpow (Real.log t) (3 + ε) ≤ (ramsey 5 t : ℝ) ∧ + (ramsey 5 t : ℝ) ≤ C * (t : ℝ) ^ 4 / (Real.log t) ^ 3 + +def SharpExponent : Prop := + Filter.Tendsto + (fun t : ℕ => (4 * Real.log (t : ℝ) - Real.log (ramsey 5 t : ℝ)) / + Real.log (Real.log (t : ℝ))) + Filter.atTop (nhds (3 : ℝ)) + +theorem main : SharpBounds ∧ SharpExponent := by + sorry + +end SharpRamseyFive + +end OAI diff --git a/lean/ComparatorChallenges/RandomizedMeanPayoff.json b/lean/ComparatorChallenges/RandomizedMeanPayoff.json new file mode 100644 index 0000000000000000000000000000000000000000..293f8308c91f1423d36b711d7738262fdb95f89e --- /dev/null +++ b/lean/ComparatorChallenges/RandomizedMeanPayoff.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RandomizedMeanPayoff", + "solution_module": "OAI.Computability.RandomMean.Main", + "theorem_names": [ + "OAI.randomized_quasipolynomial_mean_payoff" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RandomizedMeanPayoff.lean b/lean/ComparatorChallenges/RandomizedMeanPayoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc70577163b98c4489466ec919a6985ee03397f1 --- /dev/null +++ b/lean/ComparatorChallenges/RandomizedMeanPayoff.lean @@ -0,0 +1,126 @@ +import Mathlib + +namespace OAI + +namespace MeanPayoff +structure Game where + n : ℕ + positive : 0 < n + m : ℕ + tail : Fin m → Fin n + head : Fin m → Fin n + maxOwner : Fin n → Bool + weight : Fin m → ℤ + total : ∀ v : Fin n, ∃ e : Fin m, tail e = v + +def Strategy (G : Game) := + List (Fin G.m) → (v : Fin G.n) → {e : Fin G.m // G.tail e = v} + +def move (G : Game) (σ τ : Strategy G) (v : Fin G.n) + (history : List (Fin G.m)) : Fin G.m := + if G.maxOwner v then (σ history v).val else (τ history v).val + +def position (G : Game) (σ τ : Strategy G) (start : Fin G.n) : + ℕ → Fin G.n × List (Fin G.m) + | 0 => (start, []) + | t + 1 => + let p := position G σ τ start t + let e := move G σ τ p.1 p.2 + (G.head e, p.2 ++ [e]) + +def play (G : Game) (σ τ : Strategy G) (start : Fin G.n) (t : ℕ) : Fin G.m := + let p := position G σ τ start t + move G σ τ p.1 p.2 + +noncomputable def meanPayoff (G : Game) (π : ℕ → Fin G.m) : ℝ := + Filter.liminf (fun T : ℕ => + (∑ j ∈ Finset.range T, (G.weight (π j) : ℝ)) / (T : ℝ)) Filter.atTop + +def Winning (G : Game) (v : Fin G.n) : Prop := + ∃ σ : Strategy G, ∀ τ : Strategy G, 0 ≤ meanPayoff G (play G σ τ v) + +def encodeNat (n : ℕ) : List Bool := + let bits := Nat.bits (n + 1) + List.replicate bits.length true ++ [false] ++ bits + +def encodeInt (z : ℤ) : List Bool := + decide (z < 0) :: encodeNat z.natAbs + +def input (G : Game) : List Bool := + encodeNat G.n ++ encodeNat G.m ++ List.ofFn G.maxOwner ++ + (List.ofFn (fun e : Fin G.m => + encodeNat ((G.tail e).val + 1) ++ encodeNat ((G.head e).val + 1) ++ + encodeInt (G.weight e))).flatten + +abbrev Symbol := Option Bool + +inductive Direction where + | left | stay | right + deriving DecidableEq + +def Direction.offset : Direction → ℤ + | .left => -1 + | .stay => 0 + | .right => 1 + +structure Action (q : ℕ) where + next : Fin q + write : Fin 3 → Symbol + shift : Fin 3 → Direction + +structure Machine where + states : ℕ + start : Fin states + transition : Fin states → (Fin 3 → Symbol) → Bool → Option (Action states) + +structure Configuration (M : Machine) where + control : Option (Fin M.states) + head : Fin 3 → ℤ + tape : Fin 3 → ℤ → Symbol + +def initial (M : Machine) (code : List Bool) : Configuration M where + control := some M.start + head := fun _ => 0 + tape := fun k j => if k = 0 ∧ 0 ≤ j then code[j.toNat]? else none + +def step (M : Machine) (c : Configuration M) (bit : Bool) : Configuration M := + match c.control with + | none => c + | some s => + match M.transition s (fun k => c.tape k (c.head k)) bit with + | none => { c with control := none } + | some a => + { control := some a.next + head := fun k => c.head k + (a.shift k).offset + tape := fun k => Function.update (c.tape k) (c.head k) (a.write k) } + +def run (M : Machine) (code : List Bool) (random : ℕ → Bool) : ℕ → Configuration M + | 0 => initial M code + | t + 1 => step M (run M code random t) (random t) + +def padBits {T : ℕ} (bits : Fin T → Bool) (j : ℕ) : Bool := + if h : j < T then bits ⟨j, h⟩ else false + +def result (M : Machine) (G : Game) (T : ℕ) (bits : Fin T → Bool) : Configuration M := + run M (input G) (padBits bits) T + +def CorrectOutput (G : Game) {M : Machine} (c : Configuration M) : Prop := + c.control = none ∧ + (∀ v : Fin G.n, c.tape 2 (v.val : ℤ) = some true ↔ Winning G v) ∧ + (∀ v : Fin G.n, c.tape 2 (v.val : ℤ) = some false ↔ ¬ Winning G v) ∧ + ∀ j : ℤ, (j < 0 ∨ (G.n : ℤ) ≤ j) → c.tape 2 j = none + +noncomputable def MainClaim : Prop := by + classical + exact ∃ M : Machine, ∃ C : ℝ, 0 < C ∧ ∀ G : Game, ∃ T : ℕ, + (T : ℝ) ≤ (2 : ℝ) ^ (C * (Real.logb 2 ((input G).length + 2)) ^ 2) ∧ + (∀ bits : Fin T → Bool, (result M G T bits).control = none) ∧ + 7 * 2 ^ T ≤ 8 * (Finset.univ.filter + (fun bits : Fin T → Bool => CorrectOutput G (result M G T bits))).card + +end MeanPayoff + +theorem randomized_quasipolynomial_mean_payoff : MeanPayoff.MainClaim := by + sorry + +end OAI diff --git a/lean/ComparatorChallenges/RationalHitting.json b/lean/ComparatorChallenges/RationalHitting.json new file mode 100644 index 0000000000000000000000000000000000000000..c13cb85bb4833ab52f05c20b4576fded30c0f610 --- /dev/null +++ b/lean/ComparatorChallenges/RationalHitting.json @@ -0,0 +1,13 @@ +{ + "challenge_module": "ComparatorChallenges.RationalHitting", + "solution_module": "OAI.Computability.RationalHitting.Main", + "theorem_names": [ + "OAI.RationalHitting.main" + ], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RationalHitting.lean b/lean/ComparatorChallenges/RationalHitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..7693842d66f4f3660251b4571903e2f8ec6980a8 --- /dev/null +++ b/lean/ComparatorChallenges/RationalHitting.lean @@ -0,0 +1,113 @@ +import Mathlib + +namespace OAI + +namespace RationalHitting + +universe u + +inductive Formula (n : ℕ) where + | var : Fin n → Formula n + | const : ℚ → Formula n + | add : Formula n → Formula n → Formula n + | mul : Formula n → Formula n → Formula n + | inv : Formula n → Formula n + deriving DecidableEq + +namespace Formula + +def size {n : ℕ} : Formula n → ℕ + | .var _ | .const _ => 1 + | .add f g | .mul f g => f.size + g.size + 1 + | .inv f => f.size + 1 + +/-- Evaluation in any rational algebra; a unary inverse requires an actual + two-sided inverse of the evaluated operand, not a totalized inverse. -/ +inductive Eval {n : ℕ} {R : Type u} [Ring R] + (c : ℚ →+* R) (X : Fin n → R) : Formula n → R → Prop where + | var (i) : Eval c X (.var i) (X i) + | const (a) : Eval c X (.const a) (c a) + | add {f g a b} : Eval c X f a → Eval c X g b → Eval c X (.add f g) (a + b) + | mul {f g a b} : Eval c X f a → Eval c X g b → Eval c X (.mul f g) (a * b) + | inv {f a b} : Eval c X f a → a * b = 1 → b * a = 1 → Eval c X (.inv f) b + +end Formula + +abbrev Mat (d : ℕ) := Matrix (Fin d) (Fin d) ℚ +abbrev Tuple (n d : ℕ) := Fin n → Mat d + +def Evaluates {n d : ℕ} (f : Formula n) (X : Tuple n d) (v : Mat d) : Prop := + f.Eval (algebraMap ℚ (Mat d)) X v + +def Admissible {n : ℕ} (f : Formula n) : Prop := + ∃ d, 0 < d ∧ ∃ (X : Tuple n d), ∃ v, Evaluates f X v + +def Nonzero {n : ℕ} (f : Formula n) : Prop := + ∃ d, 0 < d ∧ ∃ (X : Tuple n d), ∃ v, Evaluates f X v ∧ v ≠ 0 + +/-- All output tuples have one common positive dimension. -/ +structure Output (n : ℕ) where + dimension : ℕ + dimension_pos : 0 < dimension + tuples : List (Tuple n dimension) + +/-- Little-endian unsigned binary, prefixed by a unary bit-length and a zero + terminator. This is a self-delimiting binary encoding, including zero. -/ +def encodeNat (a : ℕ) : List Bool := + let ds := (Nat.digits 2 a).map (fun b => b != 0) + List.replicate ds.length true ++ [false] ++ ds + +/-- Sign bit, binary numerator magnitude, and positive binary denominator. + Rat.num and Rat.den are the canonical reduced numerator and denominator. -/ +def encodeRat (a : ℚ) : List Bool := + [decide (a.num < 0)] ++ encodeNat a.num.natAbs ++ encodeNat a.den + +def encodeTuple {n d : ℕ} (X : Tuple n d) : List Bool := + (List.finRange n).flatMap fun i => + (List.finRange d).flatMap fun j => + (List.finRange d).flatMap fun k => encodeRat (X i j k) + +def encodeOutput {n : ℕ} (H : Output n) : List Bool := + encodeNat H.dimension ++ encodeNat H.tuples.length ++ H.tuples.flatMap encodeTuple + +/-- 0 is blank, 1 and 2 are the two literal binary digits, 3 is work space. + Fixed finite tape alphabet and finite state space; no advice or oracle. -/ +abbrev Alphabet := Fin 4 +abbrev Machine (m : ℕ) := Turing.TM0.Machine Alphabet (Fin (m + 1)) +abbrev Config (m : ℕ) := Turing.TM0.Cfg Alphabet (Fin (m + 1)) + +def tapeBit (b : Bool) : Alphabet := if b then 2 else 1 + +def unaryInput (n s : ℕ) : List Alphabet := + List.replicate n 2 ++ [1] ++ List.replicate s 2 + +/-- Exactly t ordinary deterministic TM0 transitions. -/ +def run {m : ℕ} (G : Machine m) : ℕ → Config m → Option (Config m) + | 0, a => some a + | t + 1, a => (Turing.TM0.step G a).bind (run G t) + +def OutputsWithin {m n : ℕ} (G : Machine m) (s bound : ℕ) (H : Output n) : Prop := + ∃ t ≤ bound, ∃ a : Config m, + run G t (Turing.TM0.init (unaryInput n s)) = some a ∧ + Turing.TM0.step G a = none ∧ + a.Tape.right₀ = Turing.ListBlank.mk ((encodeOutput H).map tapeBit) + +def Hits {n : ℕ} (s : ℕ) (H : Output n) : Prop := + ∀ f : Formula n, f.size ≤ s → Admissible f → Nonzero f → + ∃ X ∈ H.tuples, ∃ v, Evaluates f X v ∧ IsUnit v + +/-- A fixed polynomial bound on bit time, full binary output length, +and common positive dimension. -/ +def MainStatement : Prop := + ∃ (m : ℕ) (G : Machine m) (C k : ℕ), 0 < C ∧ 0 < k ∧ + ∀ n s : ℕ, 1 ≤ n → 1 ≤ s → ∃ H : Output n, + H.dimension ≤ C * (n + s + 1) ^ k ∧ + (encodeOutput H).length ≤ C * (n + s + 1) ^ k ∧ + OutputsWithin G s (C * (n + s + 1) ^ k) H ∧ Hits s H + +theorem main : MainStatement := by + sorry + +end RationalHitting + +end OAI diff --git a/lean/ComparatorChallenges/RealL1Renorming.json b/lean/ComparatorChallenges/RealL1Renorming.json new file mode 100644 index 0000000000000000000000000000000000000000..bfc08e9958e9e36b9ee9426ec42e6f236b644a5c --- /dev/null +++ b/lean/ComparatorChallenges/RealL1Renorming.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RealL1Renorming", + "solution_module": "OAI.Analysis.LipschitzFree.Renorming", + "theorem_names": [ + "OAI.DiscreteFree.real_l1_quantitative_renorming" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RealL1Renorming.lean b/lean/ComparatorChallenges/RealL1Renorming.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec37135e0c8c463a944115a1e167a17ce9860dc8 --- /dev/null +++ b/lean/ComparatorChallenges/RealL1Renorming.lean @@ -0,0 +1,55 @@ +import Mathlib.Analysis.Normed.Lp.lpSpace +import Mathlib.Analysis.Normed.Operator.Basic +import Mathlib.RingTheory.Finiteness.Defs + +namespace OAI + +noncomputable section + +/-! +# Quantitative renorming of real ℓ¹ with fixed vector-space operations +-/ + +open scoped BigOperators ENNReal + +namespace DiscreteFree + +variable {M : Type*} [MetricSpace M] + +def HasBAP (X : Type*) [NormedAddCommGroup X] [NormedSpace ℝ X] (Λ : ℝ) : Prop := + ∀ C : Set X, IsCompact C → ∀ ε : ℝ, 0 < ε → + ∃ T : X →L[ℝ] X, Module.Finite ℝ (LinearMap.range T.toLinearMap) ∧ + ‖T‖ ≤ Λ ∧ ∃ η : ℝ, η < ε ∧ ∀ u ∈ C, ‖T u - u‖ ≤ η + +def blockBound (p : ℕ) : ℝ := 300 * (p : ℝ)^2 + 150 * (p : ℝ) + 5 + +open scoped BigOperators ENNReal + +def RealL1 : Type := lp (fun _ : ℕ => ℝ) (1 : ENNReal) + +noncomputable instance : NormedAddCommGroup RealL1 := + inferInstanceAs (NormedAddCommGroup (lp (fun _ : ℕ => ℝ) (1 : ENNReal))) + +noncomputable instance : NormedSpace ℝ RealL1 := + inferInstanceAs (NormedSpace ℝ (lp (fun _ : ℕ => ℝ) (1 : ENNReal))) + +def RealL1RenormingStatement : Prop := + ∀ p : ℕ, 1 ≤ p → ∃ N : AddGroupNorm RealL1, + (∀ (r : ℝ) (c : RealL1), N (r • c) = |r| * N c) ∧ + (∀ c : RealL1, (1 / 2 : ℝ) * ‖c‖ ≤ N c ∧ N c ≤ blockBound p * ‖c‖) ∧ + (let m : Module ℝ RealL1 := inferInstance + letI : NormedAddCommGroup RealL1 := N.toNormedAddCommGroup + ∃ s : NormedSpace ℝ RealL1, s.toModule = m ∧ + letI := s + CompleteSpace RealL1 ∧ + HasBAP RealL1 (2 * blockBound p) ∧ ¬ HasBAP RealL1 (p : ℝ) ∧ + (p = 1 → ¬ HasBAP RealL1 1)) + +theorem real_l1_quantitative_renorming : RealL1RenormingStatement := by + sorry + +end DiscreteFree + +end + +end OAI diff --git a/lean/ComparatorChallenges/RecursivePotentials.json b/lean/ComparatorChallenges/RecursivePotentials.json new file mode 100644 index 0000000000000000000000000000000000000000..19c3404b7923cfee0cae594f3526b8bc70de4295 --- /dev/null +++ b/lean/ComparatorChallenges/RecursivePotentials.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RecursivePotentials", + "solution_module": "OAI.Analysis.RecursivePotentials.Challenge", + "theorem_names": [ + "OAI.ComparatorModel.RecursivePotentials.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RecursivePotentials.lean b/lean/ComparatorChallenges/RecursivePotentials.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a6258dc2253ba0a22adf82e1450432c64a2bd8a --- /dev/null +++ b/lean/ComparatorChallenges/RecursivePotentials.lean @@ -0,0 +1,964 @@ +import Mathlib + +namespace OAI + +noncomputable section + +/-! +The final claim constructs the spaces and states all eleven original results. +`Analysis.RecursivePotentials.Challenge.main_iff_original` verifies statement preservation. +-/ + +universe uIndex uSpace uOther uDomain uTarget uFiber + +open scoped BigOperators + +namespace RecursivePotentials + +def leastPair (x a b : ℝ) : ℝ × ℝ := (max a (x + b), max b (-x + a)) + +structure FiniteRootedTree (ι : Type uIndex) where + root : ι + parent : ι → ι + depth : ι → ℕ + parent_root : parent root = root + depth_root : depth root = 0 + parent_depth : ∀ i, i ≠ root → depth (parent i) < depth i + +namespace FiniteRootedTree + +section + +variable {ι : Type uIndex} [indexFinite : Fintype ι] [indexDecidable : DecidableEq ι] + (T : FiniteRootedTree ι) + +def children (s : ι) : Finset ι := + Finset.univ.filter fun c => c ≠ T.root ∧ T.parent c = s + +def maxDepth : ℕ := Finset.univ.sup T.depth + +noncomputable def fields (v : ι → ℝ) (s : ι) : ℝ × ℝ := + leastPair (v s) + (Real.sqrt (∑ c : {c // c ∈ T.children s}, (fields v c.1).1 ^ 2)) + (Real.sqrt (∑ c : {c // c ∈ T.children s}, (fields v c.1).2 ^ 2)) +termination_by T.maxDepth - T.depth s +decreasing_by + all_goals + have hc := (Finset.mem_filter.mp c.2).2 + have hd := T.parent_depth c.1 hc.1 + rw [hc.2] at hd + have hm : T.depth c.1 ≤ T.maxDepth := Finset.le_sup (Finset.mem_univ c.1) + omega + +def Initial (H : Finset ι) : Prop := T.root ∈ H ∧ ∀ s ∈ H, T.parent s ∈ H + +end + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +def ancestors (s : ι) : Finset ι := + if _hs : s = T.root then {s} else insert s (ancestors (T.parent s)) +termination_by T.depth s +decreasing_by exact T.parent_depth s _hs + +def ancestorClosure (S : Finset ι) : Finset ι := + insert T.root (S.biUnion T.ancestors) + +def restrict (H : Finset ι) (hH : T.Initial H) : FiniteRootedTree H where + root := ⟨T.root, hH.1⟩ + parent s := ⟨T.parent s, hH.2 s.1 s.2⟩ + depth s := T.depth s + parent_root := Subtype.ext T.parent_root + depth_root := T.depth_root + parent_depth s hs := T.parent_depth s (fun h => hs (Subtype.ext h)) + +noncomputable def extend (H : Finset ι) (f : H → ℝ) : ι →₀ ℝ := + Finsupp.onFinset H (fun s => if hs : s ∈ H then f ⟨s, hs⟩ else 0) + (fun s hs => by by_contra hh; simp [hh] at hs) + +def head (v : ι →₀ ℝ) : Finset ι := T.ancestorClosure v.support + +def projectHead (_T : FiniteRootedTree ι) (H : Finset ι) (v : ι →₀ ℝ) : ι →₀ ℝ := v.filter (· ∈ H) + +end FiniteRootedTree + +structure CofiniteSubspace (E : Type uSpace) [NormedAddCommGroup E] [NormedSpace ℝ E] where + space : Submodule ℝ E + closed : IsClosed (space : Set E) + finiteQuotient : Module.Finite ℝ (E ⧸ space) + +section Moduli + +variable {E : Type uSpace} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def averagedGain (x : E) (t : ℝ) (y : E) : ℝ := (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 + +noncomputable def averagedInner (x : E) (t : ℝ) (F : CofiniteSubspace E) : ℝ := + sInf {r : ℝ | ∃ y ∈ F.space, 1 ≤ ‖y‖ ∧ r = averagedGain x t y} + +noncomputable def averagedModulus (E : Type uSpace) [NormedAddCommGroup E] [NormedSpace ℝ E] + (t : ℝ) : ℝ := + sInf {r : ℝ | ∃ x : E, ‖x‖ = 1 ∧ r = sSup (Set.range (averagedInner x t))} + +end Moduli + +def sequenceTree : FiniteRootedTree (List ℕ) where + root := [] + parent := List.dropLast + depth := List.length + parent_root := rfl + depth_root := rfl + parent_depth s hs := by + rw [List.length_dropLast] + have h := List.length_pos_iff_ne_nil.mpr hs + omega + +abbrev ComponentNode (h : ℕ+) := {s : List ℕ // s.length ≤ h.val} + +abbrev JoinedNode := Option (Σ h : ℕ+, ComponentNode h) + +def joinedTree : FiniteRootedTree JoinedNode where + root := none + parent + | none => none + | some ⟨h, s⟩ => if s.1 = [] then none else + some ⟨h, ⟨s.1.dropLast, by rw [List.length_dropLast]; have := s.2; omega⟩⟩ + depth + | none => 0 + | some ⟨_, s⟩ => s.1.length + 1 + parent_root := rfl + depth_root := rfl + parent_depth s hs := by + cases s with + | none => exact (hs rfl).elim + | some s => + obtain ⟨h, s⟩ := s + dsimp + by_cases he : s.1 = [] + · simp [he] + · rw [ite_eq_right he] + dsimp + rw [List.length_dropLast] + have hpos := List.length_pos_iff_ne_nil.mpr he + omega + +open Filter Topology + +def WeaklyNull {E : Type uSpace} [NormedAddCommGroup E] [NormedSpace ℝ E] (d : ℕ → E) : Prop := + ∀ f : E →L[ℝ] ℝ, Tendsto (fun k => f (d k)) atTop (𝓝 0) + +structure EquivalentNorm (E : Type uSpace) [NormedAddCommGroup E] [NormedSpace ℝ E] where + N : Seminorm ℝ E + lower : ℝ + upper : ℝ + lower_pos : 0 < lower + lower_le_upper : lower ≤ upper + lower_bound : ∀ x, lower * ‖x‖ ≤ N x + upper_bound : ∀ x, N x ≤ upper * ‖x‖ + +namespace EquivalentNorm + +variable {E : Type uSpace} [NormedAddCommGroup E] [NormedSpace ℝ E] (A : EquivalentNorm E) + +noncomputable def inner (x : E) (t : ℝ) (F : CofiniteSubspace E) : ℝ := + sInf {r : ℝ | ∃ y ∈ F.space, A.N y = 1 ∧ r = A.N (x + t • y) - 1} + +noncomputable def modulus (t : ℝ) : ℝ := + sInf {r : ℝ | ∃ x : E, A.N x = 1 ∧ r = sSup (Set.range (A.inner x t))} + +def AUC : Prop := ∀ t : ℝ, 0 < t → 0 < A.modulus t + +end EquivalentNorm + +open scoped ENNReal + +def IsReflexive (E : Type uSpace) [NormedAddCommGroup E] [NormedSpace ℝ E] : Prop := + Function.Surjective (NormedSpace.inclusionInDoubleDual ℝ E) + +namespace SquareSum + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (E : ι → Type uFiber) + [∀ i, NormedAddCommGroup (E i)] [fiberNormedSpace : ∀ i, NormedSpace ℝ (E i)] + +abbrev Space : Type _ := ↥(lp E 2) + +end SquareSum + +open UniformSpace + +def completionEquivOfDense {E : Type uSpace} {F : Type uOther} [NormedAddCommGroup E] + [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] (f : E →L[ℝ] F) + (K : NNReal) (hK : ∀ x, ‖x‖ ≤ K * ‖f x‖) (hdense : DenseRange f) : Completion E ≃L[ℝ] F := by + let g := f.fromCompletion + have hbound : ∀ x : Completion E, ‖x‖ ≤ K * ‖g x‖ := by + intro x + induction x using Completion.induction_on with + | hp => exact isClosed_le continuous_norm (continuous_const.mul (g.continuous.norm)) + | ih x => simpa only [g, ContinuousLinearMap.fromCompletion_apply_coe, Completion.norm_coe] using hK x + have hanti := g.antilipschitz_of_bound hbound + have hclosed := hanti.isClosed_range g.uniformContinuous + have hsurj : Function.Surjective g := by + intro y + have hh : y ∈ closure (Set.range f) := hdense y + have hsub : Set.range f ⊆ Set.range g := by + rintro _ ⟨x, rfl⟩ + exact ⟨(x : Completion E), ContinuousLinearMap.fromCompletion_apply_coe f x⟩ + have hm := closure_mono hsub hh + rw [hclosed.closure_eq] at hm + exact hm + exact ContinuousLinearEquiv.ofBijective g (LinearMap.ker_eq_bot.mpr hanti.injective) + (LinearMap.range_eq_top.mpr hsurj) + +def componentTree (h : ℕ+) : FiniteRootedTree (ComponentNode h) where + root := ⟨[], by simp⟩ + parent s := ⟨s.1.dropLast, by rw [List.length_dropLast]; have := s.2; omega⟩ + depth s := s.1.length + parent_root := Subtype.ext rfl + depth_root := rfl + parent_depth s hs := by + rw [List.length_dropLast] + have hne : s.1 ≠ [] := fun h => hs (Subtype.ext h) + have hp := List.length_pos_iff_ne_nil.mpr hne + omega + +def logarithmicGamma (M β : ℝ) : ℝ := + let h := β ^ 2 / (2 * M ^ 2) + let c := β * Real.sqrt h / 8 + let H := 1 + Real.log (M / c) + let K := 4 * (2 + Real.sqrt 6) * H / h + β * h / 8 * Real.exp (-K) + +open Filter + +open scoped Topology + +structure ChildExponent where + val : ℝ + one_le : 1 ≤ val + +namespace ChildExponent + +variable (p : ChildExponent) + +def agg {ι : Type uIndex} (s : Finset ι) (f : ι → ℝ) : ℝ := + (∑ i ∈ s, |f i| ^ p.val) ^ (1 / p.val) + +end ChildExponent + +section + +variable {ι : Type uIndex} [indexFinite : Fintype ι] [indexDecidable : DecidableEq ι] + (T : FiniteRootedTree ι) (p : ChildExponent) + +def FiniteRootedTree.pfields (v : ι → ℝ) (s : ι) : ℝ × ℝ := + leastPair (v s) + (p.agg Finset.univ (fun c : {c // c ∈ T.children s} => (pfields v c.1).1)) + (p.agg Finset.univ (fun c : {c // c ∈ T.children s} => (pfields v c.1).2)) +termination_by T.maxDepth - T.depth s +decreasing_by + all_goals + have hc := (Finset.mem_filter.mp c.2).2 + have hd := T.parent_depth c.1 hc.1 + rw [hc.2] at hd + have hm : T.depth c.1 ≤ T.maxDepth := Finset.le_sup (Finset.mem_univ c.1) + omega + +end + +namespace VariableExponent + +def heightExponent (h : ℕ+) : ℝ := 1 + 1 / (h.val : ℝ) + +def cubicConstant : ℝ := (6 * Real.exp 1)⁻¹ ^ 3 + +def sixthConstant : ℝ := 2 * Real.exp (-(Real.exp 1 - 1)) * (4 : ℝ)⁻¹ ^ 6 + +end VariableExponent + +open Filter Topology TopologicalSpace + +end RecursivePotentials + +namespace ComparatorModel + +open scoped BigOperators + +namespace RecursivePotentials + +section + +noncomputable abbrev leastPair := @_root_.OAI.RecursivePotentials.leastPair + +noncomputable abbrev FiniteRootedTree := @_root_.OAI.RecursivePotentials.FiniteRootedTree + +namespace FiniteRootedTree + +section + +variable {ι : Type uIndex} [indexFinite : Fintype ι] [indexDecidable : DecidableEq ι] + (T : FiniteRootedTree ι) + +noncomputable abbrev Initial (T : FiniteRootedTree ι) := _root_.OAI.RecursivePotentials.FiniteRootedTree.Initial T + +end + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +noncomputable abbrev restrict (T : FiniteRootedTree ι) := _root_.OAI.RecursivePotentials.FiniteRootedTree.restrict T + +noncomputable abbrev extend (H : Finset ι) := _root_.OAI.RecursivePotentials.FiniteRootedTree.extend H + +noncomputable abbrev head (T : FiniteRootedTree ι) := _root_.OAI.RecursivePotentials.FiniteRootedTree.head T + +class Heads : Prop where + initial : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) (v : ι →₀ ℝ), + T.Initial (T.head v) + +variable [ComparatorModel.RecursivePotentials.FiniteRootedTree.Heads] + +noncomputable def P (v : ι →₀ ℝ) : ι →₀ ℝ := + extend (T.head v) (fun s => ((T.restrict (T.head v) (FiniteRootedTree.Heads.initial T v)).fields + (fun s => v s.1) s).1) + +noncomputable def Q (v : ι →₀ ℝ) : ι →₀ ℝ := + extend (T.head v) (fun s => ((T.restrict (T.head v) (FiniteRootedTree.Heads.initial T v)).fields + (fun s => v s.1) s).2) + +noncomputable def normSum (v : ι →₀ ℝ) : ℝ := T.P v T.root + T.Q v T.root + +noncomputable abbrev projectHead (T : FiniteRootedTree ι) := _root_.OAI.RecursivePotentials.FiniteRootedTree.projectHead T + +end FiniteRootedTree + +variable [ComparatorModel.RecursivePotentials.FiniteRootedTree.Heads] + +def TreeVector {ι : Type uIndex} (_T : FiniteRootedTree ι) := ι →₀ ℝ + +namespace TreeVector + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +instance : AddCommGroup (TreeVector T) := inferInstanceAs (AddCommGroup (ι →₀ ℝ)) + +instance : Module ℝ (TreeVector T) := inferInstanceAs (Module ℝ (ι →₀ ℝ)) + +instance : CoeFun (TreeVector T) (fun _ => ι → ℝ) := ⟨fun v => (show ι →₀ ℝ from v)⟩ + +noncomputable instance : Norm (TreeVector T) := ⟨fun v => T.normSum v⟩ + +class Construction : Prop where + core : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι), + NormedSpace.Core ℝ (TreeVector T) + coordinate_bound : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (v : ι →₀ ℝ) (s : ι), |v s| ≤ T.normSum v + projection_bound : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (H : Finset ι), T.Initial H → ∀ v, T.normSum (T.projectHead H v) ≤ T.normSum v + +variable [ComparatorModel.RecursivePotentials.TreeVector.Construction] + +noncomputable instance : NormedAddCommGroup (TreeVector T) := + NormedAddCommGroup.ofCore (TreeVector.Construction.core T) + +noncomputable instance : NormedSpace ℝ (TreeVector T) := NormedSpace.ofCore (TreeVector.Construction.core T) + +def coordinateLinear (s : ι) : TreeVector T →ₗ[ℝ] ℝ where + toFun v := v s + map_add' _v _w := rfl + map_smul' _a _v := rfl + +noncomputable def coordinate (s : ι) : TreeVector T →L[ℝ] ℝ := + (coordinateLinear T s).mkContinuous 1 (fun v => by + change ‖v s‖ ≤ 1 * T.normSum v + rw [Real.norm_eq_abs, one_mul] + exact TreeVector.Construction.coordinate_bound T v s) + +def projectionLinear (H : Finset ι) : TreeVector T →ₗ[ℝ] TreeVector T where + toFun := T.projectHead H + map_add' v w := by + change ι →₀ ℝ at v w + apply Finsupp.ext + intro s + change T.projectHead H (v + w) s = (T.projectHead H v + T.projectHead H w) s + by_cases hs : s ∈ H <;> simp [FiniteRootedTree.projectHead, _root_.OAI.RecursivePotentials.FiniteRootedTree.projectHead, hs] + map_smul' a v := by + change ι →₀ ℝ at v + apply Finsupp.ext + intro s + change T.projectHead H (a • v) s = (a • T.projectHead H v) s + by_cases hs : s ∈ H <;> simp [FiniteRootedTree.projectHead, _root_.OAI.RecursivePotentials.FiniteRootedTree.projectHead, hs] + +noncomputable def projection (H : Finset ι) (hH : T.Initial H) : + TreeVector T →L[ℝ] TreeVector T := + (projectionLinear T H).mkContinuous 1 (fun v => by + change T.normSum (T.projectHead H v) ≤ 1 * T.normSum v + rw [one_mul] + exact TreeVector.Construction.projection_bound T H hH v) + +end TreeVector + +variable [ComparatorModel.RecursivePotentials.TreeVector.Construction] + +abbrev TreeSpace {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) := + UniformSpace.Completion (TreeVector T) + +namespace TreeSpace + +open UniformSpace + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +def coordinate (s : ι) : TreeSpace T →L[ℝ] ℝ := (TreeVector.coordinate T s).fromCompletion + +def P (s : ι) : TreeSpace T → ℝ := + Completion.extension (fun v : TreeVector T => T.P v s) + +def Q (s : ι) : TreeSpace T → ℝ := + Completion.extension (fun v : TreeVector T => T.Q v s) + +def projection (H : Finset ι) (hH : T.Initial H) : TreeSpace T →L[ℝ] TreeSpace T := + (TreeVector.projection T H hH).completion + +def tail (H : Finset ι) (hH : T.Initial H) : Submodule ℝ (TreeSpace T) := + (projection T H hH).ker + +end TreeSpace + +section Moduli + +variable {E : Type uSpace} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable abbrev averagedModulus := @_root_.OAI.RecursivePotentials.averagedModulus + +end Moduli + +noncomputable abbrev sequenceTree := @_root_.OAI.RecursivePotentials.sequenceTree + +noncomputable abbrev ComponentNode := @_root_.OAI.RecursivePotentials.ComponentNode + +noncomputable abbrev JoinedNode := @_root_.OAI.RecursivePotentials.JoinedNode + +noncomputable abbrev joinedTree := @_root_.OAI.RecursivePotentials.joinedTree + +abbrev XSigma := TreeSpace sequenceTree + +abbrev XJoined := TreeSpace joinedTree + +def ZeroTreeVector {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) : Type _ := + ↥((TreeVector.coordinate T T.root).ker) + +namespace ZeroTreeVector + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +instance : AddCommGroup (ZeroTreeVector T) := + inferInstanceAs (AddCommGroup (TreeVector.coordinate T T.root).ker) + +instance : Module ℝ (ZeroTreeVector T) := + inferInstanceAs (Module ℝ (TreeVector.coordinate T T.root).ker) + +def toTree : ZeroTreeVector T →ₗ[ℝ] TreeVector T := + (TreeVector.coordinate T T.root).ker.subtype + +instance : Norm (ZeroTreeVector T) := ⟨fun v => T.P (toTree T v) T.root⟩ + +class Construction : Prop where + core : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι), + NormedSpace.Core ℝ (ZeroTreeVector T) + half : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (v : ZeroTreeVector T), ‖v‖ = ‖toTree T v‖ / 2 + +variable [ComparatorModel.RecursivePotentials.ZeroTreeVector.Construction] + +instance : NormedAddCommGroup (ZeroTreeVector T) := NormedAddCommGroup.ofCore (ZeroTreeVector.Construction.core T) + +instance : NormedSpace ℝ (ZeroTreeVector T) := NormedSpace.ofCore (ZeroTreeVector.Construction.core T) + +def inclusion : ZeroTreeVector T →L[ℝ] TreeVector T := + (toTree T).mkContinuous 2 (fun v => by rw [ZeroTreeVector.Construction.half]; exact le_of_eq (by ring)) + +def projectionLinear (H : Finset ι) (hH : T.Initial H) : ZeroTreeVector T →ₗ[ℝ] ZeroTreeVector T := + (((TreeVector.projection T H hH).toLinearMap).comp (toTree T)).codRestrict + (TreeVector.coordinate T T.root).ker (fun v => by + change TreeVector.coordinate T T.root (TreeVector.projection T H hH (toTree T v)) = 0 + change T.projectHead H (toTree T v) T.root = 0 + change (if T.root ∈ H then toTree T v T.root else 0) = 0 + rw [ite_eq_left hH.1] + exact v.2) + +def projection (H : Finset ι) (hH : T.Initial H) : ZeroTreeVector T →L[ℝ] ZeroTreeVector T := + (projectionLinear T H hH).mkContinuous 1 (fun v => by + rw [one_mul, ZeroTreeVector.Construction.half, ZeroTreeVector.Construction.half] + exact (div_le_div_iff_of_pos_right (by norm_num : (0 : ℝ) < 2)).mpr + (TreeVector.Construction.projection_bound T H hH (toTree T v))) + +end ZeroTreeVector + +variable [ComparatorModel.RecursivePotentials.ZeroTreeVector.Construction] + +abbrev ZeroTreeSpace {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) := + UniformSpace.Completion (ZeroTreeVector T) + +namespace ZeroTreeSpace + +open UniformSpace + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +def inclusion : ZeroTreeSpace T →L[ℝ] TreeSpace T := (ZeroTreeVector.inclusion T).completion + +def projection (H : Finset ι) (hH : T.Initial H) : ZeroTreeSpace T →L[ℝ] ZeroTreeSpace T := + (ZeroTreeVector.projection T H hH).completion + +def tail (H : Finset ι) (hH : T.Initial H) : Submodule ℝ (ZeroTreeSpace T) := + (projection T H hH).ker + +end ZeroTreeSpace + +abbrev XZero := ZeroTreeSpace joinedTree + +section + +open UniformSpace + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + +def ZeroTreeSpace.coordinate (s : ι) : ZeroTreeSpace T →L[ℝ] ℝ := + (TreeSpace.coordinate T s).comp (inclusion T) + +def ZeroTreeSpace.P (s : ι) (x : ZeroTreeSpace T) : ℝ := TreeSpace.P T s (inclusion T x) + +def ZeroTreeSpace.Q (s : ι) (x : ZeroTreeSpace T) : ℝ := TreeSpace.Q T s (inclusion T x) + +end + +open Filter Topology + +noncomputable abbrev WeaklyNull := @_root_.OAI.RecursivePotentials.WeaklyNull + +noncomputable abbrev EquivalentNorm := @_root_.OAI.RecursivePotentials.EquivalentNorm + +namespace EquivalentNorm + +variable {E : Type uSpace} [NormedAddCommGroup E] [NormedSpace ℝ E] (A : EquivalentNorm E) + +noncomputable abbrev modulus (A : EquivalentNorm E) := _root_.OAI.RecursivePotentials.EquivalentNorm.modulus A + +noncomputable abbrev AUC (A : EquivalentNorm E) := _root_.OAI.RecursivePotentials.EquivalentNorm.AUC A + +end EquivalentNorm + +open scoped ENNReal + +noncomputable abbrev IsReflexive := @_root_.OAI.RecursivePotentials.IsReflexive + +namespace SquareSum + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (E : ι → Type uFiber) + [∀ i, NormedAddCommGroup (E i)] [fiberNormedSpace : ∀ i, NormedSpace ℝ (E i)] + +noncomputable abbrev Space := @_root_.OAI.RecursivePotentials.SquareSum.Space + +end SquareSum + +open UniformSpace + +noncomputable abbrev completionEquivOfDense := @_root_.OAI.RecursivePotentials.completionEquivOfDense + +noncomputable abbrev componentTree := @_root_.OAI.RecursivePotentials.componentTree + +noncomputable abbrev logarithmicGamma := @_root_.OAI.RecursivePotentials.logarithmicGamma + +open Filter + +open scoped Topology + +def XJoined_separated_familiesStatement : Prop := ∀ {ε : ℝ} (_hε : 0 < ε), + ∃ η : ℝ, 0 < η ∧ η < 1 ∧ + (ε ≤ 2 → η = min (1/2) (logarithmicGamma 2 (ε/16))) ∧ + ∀ (x : XJoined) (z : ℕ → XJoined), + (∀ n, ‖x+z n‖ ≤ 1) → (∀ n, ‖x-z n‖ ≤ 1) → + (∀ i j, i ≠ j → ε ≤ ‖z i-z j‖) → ‖x‖ ≤ 1-η + +noncomputable abbrev ChildExponent := @_root_.OAI.RecursivePotentials.ChildExponent + +namespace VariableExponent + +noncomputable abbrev heightExponent := @_root_.OAI.RecursivePotentials.VariableExponent.heightExponent + +noncomputable abbrev cubicConstant := @_root_.OAI.RecursivePotentials.VariableExponent.cubicConstant + +noncomputable abbrev sixthConstant := @_root_.OAI.RecursivePotentials.VariableExponent.sixthConstant + +end VariableExponent + +namespace VariableTree + +open FiniteRootedTree + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) + +noncomputable def P (v : ι →₀ ℝ) : ι →₀ ℝ := + extend (T.head v) (fun s => ((T.restrict (T.head v) (FiniteRootedTree.Heads.initial T v)).pfields e + (fun s => v s.1) s).1) + +noncomputable def Q (v : ι →₀ ℝ) : ι →₀ ℝ := + extend (T.head v) (fun s => ((T.restrict (T.head v) (FiniteRootedTree.Heads.initial T v)).pfields e + (fun s => v s.1) s).2) + +noncomputable def normSum (v : ι →₀ ℝ) : ℝ := P T e v T.root + Q T e v T.root + +end VariableTree + +def AggregationVector {ι : Type uIndex} (_T : FiniteRootedTree ι) (_e : ChildExponent) := ι →₀ ℝ + +namespace AggregationVector + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) + +instance : AddCommGroup (AggregationVector T e) := inferInstanceAs (AddCommGroup (ι →₀ ℝ)) + +instance : Module ℝ (AggregationVector T e) := inferInstanceAs (Module ℝ (ι →₀ ℝ)) + +instance : CoeFun (AggregationVector T e) (fun _ => ι → ℝ) := ⟨fun v => (show ι →₀ ℝ from v)⟩ + +noncomputable instance : Norm (AggregationVector T e) := ⟨fun v => VariableTree.normSum T e v⟩ + +class Construction : Prop where + core : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) (e : ChildExponent), + NormedSpace.Core ℝ (AggregationVector T e) + coordinate_bound : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) (v : ι →₀ ℝ) (s : ι), |v s| ≤ VariableTree.normSum T e v + +variable [ComparatorModel.RecursivePotentials.AggregationVector.Construction] + +noncomputable instance : NormedAddCommGroup (AggregationVector T e) := + NormedAddCommGroup.ofCore (AggregationVector.Construction.core T e) + +noncomputable instance : NormedSpace ℝ (AggregationVector T e) := NormedSpace.ofCore (AggregationVector.Construction.core T e) + +def coordinateLinear (s : ι) : AggregationVector T e →ₗ[ℝ] ℝ where + toFun v := v s + map_add' _v _w := rfl + map_smul' _a _v := rfl + +noncomputable def coordinate (s : ι) : AggregationVector T e →L[ℝ] ℝ := + (coordinateLinear T e s).mkContinuous 1 (fun v => by + change ‖v s‖ ≤ 1 * VariableTree.normSum T e v + rw [Real.norm_eq_abs, one_mul] + exact AggregationVector.Construction.coordinate_bound T e v s) + +end AggregationVector + +variable [ComparatorModel.RecursivePotentials.AggregationVector.Construction] + +abbrev AggregationSpace {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) := + UniformSpace.Completion (AggregationVector T e) + +namespace AggregationSpace + +open UniformSpace + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) + +def coordinate (s : ι) : + AggregationSpace T e →L[ℝ] ℝ := (AggregationVector.coordinate T e s).fromCompletion + +def P (s : ι) : AggregationSpace T e → ℝ := + Completion.extension (fun v : AggregationVector T e => VariableTree.P T e v s) + +def Q (s : ι) : AggregationSpace T e → ℝ := + Completion.extension (fun v : AggregationVector T e => VariableTree.Q T e v s) + +end AggregationSpace + +section + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) + +def AggregationVector.basisVector (s : ι) : AggregationVector T e := Finsupp.single s 1 + +end + +open Filter Topology TopologicalSpace + +namespace ChildExponent + +instance (e : ChildExponent) : Fact (1 ≤ ENNReal.ofReal e.val) := + ⟨by simpa using ENNReal.ofReal_le_ofReal e.one_le⟩ + +end ChildExponent + +section + +open scoped ENNReal + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) + +abbrev AggregationVector.CoordinateLp (ι : Type uIndex) (e : ChildExponent) := ↥(lp (fun _ : ι => ℝ) (ENNReal.ofReal e.val)) + +def AggregationVector.toLpLinear : AggregationVector T e →ₗ[ℝ] CoordinateLp ι e := + Finsupp.lsum ℝ (fun s => lp.lsingle (𝕜 := ℝ) (E := fun _ : ι => ℝ) (ENNReal.ofReal e.val) s) + +class AggregationVector.LpConstruction : Prop where + bounds : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent), 1 < e.val → + (∀ c, c ≠ T.root → T.depth c = T.depth (T.parent c) + 1) → + ∀ h : ℕ, (∀ s, T.depth s ≤ h) → ∀ v : AggregationVector T e, + ‖v‖ ≤ (2*(h+1:ℝ)^(1-1/e.val))*‖toLpLinear T e v‖ ∧ + ‖toLpLinear T e v‖ ≤ (h+1:ℝ)^(1/e.val)*‖v‖ + dense : ∀ {ι : Type uIndex} [DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent), DenseRange (toLpLinear T e) + +variable [ComparatorModel.RecursivePotentials.AggregationVector.LpConstruction] + +def AggregationVector.toLp (hp : 1 < e.val) + (hstep : ∀ c, c ≠ T.root → T.depth c = T.depth (T.parent c) + 1) + (h : ℕ) (hh : ∀ s, T.depth s ≤ h) : AggregationVector T e →L[ℝ] CoordinateLp ι e := + (toLpLinear T e).mkContinuous ((h+1:ℝ)^(1/e.val)) + (fun v => (LpConstruction.bounds T e hp hstep h hh v).2) + +end + +section + +open AggregationVector + +variable {ι : Type uIndex} [indexDecidable : DecidableEq ι] (T : FiniteRootedTree ι) + (e : ChildExponent) + +variable [ComparatorModel.RecursivePotentials.AggregationVector.LpConstruction] + +def AggregationSpace.lpEquiv (hp : 1 < e.val) + (hstep : ∀ c, c ≠ T.root → T.depth c = T.depth (T.parent c) + 1) + (h : ℕ) (hh : ∀ s, T.depth s ≤ h) : AggregationSpace T e ≃L[ℝ] CoordinateLp ι e := + completionEquivOfDense (AggregationVector.toLp T e hp hstep h hh) + ⟨2*(h+1:ℝ)^(1-1/e.val),by positivity⟩ + (fun v => (AggregationVector.LpConstruction.bounds T e hp hstep h hh v).1) + (AggregationVector.LpConstruction.dense T e) + +end + +namespace Variable + +section + +open UniformSpace VariableExponent Filter Topology TopologicalSpace + +variable [ComparatorModel.RecursivePotentials.AggregationVector.LpConstruction] + +def exponent (h : ℕ+) : ChildExponent := ⟨heightExponent h,(by + dsimp [heightExponent] + have hh : (0 : ℝ) < h.val := by exact_mod_cast h.pos + exact le_add_of_nonneg_right (le_of_lt (one_div_pos.mpr hh)))⟩ + +abbrev Component (h : ℕ+) := AggregationSpace (componentTree h) (exponent h) + +abbrev Xv := SquareSum.Space Component + +abbrev Node := Σ h : ℕ+, ComponentNode h + +def componentEquiv (h : ℕ+) : + Component h ≃L[ℝ] AggregationVector.CoordinateLp (ComponentNode h) (exponent h) := + AggregationSpace.lpEquiv (componentTree h) (exponent h) (by + dsimp [exponent, heightExponent] + have hh : (0 : ℝ) < h.val := by exact_mod_cast h.pos + exact lt_add_of_pos_right _ (one_div_pos.mpr hh)) + (by + intro c hc + change c.1.length = c.1.dropLast.length + 1 + rw [List.length_dropLast] + have hp := List.length_pos_iff_ne_nil.mpr (show c.1 ≠ [] from fun he => hc (Subtype.ext he)) + omega) h.val (fun c => c.2) + +def componentCoordinate (h : ℕ+) (s : ComponentNode h) : Component h →L[ℝ] ℝ := + AggregationSpace.coordinate (componentTree h) (exponent h) s + +def coordinate (s : Node) : Xv →L[ℝ] ℝ := + (componentCoordinate s.1 s.2).comp (lp.evalCLM ℝ Component 2 s.1) + +def basis (s : Node) : Xv := lp.single 2 s.1 + ((AggregationVector.basisVector (componentTree s.1) (exponent s.1) s.2 : AggregationVector (componentTree s.1) (exponent s.1)) : Component s.1) + +def FiniteTotalSupport (x : Xv) : Prop := ∃ S : Finset Node, ∀ s ∉ S, coordinate s x = 0 + +def projection (S : Finset Node) : Xv →L[ℝ] Xv := ∑ s ∈ S, (coordinate s).smulRight (basis s) + +def AdmissibleHeads (x y : Xv) (A : ∀ h, Finset (ComponentNode h)) : Prop := + ∀ h, x h ≠ 0 → (componentTree h).Initial (A h) ∧ + (∀ s ∉ A h, componentCoordinate h s (x h) = 0) ∧ + (∀ s ∈ A h, componentCoordinate h s (y h) = 0) + +def cubic_stabilityStatement : Prop := ∀ (x y : Xv) (_hx : FiniteTotalSupport x) (A : ∀ h, Finset (ComponentNode h)) + (_hA : AdmissibleHeads x y A) {R : ℝ} (_hR : 0 < R) (_hp : ‖x+y‖ ≤ R) (_hm : ‖x-y‖ ≤ R), + ‖x‖^2+cubicConstant/(2*Real.sqrt 2*R)*‖y‖^3 ≤ R^2 + +def sixth_stabilityStatement : Prop := ∀ (x y : Xv) (_hx : FiniteTotalSupport x) (A : ∀ h, Finset (ComponentNode h)) + (_hA : AdmissibleHeads x y A), + sixthConstant*‖y‖^6/(‖x+y‖^2+‖x-y‖^2)^2 ≤ ‖x+y‖^2+‖x-y‖^2-2*‖x‖^2 + +open UniformSpace VariableExponent Filter Topology TopologicalSpace + +def weakTailConstant : ℝ := cubicConstant/(2*Real.sqrt 2) + +def theta (ε : ℝ) : ℝ := Real.sqrt (1-weakTailConstant*ε^3) + +def weak_tailStatement : Prop := ∀ (x : Xv) {ε : ℝ} (_hε : 0 < ε) (_hε1 : ε ≤ 1) + (y : ℕ → Xv) (_hy : WeaklyNull y) (_hyε : ∀ j, ε ≤ ‖y j‖) + (_hp : ∀ j, ‖x+y j‖ ≤ 1) (_hm : ∀ j, ‖x-y j‖ ≤ 1), + ‖x‖ ≤ theta ε ∧ theta ε < 1 + +end + +open UniformSpace VariableExponent Filter Topology + +variable [ComparatorModel.RecursivePotentials.AggregationVector.LpConstruction] + +def one_sided_modulus_zeroStatement : Prop := ∀ (A : EquivalentNorm Xv), + A.modulus (A.lower/A.upper) = 0 + +def no_equivalent_AUCStatement : Prop := ∀ (A : EquivalentNorm Xv), + ¬A.AUC + +end Variable + +variable [ComparatorModel.RecursivePotentials.AggregationVector.LpConstruction] + +structure RootSumCompletionStatement {ι : Type uIndex} [DecidableEq ι] + (T : FiniteRootedTree ι) : Prop where + complete : CompleteSpace (TreeSpace T) + infinite_dimensional : ¬Module.Finite ℝ (TreeSpace T) + coordinate_continuous : ∀ s, Continuous (TreeSpace.coordinate T s) + coordinate_extends : ∀ s (v : TreeVector T), TreeSpace.coordinate T s (v : TreeSpace T) = v s + fields_continuous : ∀ s, Continuous (TreeSpace.P T s) ∧ Continuous (TreeSpace.Q T s) + fields_extend : ∀ s (v : TreeVector T), + TreeSpace.P T s (v : TreeSpace T) = T.P v s ∧ TreeSpace.Q T s (v : TreeSpace T) = T.Q v s + root_formula : ∀ x : TreeSpace T, ‖x‖ = TreeSpace.P T T.root x + TreeSpace.Q T T.root x + projections : ∀ (H : Finset ι) (hH : T.Initial H), + (∀ x : TreeSpace T, ‖TreeSpace.projection T H hH x‖ ≤ ‖x‖) ∧ + (∀ x : TreeSpace T, TreeSpace.projection T H hH (TreeSpace.projection T H hH x) = TreeSpace.projection T H hH x) ∧ + (∀ (s : ι) (x : TreeSpace T), TreeSpace.coordinate T s (TreeSpace.projection T H hH x) = + if s ∈ H then TreeSpace.coordinate T s x else 0) ∧ + FiniteDimensional ℝ (TreeSpace.projection T H hH).range ∧ + IsClosed (TreeSpace.tail T H hH : Set (TreeSpace T)) ∧ + Module.Finite ℝ (TreeSpace T ⧸ TreeSpace.tail T H hH) ∧ + ∀ x ∈ TreeSpace.tail T H hH, ∀ ε : ℝ, 0 < ε → + ∃ v : TreeVector T, TreeVector.projection T H hH v = 0 ∧ ‖(v : TreeSpace T)-x‖ < ε + +structure ZeroRootCompletionStatement {ι : Type uIndex} [DecidableEq ι] + (T : FiniteRootedTree ι) : Prop where + complete : CompleteSpace (ZeroTreeSpace T) + infinite_dimensional : ¬Module.Finite ℝ (ZeroTreeSpace T) + coordinate_continuous : ∀ s, Continuous (ZeroTreeSpace.coordinate T s) + coordinate_extends : ∀ s (v : ZeroTreeVector T), + ZeroTreeSpace.coordinate T s (v : ZeroTreeSpace T) = ZeroTreeVector.toTree T v s + fields_continuous : ∀ s, Continuous (ZeroTreeSpace.P T s) ∧ Continuous (ZeroTreeSpace.Q T s) + fields_extend : ∀ s (v : ZeroTreeVector T), + ZeroTreeSpace.P T s (v : ZeroTreeSpace T) = T.P (ZeroTreeVector.toTree T v) s ∧ + ZeroTreeSpace.Q T s (v : ZeroTreeSpace T) = T.Q (ZeroTreeVector.toTree T v) s + root_fixed : ∀ x : ZeroTreeSpace T, ZeroTreeSpace.coordinate T T.root x = 0 + root_formula : ∀ x : ZeroTreeSpace T, ‖x‖ = ZeroTreeSpace.P T T.root x ∧ ‖x‖ = ZeroTreeSpace.Q T T.root x + projections : ∀ (H : Finset ι) (hH : T.Initial H), + (∀ x : ZeroTreeSpace T, ‖ZeroTreeSpace.projection T H hH x‖ ≤ ‖x‖) ∧ + (∀ x : ZeroTreeSpace T, ZeroTreeSpace.projection T H hH (ZeroTreeSpace.projection T H hH x) = ZeroTreeSpace.projection T H hH x) ∧ + (∀ (s : ι) (x : ZeroTreeSpace T), ZeroTreeSpace.coordinate T s (ZeroTreeSpace.projection T H hH x) = + if s ∈ H then ZeroTreeSpace.coordinate T s x else 0) ∧ + FiniteDimensional ℝ (ZeroTreeSpace.projection T H hH).range ∧ + IsClosed (ZeroTreeSpace.tail T H hH : Set (ZeroTreeSpace T)) ∧ + Module.Finite ℝ (ZeroTreeSpace T ⧸ ZeroTreeSpace.tail T H hH) ∧ + ∀ x ∈ ZeroTreeSpace.tail T H hH, ∀ ε : ℝ, 0 < ε → + ∃ v : ZeroTreeVector T, ZeroTreeVector.projection T H hH v = 0 ∧ ‖(v : ZeroTreeSpace T)-x‖ < ε + +def rec_completionStatement : Prop := RootSumCompletionStatement sequenceTree ∧ + ZeroRootCompletionStatement joinedTree ∧ RootSumCompletionStatement joinedTree ∧ + IsReflexive XZero ∧ IsReflexive XJoined + +def rec_mainStatement : Prop := (∀ t : ℝ, 0 < t → t < 1 → t^3/128 ≤ averagedModulus XSigma t ∧ t^3/128 ≤ averagedModulus XJoined t) ∧ + (∀ (H : Finset JoinedNode), joinedTree.Initial H → ∀ x : XZero, + (∀ s ∉ H, ZeroTreeSpace.coordinate joinedTree s x = 0) → ∀ z : XZero, + (∀ s ∈ H, ZeroTreeSpace.coordinate joinedTree s z = 0) → z ≠ 0 → + (‖x+z‖+‖x-z‖)/2 ≥ ‖x‖+‖z‖^3/(8*(2*‖x‖+‖z‖)^2)) ∧ + (∀ A : EquivalentNorm XSigma, ¬A.AUC) ∧ + (∀ A : EquivalentNorm XZero, ¬A.AUC) ∧ + (∀ A : EquivalentNorm XJoined, ¬A.AUC) + +def stop_all_radiiStatement : Prop := ∀ {t : ℝ} (_ht : 0 < t), + 0 < averagedModulus XSigma t + +open VariableExponent + +def Variable.nu (h : ℕ+) (v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h)) : ℝ := + AggregationSpace.P (componentTree h) (exponent h) (componentTree h).root ((componentEquiv h).symm v) + + AggregationSpace.Q (componentTree h) (exponent h) (componentTree h).root ((componentEquiv h).symm v) + +structure Variable.SourceNormStatement (h : ℕ+) : Prop where + nonneg : ∀ v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h), 0 ≤ nu h v + definite : ∀ v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h), nu h v = 0 ↔ v = 0 + triangle : ∀ v w : AggregationVector.CoordinateLp (ComponentNode h) (exponent h), + nu h (v+w) ≤ nu h v + nu h w + homogeneous : ∀ (a : ℝ) (v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h)), + nu h (a • v) = |a| * nu h v + +def Variable.spaceStatement : Prop := (∀ h : ℕ+, CompleteSpace (Component h) ∧ IsReflexive (Component h) ∧ + SeparableSpace (Component h →L[ℝ] ℝ) ∧ SourceNormStatement h ∧ + ∀ v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h), + (h.val+1:ℝ)^(-1/heightExponent h)*‖v‖ ≤ nu h v ∧ + nu h v ≤ 2*(h.val+1:ℝ)^(1-1/heightExponent h)*‖v‖) ∧ + CompleteSpace Xv ∧ IsReflexive Xv ∧ SeparableSpace (Xv →L[ℝ] ℝ) ∧ + Dense {x : Xv | FiniteTotalSupport x} ∧ + ∀ S : Finset Node, Continuous (projection S) ∧ FiniteDimensional ℝ (projection S).range ∧ + (∀ x : Xv, projection S (projection S x) = projection S x) ∧ + ∀ (s : Node) (x : Xv), coordinate s (projection S x) = if s ∈ S then coordinate s x else 0 + +def Variable.aggregateChildren (h : ℕ+) (s : ComponentNode h) (f : ComponentNode h → ℝ) : ℝ := + (∑' c, if c ≠ (componentTree h).root ∧ (componentTree h).parent c = s then + f c ^ heightExponent h else 0) ^ (1/heightExponent h) + +def Variable.lpPotentials (h : ℕ+) (v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h)) + (s : ComponentNode h) : ℝ × ℝ := + (AggregationSpace.P (componentTree h) (exponent h) s ((componentEquiv h).symm v), + AggregationSpace.Q (componentTree h) (exponent h) s ((componentEquiv h).symm v)) + +def Variable.lp_model_exactStatement : Prop := ∀ (h : ℕ+) + (v : AggregationVector.CoordinateLp (ComponentNode h) (exponent h)) + (f : ComponentNode h → ℝ × ℝ) + (_hf : ∀ s, f s = leastPair (v s) + (aggregateChildren h s (fun c => (f c).1)) + (aggregateChildren h s (fun c => (f c).2))), + f = lpPotentials h v ∧ nu h v = (f (componentTree h).root).1+(f (componentTree h).root).2 + +end + +def MainClaim : Prop := + ∃ h0 : FiniteRootedTree.Heads.{0}, letI := h0; + ∃ h1 : TreeVector.Construction.{0}, letI := h1; + ∃ h2 : ZeroTreeVector.Construction.{0}, letI := h2; + ∃ h3 : AggregationVector.Construction.{0}, letI := h3; + ∃ h4 : AggregationVector.LpConstruction.{0}, letI := h4; + rec_mainStatement ∧ + rec_completionStatement ∧ + stop_all_radiiStatement ∧ + XJoined_separated_familiesStatement ∧ + Variable.spaceStatement ∧ + Variable.lp_model_exactStatement ∧ + Variable.one_sided_modulus_zeroStatement ∧ + Variable.no_equivalent_AUCStatement ∧ + Variable.sixth_stabilityStatement ∧ + Variable.cubic_stabilityStatement ∧ + Variable.weak_tailStatement + +theorem main : MainClaim := by + sorry + +end RecursivePotentials + +end ComparatorModel + +end + +end OAI diff --git a/lean/ComparatorChallenges/ReflexiveFixedPoints.json b/lean/ComparatorChallenges/ReflexiveFixedPoints.json new file mode 100644 index 0000000000000000000000000000000000000000..509dbadd66ed99e390c6bae370a8a48a2af44597 --- /dev/null +++ b/lean/ComparatorChallenges/ReflexiveFixedPoints.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ReflexiveFixedPoints", + "solution_module": "OAI.Analysis.Nonexpansive.Main", + "theorem_names": [ + "OAI.ReflexiveFixedPoints.exists_fixedPoint_of_canonicallyReflexive" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ReflexiveFixedPoints.lean b/lean/ComparatorChallenges/ReflexiveFixedPoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c99bec5eeebf53ed44a6a91e627a5b6c98d06a6 --- /dev/null +++ b/lean/ComparatorChallenges/ReflexiveFixedPoints.lean @@ -0,0 +1,35 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace ReflexiveFixedPoints + +universe u + +variable (X : Type u) [NormedAddCommGroup X] [NormedSpace ℝ X] + +/-- Surjectivity of the canonical map into the continuous bidual. -/ +def CanonicallyReflexive : Prop := + Function.Surjective (NormedSpace.inclusionInDoubleDual ℝ X) + +variable {X} + +/-- Every nonexpansive selfmap of a nonempty closed bounded convex set has +an actual fixed point, with nonexpansiveness stated in the original norm. -/ +theorem exists_fixedPoint_of_canonicallyReflexive + {X : Type u} [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] + (hX : CanonicallyReflexive X) (C : Set X) + (hne : C.Nonempty) (hclosed : IsClosed C) + (hbounded : Bornology.IsBounded C) (hconvex : Convex ℝ C) + (F : C → C) + (hF : ∀ a b : C, ‖(F a : X) - (F b : X)‖ ≤ ‖(a : X) - (b : X)‖) : + ∃ a : C, F a = a := by + sorry + +end ReflexiveFixedPoints + +end + +end OAI diff --git a/lean/ComparatorChallenges/RegularParity.json b/lean/ComparatorChallenges/RegularParity.json new file mode 100644 index 0000000000000000000000000000000000000000..10d1700791431a1510c3690cb256ec1452f5d379 --- /dev/null +++ b/lean/ComparatorChallenges/RegularParity.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RegularParity", + "solution_module": "OAI.InformationTheory.QuantumCircuit.Main", + "theorem_names": [ + "OAI.QAC.parity_lower_bound_polynomial_size" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RegularParity.lean b/lean/ComparatorChallenges/RegularParity.lean new file mode 100644 index 0000000000000000000000000000000000000000..af6aa2abfaefc5766ad5676c02087278ecbc03e2 --- /dev/null +++ b/lean/ComparatorChallenges/RegularParity.lean @@ -0,0 +1,75 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator + +namespace QAC + +abbrev Bit := Fin 2 +abbrev Word (N : ℕ) := Fin N → Bit +abbrev Operator (N : ℕ) := Matrix (Word N) (Word N) ℂ +abbrev QubitOperator := Matrix Bit Bit ℂ + +/-- Tensor product in the computational basis. -/ +def tensorMatrix {N : ℕ} (a : Fin N → QubitOperator) : Operator N := + fun x y => ∏ i, a i (x i) (y i) + +/-- A one-qubit unitary or an unbounded-arity Toffoli gate. -/ +inductive Gate (N : ℕ) where + | local (q : Fin N) (u : Matrix.unitaryGroup Bit ℂ) + | toffoli (controls : Finset (Fin N)) (target : Fin N) (hne : target ∉ controls) + +namespace Gate + +def support {N : ℕ} : Gate N → Finset (Fin N) + | .local q _ => {q} + | .toffoli c t _ => insert t c + +/-- A Toffoli flips its target iff all controls are one. -/ +def toffoliWord {N : ℕ} (c : Finset (Fin N)) (t : Fin N) (x : Word N) : Word N := + if ∀ i ∈ c, x i = 1 then Function.update x t (1 - x t) else x + +def matrix {N : ℕ} : Gate N → Operator N + | .local q u => tensorMatrix fun i => if i = q then (u : QubitOperator) else 1 + | .toffoli c t _ => fun x y => if x = toffoliWord c t y then 1 else 0 + +end Gate + +structure PhysicalLayer (N : ℕ) where + gates : List (Gate N) + disjoint : gates.Pairwise (fun A B => Disjoint A.support B.support) + +def physicalLayerMatrix {N : ℕ} (L : PhysicalLayer N) : Operator N := + (L.gates.map Gate.matrix).prod + +/-- Chronological order: the rightmost matrix acts first. -/ +def physicalCircuitMatrix {N : ℕ} (layers : List (PhysicalLayer N)) : Operator N := + ((layers.map physicalLayerMatrix).reverse).prod + +/-- The computational-basis input with the remaining qubits initialized to zero. -/ +def inputWord {n N : ℕ} (x : Word n) : Word N := + fun i => if h : i.val < n then x ⟨i.val, h⟩ else 0 + +def parity {n : ℕ} (x : Word n) : Bit := ∑ i, x i + +/-- Born probability, summing all final garbage with no cleanliness assumption. -/ +def successProbability {n N : ℕ} (W : Operator N) (out : Fin N) (x : Word n) : ℝ := + ∑ y : Word N, if y out = parity x then Complex.normSq (W y (inputWord x)) else 0 + +/-- Fixed-depth circuits with polynomially many total qubits cannot compute parity +with worst-case success at least two thirds. -/ +theorem parity_lower_bound_polynomial_size (d k C : ℕ) + (_hd : 0 < d) (_hk : 0 < k) (_hC : 0 < C) : + ∃ n₀ : ℕ, ∀ n ≥ n₀, ∀ N : ℕ, n ≤ N → N ≤ C * (n + 1) ^ k → + ∀ layers : List (PhysicalLayer N), layers.length ≤ d → + ∀ out : Fin N, ∃ x : Word n, + successProbability (physicalCircuitMatrix layers) out x < (2 : ℝ) / 3 := by + sorry + +end QAC + +end + +end OAI diff --git a/lean/ComparatorChallenges/RelativeGeneration.json b/lean/ComparatorChallenges/RelativeGeneration.json new file mode 100644 index 0000000000000000000000000000000000000000..dce28130e734406bf97ceeb80deddfa895317ef1 --- /dev/null +++ b/lean/ComparatorChallenges/RelativeGeneration.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RelativeGeneration", + "solution_module": "OAI.Analysis.RelativeGeneration.Main", + "theorem_names": [ + "OAI.RelativeGeneration.main_theorem" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RelativeGeneration.lean b/lean/ComparatorChallenges/RelativeGeneration.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfb87a4dfbb7e584b0f44d7657aff8084650f4a7 --- /dev/null +++ b/lean/ComparatorChallenges/RelativeGeneration.lean @@ -0,0 +1,110 @@ +import Mathlib + +namespace OAI + +noncomputable section + +universe level + +namespace RelativeGeneration + +variable {Hilbert : Type level} [NormedAddCommGroup Hilbert] + [InnerProductSpace ℂ Hilbert] [CompleteSpace Hilbert] + +/-- Weak operator closedness of a concrete unital star subalgebra. -/ +def WOTClosed (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) : Prop := + IsClosed {operator : Hilbert →WOT[ℂ] Hilbert | operator.toCLM ∈ algebra} + +/-- The weakly closed unital star algebra generated by a set of operators. -/ +def wstar (operators : Set (Hilbert →L[ℂ] Hilbert)) : + StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert) := + sInf {algebra | WOTClosed algebra ∧ operators ⊆ algebra} + +/-- A nonzero, weakly closed, finite diffuse algebra with scalar center. -/ +structure IsII1Factor (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) : Prop where + nonzero : (0 : Hilbert →L[ℂ] Hilbert) ≠ 1 + weaklyClosed : WOTClosed algebra + factor : ∀ element : algebra, (∀ other : algebra, other * element = element * other) → + ∃ scalar : ℂ, element = algebraMap ℂ algebra scalar + finite : ∀ isometry : algebra, star isometry * isometry = 1 → isometry * star isometry = 1 + diffuse : ∀ projection : algebra, IsStarProjection projection → projection ≠ 0 → + ∃ subprojection : algebra, IsStarProjection subprojection ∧ subprojection ≠ 0 ∧ + subprojection ≠ projection ∧ projection * subprojection = subprojection ∧ + subprojection * projection = subprojection + +/-- A same-universe separable Banach predual, with the conjugate-linear dual convention. +This imposes no separability on the Hilbert representation or the operator norm topology. -/ +def HasSeparablePredual (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) : Prop := + ∃ (Banach : Type level) (_ : NormedAddCommGroup Banach) (_ : NormedSpace ℂ Banach) + (_ : CompleteSpace Banach) (_ : TopologicalSpace.SeparableSpace Banach), + Nonempty (StrongDual ℂ Banach ≃ₗᵢ⋆[ℂ] algebra) + +/-- The ultraweak topology is generated by absolutely summable vector functionals. -/ +abbrev ultraweakTopology (Hilbert : Type level) [NormedAddCommGroup Hilbert] + [InnerProductSpace ℂ Hilbert] [CompleteSpace Hilbert] : + TopologicalSpace (Hilbert →L[ℂ] Hilbert) := + ⨅ (left : ℕ → Hilbert) (right : ℕ → Hilbert) + (_ : Summable (fun index => ‖left index‖ * ‖right index‖)), + TopologicalSpace.induced + (fun operator : Hilbert →L[ℂ] Hilbert => + ∑' index, inner ℂ (left index) (operator (right index))) inferInstance + +/-- The concrete algebra carries the induced ultraweak topology. -/ +abbrev algebraUltraweakTopology (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) : + TopologicalSpace algebra := + TopologicalSpace.induced (fun operator : algebra => (operator : Hilbert →L[ℂ] Hilbert)) + (ultraweakTopology Hilbert) + +/-- A faithful normal normalized trace, not an additional hypothesis on the inclusion. -/ +structure IsNormalizedTrace (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) + (trace : algebra →L[ℂ] ℂ) : Prop where + normalized : trace 1 = 1 + positive : ∀ element : algebra, 0 ≤ (trace (star element * element)).re + star_preserving : ∀ element : algebra, trace (star element) = star (trace element) + tracial : ∀ left right : algebra, trace (left * right) = trace (right * left) + faithful : ∀ element : algebra, trace (star element * element) = 0 → element = 0 + normal : @Continuous algebra ℂ (algebraUltraweakTopology algebra) inferInstance trace + +/-- The normalized trace two-distance between genuine unitaries of the original algebra. -/ +def traceDistance (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) + (trace : algebra →L[ℂ] ℂ) (left right : unitary algebra) : ℝ := + Real.sqrt (trace (star ((left : algebra) - (right : algebra)) * + ((left : algebra) - (right : algebra)))).re + +/-- The topology generated by trace two-distance balls, not the inherited operator norm topology. -/ +abbrev traceTopology (algebra : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) + (trace : algebra →L[ℂ] ℂ) : TopologicalSpace (unitary algebra) := + TopologicalSpace.generateFrom {ball | ∃ center : unitary algebra, ∃ radius : ℝ, + 0 < radius ∧ ball = {point | traceDistance algebra trace center point < radius}} + +/-- The entire relative-generator locus in the original unitary group. -/ +def relativeGeneratorLocus (small large : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)) : + Set (unitary large) := + {element | wstar ((small : Set (Hilbert →L[ℂ] Hilbert)) ∪ + {((element : large) : Hilbert →L[ℂ] Hilbert)}) = large} + +/-- Every irreducible inclusion of concrete type II₁ factors with separable predual +of the larger factor has a dense Gδ full relative-generator locus in the normalized +trace two-topology. The normalized faithful normal trace is asserted to exist; +no representation, transport, cyclicity, or perturbation premise is imposed. -/ +def MainTarget : Prop := + ∀ (Hilbert : Type level) [NormedAddCommGroup Hilbert] [InnerProductSpace ℂ Hilbert] + [CompleteSpace Hilbert] (small large : StarSubalgebra ℂ (Hilbert →L[ℂ] Hilbert)), + IsII1Factor small → IsII1Factor large → ∀ inclusion : small ≤ large, + (∀ element : large, + (∀ member : small, StarSubalgebra.inclusion inclusion member * element = + element * StarSubalgebra.inclusion inclusion member) → + ∃ scalar : ℂ, element = algebraMap ℂ large scalar) → + HasSeparablePredual large → + ∃ trace : large →L[ℂ] ℂ, IsNormalizedTrace large trace ∧ + @IsGδ (unitary large) (traceTopology large trace) (relativeGeneratorLocus small large) ∧ + @Dense (unitary large) (traceTopology large trace) (relativeGeneratorLocus small large) + +theorem main_theorem : MainTarget.{level} := by + sorry + +end RelativeGeneration + +end + +end OAI diff --git a/lean/ComparatorChallenges/RieszQuantitative.json b/lean/ComparatorChallenges/RieszQuantitative.json new file mode 100644 index 0000000000000000000000000000000000000000..8ed20da623efe0cf7530e87cafa9524fd0e3659c --- /dev/null +++ b/lean/ComparatorChallenges/RieszQuantitative.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RieszQuantitative", + "solution_module": "OAI.Analysis.RieszRectifiability.Main", + "theorem_names": [ + "OAI.RieszRectifiability.quantitative_higher_codimension_riesz_rectifiability" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RieszQuantitative.lean b/lean/ComparatorChallenges/RieszQuantitative.lean new file mode 100644 index 0000000000000000000000000000000000000000..d30279bd079ff248ecb471e546be1080a54c7b57 --- /dev/null +++ b/lean/ComparatorChallenges/RieszQuantitative.lean @@ -0,0 +1,62 @@ +import Mathlib + +namespace OAI + +namespace RieszRectifiability +noncomputable section +open MeasureTheory Set Metric +open scoped NNReal ENNReal + +abbrev Ambient (d : ℕ) := EuclideanSpace ℝ (Fin d) + +def AdmissibleRadius {d : ℕ} (μ : Measure (Ambient d)) (r : ℝ) : Prop := + 0 < r ∧ ENNReal.ofReal r ≤ Metric.ediam μ.support + +def kernel {d : ℕ} (n : ℕ) (x y : Ambient d) : Ambient d := + (‖x - y‖ ^ (n + 1))⁻¹ • (x - y) + +def truncated {d : ℕ} (n : ℕ) (μ : Measure (Ambient d)) + (ε : ℝ) (f : Ambient d → ℝ) (x : Ambient d) : Ambient d := + ∫ y in {y | ε < dist x y}, f y • kernel n x y ∂μ + +def ADRegularWithConstant {d : ℕ} (n : ℕ) (C : ℝ) + (μ : Measure (Ambient d)) : Prop := + 1 ≤ C ∧ ∀ x ∈ μ.support, ∀ r : ℝ, AdmissibleRadius μ r → + ENNReal.ofReal (r ^ n / C) ≤ μ (ball x r) ∧ + μ (ball x r) ≤ ENNReal.ofReal (C * r ^ n) + +def RieszL2BoundedWithConstant {d : ℕ} (n : ℕ) (C : ℝ≥0) + (μ : Measure (Ambient d)) : Prop := + ∀ ε : ℝ, 0 < ε → ∀ f : Ambient d → ℝ, + MemLp f 2 μ → MemLp (truncated n μ ε f) 2 μ ∧ + eLpNorm (truncated n μ ε f) 2 μ ≤ (C : ℝ≥0∞) * eLpNorm f 2 μ + +def BallImageConclusion {d : ℕ} (n : ℕ) (μ : Measure (Ambient d)) + (θ : ℝ) (M : ℝ≥0) : Prop := + ∀ x ∈ μ.support, ∀ r : ℝ, AdmissibleRadius μ r → + ∃ g : (ball (0 : Ambient n) r) → Ambient d, + LipschitzWith M g ∧ + ENNReal.ofReal (θ * r ^ n) ≤ μ (ball x r ∩ range g) + +/-- A single mass fraction and Lipschitz bound work for all measures with fixed AD and Riesz bounds. -/ +def QuantitativeFullStatement : Prop := + ∀ d n : ℕ, 4 ≤ d → 2 ≤ n → n + 2 ≤ d → + ∀ C_AD : ℝ, 1 ≤ C_AD → ∀ C_R : ℝ≥0, + ∃ θ : ℝ, 0 < θ ∧ ∃ M : ℝ≥0, + ∀ μ : Measure (Ambient d), μ.Regular → + ADRegularWithConstant n C_AD μ → + RieszL2BoundedWithConstant n C_R μ → + BallImageConclusion n μ θ M + +end +end RieszRectifiability + +namespace RieszRectifiability + +/-- Class-uniform Lipschitz ball images from fixed AD and hard-truncation L² bounds. -/ +theorem quantitative_higher_codimension_riesz_rectifiability : QuantitativeFullStatement := by + sorry + +end RieszRectifiability + +end OAI diff --git a/lean/ComparatorChallenges/Rokhlin.json b/lean/ComparatorChallenges/Rokhlin.json new file mode 100644 index 0000000000000000000000000000000000000000..0d34e548f8a0b4a10082fd4702221c770db40163 --- /dev/null +++ b/lean/ComparatorChallenges/Rokhlin.json @@ -0,0 +1,19 @@ +{ + "challenge_module": "ComparatorChallenges.Rokhlin", + "solution_module": "OAI.Dynamics.MultipleMixing.Main", + "theorem_names": [ + "OAI.Rokhlin.mixing_all_finite_orders" + ], + "definition_names": [ + "OAI.Rokhlin.timeMap", + "OAI.Rokhlin.IsMixing", + "OAI.Rokhlin.layoutTime", + "OAI.Rokhlin.MixingOfOrder" + ], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/Rokhlin.lean b/lean/ComparatorChallenges/Rokhlin.lean new file mode 100644 index 0000000000000000000000000000000000000000..39cd6de52ff29c3dc4b799925f43d9d6005e565a --- /dev/null +++ b/lean/ComparatorChallenges/Rokhlin.lean @@ -0,0 +1,37 @@ +import Mathlib + +namespace OAI + +open MeasureTheory Filter +open scoped BigOperators Topology + +namespace Rokhlin + +variable {Ω : Type*} [MeasurableSpace Ω] + +def timeMap (T : Ω ≃ᵐ Ω) (n : ℤ) : Ω → Ω := + ⇑((T.toEquiv : Equiv.Perm Ω) ^ n) + +def IsMixing (μ : Measure Ω) (T : Ω ≃ᵐ Ω) : Prop := + ∀ A B : Set Ω, MeasurableSet A → MeasurableSet B → + Tendsto (fun n : ℤ => μ (A ∩ timeMap T n ⁻¹' B)) + (comap Int.natAbs atTop) (𝓝 (μ A * μ B)) + +def layoutTime {k : ℕ} (gaps : Fin (k - 1) → ℕ+) (i : Fin k) : ℕ := + ∑ j : Fin (k - 1), if j.val < i.val then (gaps j : ℕ) else 0 + +def MixingOfOrder (μ : Measure Ω) (T : Ω ≃ᵐ Ω) (k : ℕ) : Prop := + ∀ A : Fin k → Set Ω, (∀ i, MeasurableSet (A i)) → + Tendsto + (fun gaps : Fin (k - 1) → ℕ+ => + μ (⋂ i : Fin k, timeMap T (layoutTime gaps i : ℤ) ⁻¹' A i)) + atTop (𝓝 (∏ i : Fin k, μ (A i))) + +theorem mixing_all_finite_orders (μ : Measure Ω) [IsProbabilityMeasure μ] + (T : Ω ≃ᵐ Ω) (h_pres : MeasurePreserving T μ μ) (h_mix : IsMixing μ T) : + ∀ k : ℕ, 3 ≤ k → MixingOfOrder μ T k := by + sorry + +end Rokhlin + +end OAI diff --git a/lean/ComparatorChallenges/RuledCovering.json b/lean/ComparatorChallenges/RuledCovering.json new file mode 100644 index 0000000000000000000000000000000000000000..3a400c06f1989017a2ba24592301e84987e0456d --- /dev/null +++ b/lean/ComparatorChallenges/RuledCovering.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RuledCovering", + "solution_module": "OAI.Geometry.RuledCovering.Main", + "theorem_names": [ + "OAI.RuledApproximation.fullMain" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RuledCovering.lean b/lean/ComparatorChallenges/RuledCovering.lean new file mode 100644 index 0000000000000000000000000000000000000000..453e3cbc43dc28e8075c98cee588311da98cfde0 --- /dev/null +++ b/lean/ComparatorChallenges/RuledCovering.lean @@ -0,0 +1,222 @@ +import Mathlib + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Topology ContDiff +namespace RuledApproximation + +abbrev Plane := EuclideanSpace ℝ (Fin 2) +abbrev Space := EuclideanSpace ℝ (Fin 3) + +def vec2 (x y : ℝ) : Plane := WithLp.toLp 2 ![x, y] +def vec3 (x y z : ℝ) : Space := WithLp.toLp 2 ![x, y, z] +def axial (s : ℝ) (p : Plane) : Space := vec3 s (p 0) (p 1) + +def IsParallelogram {E : Type*} [AddCommGroup E] [Module ℝ E] (P : Set E) : Prop := + ∃ c u v : E, LinearIndependent ℝ ![u, v] ∧ + P = {x | ∃ s ∈ Icc (0 : ℝ) 1, ∃ t ∈ Icc (0 : ℝ) 1, + x = c + s • u + t • v} + +def IsTriangle {E : Type*} [AddCommGroup E] [Module ℝ E] (P : Set E) : Prop := + ∃ c u v : E, LinearIndependent ℝ ![u, v] ∧ + P = {x | ∃ s : ℝ, ∃ t : ℝ, 0 ≤ s ∧ 0 ≤ t ∧ s + t ≤ 1 ∧ + x = c + s • u + t • v} + +structure Cylinder where + axis : Space + unit_axis : ‖axis‖ = 1 + base : Set ((Submodule.span ℝ ({axis} : Set Space))ᗮ) + +namespace Cylinder + +def carrier (C : Cylinder) : Set Space := + {x | ∃ b ∈ C.base, ∃ t : ℝ, x = (b : Space) + t • C.axis} + +def area (C : Cylinder) : ℝ := volume.real C.base + +def parallelogram (C : Cylinder) : Prop := IsParallelogram C.base + +def triangle (C : Cylinder) : Prop := IsTriangle C.base + +def openBounded (C : Cylinder) : Prop := + IsOpen C.base ∧ Bornology.IsBounded C.base ∧ MeasurableSet C.base +end Cylinder + +def familySet {n : ℕ} (C : Fin n → Cylinder) : Set Space := ⋃ i, (C i).carrier +def familyArea {n : ℕ} (C : Fin n → Cylinder) : ℝ := ∑ i, (C i).area + +def HasFiniteCover (shape : Cylinder → Prop) (S : Set Space) (A : ℝ) : Prop := + ∃ n : ℕ, ∃ C : Fin n → Cylinder, + (∀ i, shape (C i)) ∧ S ⊆ familySet C ∧ familyArea C ≤ A + +/-- No boundary hypothesis is included in this neighborhood regularity predicate. -/ +def SmoothNear (n : WithTop ℕ∞) (D : Set Plane) (v : Plane → Plane) : Prop := + ∃ U : Set Plane, IsOpen U ∧ D ⊆ U ∧ ContDiffOn ℝ n v U + +/-- In dimension two these two distinct nonzero eigenvalues are all the eigenvalues. -/ +def HyperbolicAt (L : ℝ) (v : Plane → Plane) (p : Plane) : Prop := + ∃ lam : ℝ, 0 < L * lam ∧ L * lam < 1 ∧ + Module.End.HasEigenvalue (fderiv ℝ v p).toLinearMap lam ∧ + Module.End.HasEigenvalue (fderiv ℝ v p).toLinearMap (-lam) + +def weight (v : Plane) : ℝ := 1 / Real.sqrt (1 + ‖v‖ ^ 2) +def physicalWeight (h : ℝ) (w : Plane) : ℝ := + 1 / Real.sqrt (1 + w 0 ^ 2 + h ^ 2 * w 1 ^ 2) + +def ruled (D : Set Plane) (v : Plane → Plane) (L : ℝ) : Set Space := + {z | ∃ p ∈ D, ∃ r : ℝ, |r| ≤ L ∧ + z = vec3 (p 0 + r * v p 0) (p 1 + r * v p 1) r} + +def physicalRuled (h : ℝ) (D : Set Plane) (v : Plane → Plane) (L : ℝ) : Set Space := + {z | ∃ p ∈ D, ∃ s : ℝ, |s| ≤ L ∧ + z = vec3 s (p 0 + s * v p 0) (h * (p 1 + s * v p 1))} + +def HyperbolicStatement : Prop := + ∀ (D : Set Plane) (v : Plane → Plane) (L : ℝ), + IsCompact D → SmoothNear 1 D v → 0 < L → + (∀ p ∈ D, HyperbolicAt L v p) → + ∀ e : ℝ, 0 < e → HasFiniteCover Cylinder.parallelogram (ruled D v L) + ((∫ p in D, weight (v p)) + e) + +def PhysicalHyperbolicStatement : Prop := + ∀ (h L : ℝ) (D : Set Plane) (v : Plane → Plane), + 0 < h → 0 < L → IsCompact D → SmoothNear 1 D v → + (∀ p ∈ D, HyperbolicAt L v p) → + ∀ (e : ℝ), 0 < e → ∀ F : Space ≃ᵢ Space, + HasFiniteCover Cylinder.parallelogram (F '' physicalRuled h D v L) + (h * (∫ p in D, physicalWeight h (v p)) + e) + +def OpenRectangleC2 (D : Set Plane) (v : Plane → Plane) : Prop := + ∃ a b : Plane, (∀ i, a i < b i) ∧ + D ⊆ {p | ∀ i, p i ∈ Ioo (a i) (b i)} ∧ + ContDiffOn ℝ 2 v {p | ∀ i, p i ∈ Ioo (a i) (b i)} + +def LogarithmicStatement : Prop := + ∀ (X k : ℝ) (D : Set Plane) (v : Plane → Plane), + 0 < X → 0 < k → IsCompact D → volume (frontier D) = 0 → + OpenRectangleC2 D v → + (∀ p ∈ D, LinearMap.trace ℝ Plane (fderiv ℝ v p).toLinearMap = 0 ∧ + LinearMap.det (fderiv ℝ v p).toLinearMap < 0 ∧ + k * X * Real.sqrt (-LinearMap.det (fderiv ℝ v p).toLinearMap) < 1) → + ∀ e : ℝ, 0 < e → HasFiniteCover Cylinder.openBounded + (physicalRuled 1 D (fun p => k • v p) X) + ((∫ p in D, 1 / Real.sqrt (1 + k ^ 2 * ‖v p‖ ^ 2)) + e) + +def ProductCellStatement : Prop := + ∀ (h M : ℝ) (D : Set Plane) (v : Plane → Plane), + 0 < h → 0 < M → IsCompact D → volume (frontier D) = 0 → + SmoothNear 1 D v → (∀ p ∈ D, HyperbolicAt M v p) → + ∀ e : ℝ, 0 < e → HasFiniteCover Cylinder.openBounded (physicalRuled h D v M) + (h * (∫ p in D, physicalWeight h (v p)) + e) + +def OrthogonalGridStatement : Prop := + ∀ (D : Set Plane) (v : Plane → Plane) (kappa : ℝ), + IsCompact D → volume (frontier D) = 0 → SmoothNear 1 D v → kappa < 1 → + (∀ p ∈ D, LinearMap.trace ℝ Plane (fderiv ℝ v p).toLinearMap = 0 ∧ + LinearMap.det (fderiv ℝ v p).toLinearMap < 0 ∧ ‖fderiv ℝ v p‖ ≤ kappa) → + ∀ e : ℝ, 0 < e → HasFiniteCover Cylinder.parallelogram + (physicalRuled (Real.sqrt 2) D v 1) + (Real.sqrt 2 * (∫ p in D, + 1 / Real.sqrt (1 + v p 0 ^ 2 + 2 * v p 1 ^ 2)) + e) + +def unitSquare : Set Plane := {x | ∀ i, |x i| ≤ (1 : ℝ) / 2} + +def IsSquareTile (T : Set Plane) : Prop := + ∃ c : Plane, ∃ R : Plane ≃ₗᵢ[ℝ] Plane, ∃ a : ℝ, 0 < a ∧ + T = (fun x => c + a • R x) '' unitSquare + +def auxiliaryCylinder (T : Set Plane) (g : Plane) : Set Space := + {z | ∃ s : ℝ, ∃ b ∈ T, z = axial s (b + s • g)} + +def firstPhysicalMap (h : ℝ) (z : Space) : Space := vec3 (z 0) (z 1) (h * z 2) +def secondPhysicalMap (h a : ℝ) (z : Space) : Space := + vec3 (z 1) (z 0) (h * (a - z 2)) + +def NilpotentStatement : Prop := + ∀ (D : Set Plane) (G : Plane → Plane), IsCompact D → SmoothNear ∞ D G → + (∀ b ∈ D, (fderiv ℝ G b).comp (fderiv ℝ G b) = 0) → + ∀ h eps : ℝ, 0 < h → 0 < eps → + ∃ n : ℕ, ∃ T : Fin n → Set Plane, ∃ g : Fin n → Plane, + (∀ i, IsSquareTile (T i)) ∧ + physicalRuled 1 D G 1 ⊆ ⋃ i, auxiliaryCylinder (T i) (g i) ∧ + (∑ i, volume.real (T i) * physicalWeight h (g i)) ≤ + (∫ b in D, physicalWeight h (G b)) + eps ∧ + ∀ a : ℝ, ∃ C₁ C₂ : Fin n → Cylinder, + (∀ i, (C₁ i).parallelogram ∧ (C₂ i).parallelogram ∧ + (C₁ i).carrier = firstPhysicalMap h '' auxiliaryCylinder (T i) (g i) ∧ + (C₂ i).carrier = secondPhysicalMap h a '' auxiliaryCylinder (T i) (g i) ∧ + (C₁ i).area = h * volume.real (T i) * physicalWeight h (g i) ∧ + (C₂ i).area = h * volume.real (T i) * physicalWeight h (g i)) + +/-- The regular edge-2 tetrahedron in physical coordinates. -/ +def tetrahedron : Set Space := + {z | ∃ t : ℝ, 0 ≤ t ∧ t ≤ 1 ∧ |z 0| ≤ 1 - t ∧ |z 1| ≤ t ∧ + z 2 = Real.sqrt 2 * t} + +def singularField (p : ℝ) (b : Plane) : Plane := + vec2 (((1 / 2 : ℝ) / 2) * (b 1 / (1 / 2)) ^ (p - 1) * + (p + (2 - p) * (b 0 / b 1) ^ 2)) + ((b 1 / (1 / 2)) ^ (p - 2) * b 0) + +def ceilingPolynomial (p b : ℝ) : ℝ := + b ^ 2 * ((1 / 2 : ℝ) * p / 2 + (2 - p) / (2 * (1 / 2)) * b ^ 2) + +def singularDomain (p gamma c : ℝ) : Set Plane := + {b | c ^ gamma ≤ b 1 ∧ b 1 ≤ 2 ∧ |b 0| ≤ b 1 ∧ + b 1 ≤ (1 / 2 : ℝ) + c ^ 2 * ceilingPolynomial p (b 0) + c ^ (5 / 2 : ℝ)} + +def singularLower (p gamma c : ℝ) : Set Space := + physicalRuled (Real.sqrt 2) (singularDomain p gamma c) + (fun b => c • singularField p b) 1 + +def singularUpper (p gamma c : ℝ) : Set Space := + {z | ∃ b ∈ singularDomain p gamma c, ∃ y : ℝ, |y| ≤ 1 ∧ + z = vec3 (b 0 - c * y * singularField p b 0) y + (Real.sqrt 2 * (1 - (b 1 - c * y * singularField p b 1)))} + +def lowerTip (d : ℝ) : Set Space := + {z | ∃ t : ℝ, 0 ≤ t ∧ t ≤ 2 * d ∧ |z 1| ≤ t ∧ z 2 = Real.sqrt 2 * t} + +def upperTip (d : ℝ) : Set Space := + {z | ∃ s : ℝ, 0 ≤ s ∧ s ≤ 2 * d ∧ |z 0| ≤ s ∧ z 2 = Real.sqrt 2 * (1 - s)} + +def singularCost (p gamma c : ℝ) : ℝ := + Real.sqrt 2 * ∫ b in singularDomain p gamma c, + physicalWeight (Real.sqrt 2) (c • singularField p b) + +def singularCoefficient (p : ℝ) : ℝ := + (1 / 2 : ℝ) ^ 4 * (2 * p ^ 2 + 10 * p - 13) / (30 * p) + +def SingularStatement : Prop := + ∀ p gamma : ℝ, 1 < p → p < (Real.sqrt 51 - 5) / 2 → + 1 < gamma → gamma < 1 / (2 - p) → + singularCoefficient p < 0 ∧ + Asymptotics.IsLittleO (𝓝[>] (0 : ℝ)) + (fun c => 2 * singularCost p gamma c + 8 * Real.sqrt 2 * (c ^ gamma) ^ 2 - + (Real.sqrt 2 / 2 + 2 * Real.sqrt 2 * singularCoefficient p * c ^ 2)) + (fun c => c ^ 2) ∧ + ∀ᶠ c : ℝ in 𝓝[>] (0 : ℝ), + ∃ n m : ℕ, ∃ C : Fin n → Cylinder, ∃ D : Fin m → Cylinder, + ∃ B₁ B₂ : Cylinder, + (∀ i, (C i).parallelogram) ∧ (∀ j, (D j).parallelogram) ∧ + B₁.triangle ∧ B₂.triangle ∧ + singularLower p gamma c ⊆ familySet C ∧ + singularUpper p gamma c ⊆ familySet D ∧ + B₁.carrier = lowerTip (c ^ gamma) ∧ B₂.carrier = upperTip (c ^ gamma) ∧ + tetrahedron ⊆ familySet C ∪ familySet D ∪ B₁.carrier ∪ B₂.carrier ∧ + familyArea C + familyArea D + B₁.area + B₂.area < Real.sqrt 2 / 2 + +def FullMain : Prop := + HyperbolicStatement ∧ PhysicalHyperbolicStatement ∧ LogarithmicStatement ∧ + ProductCellStatement ∧ OrthogonalGridStatement ∧ NilpotentStatement ∧ SingularStatement + +theorem fullMain : FullMain := by + sorry + +end RuledApproximation + +end + +end OAI diff --git a/lean/ComparatorChallenges/RyserCovering.json b/lean/ComparatorChallenges/RyserCovering.json new file mode 100644 index 0000000000000000000000000000000000000000..e35a0eb6789730d6cf32828f48c4cdf7371e9f76 --- /dev/null +++ b/lean/ComparatorChallenges/RyserCovering.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RyserCovering", + "solution_module": "OAI.Combinatorics.Ryser.Construction.Main", + "theorem_names": [ + "OAI.RyserCoveringCounterexample.exists_prime_eventually_counterexampleRank" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RyserCovering.lean b/lean/ComparatorChallenges/RyserCovering.lean new file mode 100644 index 0000000000000000000000000000000000000000..d57361e616da5348374a59ef77ac695a6a166fb4 --- /dev/null +++ b/lean/ComparatorChallenges/RyserCovering.lean @@ -0,0 +1,59 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace RyserCoveringCounterexample + +abbrev Hypergraph (V : Type*) := Finset (Finset V) + +section + +variable {V : Type*} [DecidableEq V] + +def IsCover (H : Hypergraph V) (C : Finset V) : Prop := + ∀ e ∈ H, ∃ v ∈ C, v ∈ e + +def Intersecting (H : Hypergraph V) : Prop := + ∀ e ∈ H, ∀ f ∈ H, e ≠ f → (e ∩ f).Nonempty + +attribute [-instance] instDecidablePairwiseCoeFinsetOfDecidableEqOfDecidableRel in +def matchings (H : Hypergraph V) : Finset (Hypergraph V) := by + classical + exact H.powerset.filter fun M => (M : Set (Finset V)).Pairwise Disjoint + +def matchingNumber (H : Hypergraph V) : ℕ := (matchings H).sup Finset.card + +def coverCardinalities (H : Hypergraph V) : Set ℕ := + {n | ∃ C : Finset V, IsCover H C ∧ C.card = n} + +def coverNumber (H : Hypergraph V) : ℕ := sInf (coverCardinalities H) + +def PartiteUniform {I : Type*} (part : V → I) (H : Hypergraph V) : Prop := + ∀ e ∈ H, ∀ i : I, ∃! v : V, v ∈ e ∧ part v = i + +def RPartiteUniform (r : ℕ) (H : Hypergraph V) : Prop := + ∃ part : V → Fin r, PartiteUniform part H + +end + +def CounterexampleRank (r : ℕ) : Prop := + ∃ (V : Type) (fin : Fintype V) (dec : DecidableEq V), + letI : Fintype V := fin + letI : DecidableEq V := dec + ∃ H : Hypergraph V, + 0 < r ∧ H.Nonempty ∧ RPartiteUniform r H ∧ Intersecting H ∧ + (∃ C : Finset V, IsCover H C) ∧ matchingNumber H = 1 ∧ coverNumber H = r + +theorem exists_prime_eventually_counterexampleRank : + ∃ p : ℕ, p.Prime ∧ 5 < p ∧ p % 3 = 2 ∧ + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → n.Prime → 2 < n → + CounterexampleRank (p ^ n + 1) := by + sorry + +end RyserCoveringCounterexample + +end + +end OAI diff --git a/lean/ComparatorChallenges/RyserOddExtensions.json b/lean/ComparatorChallenges/RyserOddExtensions.json new file mode 100644 index 0000000000000000000000000000000000000000..89d0069c0e2bd85ea4f4efdd6f5ac2f211054f0d --- /dev/null +++ b/lean/ComparatorChallenges/RyserOddExtensions.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.RyserOddExtensions", + "solution_module": "OAI.Combinatorics.Ryser.OddExtensions", + "theorem_names": [ + "OAI.RyserOdd.eventualOddFailures_and_infinite" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/RyserOddExtensions.lean b/lean/ComparatorChallenges/RyserOddExtensions.lean new file mode 100644 index 0000000000000000000000000000000000000000..e41426a80f37da6ba537f7d9090a6ac467c99b97 --- /dev/null +++ b/lean/ComparatorChallenges/RyserOddExtensions.lean @@ -0,0 +1,74 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace RyserCoveringCounterexample + +abbrev Hypergraph (Vertex : Type*) := Finset (Finset Vertex) + +variable {Vertex : Type*} [DecidableEq Vertex] + +def IsCover (hypergraph : Hypergraph Vertex) (cover : Finset Vertex) : Prop := + ∀ edge ∈ hypergraph, ∃ vertex ∈ cover, vertex ∈ edge + +def Intersecting (hypergraph : Hypergraph Vertex) : Prop := + ∀ edge ∈ hypergraph, ∀ other ∈ hypergraph, edge ≠ other → (edge ∩ other).Nonempty + +attribute [-instance] instDecidablePairwiseCoeFinsetOfDecidableEqOfDecidableRel in +def matchings (hypergraph : Hypergraph Vertex) : Finset (Hypergraph Vertex) := by + classical + exact hypergraph.powerset.filter fun matching => + (matching : Set (Finset Vertex)).Pairwise Disjoint + +def matchingNumber (hypergraph : Hypergraph Vertex) : ℕ := + (matchings hypergraph).sup Finset.card + +def coverCardinalities (hypergraph : Hypergraph Vertex) : Set ℕ := + {size | ∃ cover : Finset Vertex, IsCover hypergraph cover ∧ cover.card = size} + +def coverNumber (hypergraph : Hypergraph Vertex) : ℕ := sInf (coverCardinalities hypergraph) + +def Uniform (rank : ℕ) (hypergraph : Hypergraph Vertex) : Prop := + ∀ edge ∈ hypergraph, edge.card = rank + +def PartiteUniform {Index : Type*} (part : Vertex → Index) + (hypergraph : Hypergraph Vertex) : Prop := + ∀ edge ∈ hypergraph, ∀ index : Index, + ∃! vertex : Vertex, vertex ∈ edge ∧ part vertex = index + +def RPartiteUniform (rank : ℕ) (hypergraph : Hypergraph Vertex) : Prop := + ∃ part : Vertex → Fin rank, PartiteUniform part hypergraph + +end RyserCoveringCounterexample + +namespace RyserOdd + +open RyserCoveringCounterexample + +def Specification.ExplicitFailureAt (rank : ℕ) : Prop := + ∃ (Vertex : Type) (finiteVertices : Fintype Vertex) (decidableVertices : DecidableEq Vertex), + letI : Fintype Vertex := finiteVertices + letI : DecidableEq Vertex := decidableVertices + ∃ hypergraph : RyserCoveringCounterexample.Hypergraph Vertex, + 0 < rank ∧ hypergraph.Nonempty ∧ RPartiteUniform rank hypergraph ∧ + Uniform rank hypergraph ∧ Intersecting hypergraph ∧ + (∃ cover : Finset Vertex, IsCover hypergraph cover) ∧ + matchingNumber hypergraph = 1 ∧ coverNumber hypergraph = rank ∧ + (rank - 1) * matchingNumber hypergraph < coverNumber hypergraph + +theorem eventualOddFailures_and_infinite : + (∃ primeThreshold : ℕ, ∀ prime : ℕ, primeThreshold ≤ prime → + prime.Prime → prime % 3 = 2 → + ∃ degreeThreshold : ℕ, 3 ≤ degreeThreshold ∧ + ∀ degree : ℕ, degreeThreshold ≤ degree → Odd degree → + Specification.ExplicitFailureAt (prime ^ degree + 1)) ∧ + Set.Infinite {rank : ℕ | Specification.ExplicitFailureAt rank} := by + sorry + +end RyserOdd + +end + +end OAI diff --git a/lean/ComparatorChallenges/SATComputability.json b/lean/ComparatorChallenges/SATComputability.json new file mode 100644 index 0000000000000000000000000000000000000000..4a92f97765737cd809d7c951fe3f6098ebcbbd7e --- /dev/null +++ b/lean/ComparatorChallenges/SATComputability.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SATComputability", + "solution_module": "OAI.Probability.SATComputability.Main", + "theorem_names": [ + "OAI.FixedClauseThreshold.Computability.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SATComputability.lean b/lean/ComparatorChallenges/SATComputability.lean new file mode 100644 index 0000000000000000000000000000000000000000..e53464102629dd92966153f26864fe82995a38aa --- /dev/null +++ b/lean/ComparatorChallenges/SATComputability.lean @@ -0,0 +1,50 @@ +import Mathlib + +namespace OAI + +namespace FixedClauseThreshold + +abbrev Assignment (n : ℕ) := Fin n → Bool + +abbrev ProperClause (n k : ℕ) := + { C : Fin n → Option Bool // (Finset.univ.filter fun i => (C i).isSome).card = k } + +abbrev Formula (n k m : ℕ) := Fin m → ProperClause n k + +def SatisfiesClause {n k : ℕ} (σ : Assignment n) (C : ProperClause n k) : Prop := + ∃ i : Fin n, C.val i = some (σ i) + +def Satisfies {n k m : ℕ} (σ : Assignment n) (F : Formula n k m) : Prop := + ∀ j, SatisfiesClause σ (F j) + +def Satisfiable {n k m : ℕ} (F : Formula n k m) : Prop := + ∃ σ : Assignment n, Satisfies σ F + +noncomputable def properSATProbability (n k m : ℕ) : ℝ := by + classical + exact (Fintype.card { F : Formula n k m // Satisfiable F } : ℝ) / + (Fintype.card (Formula n k m) : ℝ) +end FixedClauseThreshold + +namespace FixedClauseThreshold.Computability + +open Filter +open scoped Topology NNReal + +def MainStatement : Prop := + ∃ (α : ℝ) (q : ℕ → ℚ) (c : Nat.Partrec.Code), + 0 < α ∧ + (∀ a : ℝ, 0 ≤ a → a < α → + Tendsto (fun n : ℕ => properSATProbability n 3 ⌊a*(n : ℝ)⌋₊) atTop (nhds 1)) ∧ + (∀ a : ℝ, α < a → + Tendsto (fun n : ℕ => properSATProbability n 3 ⌊a*(n : ℝ)⌋₊) atTop (nhds 0)) ∧ + Computable (fun r => Encodable.encode (q r)) ∧ + (∀ r, c.eval r = Part.some (Encodable.encode (q r))) ∧ + (∀ r, |(q r : ℝ)-α| ≤ (2^r : ℝ)⁻¹) + +theorem main : MainStatement := by + sorry + +end FixedClauseThreshold.Computability + +end OAI diff --git a/lean/ComparatorChallenges/SATSharpness.json b/lean/ComparatorChallenges/SATSharpness.json new file mode 100644 index 0000000000000000000000000000000000000000..af9e8972a1696b8180f0175384799cb40605d3dd --- /dev/null +++ b/lean/ComparatorChallenges/SATSharpness.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SATSharpness", + "solution_module": "OAI.Probability.SATVariance.Sharpness", + "theorem_names": [ + "OAI.RandomKSAT.sharpness" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SATSharpness.lean b/lean/ComparatorChallenges/SATSharpness.lean new file mode 100644 index 0000000000000000000000000000000000000000..31c865b89d5fee2f3b1e8efcbd4f4c95f8162304 --- /dev/null +++ b/lean/ComparatorChallenges/SATSharpness.lean @@ -0,0 +1,78 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open MeasureTheory ProbabilityTheory + +namespace RandomKSAT + +open scoped Classical ENNReal + +abbrev Assignment (n : ℕ) := Fin n → Bool + +def Clause (n k : ℕ) := + (s : {s : Finset (Fin n) // s.card = k}) × (s.1 → Bool) + +instance clauseFintype (n k : ℕ) : Fintype (Clause n k) := by + classical + unfold Clause + infer_instance + +instance clauseMeasurableSpace (n k : ℕ) : MeasurableSpace (Clause n k) := ⊤ + +instance clauseMeasurableSingletonClass (n k : ℕ) : + MeasurableSingletonClass (Clause n k) := ⟨fun _ => trivial⟩ + +def Satisfies {n k : ℕ} (c : Clause n k) (a : Assignment n) : Prop := + ∃ v : c.1.1, a v = c.2 v + +abbrev Stream (n k : ℕ) := ℕ → Clause n k + +def clauseLaw (n k : ℕ) : Measure (Clause n k) := uniformOn Set.univ + +def streamLaw (n k : ℕ) : Measure (Stream n k) := + Measure.infinitePi (fun _ : ℕ => clauseLaw n k) + +def SetSAT {u s : ℕ} (S : Finset (Assignment u)) (ω : Stream u s) (g : ℕ) : Prop := + ∃ a ∈ S, ∀ i < g, Satisfies (ω i) a + +def blockKill (u s : ℕ) (S : Finset (Assignment u)) (g : ℕ) : ℝ := + (streamLaw u s {ω | ¬ SetSAT S ω g}).toReal + +def favg.{u_1} {α : Type u_1} [Fintype α] (f : α → ℝ) : ℝ := + (∑ a, f a) / Fintype.card α + +def clauseStep (u s : ℕ) (f : Finset (Assignment u) → ℝ) + (S : Finset (Assignment u)) : ℝ := + favg fun c : Clause u s => f (S.filter (Satisfies c)) + +def alive (u : ℕ) (S : Finset (Assignment u)) : ℝ := if S.Nonempty then 1 else 0 + +def survival (u s : ℕ) (S : Finset (Assignment u)) (m : ℕ) : ℝ := + (clauseStep u s)^[m] (alive u) S + +def lifetime (u s : ℕ) (S : Finset (Assignment u)) : ℝ := ∑' m, survival u s S m + +theorem sharpness (k : ℕ) (hk : 3 ≤ k) : + (∀ γ D A : ℝ, γ < (k : ℝ) / ((k-1 : ℕ) : ℝ) → 0 < D → 0 < A → + ∀ N : ℕ, ∃ u : ℕ, N ≤ u ∧ k ≤ u ∧ ∃ S : Finset (Assignment u), + S.Nonempty ∧ A * (u : ℝ) ^ (-((k-1 : ℕ) : ℝ)) ≤ blockKill u (k-1) S 1 ∧ + D * (blockKill u (k-1) S 1) ^ (-γ) < lifetime u k S) ∧ + (∃ u : ℕ → ℕ, ∃ S : ∀ g, Finset (Assignment (u g)), + (∀ g, 2 ≤ g → k ≤ u g ∧ (S g).Nonempty) ∧ + Asymptotics.IsEquivalent Filter.atTop + (fun g => blockKill (u g) (k-1) (S g) 1 - blockKill (u g) k (S g) g) + (fun g => ((2 : ℝ)^k)⁻¹ * (g : ℝ)^(-((k-1 : ℕ) : ℝ)))) ∧ + (¬ ∃ e : ℕ → ℝ, + Asymptotics.IsLittleO Filter.atTop e (fun g => (g : ℝ)^(-((k-1 : ℕ) : ℝ))) ∧ + ∀ u, k ≤ u → ∀ S : Finset (Assignment u), S.Nonempty → ∀ g, 2 ≤ g → + blockKill u (k-1) S 1 - e g ≤ blockKill u k S g) := by + sorry + +end RandomKSAT + +end + +end OAI diff --git a/lean/ComparatorChallenges/SATVariance.json b/lean/ComparatorChallenges/SATVariance.json new file mode 100644 index 0000000000000000000000000000000000000000..a59131c3efb38968d4e9c94c4bf34fc2ea974244 --- /dev/null +++ b/lean/ComparatorChallenges/SATVariance.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SATVariance", + "solution_module": "OAI.Probability.SATVariance.Main", + "theorem_names": [ + "OAI.RandomKSAT.variance_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SATVariance.lean b/lean/ComparatorChallenges/SATVariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ecf51d98833741230b4421bf7e7ffa47ba45d44 --- /dev/null +++ b/lean/ComparatorChallenges/SATVariance.lean @@ -0,0 +1,70 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open MeasureTheory ProbabilityTheory + +namespace RandomKSAT + +abbrev Assignment (n : ℕ) := Fin n → Bool + +def Clause (n k : ℕ) := + (s : {s : Finset (Fin n) // s.card = k}) × (s.1 → Bool) + +instance clauseFintype (n k : ℕ) : Fintype (Clause n k) := by + classical + unfold Clause + infer_instance + +instance clauseMeasurableSpace (n k : ℕ) : MeasurableSpace (Clause n k) := ⊤ + +instance clauseMeasurableSingletonClass (n k : ℕ) : + MeasurableSingletonClass (Clause n k) := ⟨fun _ => trivial⟩ + +def Satisfies {n k : ℕ} (c : Clause n k) (a : Assignment n) : Prop := + ∃ v : c.1.1, a v = c.2 v + +abbrev Stream (n k : ℕ) := ℕ → Clause n k + +def clauseLaw (n k : ℕ) : Measure (Clause n k) := uniformOn Set.univ + +def streamLaw (n k : ℕ) : Measure (Stream n k) := + Measure.infinitePi (fun _ : ℕ => clauseLaw n k) + +def PrefixSAT {n k : ℕ} (ω : Stream n k) (m : ℕ) : Prop := + ∃ a : Assignment n, ∀ i < m, Satisfies (ω i) a + +def firstFailure {n k : ℕ} (ω : Stream n k) : ℕ∞ := + sInf ((fun m : ℕ => (m : ℕ∞)) '' {m | ¬ PrefixSAT ω m}) + +def H {n k : ℕ} (ω : Stream n k) : ℝ := (firstFailure ω).toNat + +def cap (n : ℕ) (B : ℝ) : ℕ := ⌊B * n⌋₊ + +def T {n k : ℕ} (B : ℝ) (ω : Stream n k) : ℝ := + (min (firstFailure ω) (cap n B : ℕ∞)).toNat + +def ell (k n : ℕ) : ℝ := + if k = 3 then Real.log (Real.exp 1 * n) else 1 + +def U (k : ℕ) : ℝ := Real.log 2 / (-Real.log (1 - ((2 : ℝ) ^ k)⁻¹)) + +theorem variance_main (k : ℕ) (hk : 3 ≤ k) : + (∃ C : ℝ, 0 ≤ C ∧ ∀ n : ℕ, k ≤ n → + variance (H : Stream n k → ℝ) (streamLaw n k) ≤ C * n * ell k n) ∧ + (∀ B : ℝ, 0 < B → ∃ C : ℝ, 0 ≤ C ∧ ∀ n : ℕ, k ≤ n → + variance (T B : Stream n k → ℝ) (streamLaw n k) ≤ C * n * ell k n) ∧ + (∃ c : ℝ, 0 < c ∧ + (∃ N : ℕ, ∀ n : ℕ, N ≤ n → k ≤ n → + c * n ≤ variance (H : Stream n k → ℝ) (streamLaw n k)) ∧ + (∀ B : ℝ, U k < B → ∃ N : ℕ, ∀ n : ℕ, N ≤ n → k ≤ n → + c * n ≤ variance (T B : Stream n k → ℝ) (streamLaw n k))) := by + sorry + +end RandomKSAT + +end + +end OAI diff --git a/lean/ComparatorChallenges/SKBarriers.json b/lean/ComparatorChallenges/SKBarriers.json new file mode 100644 index 0000000000000000000000000000000000000000..fd5e9cd36185cbe8a3c7aa5d59fafadc6f198994 --- /dev/null +++ b/lean/ComparatorChallenges/SKBarriers.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SKBarriers", + "solution_module": "OAI.Probability.SKBarriers.Main", + "theorem_names": [ + "OAI.SK.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SKBarriers.lean b/lean/ComparatorChallenges/SKBarriers.lean new file mode 100644 index 0000000000000000000000000000000000000000..c38d2c1bfa9e9c6d06d9a46b792446795c4d2f09 --- /dev/null +++ b/lean/ComparatorChallenges/SKBarriers.lean @@ -0,0 +1,92 @@ +import Mathlib + +namespace OAI + +section + +section + +noncomputable section +open scoped BigOperators Topology +open MeasureTheory ProbabilityTheory Filter + +namespace SK +abbrev Config (n : ℕ) := Fin n → Bool +abbrev Edge (n : ℕ) := {p : Fin n × Fin n // p.1 < p.2} +abbrev Disorder (n : ℕ) := Edge n → ℝ + +def spin (b : Bool) : ℝ := if b then 1 else -1 + +def hamiltonian {n : ℕ} (J : Disorder n) (x : Config n) : ℝ := + (∑ e : Edge n, J e * spin (x e.val.1) * spin (x e.val.2)) / Real.sqrt n + +def partition {n : ℕ} (β : ℝ) (J : Disorder n) : ℝ := + ∑ x : Config n, Real.exp (β * hamiltonian J x) + +def gibbs {n : ℕ} (β : ℝ) (J : Disorder n) (x : Config n) : ℝ := + Real.exp (β * hamiltonian J x) / partition β J + +def coupling {n : ℕ} (J : Disorder n) (i j : Fin n) : ℝ := + if h : i < j then J ⟨(i, j), h⟩ else + if h : j < i then J ⟨(j, i), h⟩ else 0 + +def localField {n : ℕ} (J : Disorder n) (x : Config n) (i : Fin n) : ℝ := + (∑ j : Fin n, coupling J i j * spin (x j)) / Real.sqrt n + +def heatBath {n : ℕ} (β : ℝ) (J : Disorder n) (x y : Config n) : ℝ := + (∑ i : Fin n, if Function.update x i (y i) = y then + Real.exp (β * spin (y i) * localField J x i) / + (2 * Real.cosh (β * localField J x i)) else 0) / n + +def discreteKernel {n : ℕ} (β : ℝ) (J : Disorder n) : ℕ → Config n → Config n → ℝ + | 0, x, y => if x = y then 1 else 0 + | k + 1, x, y => ∑ z : Config n, heatBath β J x z * discreteKernel β J k z y + +def continuousKernel {n : ℕ} (β : ℝ) (J : Disorder n) (t : ℝ) + (x y : Config n) : ℝ := + ∑' k : ℕ, (Real.exp (-(n : ℝ) * t) * ((n : ℝ) * t) ^ k / + (Nat.factorial k : ℝ)) * discreteKernel β J k x y + +def discreteDistance {n : ℕ} (β : ℝ) (J : Disorder n) + (x : Config n) (k : ℕ) : ℝ := + (1 / 2 : ℝ) * ∑ y : Config n, |discreteKernel β J k x y - gibbs β J y| + +def continuousDistance {n : ℕ} (β : ℝ) (J : Disorder n) + (x : Config n) (t : ℝ) : ℝ := + (1 / 2 : ℝ) * ∑ y : Config n, |continuousKernel β J t x y - gibbs β J y| + +def disorderLaw (n : ℕ) : Measure (Disorder n) := + Measure.pi (fun _ : Edge n => gaussianReal 0 1) + +def kappa : ℝ := 1 / 10000 + +def timeScale (n : ℕ) : ℝ := Real.exp ((n : ℝ) ^ kappa) + +def continuousBadMass (β : ℝ) (n : ℕ) : ℝ := + ∫ J : Disorder n, (∑ x : Config n, if 1 / 4 < continuousDistance β J x (timeScale n) + then gibbs β J x else 0) ∂disorderLaw n + +def discreteBadMass (β : ℝ) (n : ℕ) : ℝ := + ∫ J : Disorder n, (∑ x : Config n, if 1 / 4 < discreteDistance β J x ⌊timeScale n⌋₊ + then gibbs β J x else 0) ∂disorderLaw n + +end SK +end +end +end + +noncomputable section +open scoped BigOperators Topology +open MeasureTheory ProbabilityTheory Filter + +namespace SK + +theorem main (β : ℝ) (hβ : 1 < β) : + Tendsto (continuousBadMass β) atTop (𝓝 1) ∧ + Tendsto (discreteBadMass β) atTop (𝓝 1) := by + sorry + +end SK +end + +end OAI diff --git a/lean/ComparatorChallenges/SKFullSupport.json b/lean/ComparatorChallenges/SKFullSupport.json new file mode 100644 index 0000000000000000000000000000000000000000..1877a6b689adbc033c875b52fadd2d593c3a86ad --- /dev/null +++ b/lean/ComparatorChallenges/SKFullSupport.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SKFullSupport", + "solution_module": "OAI.Probability.SKSupport.Main", + "theorem_names": [ + "OAI.ZeroTemperatureSK.full_support" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SKFullSupport.lean b/lean/ComparatorChallenges/SKFullSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a4bdf1cabdbf723ea9ea2bd1705a6ee038e4f71 --- /dev/null +++ b/lean/ComparatorChallenges/SKFullSupport.lean @@ -0,0 +1,98 @@ +import Mathlib + +namespace OAI + +open MeasureTheory ProbabilityTheory Set Filter +open scoped ENNReal NNReal Topology + +noncomputable section + +namespace ZeroTemperatureSK + +abbrev Time := Set.Ico (0 : ℝ) 1 + +def extend (γ : Time → ℝ) (t : ℝ) : ℝ := + if ht : t ∈ Set.Ico (0 : ℝ) 1 then γ ⟨t, ht⟩ else 0 + +structure OrderParameter where + val : Time → ℝ + nonneg : ∀ t, 0 ≤ val t + monotone : Monotone val + right_continuous : ∀ t, ContinuousWithinAt val (Set.Ici t) t + integrable : Integrable (extend val) + +structure BrownianSystem (Ω : Type*) [MeasurableSpace Ω] where + law : Measure Ω + isProbability : IsProbabilityMeasure law + B : ℝ≥0 → Ω → ℝ + measurable : ∀ t, Measurable (B t) + brownian : IsBrownianReal B law + +variable {Ω : Type*} [MeasurableSpace Ω] + +def incrementFiltration (W : BrownianSystem Ω) (t : ℝ≥0) : + Filtration ℝ≥0 ‹MeasurableSpace Ω› := + Filtration.natural (fun s ω => W.B (t + s) ω - W.B t ω) + (fun s => ((W.measurable (t + s)).sub (W.measurable t)).stronglyMeasurable) + +structure Control (W : BrownianSystem Ω) (t : ℝ≥0) where + val : ℝ≥0 → Ω → ℝ + progressive : IsProgressive (incrementFiltration W t) val + bound : ∀ s ω, |val s ω| ≤ 1 + +def controlPayoff (W : BrownianSystem Ω) (γ : OrderParameter) (t x : ℝ) + (α : Control W (Real.toNNReal t)) (ω : Ω) : ℝ := + |x + W.B 1 ω - W.B (Real.toNNReal t) ω + + ∫ s in t..1, extend γ.val s * α.val (Real.toNNReal (s - t)) ω| - + (1 / 2 : ℝ) * ∫ s in t..1, extend γ.val s * (α.val (Real.toNNReal (s - t)) ω)^2 + +def value (W : BrownianSystem Ω) (γ : OrderParameter) (t x : ℝ) : ℝ := + sSup (Set.range (fun α : Control W (Real.toNNReal t) => + ∫ ω, controlPayoff W γ t x α ω ∂W.law)) + +def gradient (W : BrownianSystem Ω) (γ : OrderParameter) (t x : ℝ) : ℝ := + deriv (value W γ t) x + +def curvature (W : BrownianSystem Ω) (γ : OrderParameter) (t x : ℝ) : ℝ := + deriv (gradient W γ t) x + +def parisi (W : BrownianSystem Ω) (γ : OrderParameter) : ℝ := + value W γ 0 0 - (1 / 2 : ℝ) * ∫ t in (0 : ℝ)..1, t * extend γ.val t + +def IsMinimizer (W : BrownianSystem Ω) (γ : OrderParameter) : Prop := + ∀ η : OrderParameter, parisi W γ ≤ parisi W η + +def IsStieltjesMeasure (γ : OrderParameter) (μ : Measure Time) : Prop := + ∀ t : Time, μ (Set.Iic t) = ENNReal.ofReal (γ.val t) + +def IsDiffusion (W : BrownianSystem Ω) (γ : OrderParameter) + (X : ℝ≥0 → Ω → ℝ) : Prop := + IsProgressive (Filtration.natural W.B (fun t => (W.measurable t).stronglyMeasurable)) X ∧ + (∀ᵐ ω ∂W.law, ContinuousOn (fun t : ℝ => X (Real.toNNReal t) ω) (Set.Icc 0 1) ∧ + X 0 ω = 0 ∧ ∀ t ∈ Set.Icc (0 : ℝ) 1, + X (Real.toNNReal t) ω = W.B (Real.toNNReal t) ω + + ∫ s in (0 : ℝ)..t, extend γ.val s * + gradient W γ s (X (Real.toNNReal s) ω)) + +def squareMoment (W : BrownianSystem Ω) (γ : OrderParameter) + (X : ℝ≥0 → Ω → ℝ) (t : ℝ) : ℝ := + ∫ ω, (gradient W γ t (X (Real.toNNReal t) ω))^2 ∂W.law + +def FullSupportConclusion (W : BrownianSystem Ω) (γ : OrderParameter) : Prop := + (∃ μ : Measure Time, IsStieltjesMeasure γ μ) ∧ + (∃ X : ℝ≥0 → Ω → ℝ, IsDiffusion W γ X) ∧ + (∀ μ : Measure Time, IsStieltjesMeasure γ μ → μ.support = Set.univ) ∧ + (∀ a b : Time, a < b → γ.val a < γ.val b) ∧ + ∀ X : ℝ≥0 → Ω → ℝ, IsDiffusion W γ X → ∀ t : Time, + squareMoment W γ X t = (t : ℝ) ∧ + (∫ ω, (curvature W γ t (X (Real.toNNReal t) ω))^2 ∂W.law) = 1 + +theorem full_support (W : BrownianSystem Ω) (γ : OrderParameter) + (hmin : IsMinimizer W γ) : FullSupportConclusion W γ := by + sorry + +end ZeroTemperatureSK + +end + +end OAI diff --git a/lean/ComparatorChallenges/SKHighTemperature.json b/lean/ComparatorChallenges/SKHighTemperature.json new file mode 100644 index 0000000000000000000000000000000000000000..a7c18be895a345e1c7ac8dd8b2fcaea1e657c5bd --- /dev/null +++ b/lean/ComparatorChallenges/SKHighTemperature.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SKHighTemperature", + "solution_module": "OAI.Probability.SKGap.Main", + "theorem_names": [ + "OAI.SKGap.sk_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SKHighTemperature.lean b/lean/ComparatorChallenges/SKHighTemperature.lean new file mode 100644 index 0000000000000000000000000000000000000000..37292861ce05cada135d6e83eb4c376931fb372a --- /dev/null +++ b/lean/ComparatorChallenges/SKHighTemperature.lean @@ -0,0 +1,76 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators +open MeasureTheory ProbabilityTheory Filter + +namespace SKGap + +abbrev Spin (n : ℕ) := Fin n → Bool +abbrev Edge (n : ℕ) := {p : Fin n × Fin n // p.1 < p.2} +abbrev Disorder (n : ℕ) := Edge n → ℝ + +def spinValue (b : Bool) : ℝ := if b then 1 else -1 + +def coupling {n : ℕ} (g : Disorder n) (i k : Fin n) : ℝ := + if h : i < k then g ⟨(i, k), h⟩ else + if h : k < i then g ⟨(k, i), h⟩ else 0 + +def hamiltonian {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (x : Spin n) : ℝ := + (1 / 2 : ℝ) * ∑ i, ∑ k, spinValue (x i) * coupling g i k * spinValue (x k) + + ∑ i, h i * spinValue (x i) + +def weight {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (x : Spin n) : ℝ := + Real.exp (hamiltonian g h x) + +def partition {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) : ℝ := + ∑ x, weight g h x + +def mass {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (x : Spin n) : ℝ := + weight g h x / partition g h + +def expectation {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (f : Spin n → ℝ) : ℝ := + ∑ x, mass g h x * f x + +def variance {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (f : Spin n → ℝ) : ℝ := + expectation g h (fun x => (f x - expectation g h f) ^ 2) + +def flip {n : ℕ} (i : Fin n) (x : Spin n) : Spin n := + Function.update x i (!(x i)) + +/-- Conditional expectation under the actual Gibbs law given all other spins. -/ +def conditionalExpectation {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) + (i : Fin n) (f : Spin n → ℝ) (x : Spin n) : ℝ := + (weight g h x * f x + weight g h (flip i x) * f (flip i x)) / + (weight g h x + weight g h (flip i x)) + +/-- Unscaled form: each site has a rate-one clock. -/ +def dirichlet {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (f : Spin n → ℝ) : ℝ := + ∑ i, expectation g h (fun x => (f x - conditionalExpectation g h i f x) ^ 2) + +def disorderLaw (β : ℝ) (n : ℕ) : Measure (Disorder n) := + Measure.pi (fun _ : Edge n => gaussianReal 0 (Real.toNNReal (β ^ 2 / n))) + +def poincareEvent (n : ℕ) (C : ℝ) : Set (Disorder n) := + {g | ∀ f : Spin n → ℝ, variance g 0 f ≤ C * dirichlet g 0 f} + +/-- Rayleigh quotient definition of the uniform-site discrete heat-bath gap. -/ +def discreteGap {n : ℕ} (g : Disorder n) : ℝ := + sInf {r : ℝ | ∃ f : Spin n → ℝ, 0 < variance g 0 f ∧ + r = dirichlet g 0 f / ((n : ℝ) * variance g 0 f)} + +def MainStatement (β : ℝ) : Prop := + ∃ C : ℝ, 0 < C ∧ + Tendsto (fun n : ℕ => disorderLaw β n (poincareEvent n C)) atTop (nhds 1) ∧ + Tendsto (fun n : ℕ => disorderLaw β n {g | 1 / (C * (n : ℝ)) ≤ discreteGap g}) + atTop (nhds 1) + +theorem sk_main (β : ℝ) (hβ0 : 0 < β) (hβ1 : β < 1) : MainStatement β := by + sorry + +end SKGap +end + +end OAI diff --git a/lean/ComparatorChallenges/SKRatio.json b/lean/ComparatorChallenges/SKRatio.json new file mode 100644 index 0000000000000000000000000000000000000000..6cc0d3212254865dd71c7a039d84a2a625d9979a --- /dev/null +++ b/lean/ComparatorChallenges/SKRatio.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SKRatio", + "solution_module": "OAI.Probability.SKRatio.Main", + "theorem_names": [ + "OAI.SKRatio.ratio_cutoff" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SKRatio.lean b/lean/ComparatorChallenges/SKRatio.lean new file mode 100644 index 0000000000000000000000000000000000000000..01126cf41ef081d90e3b4223c825d250fa3e6f71 --- /dev/null +++ b/lean/ComparatorChallenges/SKRatio.lean @@ -0,0 +1,74 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Topology +open MeasureTheory ProbabilityTheory Filter + +namespace SKRatio + +abbrev Spin (n : ℕ) := Fin n → Bool +abbrev Edge (n : ℕ) := {p : Fin n × Fin n // p.1 < p.2} +abbrev Disorder (n : ℕ) := Edge n → ℝ + +def spinValue (b : Bool) : ℝ := if b then 1 else -1 + +def coupling {n : ℕ} (g : Disorder n) (i j : Fin n) : ℝ := + if h : i < j then g ⟨(i, j), h⟩ else + if h : j < i then g ⟨(j, i), h⟩ else 0 + +def hamiltonian {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (x : Spin n) : ℝ := + (1 / 2 : ℝ) * ∑ i, ∑ j, spinValue (x i) * coupling g i j * spinValue (x j) + + ∑ i, h i * spinValue (x i) + +def weight {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (x : Spin n) : ℝ := + Real.exp (hamiltonian g h x) + +def partition {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) : ℝ := + ∑ x, weight g h x + +def mass {n : ℕ} (g : Disorder n) (h : Fin n → ℝ) (x : Spin n) : ℝ := + weight g h x / partition g h + +def flip {n : ℕ} (i : Fin n) (x : Spin n) : Spin n := + Function.update x i (!(x i)) + +def disorderLaw (β : ℝ) (n : ℕ) : Measure (Disorder n) := + Measure.pi (fun _ : Edge n => gaussianReal 0 (Real.toNNReal (β ^ 2 / n))) + +def siteKernel {n : ℕ} (g : Disorder n) (i : Fin n) : + Matrix (Spin n) (Spin n) ℝ := fun x y => + (if y = x then mass g 0 x / (mass g 0 x + mass g 0 (flip i x)) else 0) + + (if y = flip i x then + mass g 0 (flip i x) / (mass g 0 x + mass g 0 (flip i x)) else 0) + +def transition {n : ℕ} (g : Disorder n) : Matrix (Spin n) (Spin n) ℝ := + if n = 0 then 1 else fun x y => (∑ i, siteKernel g i x y) / (n : ℝ) + +def totalVariation {α : Type*} [Fintype α] (p q : α → ℝ) : ℝ := + (1 / 2 : ℝ) * ∑ y, |p y - q y| + +def discreteDistance {n : ℕ} (g : Disorder n) (k : ℕ) : ℝ := + Finset.univ.sup' Finset.univ_nonempty + (fun x : Spin n => totalVariation ((transition g ^ k) x) (mass g 0)) + +def mixingTime {n : ℕ} (g : Disorder n) (ε : ℝ) : ℕ := + sInf {k : ℕ | discreteDistance g k ≤ ε} + +theorem ratio_cutoff (β ε η : ℝ) + (hβ0 : 0 ≤ β) (hβhalf : β < 1 / 2) + (hε0 : 0 < ε) (hεhalf : ε < 1 / 2) (hη : 0 < η) : + Tendsto + (fun n : ℕ => disorderLaw β n + {g : Disorder n | 1 + η < + (mixingTime g ε : ℝ) / (mixingTime g (1 - ε) : ℝ)}) + atTop (𝓝 0) ∧ + (∀ᶠ n : ℕ in atTop, ∀ g : Disorder n, 0 < mixingTime g (1 - ε)) := by + sorry + +end SKRatio + +end + +end OAI diff --git a/lean/ComparatorChallenges/SKValue.json b/lean/ComparatorChallenges/SKValue.json new file mode 100644 index 0000000000000000000000000000000000000000..e290607e35b114e0c4cda5f1bf1a12f2cb315957 --- /dev/null +++ b/lean/ComparatorChallenges/SKValue.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SKValue", + "solution_module": "OAI.Probability.SKValue.Main", + "theorem_names": [ + "OAI.SKValue.value_consequences" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SKValue.lean b/lean/ComparatorChallenges/SKValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a510a0fc583650d790619484068e330a2b4b2b7 --- /dev/null +++ b/lean/ComparatorChallenges/SKValue.lean @@ -0,0 +1,175 @@ +import Mathlib + +namespace OAI + +open MeasureTheory ProbabilityTheory Filter Set +open scoped Topology ENNReal NNReal BigOperators + +namespace SKValue + +noncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1 + +instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instance + +noncomputable def gaussianProduct (ι : Type) [Fintype ι] : Measure (ι → ℝ) := + Measure.pi (fun _ : ι ↦ standardGaussian) +instance gaussianProduct_probability (ι : Type) [Fintype ι] : + IsProbabilityMeasure (gaussianProduct ι) := by + unfold gaussianProduct + infer_instance + +def coordinate (N : ℕ) (j : ℕ) (z : Fin (N+1) → ℝ) : ℝ := + z ⟨j % (N+1), Nat.mod_lt _ (Nat.succ_pos _)⟩ + +noncomputable def stepSize (T : ℝ) (N : ℕ) : ℝ := T / N +noncomputable def meshTime (T : ℝ) (N j : ℕ) : ℝ := j * stepSize T N + +noncomputable def euler (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) + (z : Fin (N+1) → ℝ) : ℕ → ℝ + | 0 => 0 + | j+1 => euler T N γ u z j + Real.sqrt (stepSize T N) * coordinate N j z + + stepSize T N * γ (meshTime T N j) * u (meshTime T N j) (euler T N γ u z j) + +structure OrderParameter where + coeff : ℝ → ℝ + nonneg : ∀ t ∈ Ico (0 : ℝ) 1, 0 ≤ coeff t + monotone : MonotoneOn coeff (Ico (0 : ℝ) 1) + rightContinuous : ∀ t ∈ Ico (0 : ℝ) 1, ContinuousWithinAt coeff (Ici t) t + integrable : IntegrableOn coeff (Ioc (0 : ℝ) 1) + +structure BrownianSpace where + Ω : Type + measurableSpace : MeasurableSpace Ω + μ : @Measure Ω measurableSpace + probability : @IsProbabilityMeasure Ω measurableSpace μ + B : ℝ≥0 → Ω → ℝ + measurable : ∀ t, @StronglyMeasurable Ω ℝ _ measurableSpace (B t) + brownian : @IsBrownianReal Ω measurableSpace B μ + +attribute [instance] BrownianSpace.measurableSpace BrownianSpace.probability + +noncomputable def BrownianSpace.filtration (W : BrownianSpace) : + Filtration ℝ≥0 W.measurableSpace := Filtration.natural W.B W.measurable + +noncomputable def shiftedFiltration (W : BrownianSpace) (t : ℝ) : + Filtration ℝ≥0 W.measurableSpace := + Filtration.natural (fun s ω ↦ W.B (Real.toNNReal t + s) ω - W.B (Real.toNNReal t) ω) + (fun _ ↦ (W.measurable _).sub (W.measurable _)) + +def Admissible (W : BrownianSpace) (t : ℝ) (α : ℝ≥0 → W.Ω → ℝ) : Prop := + IsProgressive (shiftedFiltration W t) α ∧ ∀ s ω, |α s ω| ≤ 1 + +noncomputable def controlPayoff (W : BrownianSpace) (γ : OrderParameter) + (t x : ℝ) (α : ℝ≥0 → W.Ω → ℝ) : ℝ := + ∫ ω, (|x + W.B 1 ω - W.B (Real.toNNReal t) ω + + ∫ s in (0 : ℝ)..(1-t), γ.coeff (t+s) * α (Real.toNNReal s) ω| - + (1/2 : ℝ) * ∫ s in (0 : ℝ)..(1-t), γ.coeff (t+s) * α (Real.toNNReal s) ω ^ 2) ∂W.μ + +noncomputable def phi (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ := + sSup {r | ∃ α, Admissible W t α ∧ r = controlPayoff W γ t x α} + +noncomputable def gradient (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ := + deriv (phi W γ t) x + +noncomputable def curvature (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ := + deriv (gradient W γ t) x + +noncomputable def parisi (W : BrownianSpace) (γ : OrderParameter) : ℝ := + phi W γ 0 0 - (1/2 : ℝ) * ∫ t in (0 : ℝ)..1, t * γ.coeff t + +def IsMinimizer (W : BrownianSpace) (γ : OrderParameter) : Prop := + ∀ η : OrderParameter, parisi W γ ≤ parisi W η + +def IsDiffusion (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ) : Prop := + Adapted W.filtration (fun t ω ↦ X (min (t : ℝ) 1) ω) ∧ + (∀ᵐ ω ∂W.μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) 1) ∧ + ∀ t ∈ Icc (0 : ℝ) 1, + X t ω = W.B (Real.toNNReal t) ω + + ∫ s in (0 : ℝ)..t, γ.coeff s * gradient W γ s (X s ω)) + +noncomputable def spin (b : Bool) : ℝ := if b then 1 else -1 + +noncomputable def hamiltonian (n : ℕ) (J : (Fin n × Fin n) → ℝ) + (σ : Fin n → Bool) : ℝ := + (Real.sqrt (n : ℝ))⁻¹ * + ∑ i : Fin n, ∑ j : Fin n, if i < j then J (i,j) * spin (σ i) * spin (σ j) else 0 + +noncomputable def groundStateSequence (n : ℕ) : ℝ := + (n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n) + +noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequence + +noncomputable def gradientStopped (W : BrownianSpace) (γ : OrderParameter) + (X : ℝ → W.Ω → ℝ) (U : W.Ω → ℝ) (t : ℝ≥0) (ω : W.Ω) : ℝ := + if (t : ℝ) < 1 then gradient W γ t (X t ω) else U ω + +def ScalarValueConclusion (W : BrownianSpace) (γ : OrderParameter) + (X : ℝ → W.Ω → ℝ) : Prop := + Tendsto groundStateSequence atTop (𝓝 groundStateValue) ∧ + ∃ U : W.Ω → ℝ, + Martingale (gradientStopped W γ X U) W.filtration W.μ ∧ + (∀ᵐ ω ∂W.μ, |U ω| ≤ 1 ∧ (U ω)^2 = 1 ∧ + Tendsto (fun t ↦ gradient W γ t (X t ω)) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) ∧ + Tendsto (fun t ↦ ∫ ω, (gradient W γ t (X t ω) - U ω)^2 ∂W.μ) + (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) ∧ + groundStateValue = (∫ ω, |X 1 ω| ∂W.μ) - ∫ t in (0 : ℝ)..1, t * γ.coeff t ∧ + groundStateValue = ∫ ω, U ω * W.B 1 ω ∂W.μ ∧ + groundStateValue = ∫ t in (0 : ℝ)..1, ∫ ω, curvature W γ t (X t ω) ∂W.μ ∧ + IntervalIntegrable (fun t ↦ ∫ ω, curvature W γ t (X t ω) ∂W.μ) volume 0 1 + +noncomputable def eulerPath (W : BrownianSpace) (γ : OrderParameter) (T : ℝ) (N : ℕ) + (z : Fin (N+1) → ℝ) (j : ℕ) : ℝ := + euler T N γ.coeff (gradient W γ) z j + +noncomputable def rawCoefficient (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N j : ℕ) (z : Fin (N+1) → ℝ) : ℝ := + curvature W γ (meshTime T N j) (eulerPath W γ T N z j) + +noncomputable def normalizer (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N j : ℕ) : ℝ := + (Real.sqrt (∫ z, (rawCoefficient W γ T N j z)^2 ∂gaussianProduct (Fin (N+1))))⁻¹ + +noncomputable def gaussianIncrement (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N j : ℕ) (z : Fin (N+1) → ℝ) : ℝ := + normalizer W γ T N j * rawCoefficient W γ T N j z * coordinate N j z + +noncomputable def roundedSign (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ := + Real.sign (gradient W γ T (eulerPath W γ T N z N) + + 2 * cdf standardGaussian (coordinate N N z) - 1) + +noncomputable def coefficientA (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N j : ℕ) : ℝ := + if j = 0 then 0 else + ∫ z, roundedSign W γ T N z * gaussianIncrement W γ T N (j-1) z + ∂gaussianProduct (Fin (N+1)) + +noncomputable def coefficientB (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N i : ℕ) : ℝ := + ∫ z, roundedSign W γ T N z * coordinate N (i-1) z ∂gaussianProduct (Fin (N+1)) + +noncomputable def shiftedCoefficientSum (W : BrownianSpace) (γ : OrderParameter) + (T : ℝ) (N : ℕ) : ℝ := + ∑ j ∈ Finset.range (N+1), coefficientA W γ T N j * coefficientB W γ T N (j+1) + +def FiniteGaussianConclusion (W : BrownianSpace) (γ : OrderParameter) + (X : ℝ → W.Ω → ℝ) (T : ℝ) : Prop := + (∀ᶠ N in atTop, ∀ j < N, 0 < normalizer W γ T N j) ∧ + Tendsto (shiftedCoefficientSum W γ T) atTop + (𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, curvature W γ t (X t ω) ∂W.μ)) ∧ + Tendsto (fun S ↦ ∫ t in (0 : ℝ)..S, ∫ ω, curvature W γ t (X t ω) ∂W.μ) + (𝓝[<] (1 : ℝ)) (𝓝 groundStateValue) + +theorem value_consequences : + (∀ (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ), + IsMinimizer W γ → IsDiffusion W γ X → ScalarValueConclusion W γ X) ∧ + (∀ (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ) (T : ℝ), + 0 < T → T < 1 → IsMinimizer W γ → IsDiffusion W γ X → + FiniteGaussianConclusion W γ X T) ∧ + (∀ (W : BrownianSpace) (γ : OrderParameter), + IsMinimizer W γ → groundStateValue = parisi W γ) := by + sorry + +end SKValue + +end OAI diff --git a/lean/ComparatorChallenges/SLELowerPositivity.json b/lean/ComparatorChallenges/SLELowerPositivity.json new file mode 100644 index 0000000000000000000000000000000000000000..1c583f388f765a4e8dce2c084ea0b06ec66f155a --- /dev/null +++ b/lean/ComparatorChallenges/SLELowerPositivity.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SLELowerPositivity", + "solution_module": "OAI.Probability.SLE.LowerPositivity", + "theorem_names": [ + "OAI.SLEExactGauge.sourceLowerMain_proved" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SLELowerPositivity.lean b/lean/ComparatorChallenges/SLELowerPositivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..263176269e19986fc030c344da18d511b9a635b2 --- /dev/null +++ b/lean/ComparatorChallenges/SLELowerPositivity.lean @@ -0,0 +1,85 @@ +import Mathlib + +namespace OAI + +/-! Positivity of the explicit Hausdorff gauge on all positive-time SLE segments. -/ + +noncomputable section +open Set Filter MeasureTheory +open scoped Topology ENNReal NNReal +namespace SLEExactGauge +universe v_lower + +noncomputable def dimension (κ : ℝ) : ℝ := 1 + κ / 8 + +noncomputable def codimension (κ : ℝ) : ℝ := ((2 : ℕ) : ℝ) - dimension κ + +def upperHalfPlane : Set ℂ := {z | 0 < z.im} + +def survivingDomain (γ : ℝ≥0 → ℂ) (t : ℝ≥0) : Set ℂ := + {z | z ∈ upperHalfPlane \ (γ '' Icc 0 t) ∧ + ¬ Bornology.IsBounded (connectedComponentIn (upperHalfPlane \ (γ '' Icc 0 t)) z)} + +def IsCapacityTwoWitness (U : ℝ≥0 → ℝ) (γ : ℝ≥0 → ℂ) + (G F : ℝ≥0 → ℂ → ℂ) : Prop := + Continuous γ ∧ γ 0 = 0 ∧ (∀ t, 0 ≤ (γ t).im) ∧ + (∀ t, DifferentiableOn ℂ (G t) (survivingDomain γ t)) ∧ + (∀ t, DifferentiableOn ℂ (F t) upperHalfPlane) ∧ + (∀ t, MapsTo (G t) (survivingDomain γ t) upperHalfPlane) ∧ + (∀ t, MapsTo (F t) upperHalfPlane (survivingDomain γ t)) ∧ + (∀ t z, z ∈ survivingDomain γ t → F t (G t z) = z) ∧ + (∀ t z, z ∈ upperHalfPlane → G t (F t z) = z) ∧ + (∀ z ∈ upperHalfPlane, G 0 z = z) ∧ + (∀ t z, z ∈ survivingDomain γ t → + HasDerivWithinAt (fun u : ℝ => G (Real.toNNReal u) z) + (2 / (G t z - (U t : ℂ))) (Ici 0) (t : ℝ)) ∧ + (∀ t, Tendsto (fun z : ℂ => z * (G t z - z)) + (cocompact ℂ ⊓ 𝓟 (survivingDomain γ t)) (𝓝 (2 * (t : ℂ)))) ∧ + (∀ t, Tendsto (fun y : ℝ => F t ((U t : ℂ) + (y : ℂ) * Complex.I)) + (𝓝[>] 0) (𝓝 (γ t))) + +def IsCapacityTwoTrace (U : ℝ≥0 → ℝ) (γ : ℝ≥0 → ℂ) : Prop := + ∃ G F : ℝ≥0 → ℂ → ℂ, IsCapacityTwoWitness U γ G F + +def IsOrdinaryChordalSLE {Ω : Type*} [MeasurableSpace Ω] + (κ : ℝ) (γ : Ω → ℝ≥0 → ℂ) (P : Measure Ω) : Prop := + (∀ t, Measurable (fun ω => γ ω t)) ∧ + ∃ B : ℝ≥0 → Ω → ℝ, ProbabilityTheory.IsBrownianReal B P ∧ + ∀ᵐ ω ∂P, IsCapacityTwoTrace (fun t => Real.sqrt κ * B t ω) (γ ω) + +structure IsGauge (h : ℝ → ℝ) : Prop where + continuousOn : ContinuousOn h (Ici 0) + monotoneOn : MonotoneOn h (Ici 0) + zero : h 0 = 0 + positive : ∀ r, 0 < r → 0 < h r + +noncomputable def hFormula (κ r : ℝ) : ℝ := + r ^ dimension κ * (Real.log (Real.log (1 / r))) ^ (codimension κ / ((2 : ℕ) : ℝ)) + +def HasSmallRadiusFormula (h f : ℝ → ℝ) : Prop := + h =ᶠ[𝓝[>] 0] f + +noncomputable def extendedGauge (h : ℝ → ℝ) (r : ℝ≥0∞) : ℝ≥0∞ := + ENNReal.ofReal (h r.toReal) + +noncomputable def hausdorffGauge (h : ℝ → ℝ) : Measure ℂ := + Measure.mkMetric (extendedGauge h) + +def segment (γ : ℝ≥0 → ℂ) (s t : ℝ≥0) : Set ℂ := γ '' Icc s t + +def SourceLowerMainTarget : Prop := + ∀ (Ω : Type v_lower) (_ : MeasurableSpace Ω) (P : Measure Ω), IsProbabilityMeasure P → + ∀ κ : ℝ, 0 < κ → κ < ((8 : ℕ) : ℝ) → + ∀ (γ : Ω → ℝ≥0 → ℂ), IsOrdinaryChordalSLE κ γ P → + ∀ h : ℝ → ℝ, IsGauge h → HasSmallRadiusFormula h (hFormula κ) → + ∀ᵐ ω ∂P, ∀ s t : ℝ≥0, 0 < s → s < t → + 0 < hausdorffGauge h (segment (γ ω) s t) + +theorem sourceLowerMain_proved : SourceLowerMainTarget := by + sorry + +end SLEExactGauge + +end + +end OAI diff --git a/lean/ComparatorChallenges/Saxl.json b/lean/ComparatorChallenges/Saxl.json new file mode 100644 index 0000000000000000000000000000000000000000..de28934971681c29068ca51800717c7accd08caf --- /dev/null +++ b/lean/ComparatorChallenges/Saxl.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.Saxl", + "solution_module": "OAI.RepresentationTheory.Saxl.Main", + "theorem_names": [ + "OAI.Saxl.saxl_conjecture" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/Saxl.lean b/lean/ComparatorChallenges/Saxl.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a38a2913147886cabd314918ecc596e32d5f976 --- /dev/null +++ b/lean/ComparatorChallenges/Saxl.lean @@ -0,0 +1,119 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open scoped TensorProduct + +universe uG uV + +namespace Saxl + +/- Coefficients of position tensors on an alphabet of size `d`. -/ +abbrev WordSpace (n d : ℕ) := (Fin n → Fin d) → ℂ + +/- The position action satisfies `g e_a = e_(a ∘ g⁻¹)`. -/ +def wordRep (n d : ℕ) : Representation ℂ (Equiv.Perm (Fin n)) (WordSpace n d) where + toFun g := + { toFun := fun f a => f (a ∘ g) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext f a; rfl + map_mul' g h := by ext f a; rfl + +/- The cyclic subrepresentation generated by an actual vector. -/ +def cyclic {G : Type uG} {V : Type uV} [Group G] [AddCommGroup V] [Module ℂ V] + (ρ : Representation ℂ G V) (v : V) : Subrepresentation ρ where + toSubmodule := Submodule.span ℂ (Set.range fun g : G => ρ g v) + apply_mem_toSubmodule g := by + intro x hx + induction hx using Submodule.span_induction with + | mem x hx => + obtain ⟨h, rfl⟩ := hx + apply Submodule.subset_span + exact ⟨g * h, by simp only [map_mul, Module.End.mul_apply]⟩ + | zero => simp + | add x y hx hy ihx ihy => + simpa only [map_add] using Submodule.add_mem _ ihx ihy + | smul a x hx ih => + simpa only [map_smul] using Submodule.smul_mem _ a ih + +/- A tableau is an enumeration of all cells by the position set. -/ +abbrev Tableau (n : ℕ) (μ : YoungDiagram) := Fin n ≃ μ.cells + +/- One fixed tableau; changing its enumeration gives an isomorphic Specht module. -/ +def canonicalTableau {n : ℕ} (μ : YoungDiagram) (hn : μ.card = n) : Tableau n μ := + (Fintype.equivFinOfCardEq (by simpa using hn)).symm + +/- The row word corresponding to the tabloid of a tableau. -/ +def rowWord {n : ℕ} {μ : YoungDiagram} (t : Tableau n μ) : Fin n → Fin (μ.colLen 0) := + fun i => ⟨(t i).val.1, YoungDiagram.mem_iff_lt_colLen.mp + (μ.up_left_mem le_rfl (Nat.zero_le _) (t i).property)⟩ + +/- The column permutations of a tableau. -/ +def columnGroup {n : ℕ} {μ : YoungDiagram} (t : Tableau n μ) : + Subgroup (Equiv.Perm (Fin n)) where + carrier := {g | ∀ i, (t (g i)).val.2 = (t i).val.2} + one_mem' := by intro i; rfl + mul_mem' := by + intro g h hg hh i + exact (hg (h i)).trans (hh i) + inv_mem' := by + intro g hg i + have h := hg (g⁻¹ i) + simpa using h.symm + +/- The standard column-antisymmetrized row tabloid, with complex coefficients. -/ +def polytabloid {n : ℕ} {μ : YoungDiagram} (t : Tableau n μ) : + WordSpace n (μ.colLen 0) := by + classical + letI := Fintype.ofFinite (columnGroup t) + exact ∑ g : columnGroup t, + (((Equiv.Perm.sign (g : Equiv.Perm (Fin n))) : ℤ) : ℂ) • + wordRep n (μ.colLen 0) (g : Equiv.Perm (Fin n)) (Pi.single (rowWord t) 1) + +/- The Specht module, defined as the orbit span of a polytabloid in the +row-tabloid permutation module, realized inside the word space. -/ +def spechtSub {n : ℕ} {μ : YoungDiagram} (t : Tableau n μ) := + cyclic (wordRep n (μ.colLen 0)) (polytabloid t) + +abbrev Specht {n : ℕ} {μ : YoungDiagram} (t : Tableau n μ) := + (spechtSub t).toSubmodule + +/- The genuine symmetric-group representation on the complex Specht module. -/ +def spechtRep {n : ℕ} {μ : YoungDiagram} (t : Tableau n μ) : + Representation ℂ (Equiv.Perm (Fin n)) (Specht t) := + (spechtSub t).toRepresentation + +/- Kronecker multiplicity is the complex dimension of Hom, with the +diagonal symmetric-group action on the tensor product. -/ +def kronecker {n : ℕ} {α β μ : YoungDiagram} + (a : Tableau n α) (b : Tableau n β) (t : Tableau n μ) : ℕ := + Module.finrank ℂ (Representation.IntertwiningMap (spechtRep t) + ((spechtRep a).tprod (spechtRep b))) + + +def staircase (m : ℕ) : YoungDiagram where + cells := ((Finset.range m) ×ˢ (Finset.range m)).filter (fun x => x.1 + x.2 < m) + isLowerSet := by + intro x y hxy hy + simp only [Finset.mem_coe, Finset.mem_filter, Finset.mem_product, + Finset.mem_range] at hy ⊢ + exact ⟨⟨lt_of_le_of_lt hxy.1 hy.1.1, lt_of_le_of_lt hxy.2 hy.1.2⟩, + lt_of_le_of_lt (Nat.add_le_add hxy.1 hxy.2) hy.2⟩ + + +def SaxlConjecture : Prop := + ∀ (m : ℕ), 1 ≤ m → ∀ (μ : YoungDiagram) (hμ : μ.card = (staircase m).card), + 0 < kronecker (canonicalTableau (staircase m) rfl) + (canonicalTableau (staircase m) rfl) (canonicalTableau μ hμ) + +theorem saxl_conjecture : SaxlConjecture := by + sorry + +end Saxl + +end + +end OAI diff --git a/lean/ComparatorChallenges/SecondKahnKalai.json b/lean/ComparatorChallenges/SecondKahnKalai.json new file mode 100644 index 0000000000000000000000000000000000000000..523e4418f2d0bb19a88e1c6f71e8959540902857 --- /dev/null +++ b/lean/ComparatorChallenges/SecondKahnKalai.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SecondKahnKalai", + "solution_module": "OAI.Combinatorics.GraphThreshold.Main", + "theorem_names": [ + "OAI.LeanBlast.SecondKahnKalai.secondKahnKalaiBounds" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SecondKahnKalai.lean b/lean/ComparatorChallenges/SecondKahnKalai.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9cf65511e3bf58877869ac3d16f3a47b88c70ad --- /dev/null +++ b/lean/ComparatorChallenges/SecondKahnKalai.lean @@ -0,0 +1,74 @@ +import Mathlib.Data.Fintype.Powerset +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Combinatorics.SimpleGraph.Copy +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +noncomputable section + +universe u + +namespace LeanBlast.SecondKahnKalai + +def bernoulliWeight {X : Type u} [Fintype X] [DecidableEq X] + (p : ℝ) (W : Finset X) : ℝ := + ∏ x, if x ∈ W then p else 1 - p + +def bernoulliExpectation {X : Type u} [Fintype X] [DecidableEq X] + (p : ℝ) (f : Finset X → ℝ) : ℝ := + ∑ W, bernoulliWeight p W * f W + +def bernoulliProbability {X : Type u} [Fintype X] [DecidableEq X] + (p : ℝ) (P : Finset X → Prop) : ℝ := by + classical + exact ∑ W, if P W then bernoulliWeight p W else 0 + +/-- The unordered non-loop edges of the complete graph on `n` vertices. -/ +abbrev Edge (n : ℕ) := {e : Sym2 (Fin n) // ¬e.IsDiag} + +/-- A set of edges, interpreted as an ordinary graph on all `n` vertices. -/ +def graphOfEdges {n : ℕ} (W : Finset (Edge n)) : SimpleGraph (Fin n) := + SimpleGraph.fromEdgeSet (Subtype.val '' (W : Set (Edge n))) + +/-- The number of unordered edges, each counted once. -/ +def edgeCount {V : Type u} (H : SimpleGraph V) : ℕ := Nat.card H.edgeSet + +/-- Expected number of actual unlabelled non-induced copies in `G(n,p)`. -/ +def expectedCopies {V : Type u} (n : ℕ) (p : ℝ) (H : SimpleGraph V) : ℝ := + bernoulliExpectation p (fun W : Finset (Edge n) => + ((graphOfEdges W).copyCount H : ℝ)) + +/-- Probability that `G(n,p)` contains at least one non-induced copy. -/ +def containmentProbability {V : Type u} (n : ℕ) (p : ℝ) + (H : SimpleGraph V) : ℝ := + bernoulliProbability p (fun W : Finset (Edge n) => + 0 < (graphOfEdges W).copyCount H) + +def criticalThreshold {V : Type u} (n : ℕ) (H : SimpleGraph V) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc 0 1 ∧ (1 / 2 : ℝ) ≤ containmentProbability n p H} + +def expectationThreshold {V : Type u} (n : ℕ) (H : SimpleGraph V) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n p F.coe} + +def logTwo (x : ℝ) : ℝ := Real.log x / Real.log 2 + +def SecondKahnKalaiBounds {V : Type u} (n : ℕ) (H : SimpleGraph V) : Prop := + criticalThreshold n H ≤ + min 1 (2048 * Real.exp 50 * expectationThreshold n H * + (1 + logTwo (edgeCount H : ℝ))) ∧ + criticalThreshold n H ≤ + 6144 * Real.exp 50 * expectationThreshold n H * logTwo (n : ℝ) + +theorem secondKahnKalaiBounds (n : ℕ) (V : Type u) [Fintype V] + (H : SimpleGraph V) (hn : 2 ≤ n) (hcard : Fintype.card V ≤ n) + (hedge : 1 ≤ edgeCount H) : SecondKahnKalaiBounds n H := by + sorry + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/ComparatorChallenges/SelfSimilar.json b/lean/ComparatorChallenges/SelfSimilar.json new file mode 100644 index 0000000000000000000000000000000000000000..0588dba1e6de59a9f7f92a1f2801b4c4f3ef46f8 --- /dev/null +++ b/lean/ComparatorChallenges/SelfSimilar.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SelfSimilar", + "solution_module": "OAI.MeasureTheory.SelfSimilar.Main", + "theorem_names": [ + "OAI.EntropyRateDimension.entropy_rate_dimension" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SelfSimilar.lean b/lean/ComparatorChallenges/SelfSimilar.lean new file mode 100644 index 0000000000000000000000000000000000000000..36631fae29445952b191f98801e772aab83dcc64 --- /dev/null +++ b/lean/ComparatorChallenges/SelfSimilar.lean @@ -0,0 +1,73 @@ +import Mathlib + +namespace OAI + +universe uι + +open scoped BigOperators ENNReal +open MeasureTheory + +namespace EntropyRateDimension + +structure System (ι : Type uι) [Fintype ι] where + ratio : ι → ℝ + offset : ι → ℝ + weight : ι → ℝ + ratio_pos : ∀ i, 0 < |ratio i| + ratio_lt_one : ∀ i, |ratio i| < 1 + weight_pos : ∀ i, 0 < weight i + weight_sum : ∑ i, weight i = 1 + +namespace System + +variable {ι : Type uι} [Fintype ι] + +def affine (S : System ι) (i : ι) (x : ℝ) : ℝ := S.ratio i * x + S.offset i + +def wordAffine (S : System ι) : List ι → ℝ × ℝ + | [] => (1, 0) + | i :: w => (S.ratio i * (S.wordAffine w).1, + S.ratio i * (S.wordAffine w).2 + S.offset i) + +def completeMap (S : System ι) {n : ℕ} (w : Fin n → ι) : ℝ × ℝ := + S.wordAffine (List.ofFn w) + +noncomputable def wordWeight (S : System ι) {n : ℕ} (w : Fin n → ι) : ℝ := + ∏ j, S.weight (w j) + +noncomputable def mapSupport (S : System ι) (n : ℕ) : Finset (ℝ × ℝ) := by + classical + exact Finset.univ.image (S.completeMap (n := n)) + +noncomputable def mapMass (S : System ι) (n : ℕ) (g : ℝ × ℝ) : ℝ := by + classical + exact ∑ w ∈ (Finset.univ : Finset (Fin n → ι)).filter (S.completeMap · = g), + S.wordWeight w + +noncomputable def walkEntropy (S : System ι) (n : ℕ) : ℝ := + (∑ g ∈ S.mapSupport n, Real.negMulLog (S.mapMass n g)) / Real.log 2 + +noncomputable def entropyRate (S : System ι) : ℝ := + sInf (Set.range fun n : ℕ => S.walkEntropy (n + 1) / (n + 1 : ℕ)) + +noncomputable def lyapunov (S : System ι) : ℝ := + -(∑ i, S.weight i * (Real.log |S.ratio i| / Real.log 2)) + +def SelfSimilar (S : System ι) (μ : Measure ℝ) : Prop := + μ = ∑ i, ENNReal.ofReal (S.weight i) • μ.map (S.affine i) + +end System + +noncomputable def lowerHausdorffDimension (μ : Measure ℝ) : ℝ≥0∞ := + ⨅ (E : Set ℝ) (_ : MeasurableSet E) (_ : 0 < μ E), dimH E +open MeasureTheory + +theorem entropy_rate_dimension {ι : Type uι} [Fintype ι] [Nonempty ι] + (S : System ι) (μ : Measure ℝ) [IsProbabilityMeasure μ] + (hμ : S.SelfSimilar μ) : + lowerHausdorffDimension μ = ENNReal.ofReal (min 1 (S.entropyRate / S.lyapunov)) := by + sorry + +end EntropyRateDimension + +end OAI diff --git a/lean/ComparatorChallenges/SelfSimilarCorollaries.json b/lean/ComparatorChallenges/SelfSimilarCorollaries.json new file mode 100644 index 0000000000000000000000000000000000000000..adf6e0cf69a99c6d91992518c9678d0103cbf41b --- /dev/null +++ b/lean/ComparatorChallenges/SelfSimilarCorollaries.json @@ -0,0 +1,15 @@ +{ + "challenge_module": "ComparatorChallenges.SelfSimilarCorollaries", + "solution_module": "OAI.MeasureTheory.SelfSimilar.DimensionCorollaries", + "theorem_names": [ + "OAI.EntropyRateDimension.Extensions.homogeneous_dimension_direct", + "OAI.CorSetReference.cor_set" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Classical.choice", + "Quot.sound" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SelfSimilarCorollaries.lean b/lean/ComparatorChallenges/SelfSimilarCorollaries.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2430524a79e106ad056e71402c31a616dff26a2 --- /dev/null +++ b/lean/ComparatorChallenges/SelfSimilarCorollaries.lean @@ -0,0 +1,90 @@ +import Mathlib + +namespace OAI + +universe uι + +section + +open scoped BigOperators ENNReal +open MeasureTheory + +namespace EntropyRateDimension + +structure System (ι : Type uι) [Fintype ι] where + ratio : ι → ℝ + offset : ι → ℝ + weight : ι → ℝ + ratio_pos : ∀ i, 0 < |ratio i| + ratio_lt_one : ∀ i, |ratio i| < 1 + weight_pos : ∀ i, 0 < weight i + weight_sum : ∑ i, weight i = 1 + +namespace System +variable {ι : Type uι} [Fintype ι] + +def affine (S : System ι) (i : ι) (x : ℝ) : ℝ := S.ratio i * x + S.offset i + +def wordAffine (S : System ι) : List ι → ℝ × ℝ + | [] => (1, 0) + | i :: w => (S.ratio i * (S.wordAffine w).1, + S.ratio i * (S.wordAffine w).2 + S.offset i) + +def SelfSimilar (S : System ι) (μ : Measure ℝ) : Prop := + μ = ∑ i, ENNReal.ofReal (S.weight i) • μ.map (S.affine i) + +end System + +noncomputable def lowerHausdorffDimension (μ : Measure ℝ) : ℝ≥0∞ := + ⨅ (E : Set ℝ) (_ : MeasurableSet E) (_ : 0 < μ E), dimH E + +namespace Extensions +variable {ι : Type uι} [Fintype ι] + +def NoExactOverlaps (S : System ι) : Prop := Function.Injective S.wordAffine + +noncomputable def symbolEntropy (S : System ι) : ℝ := + ∑ i, Real.negMulLog (S.weight i) + +theorem homogeneous_dimension_direct {ι : Type uι} [Fintype ι] [Nonempty ι] (S : System ι) + {lam : ℝ} (hlam : 0 < lam) (hr : ∀ i, S.ratio i = lam) + (μ : Measure ℝ) [IsProbabilityMeasure μ] (hμ : S.SelfSimilar μ) + (h : NoExactOverlaps S) : + lowerHausdorffDimension μ = + ENNReal.ofReal (min 1 (symbolEntropy S / Real.log (1/lam))) := by + sorry + +end Extensions +end EntropyRateDimension +end + +open scoped BigOperators ENNReal + +namespace CorSetReference +variable {ι : Type uι} [Fintype ι] [Nonempty ι] + +noncomputable def codingPoint (r t : ι → ℝ) (ω : ℕ → ι) : ℝ := + ∑' n, (∏ j ∈ Finset.range n, r (ω j)) * t (ω n) + + +noncomputable def attractor (r t : ι → ℝ) : Set ℝ := + Set.range (codingPoint r t) + + +def word (r t : ι → ℝ) : List ι → ℝ × ℝ := + List.foldr (fun symbol coefficients => + (r symbol * coefficients.1, r symbol * coefficients.2 + t symbol)) (1, 0) + +theorem cor_set {ι : Type uι} [Fintype ι] [Nonempty ι] + (r t : ι → ℝ) (hr0 : ∀ i, 0 < |r i|) (hr1 : ∀ i, |r i| < 1) + (hno : ∀ u v : List ι, u ≠ [] → v ≠ [] → + word r t u = word r t v → u = v) : + IsCompact (attractor r t) ∧ (attractor r t).Nonempty ∧ + (∃! s : ℝ, 0 ≤ s ∧ ∑ i, |r i| ^ s = 1) ∧ + (∀ s : ℝ, 0 ≤ s → (∑ i, |r i| ^ s = 1) → + dimH (attractor r t) = ENNReal.ofReal (min 1 s)) := by + sorry + +end CorSetReference + +end OAI diff --git a/lean/ComparatorChallenges/SensitivitySeparation.json b/lean/ComparatorChallenges/SensitivitySeparation.json new file mode 100644 index 0000000000000000000000000000000000000000..4a045e5a5b2d3879ea54f5d6a790869a70d36da1 --- /dev/null +++ b/lean/ComparatorChallenges/SensitivitySeparation.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SensitivitySeparation", + "solution_module": "OAI.Combinatorics.Sensitivity.Separation", + "theorem_names": [ + "OAI.Paper320.quantitative_separation" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SensitivitySeparation.lean b/lean/ComparatorChallenges/SensitivitySeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2cf871bc3bb38194fc1b742666210f11498918b --- /dev/null +++ b/lean/ComparatorChallenges/SensitivitySeparation.lean @@ -0,0 +1,42 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped Classical + +namespace Paper320 + +def flip {I : Type} (x : I → Bool) (B : Finset I) : I → Bool := + fun i => if i ∈ B then !(x i) else x i + +def sensitivityAt {I : Type} [Fintype I] + (f : (I → Bool) → Bool) (x : I → Bool) : ℕ := + (Finset.univ.filter fun i => f (flip x {i}) ≠ f x).card + +def sensitivity {I : Type} [Fintype I] (f : (I → Bool) → Bool) : ℕ := + Finset.univ.sup (sensitivityAt f) + +def blockSensitivityAt {I : Type} [Fintype I] + (f : (I → Bool) → Bool) (x : I → Bool) : ℕ := + Finset.univ.sup fun blocks : Finset (Finset I) => + if (∀ A ∈ blocks, ∀ B ∈ blocks, A ≠ B → Disjoint A B) ∧ + (∀ B ∈ blocks, B.Nonempty ∧ f (flip x B) ≠ f x) + then blocks.card else 0 + +def blockSensitivity {I : Type} [Fintype I] (f : (I → Bool) → Bool) : ℕ := + Finset.univ.sup (blockSensitivityAt f) + +theorem quantitative_separation (d : ℕ) (hd : 1 ≤ d) : + ∃ (n : ℕ) (f : (Fin n → Bool) → Bool), + 0 < n ∧ f (fun _ => false) = false ∧ + (∃ x y : Fin n → Bool, f x ≠ f y) ∧ + (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ + (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by + sorry + +end Paper320 + +end + +end OAI diff --git a/lean/ComparatorChallenges/SeparableQuotientNegative.json b/lean/ComparatorChallenges/SeparableQuotientNegative.json new file mode 100644 index 0000000000000000000000000000000000000000..4d2965dcb6ecfb2524e255354c5554e4dd89f1f1 --- /dev/null +++ b/lean/ComparatorChallenges/SeparableQuotientNegative.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SeparableQuotientNegative", + "solution_module": "OAI.Analysis.SeparableQuotients.Main", + "theorem_names": [ + "OAI.SeparableQuotient.negative_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SeparableQuotientNegative.lean b/lean/ComparatorChallenges/SeparableQuotientNegative.lean new file mode 100644 index 0000000000000000000000000000000000000000..b489a0ad4b757ae0ed725db356d8a5c80c66f59a --- /dev/null +++ b/lean/ComparatorChallenges/SeparableQuotientNegative.lean @@ -0,0 +1,31 @@ +import Mathlib + +namespace OAI + +namespace SeparableQuotient + +open MeasureTheory Cardinal + +universe u + +/-- The continuum hypothesis. -/ +def CH : Prop := Cardinal.mk ℝ = Cardinal.aleph 1 + +/-- A bounded linear surjection onto an infinite-dimensional separable Banach space. -/ +def HasSeparableQuotient (𝕜 : Type) [RCLike 𝕜] + (X : Type u) [NormedAddCommGroup X] [NormedSpace 𝕜 X] : Prop := + ∃ (Y : Type u) (_ : NormedAddCommGroup Y) (_ : NormedSpace 𝕜 Y), + CompleteSpace Y ∧ TopologicalSpace.SeparableSpace Y ∧ + (¬ FiniteDimensional 𝕜 Y) ∧ ∃ T : X →L[𝕜] Y, Function.Surjective T + +/-- The separable quotient assertion at an arbitrary ambient universe. -/ +def SQ (𝕜 : Type) [RCLike 𝕜] : Prop := + ∀ (X : Type u) [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X], + (¬ FiniteDimensional 𝕜 X) → HasSeparableQuotient 𝕜 X + +theorem negative_main (hCH : CH) : ¬ SQ.{u} ℝ ∧ ¬ SQ.{u} ℂ := by + sorry + +end SeparableQuotient + +end OAI diff --git a/lean/ComparatorChallenges/SeymourSecondNeighborhood.json b/lean/ComparatorChallenges/SeymourSecondNeighborhood.json new file mode 100644 index 0000000000000000000000000000000000000000..30d626fa6821128e87fcfa95827c062bfddd65df --- /dev/null +++ b/lean/ComparatorChallenges/SeymourSecondNeighborhood.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SeymourSecondNeighborhood", + "solution_module": "OAI.Combinatorics.SecondNeighborhood.Main", + "theorem_names": [ + "OAI.SeymourSecondNeighborhood.exists_goodVertex" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SeymourSecondNeighborhood.lean b/lean/ComparatorChallenges/SeymourSecondNeighborhood.lean new file mode 100644 index 0000000000000000000000000000000000000000..70d287c3f831d0698352b144d39cdf29cac6c24b --- /dev/null +++ b/lean/ComparatorChallenges/SeymourSecondNeighborhood.lean @@ -0,0 +1,40 @@ +import Mathlib.Data.Fintype.Card +import Mathlib.Data.Finset.Union + +namespace OAI + +namespace SeymourSecondNeighborhood + +variable {V : Type*} + +structure IsOriented (r : V → V → Prop) : Prop where + loopless : ∀ v, ¬ r v v + asymmetric : ∀ {u v}, r u v → ¬ r v u + +variable [Fintype V] [DecidableEq V] + +noncomputable section + +def firstNeighbors (r : V → V → Prop) (v : V) : Finset V := by + classical + exact Finset.univ.filter (r v) + +def secondNeighbors (r : V → V → Prop) (v : V) : Finset V := by + classical + exact Finset.univ.filter (fun w => + w ≠ v ∧ ¬ r v w ∧ ∃ u, r v u ∧ r u w) + +def GoodVertex (r : V → V → Prop) (v : V) : Prop := + (firstNeighbors r v).card ≤ (secondNeighbors r v).card + +end + +variable [Nonempty V] + +theorem exists_goodVertex (r : V → V → Prop) (hr : IsOriented r) : + ∃ v, GoodVertex r v := by + sorry + +end SeymourSecondNeighborhood + +end OAI diff --git a/lean/ComparatorChallenges/SharpCAT0Filling.json b/lean/ComparatorChallenges/SharpCAT0Filling.json new file mode 100644 index 0000000000000000000000000000000000000000..13e88c2beb05aac16d7a949c8d4cabf2e385be9f --- /dev/null +++ b/lean/ComparatorChallenges/SharpCAT0Filling.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SharpCAT0Filling", + "solution_module": "OAI.Geometry.CAT0Fillings.Main", + "theorem_names": [ + "OAI.CAT0Fillings.sharp_integral_filling" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Classical.choice", + "Quot.sound" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SharpCAT0Filling.lean b/lean/ComparatorChallenges/SharpCAT0Filling.lean new file mode 100644 index 0000000000000000000000000000000000000000..65e1f6264588c62968a509ef296f1d2822bcc823 --- /dev/null +++ b/lean/ComparatorChallenges/SharpCAT0Filling.lean @@ -0,0 +1,146 @@ +import Mathlib + +namespace OAI + +open Set Filter MeasureTheory +open scoped Topology ENNReal NNReal + +namespace CAT0Fillings + +attribute [local instance] Classical.propDecidable + +universe u + +abbrev Euc (k : ℕ) := EuclideanSpace ℝ (Fin k) +abbrev Functional (X : Type u) (k : ℕ) := (X → ℝ) → (Fin k → X → ℝ) → ℝ + +section MetricCurrents + +variable {X : Type u} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + +def BoundedLip (b : X → ℝ) : Prop := + (∃ K : ℝ≥0, LipschitzWith K b) ∧ ∃ M : ℝ, ∀ x, |b x| ≤ M + +def Admissible {k : ℕ} (b : X → ℝ) (π : Fin k → X → ℝ) : Prop := + BoundedLip b ∧ ∀ i, ∃ K : ℝ≥0, LipschitzWith K (π i) + +def Controls {k : ℕ} (T : Functional X k) (μ : Measure X) : Prop := + ∀ (b : X → ℝ) (π : Fin k → X → ℝ), BoundedLip b → + (∀ i, LipschitzWith 1 (π i)) → + |T b π| ≤ ∫ x, |b x| ∂μ + +noncomputable def mass {k : ℕ} (T : Functional X k) : ℝ := + sInf {r : ℝ | ∃ μ : Measure X, + IsFiniteMeasure μ ∧ Controls T μ ∧ r = μ.real univ} + +structure IsMetricCurrent {k : ℕ} (T : Functional X k) : Prop where + offDomain : ∀ b π, ¬Admissible b π → T b π = 0 + linearFirst : ∀ b₁ b₂ π (a c : ℝ), BoundedLip b₁ → BoundedLip b₂ → + (∀ i, ∃ K : ℝ≥0, LipschitzWith K (π i)) → + T (fun x => a * b₁ x + c * b₂ x) π = a * T b₁ π + c * T b₂ π + linearCoord : ∀ b π i f (a c : ℝ), Admissible b π → + (∃ K : ℝ≥0, LipschitzWith K f) → + T b (Function.update π i (fun x => a * π i x + c * f x)) = + a * T b π + c * T b (Function.update π i f) + sequentialContinuity : ∀ b π (πs : ℕ → Fin k → X → ℝ), BoundedLip b → + (∀ i, ∃ K : ℝ≥0, ∀ j, LipschitzWith K (πs j i)) → + (∀ i x, Tendsto (fun j => πs j i x) atTop (𝓝 (π i x))) → + Tendsto (fun j => T b (πs j)) atTop (𝓝 (T b π)) + locality : ∀ b π, Admissible b π → + (∃ (i : Fin k) (U : Set X) (c : ℝ), IsOpen U ∧ Function.support b ⊆ U ∧ + ∀ x ∈ U, π i x = c) → T b π = 0 + finiteMass : ∃ μ : Measure X, IsFiniteMeasure μ ∧ Controls T μ + +noncomputable def boundarySucc {k : ℕ} (T : Functional X (k + 1)) : Functional X k := + fun b π => if Admissible b π then T (fun _ => 1) (Matrix.vecCons b π) else 0 + +noncomputable def boundary : {k : ℕ} → Functional X k → Functional X (k - 1) + | 0, _ => fun _ _ => 0 + | _ + 1, T => boundarySucc T + +structure IntegerChart (X : Type u) [MetricSpace X] (k : ℕ) where + domain : Set (Euc k) + borel : MeasurableSet domain + bounded : Bornology.IsBounded domain + param : domain → X + bilipschitz : ∃ L U : ℝ≥0, LipschitzWith L param ∧ AntilipschitzWith U param + multiplicity : Euc k → ℤ + integrable : Integrable (fun z => (multiplicity z : ℝ)) (volume.restrict domain) + +namespace IntegerChart + +variable {k : ℕ} (C : IntegerChart X k) + +noncomputable def scalar (f : X → ℝ) (z : Euc k) : ℝ := + if hz : z ∈ C.domain then f (C.param ⟨z, hz⟩) else 0 + +noncomputable def jacobian (π : Fin k → X → ℝ) (z : Euc k) : ℝ := + Matrix.det (fun i j => + (fderivWithin ℝ (C.scalar (π i)) C.domain z) (EuclideanSpace.single j 1)) + +noncomputable def action : Functional X k := + fun b π => if Admissible b π then + ∫ z in C.domain, (C.multiplicity z : ℝ) * C.scalar b z * C.jacobian π z + else 0 + +def image : Set X := Set.range C.param + +end IntegerChart + +def IntegerRectifiable {k : ℕ} (T : Functional X k) : Prop := + ∃ C : ℕ → IntegerChart X k, + Pairwise (fun i j => Disjoint (C i).image (C j).image) ∧ + (∀ i, IsMetricCurrent (C i).action) ∧ + Summable (fun i => mass (C i).action) ∧ + ∀ b π, T b π = ∑' i, (C i).action b π + +def IsIntegral : (k : ℕ) → Functional X k → Prop + | 0, T => IsMetricCurrent T ∧ IntegerRectifiable T + | _ + 1, T => IsMetricCurrent T ∧ IntegerRectifiable T ∧ + IsMetricCurrent (boundarySucc T) ∧ IntegerRectifiable (boundarySucc T) + +abbrev IntegralCurrent (X : Type u) [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + (k : ℕ) := { T : Functional X k // IsIntegral k T } + +def CompactlySupported {k : ℕ} (T : Functional X k) : Prop := + ∃ K : Set X, IsCompact K ∧ + ∀ b π, Admissible b π → (∀ x ∈ K, b x = 0) → T b π = 0 + +def IsCycle {k : ℕ} (T : Functional X k) : Prop := boundary T = fun _ _ => 0 + +end MetricCurrents + +section Geometry +variable (X : Type u) [MetricSpace X] + +def IsCAT0 : Prop := + ∃ segment : X → X → ℝ → X, + (∀ x y, segment x y 0 = x ∧ segment x y 1 = y) ∧ + (∀ x y s t, s ∈ Icc (0 : ℝ) 1 → t ∈ Icc (0 : ℝ) 1 → + dist (segment x y s) (segment x y t) = |s - t| * dist x y) ∧ + (∀ o x y s t, s ∈ Icc (0 : ℝ) 1 → t ∈ Icc (0 : ℝ) 1 → + dist (segment o x s) (segment o y t) ^ 2 ≤ + (s * dist o x - t * dist o y) ^ 2 + + s * t * ((dist x y) ^ 2 - (dist o x - dist o y) ^ 2)) + +end Geometry + +noncomputable def omega (k : ℕ) : ℝ := + (volume (Metric.ball (0 : Euc k) 1)).toReal +noncomputable def sphereArea (n : ℕ) : ℝ := (n + 1 : ℝ) * omega (n + 1) +noncomputable def fillingCoefficient (n : ℕ) : ℝ := + 1 / ((n + 1 : ℝ) * (sphereArea n) ^ (1 / (n : ℝ))) +noncomputable def fillingPower (n : ℕ) : ℝ := (n + 1 : ℝ) / (n : ℝ) + +theorem sharp_integral_filling + (X : Type u) [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X] + (hX : IsCAT0 X) (n : ℕ) (hn : 2 ≤ n) (T : IntegralCurrent X n) + (hTc : CompactlySupported T.val) (hTz : IsCycle T.val) : + ∃ S : IntegralCurrent X (n + 1), CompactlySupported S.val ∧ + boundarySucc S.val = T.val ∧ + mass S.val ≤ fillingCoefficient n * (mass T.val) ^ fillingPower n := by + sorry + +end CAT0Fillings + +end OAI diff --git a/lean/ComparatorChallenges/SharpLogRamsey.json b/lean/ComparatorChallenges/SharpLogRamsey.json new file mode 100644 index 0000000000000000000000000000000000000000..edc379f2dc405744108216a889c034683e385e50 --- /dev/null +++ b/lean/ComparatorChallenges/SharpLogRamsey.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SharpLogRamsey", + "solution_module": "OAI.Combinatorics.SharpRamsey.Main", + "theorem_names": [ + "OAI.SharpLogRamsey.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SharpLogRamsey.lean b/lean/ComparatorChallenges/SharpLogRamsey.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e9f633cf8b6d93794e79d1fe1b05c9d2a9e1b1c --- /dev/null +++ b/lean/ComparatorChallenges/SharpLogRamsey.lean @@ -0,0 +1,37 @@ +import Mathlib + +namespace OAI + +namespace SharpLogRamsey + +/-- Every graph has an s-clique or an independent set of size t. -/ +def RamseyProperty (s t N : ℕ) : Prop := + ∀ G : SimpleGraph (Fin N), + (∃ A : Finset (Fin N), G.IsNClique s A) ∨ + (∃ B : Finset (Fin N), Gᶜ.IsNClique t B) + +noncomputable def ramsey (s t : ℕ) : ℕ := sInf {N | RamseyProperty s t N} + +/-- The upper-bound constant is chosen independently of epsilon. -/ +def MainBounds (s : ℕ) : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ ε : ℝ, 0 < ε → + ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t → + (t : ℝ) ^ (s - 1) / Real.rpow (Real.log (t : ℝ)) ((s - 2 : ℕ) + ε) + ≤ (ramsey s t : ℝ) ∧ + (ramsey s t : ℝ) ≤ C * (t : ℝ) ^ (s - 1) / + (Real.log (t : ℝ)) ^ (s - 2) + +/-- The logarithmic exponent converges along all natural orders. -/ +def MainLimit (s : ℕ) : Prop := + Filter.Tendsto + (fun t : ℕ => + (((s - 1 : ℕ) : ℝ) * Real.log (t : ℝ) - Real.log (ramsey s t : ℝ)) / + Real.log (Real.log (t : ℝ))) + Filter.atTop (nhds ((s - 2 : ℕ) : ℝ)) + +theorem main (s : ℕ) (hs : 6 ≤ s) : MainBounds s ∧ MainLimit s := by + sorry + +end SharpLogRamsey + +end OAI diff --git a/lean/ComparatorChallenges/SharpThreshold.json b/lean/ComparatorChallenges/SharpThreshold.json new file mode 100644 index 0000000000000000000000000000000000000000..5ee7a3ad4c64a57b23e49e668015636f2250e7b5 --- /dev/null +++ b/lean/ComparatorChallenges/SharpThreshold.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SharpThreshold", + "solution_module": "OAI.Combinatorics.SharpThreshold.Main", + "theorem_names": [ + "OAI.Problem313.sharp_threshold_width" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SharpThreshold.lean b/lean/ComparatorChallenges/SharpThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef4ccc6106955d4c332dc3d8e6893a1fbe3248d0 --- /dev/null +++ b/lean/ComparatorChallenges/SharpThreshold.lean @@ -0,0 +1,63 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +abbrev GraphEdge (n : ℕ) := {e : Finset (Fin n) // e.card = 2} + +abbrev GraphConfig (n : ℕ) := GraphEdge n → Bool + +def permEdge {n : ℕ} (π : Equiv.Perm (Fin n)) (e : GraphEdge n) : GraphEdge n := + ⟨e.1.map π.toEmbedding, by simpa using e.2⟩ + +def permuteConfig {n : ℕ} (π : Equiv.Perm (Fin n)) + (x : GraphConfig n) : GraphConfig n := + fun e => x (permEdge π.symm e) + +def VertexInvariant {n : ℕ} (f : GraphConfig n → Bool) : Prop := + ∀ (π : Equiv.Perm (Fin n)) (x : GraphConfig n), + f (permuteConfig π x) = f x + +def ConfigLE {n : ℕ} (x y : GraphConfig n) : Prop := + ∀ e, x e = true → y e = true + +def IncreasingGraphProperty {n : ℕ} (f : GraphConfig n → Bool) : Prop := + ∀ x y, ConfigLE x y → f x = true → f y = true + +def NontrivialGraphProperty {n : ℕ} (f : GraphConfig n → Bool) : Prop := + (∃ x, f x = true) ∧ (∃ x, f x = false) + +def boolReal (b : Bool) : ℝ := + match b with + | false => 0 + | true => 1 + +def graphWeight {n : ℕ} (p : ℝ) (x : GraphConfig n) : ℝ := by + classical + exact Finset.univ.prod (fun e : GraphEdge n => + if x e = true then p else 1 - p) + +def graphMean {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : ℝ := by + classical + exact Finset.univ.sum (fun x : GraphConfig n => + graphWeight p x * boolReal (f x)) + +def graphQuantile {n : ℕ} (a : ℝ) (f : GraphConfig n → Bool) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ graphMean p f ≥ a} + +theorem sharp_threshold_width : + ∀ (n : ℕ) (f : GraphConfig n → Bool) (ε : ℝ), + 2 ≤ n → VertexInvariant f → IncreasingGraphProperty f → + NontrivialGraphProperty f → 0 < ε → ε < (1 / 2 : ℝ) → + graphQuantile (1 - ε) f - graphQuantile ε f ≤ + ((2 : ℝ) ^ 19 / (Real.log (n : ℝ)) ^ 2) * Real.log (1 / (2 * ε)) := by + sorry + +end Problem313 + +end + +end OAI diff --git a/lean/ComparatorChallenges/ShortEgyptianFractions.json b/lean/ComparatorChallenges/ShortEgyptianFractions.json new file mode 100644 index 0000000000000000000000000000000000000000..a3f718d7ce1c68a1c9a7380d2b785a374b293547 --- /dev/null +++ b/lean/ComparatorChallenges/ShortEgyptianFractions.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ShortEgyptianFractions", + "solution_module": "OAI.NumberTheory.ShortEgyptian.Main", + "theorem_names": [ + "OAI.ShortEgyptian.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ShortEgyptianFractions.lean b/lean/ComparatorChallenges/ShortEgyptianFractions.lean new file mode 100644 index 0000000000000000000000000000000000000000..da06f4ee1a07f69e099965b785ee6d0430d7b4ad --- /dev/null +++ b/lean/ComparatorChallenges/ShortEgyptianFractions.lean @@ -0,0 +1,27 @@ +import Mathlib + +namespace OAI + +namespace ShortEgyptian + +def IsExpansion (a b : ℕ) (ns : List ℕ) : Prop := + ns.Pairwise (· < ·) ∧ (∀ n ∈ ns, 2 ≤ n) ∧ + (ns.map (fun n => (1 : ℚ) / (n : ℚ))).sum = (a : ℚ) / (b : ℚ) + +noncomputable def minLength (a b : ℕ) : ℕ := + sInf {k : ℕ | ∃ ns : List ℕ, IsExpansion a b ns ∧ ns.length = k} + +noncomputable def maxMinLength (b : ℕ) : ℕ := + (Finset.Ico 1 b).sup (fun a => minLength a b) + +theorem main : + (∀ a b : ℕ, 1 ≤ a → a < b → ∃ ns : List ℕ, IsExpansion a b ns) ∧ + ∃ c₁ c₂ : ℝ, 0 < c₁ ∧ 0 < c₂ ∧ ∃ b₀ : ℕ, 2 ≤ b₀ ∧ + ∀ b : ℕ, b₀ ≤ b → + c₁ * Real.log (Real.log (b : ℝ)) ≤ (maxMinLength b : ℝ) ∧ + (maxMinLength b : ℝ) ≤ c₂ * Real.log (Real.log (b : ℝ)) := by + sorry + +end ShortEgyptian + +end OAI diff --git a/lean/ComparatorChallenges/SidorenkoCounterexample.json b/lean/ComparatorChallenges/SidorenkoCounterexample.json new file mode 100644 index 0000000000000000000000000000000000000000..3fdb7a849e7b1df1fc07013c901e1052b35170f8 --- /dev/null +++ b/lean/ComparatorChallenges/SidorenkoCounterexample.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SidorenkoCounterexample", + "solution_module": "OAI.Combinatorics.Sidorenko.RandomHost", + "theorem_names": [ + "OAI.SidorenkoCounterexample.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SidorenkoCounterexample.lean b/lean/ComparatorChallenges/SidorenkoCounterexample.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f4fa1074f812e2e823350ea50ff1a786e4a1927 --- /dev/null +++ b/lean/ComparatorChallenges/SidorenkoCounterexample.lean @@ -0,0 +1,47 @@ +import Mathlib + +namespace OAI + +/-! # A finite counterexample to Sidorenko's conjecture + +The pattern is the incidence graph of the 22 triples in Table 1 of the source. +Homomorphism density counts all edge-preserving maps, including noninjective maps. +-/ + +namespace SidorenkoCounterexample + +def faces : Fin 22 → Finset (Fin 13) := ![ + {0,1,3}, {0,1,9}, {0,2,3}, {0,2,9}, {1,3,10}, {1,7,10}, + {1,7,12}, {1,9,12}, {2,3,4}, {2,4,9}, {3,4,11}, {3,10,11}, + {4,8,9}, {4,8,11}, {5,6,7}, {5,6,11}, {5,7,10}, {5,10,11}, + {6,7,12}, {6,8,11}, {6,8,12}, {8,9,12}] + +abbrev PatternVertex := Fin 13 ⊕ Fin 22 + +def incidence : PatternVertex → PatternVertex → Prop + | .inl point, .inr face => point ∈ faces face + | .inr face, .inl point => point ∈ faces face + | _, _ => False + +def H : SimpleGraph PatternVertex where + Adj := incidence + symm.symm := by intro left right; cases left <;> cases right <;> simp [incidence] + loopless.irrefl := by intro vertex; cases vertex <;> simp [incidence] + +noncomputable def homCount {V W : Type*} (F : SimpleGraph V) (G : SimpleGraph W) : ℕ := + Nat.card {hom : V → W // ∀ left right, F.Adj left right → G.Adj (hom left) (hom right)} + +noncomputable def homDensity {V W : Type*} (F : SimpleGraph V) (G : SimpleGraph W) : ℝ := + (homCount F G : ℝ) / (Nat.card W : ℝ) ^ Nat.card V + +noncomputable def edgeDensity {W : Type*} (G : SimpleGraph W) : ℝ := + 2 * (Nat.card G.edgeSet : ℝ) / (Nat.card W : ℝ) ^ 2 + +/-- A finite simple host with at least one edge violates Sidorenko's inequality. -/ +theorem main : ∃ size : ℕ, 0 < size ∧ ∃ host : SimpleGraph (Fin size), + (∃ left right, host.Adj left right) ∧ homDensity H host < (edgeDensity host) ^ 66 := by + sorry + +end SidorenkoCounterexample + +end OAI diff --git a/lean/ComparatorChallenges/SiegelZeros.json b/lean/ComparatorChallenges/SiegelZeros.json new file mode 100644 index 0000000000000000000000000000000000000000..25989d64aa0ee538fed5921864ddfad283e61e27 --- /dev/null +++ b/lean/ComparatorChallenges/SiegelZeros.json @@ -0,0 +1,15 @@ +{ + "challenge_module": "ComparatorChallenges.SiegelZeros", + "solution_module": "OAI.NumberTheory.SiegelZeros.Main", + "theorem_names": [ + "OAI.SiegelZeros.WeightedTorusJets.exists_absolute_real_zero_gap", + "OAI.SiegelZeros.WeightedTorusJets.dirichletRealZeroBound_proof" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Classical.choice", + "Quot.sound" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SiegelZeros.lean b/lean/ComparatorChallenges/SiegelZeros.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bab3f83ef57af55c5826318b6c92df84117395f --- /dev/null +++ b/lean/ComparatorChallenges/SiegelZeros.lean @@ -0,0 +1,30 @@ +import Mathlib + +namespace OAI + +namespace SiegelZeros +namespace WeightedTorusJets + +theorem exists_absolute_real_zero_gap : + ∃ c : ℝ, 0 < c ∧ + ∀ (q : ℕ) [NeZero q], 3 ≤ q → + ∀ χ : DirichletCharacter ℂ q, + χ.IsPrimitive → χ ≠ 1 → (∀ a : ZMod q, (χ a).im = 0) → + ∀ β : ℝ, 0 < β → β < 1 → χ.LFunction (β : ℂ) = 0 → + c ≤ (1 - β) * Real.log (q : ℝ) := by + sorry + +end WeightedTorusJets + +theorem WeightedTorusJets.dirichletRealZeroBound_proof : + ∃ c : ℝ, 0 < c ∧ ∀ (q : ℕ) [NeZero q], 3 ≤ q → + ∀ χ : DirichletCharacter ℂ q, + χ.IsPrimitive → χ ≠ 1 → (∀ a : ZMod q, (χ a).im = 0) → + ∀ β : ℝ, + (0 < β ∧ β < 1 ∧ DirichletCharacter.LFunction χ (β : ℂ) = 0) → + c ≤ (1 - β) * Real.log (q : ℝ) := by + sorry + +end SiegelZeros + +end OAI diff --git a/lean/ComparatorChallenges/SignedFiniteBand.json b/lean/ComparatorChallenges/SignedFiniteBand.json new file mode 100644 index 0000000000000000000000000000000000000000..7b3fb739221a83830b560a6918a1e38a2f32794d --- /dev/null +++ b/lean/ComparatorChallenges/SignedFiniteBand.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SignedFiniteBand", + "solution_module": "OAI.Analysis.SignedDisk.Main", + "theorem_names": [ + "OAI.SignedDisk.CenteredDiskEndpoint.main_signed_finite_band" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SignedFiniteBand.lean b/lean/ComparatorChallenges/SignedFiniteBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..f481bcf3dbf2549670eede7ef02d423dc84147a3 --- /dev/null +++ b/lean/ComparatorChallenges/SignedFiniteBand.lean @@ -0,0 +1,54 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace SignedDisk + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff + +namespace CenteredDiskEndpoint + +/-- The Euclidean plane, with its Euclidean norm. -/ +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +def diskAverage (f : Plane → ℝ) (x : Plane) (r : ℝ) : ℝ := + (∫ y in Metric.ball x r, f y) / (Real.pi * r ^ 2) + +/-- The i-th coordinate derivative of a smooth test function. -/ +def testPartial (φ : Plane → ℝ) (i : Fin 2) (x : Plane) : ℝ := + fderiv ℝ φ x (EuclideanSpace.single i 1) + +/-- Distributional first derivatives represented by a vector-valued function. -/ +def HasWeakGradient (f : Plane → ℝ) (g : Plane → Plane) : Prop := + ∀ (φ : Plane → ℝ), ContDiff ℝ ∞ φ → HasCompactSupport φ → + ∀ i : Fin 2, (∫ x, f x * testPartial φ i x) = -∫ x, g x i * φ x + +/-- The gradient L1 norm in Euclidean norm. -/ +def gradientNorm (g : Plane → Plane) : ℝ := ∫ x, ‖g x‖ + +/-- Signed envelope over all real radii in the closed band, including its endpoints. -/ +def signedBand (f : Plane → ℝ) (a b : ℝ) (x : Plane) : ℝ := + sSup ((fun r => diskAverage f x r) '' Icc a b) + +def SignedFiniteBandStatement : Prop := + ∃ C : ℝ, 0 ≤ C ∧ + ∀ (f : Plane → ℝ), ContDiff ℝ ∞ f → HasCompactSupport f → + ∀ (a : ℝ), 0 < a → ∀ m : ℕ, + LocallyIntegrable (signedBand f a ((2 : ℝ)^m * a)) ∧ + ∃ G : Plane → Plane, Integrable G ∧ + HasWeakGradient (signedBand f a ((2 : ℝ)^m * a)) G ∧ + gradientNorm G ≤ C * gradientNorm (gradient f) + +theorem main_signed_finite_band : SignedFiniteBandStatement := by + sorry + +end CenteredDiskEndpoint + +end SignedDisk + +end + +end OAI diff --git a/lean/ComparatorChallenges/SignedSweepMoment.json b/lean/ComparatorChallenges/SignedSweepMoment.json new file mode 100644 index 0000000000000000000000000000000000000000..3ac5a8128b021e811e13ad47806d39739da0ed55 --- /dev/null +++ b/lean/ComparatorChallenges/SignedSweepMoment.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SignedSweepMoment", + "solution_module": "OAI.Probability.SignedSweeps.Main", + "theorem_names": [ + "OAI.SignedSweeps.signed_occurrence_moment_bound" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SignedSweepMoment.lean b/lean/ComparatorChallenges/SignedSweepMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..aca61acfccd6a63c296607787c600ffefcdad00b --- /dev/null +++ b/lean/ComparatorChallenges/SignedSweepMoment.lean @@ -0,0 +1,189 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators TensorProduct +open Module + +namespace SignedSweeps + +abbrev Partition (n : ℕ) := {lam : YoungDiagram // lam.card = n} + +abbrev SymmetricGroup (n : ℕ) := Equiv.Perm (Fin n) + +namespace Partition + +def transpose {n : ℕ} (lam : Partition n) : Partition n := + ⟨lam.1.transpose, by simpa [YoungDiagram.card, YoungDiagram.transpose] using lam.2⟩ + +def tableau {n : ℕ} (lam : Partition n) : {c // c ∈ lam.1.cells} ≃ Fin n := + Fintype.equivFinOfCardEq (by simpa using lam.2) + +def rowOf {n : ℕ} (lam : Partition n) (x : Fin n) : ℕ := + ((tableau lam).symm x).1.1 + +def colOf {n : ℕ} (lam : Partition n) (x : Fin n) : ℕ := + ((tableau lam).symm x).1.2 + +end Partition + +def fiberSubgroup {A C : Type*} (f : A → C) : Subgroup (Equiv.Perm A) where + carrier := {g | ∀ x, f (g x) = f x} + one_mem' := by intro x; rfl + mul_mem' := by + intro g h hg hh x + exact (hg (h x)).trans (hh x) + inv_mem' := by + intro g hg x + simpa using (hg (g⁻¹ x)).symm + +def rowSubgroup {n : ℕ} (lam : Partition n) : Subgroup (SymmetricGroup n) := + fiberSubgroup lam.rowOf + +def colSubgroup {n : ℕ} (lam : Partition n) : Subgroup (SymmetricGroup n) := + fiberSubgroup lam.colOf + +abbrev RegularSpace (n : ℕ) := EuclideanSpace ℂ (SymmetricGroup n) + +def regularIsometry {n : ℕ} (g : SymmetricGroup n) : + RegularSpace n ≃ₗᵢ[ℂ] RegularSpace n := + LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.mulLeft g) + +@[simp] +lemma regularIsometry_apply {n : ℕ} (g : SymmetricGroup n) + (f : RegularSpace n) (h : SymmetricGroup n) : + regularIsometry g f h = f (g⁻¹ * h) := rfl + +def regularRepresentation (n : ℕ) : Representation ℂ (SymmetricGroup n) (RegularSpace n) where + toFun g := (regularIsometry g).toLinearEquiv.toLinearMap + map_one' := by ext f h; simp + map_mul' := by + intro g h + ext f k + simp [mul_assoc] + +@[simp] +lemma regularRepresentation_apply {n : ℕ} (g : SymmetricGroup n) + (f : RegularSpace n) (h : SymmetricGroup n) : + regularRepresentation n g f h = f (g⁻¹ * h) := rfl + +def polytabloid {n : ℕ} (lam : Partition n) : RegularSpace n := by + classical + exact ∑ c : colSubgroup lam, ∑ a : rowSubgroup lam, + (((Equiv.Perm.sign (c : SymmetricGroup n) : ℤˣ) : ℤ) : ℂ) • + EuclideanSpace.single ((c : SymmetricGroup n) * (a : SymmetricGroup n)) 1 + +def spechtSubrepresentation {n : ℕ} (lam : Partition n) : + Subrepresentation (regularRepresentation n) where + toSubmodule := Submodule.span ℂ (Set.range (fun g => regularRepresentation n g (polytabloid lam))) + apply_mem_toSubmodule := by + intro g f hf + induction hf using Submodule.span_induction with + | mem v hv => + obtain ⟨h, rfl⟩ := hv + apply Submodule.subset_span + refine ⟨g * h, ?_⟩ + simp [map_mul, Module.End.mul_apply] + | zero => simp + | add x y hx hy ihx ihy => + simpa only [map_add] using Submodule.add_mem _ ihx ihy + | smul a x hx ih => + simpa only [map_smul] using Submodule.smul_mem _ a ih + +def Specht {n : ℕ} (lam : Partition n) : Type := (spechtSubrepresentation lam).toSubmodule + +instance spechtNormedAddCommGroup {n : ℕ} (lam : Partition n) : NormedAddCommGroup (Specht lam) := + inferInstanceAs (NormedAddCommGroup (spechtSubrepresentation lam).toSubmodule) + +instance spechtInnerProductSpace {n : ℕ} (lam : Partition n) : InnerProductSpace ℂ (Specht lam) := + inferInstanceAs (InnerProductSpace ℂ (spechtSubrepresentation lam).toSubmodule) + +instance spechtFiniteDimensional {n : ℕ} (lam : Partition n) : FiniteDimensional ℂ (Specht lam) := + inferInstanceAs (FiniteDimensional ℂ (spechtSubrepresentation lam).toSubmodule) + +def spechtRepresentation {n : ℕ} (lam : Partition n) : + Representation ℂ (SymmetricGroup n) (Specht lam) := + (spechtSubrepresentation lam).toRepresentation + +def spechtDimension {n : ℕ} (lam : Partition n) : ℕ := finrank ℂ (Specht lam) + +def blockEmbedding {u v l n : ℕ} (h : u + v + l = n) + (a : SymmetricGroup u) (b : SymmetricGroup v) (c : SymmetricGroup l) : + SymmetricGroup n := + let e : (Fin u ⊕ Fin v) ⊕ Fin l ≃ Fin n := + ((Equiv.sumCongr finSumFinEquiv (Equiv.refl (Fin l))).trans finSumFinEquiv).trans + (finCongr h) + e.permCongr ((a.sumCongr b).sumCongr c) + +def SignedOccurrence {u v l n : ℕ} (h : u + v + l = n) + (α : Partition u) (β : Partition v) (γ : Partition l) (lam : Partition n) : Prop := + ∃ f : ((Specht α ⊗[ℂ] Specht β.transpose) ⊗[ℂ] Specht γ) →ₗ[ℂ] Specht lam, + Function.Injective f ∧ + ∀ (a : SymmetricGroup u) (b : SymmetricGroup v) (c : SymmetricGroup l) x, + f (TensorProduct.map + (TensorProduct.map (spechtRepresentation α a) (spechtRepresentation β.transpose b)) + (spechtRepresentation γ c) x) = + spechtRepresentation lam (blockEmbedding h a b c) (f x) + +abbrev BinaryPositions (d : ℕ) := Fin d → Fin 2 + +def positionsEquiv (d : ℕ) : BinaryPositions d ≃ Fin (2 ^ d) := + Fintype.equivFinOfCardEq (by simp [BinaryPositions]) + +def coordinateSubgroup (d : ℕ) (i : Fin d) : Subgroup (SymmetricGroup (2 ^ d)) := + fiberSubgroup (fun x : Fin (2 ^ d) => + fun j : {j : Fin d // j ≠ i} => (positionsEquiv d).symm x j.1) + +def layerOperator {d : ℕ} (lam : Partition (2 ^ d)) (i : Fin d) : + Specht lam →ₗ[ℂ] Specht lam := by + classical + exact (Fintype.card (coordinateSubgroup d i) : ℂ)⁻¹ • + ∑ g : coordinateSubgroup d i, spechtRepresentation lam g.1 + +def sweepOperator {d : ℕ} (lam : Partition (2 ^ d)) : Specht lam →ₗ[ℂ] Specht lam := + ((List.ofFn (layerOperator lam)).reverse).prod + +def positiveSquare {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [FiniteDimensional ℂ E] (T : E →ₗ[ℂ] E) : E →ₗ[ℂ] E := T.adjoint * T + +def sweepSquare {d : ℕ} (lam : Partition (2 ^ d)) : Specht lam →ₗ[ℂ] Specht lam := + positiveSquare (E := Specht lam) (sweepOperator lam) + +def weightedMoment {d : ℕ} (lam : Partition (2 ^ d)) (r : ℕ) : ℝ := + (spechtDimension lam : ℝ) * (LinearMap.trace ℂ (Specht lam) (sweepSquare lam ^ r)).re + +def logMoment (x : ℝ) : EReal := if x = 0 then ⊥ else (Real.log x : EReal) + +def signedEntropy {u v : ℕ} (α : Partition u) (β : Partition v) : ℝ := + ((α.1.rowLens ++ β.1.rowLens).map + (fun a : ℕ => (a : ℝ) * Real.log (((u : ℝ) + v) / a))).sum + +def coefficient (a : ℝ) (d : ℕ) : ℝ := a * (1 - 1 / (2 * Real.sqrt d)) + +def remainderBudget (κ : ℝ) (d l : ℕ) : ℝ := + if l = 0 then 0 else + max 0 (coefficient κ d * l * Real.log (2 ^ d : ℕ) - + (l : ℝ) * Real.log ((2 ^ d : ℕ) / (l : ℝ))) + +theorem signed_occurrence_moment_bound : + ∃ η₀ : ℝ, 0 < η₀ ∧ + ∀ η : ℝ, 0 < η → η < η₀ → + ∃ κ₀ : ℝ, 0 < κ₀ ∧ κ₀ < η / 256 ∧ + ∀ κ : ℝ, 0 < κ → κ < κ₀ → + ∃ r : ℕ, 1 ≤ r ∧ + ∀ d : ℕ, 1 ≤ d → + ∀ lam : Partition (2 ^ d), + ∀ (u v l : ℕ) (h : u + v + l = 2 ^ d) + (α : Partition u) (β : Partition v) (γ : Partition l), + SignedOccurrence h α β γ lam → + logMoment (weightedMoment lam r) ≤ + ((coefficient η d * signedEntropy α β + + remainderBudget κ d l : ℝ) : EReal) := by + sorry + +end SignedSweeps + +end + +end OAI diff --git a/lean/ComparatorChallenges/SimpleAmenable.json b/lean/ComparatorChallenges/SimpleAmenable.json new file mode 100644 index 0000000000000000000000000000000000000000..621d5a5334092f2a6ec915b5d0d273d924ee0184 --- /dev/null +++ b/lean/ComparatorChallenges/SimpleAmenable.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SimpleAmenable", + "solution_module": "OAI.GroupTheory.SimpleAmenable.Main", + "theorem_names": [ + "OAI.SimpleAmenable.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SimpleAmenable.lean b/lean/ComparatorChallenges/SimpleAmenable.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5aa7393f767e42476cd02fea732c1fa1d9be5ad --- /dev/null +++ b/lean/ComparatorChallenges/SimpleAmenable.lean @@ -0,0 +1,21 @@ +import Mathlib + +namespace OAI + +open scoped symmDiff + +namespace SimpleAmenable + +noncomputable def FolnerAmenable (G : Type*) [Group G] : Prop := by + classical + exact ∀ K : Finset G, ∀ ε : ℝ, 0 < ε → + ∃ D : Finset G, D.Nonempty ∧ ∀ g ∈ K, + (((D.image (fun d => g * d)) ∆ D).card : ℝ) < ε * D.card + +theorem main : ∃ (G : Type) (_ : Group G), + Infinite G ∧ Group.IsFinitelyPresented G ∧ IsSimpleGroup G ∧ FolnerAmenable G := by + sorry + +end SimpleAmenable + +end OAI diff --git a/lean/ComparatorChallenges/SimpleOvergroups.json b/lean/ComparatorChallenges/SimpleOvergroups.json new file mode 100644 index 0000000000000000000000000000000000000000..f15458ce896fcbe61833c19f7312d4527758ea49 --- /dev/null +++ b/lean/ComparatorChallenges/SimpleOvergroups.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SimpleOvergroups", + "solution_module": "OAI.GroupTheory.SimpleOvergroups.Main", + "theorem_names": [ + "OAI.SimpleFInftyOvergroups.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SimpleOvergroups.lean b/lean/ComparatorChallenges/SimpleOvergroups.lean new file mode 100644 index 0000000000000000000000000000000000000000..f57f8b85eae36c4f85b33acd6e9a17f4d4271046 --- /dev/null +++ b/lean/ComparatorChallenges/SimpleOvergroups.lean @@ -0,0 +1,36 @@ +import Mathlib + +namespace OAI + +namespace SimpleFInftyOvergroups +universe u + +def evalWord {G : Type u} [Group G] {n : ℕ} (g : Fin n → G) + (w : List (Fin n × Bool)) : G := + (w.map fun x => if x.2 then g x.1 else (g x.1)⁻¹).prod + +def HasDecidableWordProblem (G : Type u) [Group G] : Prop := + ∃ (n : ℕ) (g : Fin n → G), Subgroup.closure (Set.range g) = ⊤ ∧ + ComputablePred (fun w : List (Fin n × Bool) => evalWord g w = 1) + +def HasTypeFInfty (H : Type u) [Group H] : Prop := + ∃ (X : Type u) (topology : TopologicalSpace X), + letI : TopologicalSpace X := topology + ∃ (cw : Topology.CWComplex (Set.univ : Set X)), + letI : Topology.CWComplex (Set.univ : Set X) := cw + T2Space X ∧ ConnectedSpace X ∧ + Topology.CWComplex.FiniteType (Set.univ : Set X) ∧ + ∃ (x : X), Nonempty (H ≃* FundamentalGroup X x) ∧ + ∃ (E : Type u) (coverTopology : TopologicalSpace E), + letI : TopologicalSpace E := coverTopology + ∃ (p : E → X), IsCoveringMap p ∧ Function.Surjective p ∧ ContractibleSpace E + +theorem main (G : Type u) [Group G] [Group.FG G] + (hG : HasDecidableWordProblem G) : + ∃ (H : Type u) (_ : Group H), Nontrivial H ∧ IsSimpleGroup H ∧ + HasTypeFInfty H ∧ ∃ f : G →* H, Function.Injective f := by + sorry + +end SimpleFInftyOvergroups + +end OAI diff --git a/lean/ComparatorChallenges/SingleFold.json b/lean/ComparatorChallenges/SingleFold.json new file mode 100644 index 0000000000000000000000000000000000000000..1bc6f3f55d586edc53c080c0014a678ead44045e --- /dev/null +++ b/lean/ComparatorChallenges/SingleFold.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SingleFold", + "solution_module": "OAI.NumberTheory.SingleFold.Main", + "theorem_names": [ + "OAI.SingleFold.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SingleFold.lean b/lean/ComparatorChallenges/SingleFold.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ca4b4e2c4aabdc4a3a8d45d661502273f4bf919 --- /dev/null +++ b/lean/ComparatorChallenges/SingleFold.lean @@ -0,0 +1,29 @@ +import Mathlib + +namespace OAI + +namespace SingleFold + +/-- Evaluation over the integers of an integer polynomial at natural inputs. -/ +noncomputable def evalNat {n m : ℕ} (P : MvPolynomial (Fin n ⊕ Fin m) ℤ) + (a : Fin n → ℕ) (w : Fin m → ℕ) : ℤ := + MvPolynomial.eval (Sum.elim (fun i => (a i : ℤ)) (fun j => (w j : ℤ))) P + +/-- Exact existence on members, no witness on nonmembers, and uniqueness of the +whole witness on every input. No coordinates are hidden outside `w`. -/ +def Represents {n m : ℕ} (P : MvPolynomial (Fin n ⊕ Fin m) ℤ) + (S : Set (Fin n → ℕ)) : Prop := + ∀ a, (a ∈ S ↔ ∃ w, evalNat P a w = 0) ∧ + ∀ w v, evalNat P a w = 0 → evalNat P a v = 0 → w = v + +/-- Single-fold representation with positive input and witness lengths. -/ +def MainStatement : Prop := + ∀ (n : ℕ), 1 ≤ n → ∀ (S : Set (Fin n → ℕ)), REPred (fun a => a ∈ S) → + ∃ (m : ℕ), 1 ≤ m ∧ ∃ P : MvPolynomial (Fin n ⊕ Fin m) ℤ, Represents P S + +theorem main : MainStatement := by + sorry + +end SingleFold + +end OAI diff --git a/lean/ComparatorChallenges/SingleLatticeCovering.json b/lean/ComparatorChallenges/SingleLatticeCovering.json new file mode 100644 index 0000000000000000000000000000000000000000..0430ba7f3fd9929271d6dccfa68444822945e9c8 --- /dev/null +++ b/lean/ComparatorChallenges/SingleLatticeCovering.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SingleLatticeCovering", + "solution_module": "OAI.Geometry.LatticeCovering.Main", + "theorem_names": [ + "OAI.SingleLatticeCovering.single_lattice_covering" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SingleLatticeCovering.lean b/lean/ComparatorChallenges/SingleLatticeCovering.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc1206bfaa5e0914fb820077a3c289e35ee6db2a --- /dev/null +++ b/lean/ComparatorChallenges/SingleLatticeCovering.lean @@ -0,0 +1,29 @@ +import Mathlib + +namespace OAI + +/-! Convex bodies and exact coverings by a single lattice in real coordinate space. -/ + +namespace SingleLatticeCovering + +open MeasureTheory +open scoped Pointwise + +abbrev Space (n : ℕ) := Fin n → ℝ + +def IsConvexBody {n : ℕ} (K : Set (Space n)) : Prop := + IsCompact K ∧ Convex ℝ K ∧ (interior K).Nonempty + +def LatticeCovers {n : ℕ} (K : Set (Space n)) (L : Submodule ℤ (Space n)) : Prop := + K + (L : Set (Space n)) = Set.univ + +theorem single_lattice_covering : + ∃ C : ℝ, 0 < C ∧ ∀ (n : ℕ), 2 ≤ n → + ∀ (K : Set (Space n)), IsConvexBody K → + ∃ (L : Submodule ℤ (Space n)) (_ : DiscreteTopology L), + IsZLattice ℝ L ∧ LatticeCovers K L ∧ + (volume K).toReal / ZLattice.covolume L ≤ C * (n : ℝ) * Real.log (n : ℝ) := by sorry + +end SingleLatticeCovering + +end OAI diff --git a/lean/ComparatorChallenges/SingletonLoopMatching.json b/lean/ComparatorChallenges/SingletonLoopMatching.json new file mode 100644 index 0000000000000000000000000000000000000000..22b315e47360c5e3ec5389704a23fab07afed07d --- /dev/null +++ b/lean/ComparatorChallenges/SingletonLoopMatching.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SingletonLoopMatching", + "solution_module": "OAI.Computability.LoopMatching.Endpoint", + "theorem_names": [ + "OAI.LoopMatching.fullEndpoint" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SingletonLoopMatching.lean b/lean/ComparatorChallenges/SingletonLoopMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e51d3717c63d11ff7a4b6f920ccbfd8a71f447a --- /dev/null +++ b/lean/ComparatorChallenges/SingletonLoopMatching.lean @@ -0,0 +1,132 @@ +import Mathlib + +namespace OAI + +universe u_1 u_2 + +namespace MatchingEntropy +structure LooplessGraph (V : Type u_1) (E : Type u_2) where + left : E → V + right : E → V + loopless : ∀ e, left e ≠ right e +namespace LooplessGraph +variable {V : Type u_1} {E : Type u_2} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] +def Incident (G : LooplessGraph V E) (v : V) (e : E) : Prop := + G.left e=v ∨ G.right e=v +end LooplessGraph +end MatchingEntropy + +namespace BinaryMatching +abbrev Pair (n : ℕ) := {ij : Fin n × Fin n // ij.1 < ij.2} +def completeGraph (n : ℕ) : MatchingEntropy.LooplessGraph (Fin n) (Pair n) where + left e := e.val.1 + right e := e.val.2 + loopless e := ne_of_lt e.property + +structure Record where + left : ℕ + right : ℕ + multiplicity : ℕ + deriving DecidableEq + +structure Input where + n : ℕ + records : List Record + valid : ∀ e∈records, e.left < e.right ∧ e.right < n + unique : (records.map (fun e => (e.left,e.right))).Nodup + +def multiplicity (G : Input) (e : Pair G.n) : ℕ := + match G.records.find? (fun r => r.left=e.val.1.val && r.right=e.val.2.val) with + | none => 0 + | some r => r.multiplicity + + +def encodeNat (n : ℕ) : List Bool := + List.replicate n.bits.length false ++ true :: n.bits + +def encodeRecord (r : Record) : List Bool := + encodeNat r.left ++ encodeNat r.right ++ encodeNat r.multiplicity + +def encodeInput (G : Input) : List Bool := + encodeNat G.n ++ encodeNat G.records.length ++ G.records.flatMap encodeRecord + +end BinaryMatching + +open scoped BigOperators + +namespace LoopMatching + +structure LoopRecord where + vertex : ℕ + multiplicity : ℕ + deriving DecidableEq + +structure Input where + ordinary : BinaryMatching.Input + loops : List LoopRecord + valid : ∀ e ∈ loops, e.vertex < ordinary.n + unique : (loops.map LoopRecord.vertex).Nodup + +abbrev Input.n (G : Input) : ℕ := G.ordinary.n + +def loopMultiplicity (G : Input) (v : Fin G.n) : ℕ := + match G.loops.find? (fun r => r.vertex == v.val) with + | none => 0 + | some r => r.multiplicity + +def IsPartialMatching (n : ℕ) (M : Finset (BinaryMatching.Pair n)) : Prop := + ∀ v : Fin n, ∀ e ∈ M, ∀ f ∈ M, + (BinaryMatching.completeGraph n).Incident v e → + (BinaryMatching.completeGraph n).Incident v f → e = f + +abbrev PartialMatching (n : ℕ) := + { M : Finset (BinaryMatching.Pair n) // IsPartialMatching n M } + +noncomputable instance partialMatchingFintype (n : ℕ) : Fintype (PartialMatching n) := + Fintype.ofFinite _ + +noncomputable def loopVertices {n : ℕ} (M : PartialMatching n) : Finset (Fin n) := by + classical + exact Finset.univ.filter (fun v => + ∀ e ∈ M.val, ¬ (BinaryMatching.completeGraph n).Incident v e) + +noncomputable def weight (G : Input) (M : PartialMatching G.n) : ℕ := + (∏ e ∈ M.val, BinaryMatching.multiplicity G.ordinary e) * + ∏ v ∈ loopVertices M, loopMultiplicity G v + +noncomputable def count (G : Input) : ℕ := ∑ M : PartialMatching G.n, weight G M + + +def encodeLoopRecord (r : LoopRecord) : List Bool := + BinaryMatching.encodeNat r.vertex ++ BinaryMatching.encodeNat r.multiplicity + +def encodeInput (G : Input) : List Bool := + BinaryMatching.encodeInput G.ordinary ++ + BinaryMatching.encodeNat G.loops.length ++ G.loops.flatMap encodeLoopRecord + +def encodeOutput (a : ℕ × ℕ) : List Bool := + BinaryMatching.encodeNat a.1 ++ BinaryMatching.encodeNat a.2 + + +def FullEndpoint : Prop := + ∃ A : Input → ℕ × ℕ, + ∃ machine : Turing.TM2ComputableInPolyTime encodeInput encodeOutput A, + (∀ k, Finite (machine.tm.Γ k)) ∧ + (∃ P : Polynomial ℕ, ∀ G, + (encodeOutput (A G)).length ≤ P.eval (encodeInput G).length) ∧ + ∀ G, 0 < (A G).2 ∧ + (A G).1 ≤ (A G).2 * count G ∧ + (A G).2 * count G ≤ 2 ^ (18 * G.n) * (A G).1 ∧ + ((A G).1 = 0 ↔ count G = 0) + +end LoopMatching + +namespace LoopMatching + +/-- A finite-alphabet polynomial-time rational approximation for singleton-loop matchings. -/ +theorem fullEndpoint : FullEndpoint := by + sorry + +end LoopMatching + +end OAI diff --git a/lean/ComparatorChallenges/SmoothInitialForm.json b/lean/ComparatorChallenges/SmoothInitialForm.json new file mode 100644 index 0000000000000000000000000000000000000000..93704ed5123303dce703f2ad4d3a5e5a8c5fca4b --- /dev/null +++ b/lean/ComparatorChallenges/SmoothInitialForm.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SmoothInitialForm", + "solution_module": "OAI.Algebra.Determinantal.InitialForm", + "theorem_names": [ + "OAI.PermanentBorder.smooth_initial_form_lower_bound" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SmoothInitialForm.lean b/lean/ComparatorChallenges/SmoothInitialForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..63b54a0eebcfc908a4f143eb1a8dcfbf54acff18 --- /dev/null +++ b/lean/ComparatorChallenges/SmoothInitialForm.lean @@ -0,0 +1,56 @@ +import Mathlib + +namespace OAI + +open MvPolynomial +namespace PermanentBorder + +open Filter +open scoped Topology + +abbrev Poly (σ : Type*) := MvPolynomial σ ℂ + +noncomputable def affineMatrixPolynomial {σ : Type*} [Fintype σ] (n : ℕ) + (A₀ : Matrix (Fin n) (Fin n) ℂ) + (A : σ → Matrix (Fin n) (Fin n) ℂ) : Poly σ := + Matrix.det (fun i j => MvPolynomial.C (A₀ i j) + + ∑ v : σ, MvPolynomial.C (A v i j) * MvPolynomial.X v) + +def HasBorderDeterminant {σ : Type*} [Fintype σ] (n : ℕ) (p : Poly σ) : Prop := + 0 < n ∧ ∃ (A₀ : ℕ → Matrix (Fin n) (Fin n) ℂ) + (A : ℕ → σ → Matrix (Fin n) (Fin n) ℂ), + ∀ d : σ →₀ ℕ, Tendsto + (fun j => (affineMatrixPolynomial n (A₀ j) (A j)).coeff d) + atTop (𝓝 (p.coeff d)) + +def HasExactDeterminant {σ : Type*} [Fintype σ] (n : ℕ) (p : Poly σ) : Prop := + 0 < n ∧ ∃ (A₀ : Matrix (Fin n) (Fin n) ℂ) + (A : σ → Matrix (Fin n) (Fin n) ℂ), affineMatrixPolynomial n A₀ A = p + +noncomputable def affineSubstitution {σ τ : Type*} [Fintype τ] + (b : σ → ℂ) (B : σ → τ → ℂ) : Poly σ →ₐ[ℂ] Poly τ := + MvPolynomial.aeval (fun v => MvPolynomial.C (b v) + + ∑ w : τ, MvPolynomial.C (B v w) * MvPolynomial.X w) + +theorem smooth_initial_form_lower_bound (d r : ℕ) (g : Poly (Fin d)) + (a : Fin d → ℂ) (hd : 2 ≤ d) (hr : 2 ≤ r) + (hG : homogeneousComponent r + (affineSubstitution a (fun i j : Fin d => if i = j then 1 else 0) g) ≠ 0) + (hlow : ∀ j < r, homogeneousComponent j + (affineSubstitution a (fun i j : Fin d => if i = j then 1 else 0) g) = 0) + (hs : ∀ y : Fin d → ℂ, + eval y (homogeneousComponent r + (affineSubstitution a (fun i j : Fin d => if i = j then 1 else 0) g)) = 0 → + (∀ i, eval y (pderiv i (homogeneousComponent r + (affineSubstitution a (fun i j : Fin d => if i = j then 1 else 0) g))) = 0) → + y = 0) : + ∀ n : ℕ, + (HasBorderDeterminant n g → + ((r - 1 : ℕ) : ℝ) * ((d - 1 : ℕ) : ℝ) / (4 * Real.exp 1) ≤ (n : ℝ)) ∧ + (HasExactDeterminant n g → + ((r - 1 : ℕ) : ℝ) * ((d - 1 : ℕ) : ℝ) / (4 * Real.exp 1) ≤ (n : ℝ)) := by + sorry + +end PermanentBorder + +end OAI diff --git a/lean/ComparatorChallenges/SmoothObstruction.json b/lean/ComparatorChallenges/SmoothObstruction.json new file mode 100644 index 0000000000000000000000000000000000000000..58c76b20ae8ccccf293206f2e455178f5e194eec --- /dev/null +++ b/lean/ComparatorChallenges/SmoothObstruction.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SmoothObstruction", + "solution_module": "OAI.Dynamics.SmoothObstruction.Main", + "theorem_names": [ + "OAI.SmoothObstruction.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SmoothObstruction.lean b/lean/ComparatorChallenges/SmoothObstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..f666502eeb7056809e186a347733f960de0bfa9c --- /dev/null +++ b/lean/ComparatorChallenges/SmoothObstruction.lean @@ -0,0 +1,99 @@ +import Mathlib + +namespace OAI + + +open MeasureTheory Set Filter +open scoped ENNReal Topology Manifold ContDiff + +namespace SmoothObstruction + +/-- Shannon entropy in bits; the value at mass zero is zero. -/ +noncomputable def entropyTerm (p : ℝ) : ℝ := -(p * Real.log p) / Real.log 2 + +/-- The entropy of the length-`n` join of the partition with labels in `Fin q`. -/ +noncomputable def blockEntropy {X : Type*} [MeasurableSpace X] + (μ : Measure X) (T : X → X) {q : ℕ} (P : X → Fin q) (n : ℕ) : ℝ := + ∑ w : Fin n → Fin q, + entropyTerm ((μ {x | ∀ j : Fin n, P ((T^[j.val]) x) = w j}).toReal) + +/-- All finite-partition entropy rates exist and have one finite real upper +bound. This spells out `sup_P lim_n H(join_{j blockEntropy μ T P n / (n : ℝ)) atTop (𝓝 h) + +/-- Measure-space isomorphism after removing measurable null sets. -/ +def ConullIsomorphic {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + (μ : Measure X) (ν : Measure Y) : Prop := + ∃ (A : Set X) (B : Set Y), MeasurableSet A ∧ MeasurableSet B ∧ + μ Aᶜ = 0 ∧ ν Bᶜ = 0 ∧ + ∃ e : A ≃ᵐ B, + MeasurePreserving e (μ.comap (Subtype.val : A → X)) + (ν.comap (Subtype.val : B → Y)) + +/-- Standard nonatomic in the source's explicit modulo-null-set sense. -/ +def StandardNonatomic {X : Type*} [MeasurableSpace X] (μ : Measure X) : Prop := + ConullIsomorphic μ + (volume.comap (Subtype.val : Set.Icc (0 : ℝ) 1 → ℝ)) + +/-- Measurable conjugacy on invariant conull measurable subsets, not a +continuous conjugacy and not merely a factor map. -/ +def ConullConjugate {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + (μ : Measure X) (T : X → X) (ν : Measure Y) (S : Y → Y) : Prop := + ∃ (A : Set X) (B : Set Y), MeasurableSet A ∧ MeasurableSet B ∧ + μ Aᶜ = 0 ∧ ν Bᶜ = 0 ∧ T ⁻¹' A = A ∧ S ⁻¹' B = B ∧ + ∃ e : A ≃ᵐ B, + MeasurePreserving e (μ.comap (Subtype.val : A → X)) + (ν.comap (Subtype.val : B → Y)) ∧ + ∀ (x y : A), T x = y → (e y : Y) = S (e x) + +/-- Positive smooth local coordinate densities. In a half-space chart, +`ContDiffOn` includes smoothness up to the boundary. Absolute Lebesgue density +is used; no orientation or volume form is part of the data. -/ +def SmoothPositiveDensity {d : ℕ} {H : Type*} [TopologicalSpace H] + (I : ModelWithCorners ℝ (EuclideanSpace ℝ (Fin d)) H) + {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [MeasurableSpace M] + (ν : Measure M) : Prop := + ∀ x : M, ∃ f : EuclideanSpace ℝ (Fin d) → ℝ, + ContDiffOn ℝ ∞ f (extChartAt I x).target ∧ + (∀ y ∈ (extChartAt I x).target, 0 < f y) ∧ + Measure.map (extChartAt I x) (ν.restrict (extChartAt I x).source) = + (volume.withDensity (fun y => ENNReal.ofReal (f y))).restrict + (extChartAt I x).target + +/-- A smooth positive-volume model with a specified Euclidean or half-space +manifold model. All model dimensions will be quantified below. -/ +def HasModelWith {X : Type*} [MeasurableSpace X] + (μ : Measure X) (T : X → X) {d : ℕ} {H : Type} [TopologicalSpace H] + (I : ModelWithCorners ℝ (EuclideanSpace ℝ (Fin d)) H) : Prop := + ∃ (M : Type) (_ : TopologicalSpace M) (_ : MeasurableSpace M) + (_ : BorelSpace M) (_ : T2Space M) (_ : SecondCountableTopology M) + (_ : CompactSpace M) (_ : ChartedSpace H M) (_ : IsManifold I ∞ M) + (ν : Measure M) (_ : IsProbabilityMeasure ν) + (S : Diffeomorph I I M M ∞), + SmoothPositiveDensity I ν ∧ MeasurePreserving S ν ν ∧ + ConullConjugate μ T ν S + +/-- Closed manifolds of all dimensions (including zero), and smooth manifolds +with boundary of every positive finite dimension. Nonorientable manifolds +are included: no orientability hypothesis occurs. -/ +def HasSmoothPositiveVolumeModel {X : Type*} [MeasurableSpace X] + (μ : Measure X) (T : X → X) : Prop := + (∃ d : ℕ, HasModelWith μ T (𝓡 d)) ∨ + (∃ d : ℕ, ∃ _ : NeZero d, HasModelWith μ T (𝓡∂ d)) + +/-- A finite-entropy standard nonatomic ergodic system with no smooth positive-volume model. -/ +theorem main : + ∃ (X : Type) (_ : MeasurableSpace X) (μ : Measure X) + (_ : IsProbabilityMeasure μ) (T : X ≃ᵐ X), + StandardNonatomic μ ∧ Ergodic T μ ∧ FiniteKSEntropy μ T ∧ + ¬ HasSmoothPositiveVolumeModel μ T := by + sorry + +end SmoothObstruction + +end OAI diff --git a/lean/ComparatorChallenges/SmoothYau.json b/lean/ComparatorChallenges/SmoothYau.json new file mode 100644 index 0000000000000000000000000000000000000000..0150bc85b0d6bde269ed7d4e00e6ca4d18491e63 --- /dev/null +++ b/lean/ComparatorChallenges/SmoothYau.json @@ -0,0 +1,15 @@ +{ + "challenge_module": "ComparatorChallenges.SmoothYau", + "solution_module": "OAI.Geometry.SmoothYau.Main", + "theorem_names": [ + "OAI.YauCounterexamples.sphere_three", + "OAI.YauCounterexamples.sphere_two_torus_two" + ], + "definition_names": [], + "enable_nanoda": false, + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ] +} diff --git a/lean/ComparatorChallenges/SmoothYau.lean b/lean/ComparatorChallenges/SmoothYau.lean new file mode 100644 index 0000000000000000000000000000000000000000..733d6791532ea3a3d892388bff13c62ffbc1bef3 --- /dev/null +++ b/lean/ComparatorChallenges/SmoothYau.lean @@ -0,0 +1,149 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace YauCounterexamples +section +open Set Filter Manifold Bundle MeasureTheory +open scoped Topology ContDiff ENNReal + + +abbrev Euclidean (n : ℕ) := EuclideanSpace ℝ (Fin n) +abbrev Sphere (n : ℕ) := Metric.sphere (0 : Euclidean (n + 1)) 1 +abbrev FourManifold := Sphere 2 × (Circle × Circle) +abbrev FourModel := Euclidean 2 × (Euclidean 1 × Euclidean 1) + +instance torusChartedSpace : ChartedSpace (Euclidean 1 × Euclidean 1) (Circle × Circle) := + prodChartedSpace (Euclidean 1) Circle (Euclidean 1) Circle + +instance torusIsManifold : IsManifold 𝓘(ℝ, Euclidean 1 × Euclidean 1) ∞ (Circle × Circle) := by + rw [modelWithCornersSelf_prod] + exact IsManifold.prod Circle Circle + +instance fourChartedSpace : ChartedSpace FourModel FourManifold := + prodChartedSpace (Euclidean 2) (Sphere 2) (Euclidean 1 × Euclidean 1) (Circle × Circle) + +instance fourIsManifold : IsManifold 𝓘(ℝ, FourModel) ∞ FourManifold := by + rw [show 𝓘(ℝ, FourModel) = 𝓘(ℝ, Euclidean 2).prod + 𝓘(ℝ, Euclidean 1 × Euclidean 1) from modelWithCornersSelf_prod] + exact IsManifold.prod (Sphere 2) (Circle × Circle) + +section Definitions +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] +variable {M : Type*} [TopologicalSpace M] [ChartedSpace E M] + [IsManifold 𝓘(ℝ, E) ∞ M] + +/-- Ordinary smooth positive-definite Riemannian metrics, with the existing tangent topology. -/ +abbrev SmoothMetric (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + (M : Type*) [TopologicalSpace M] [ChartedSpace E M] [IsManifold 𝓘(ℝ, E) ∞ M] := + ContMDiffRiemannianMetric 𝓘(ℝ, E) ∞ E (fun x : M => TangentSpace 𝓘(ℝ, E) x) + +abbrev CoordIndex (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] := Fin (Module.finrank ℝ E) + +/-- A coordinate vector, pushed from a chart back into the tangent bundle. -/ +def coordinateVector (p : M) (y : E) (i : CoordIndex E) : + TangentSpace 𝓘(ℝ, E) ((chartAt E p).symm y) := + mfderiv 𝓘(ℝ, E) 𝓘(ℝ, E) (chartAt E p).symm y (Module.finBasis ℝ E i) + +/-- Metric coefficients in a chart. Only values in the chart target are used. -/ +def metricCoefficients (g : SmoothMetric E M) (p : M) (y : E) : + Matrix (CoordIndex E) (CoordIndex E) ℝ := + fun i j => g.inner ((chartAt E p).symm y) + (coordinateVector p y i) (coordinateVector p y j) + +/-- The local coordinate formula det(g)^(-1/2) d_i(det(g)^(1/2) g^{ij} d_j u). +The chart at the evaluation point is used, so all derivatives are taken in +its open target. -/ +def laplaceBeltrami (g : SmoothMetric E M) (u : M → ℝ) (x : M) : ℝ := + let c := chartAt E x + let a := metricCoefficients g x + let density := fun y => Real.sqrt (Matrix.det (a y)) + let u' := u ∘ c.symm + (density (c x))⁻¹ * ∑ i, fderiv ℝ + (fun y => density y * ∑ j, (a y)⁻¹ i j * + fderiv ℝ u' y (Module.finBasis ℝ E j)) + (c x) (Module.finBasis ℝ E i) + +/-- One compact-chart seminorm test for the usual smooth topology of metrics. -/ +structure CoordinateTest (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] (M : Type*) [TopologicalSpace M] [ChartedSpace E M] where + center : M + compactSet : Set E + isCompact : IsCompact compactSet + inTarget : compactSet ⊆ (chartAt E center).target + order : ℕ + row : CoordIndex E + column : CoordIndex E + +/-- The finite compact-chart derivative tests defining a C∞ neighborhood. +A single positive tolerance suffices for the finitely many tests. -/ +def IsSmoothNeighborhood (g₀ : SmoothMetric E M) (N : Set (SmoothMetric E M)) : Prop := + ∃ tests : List (CoordinateTest E M), ∃ ε : ℝ, 0 < ε ∧ + ∀ g : SmoothMetric E M, + (∀ t ∈ tests, ∀ y ∈ t.compactSet, + ‖iteratedFDeriv ℝ t.order + (fun z => metricCoefficients g t.center z t.row t.column - + metricCoefficients g₀ t.center z t.row t.column) y‖ < ε) → g ∈ N + +/-- Hausdorff measure for the path distance of the actual Riemannian metric, +not the metric inherited from any ambient embedding. -/ +def nodalMeasure [T3Space M] (g : SmoothMetric E M) (d : ℝ) (u : M → ℝ) : ℝ≥0∞ := + letI : RiemannianBundle (fun x : M => TangentSpace 𝓘(ℝ, E) x) := + ⟨g.toRiemannianMetric⟩ + letI : IsContinuousRiemannianBundle E (fun x : M => TangentSpace 𝓘(ℝ, E) x) := + ⟨⟨g.inner, g.contMDiff.continuous, fun _ _ _ => rfl⟩⟩ + letI : EMetricSpace M := EMetricSpace.ofRiemannianMetric 𝓘(ℝ, E) M + letI : MeasurableSpace M := borel M + letI : BorelSpace M := ⟨rfl⟩ + Measure.hausdorffMeasure d {x | u x = 0} + +/-- The eigensequence belongs to one fixed metric and has finite nodal measure. -/ +def HasUnboundedNodalRatio [T3Space M] (g : SmoothMetric E M) (d : ℕ) : Prop := + ∃ (u : ℕ → M → ℝ) (eigenvalue : ℕ → ℝ), + (∀ j, ContMDiff 𝓘(ℝ, E) 𝓘(ℝ, ℝ) ∞ (u j) ∧ u j ≠ 0 ∧ 0 < eigenvalue j ∧ + (∀ x, -laplaceBeltrami g (u j) x = eigenvalue j * u j x) ∧ + nodalMeasure g (d - 1 : ℕ) (u j) ≠ (∞ : ℝ≥0∞)) ∧ + Tendsto eigenvalue atTop atTop ∧ + Tendsto (fun j => (nodalMeasure g (d - 1 : ℕ) (u j)).toReal / Real.sqrt (eigenvalue j)) + atTop atTop + +end Definitions + +/-- The round metric is the pullback of the Euclidean scalar product under +inclusion of the unit sphere. This predicate specifies exactly that tensor. -/ +def IsRound (g : SmoothMetric (Euclidean 3) (Sphere 3)) : Prop := + ∀ (x : Sphere 3) (v w : TangentSpace 𝓘(ℝ, Euclidean 3) x), + g.inner x v w = inner ℝ + (mfderiv 𝓘(ℝ, Euclidean 3) 𝓘(ℝ, Euclidean 4) + (fun y : Sphere 3 => (y : Euclidean 4)) x v) + (mfderiv 𝓘(ℝ, Euclidean 3) 𝓘(ℝ, Euclidean 4) + (fun y : Sphere 3 => (y : Euclidean 4)) x w) + + +end + +open Set Filter Manifold Bundle MeasureTheory +open scoped Topology ContDiff ENNReal + + +theorem sphere_three (gRound : SmoothMetric (Euclidean 3) (Sphere 3)) + (hRound : IsRound gRound) : + ∀ N : Set (SmoothMetric (Euclidean 3) (Sphere 3)), + IsSmoothNeighborhood gRound N → + ∃ g ∈ N, HasUnboundedNodalRatio g 3 := by + sorry + +theorem sphere_two_torus_two : + ∃ g : SmoothMetric FourModel FourManifold, + HasUnboundedNodalRatio g 4 := by + sorry + + + +end YauCounterexamples +end + +end OAI diff --git a/lean/ComparatorChallenges/SnakyCertificate.json b/lean/ComparatorChallenges/SnakyCertificate.json new file mode 100644 index 0000000000000000000000000000000000000000..b63d9ff957f79af75b628cabd6b30835aa4c6b7f --- /dev/null +++ b/lean/ComparatorChallenges/SnakyCertificate.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SnakyCertificate", + "solution_module": "OAI.Combinatorics.SnakyCertificate.Main", + "theorem_names": [ + "OAI.SnakyCertificate.certificate_correct" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SnakyCertificate.lean b/lean/ComparatorChallenges/SnakyCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c979b013826d1a33e903d326e266e5d3342d840 --- /dev/null +++ b/lean/ComparatorChallenges/SnakyCertificate.lean @@ -0,0 +1,1398 @@ +import Mathlib + +namespace OAI + +namespace SnakyCertificate + +instance rotationModulus_neZero : NeZero 8 := @Nat.instNeZeroSucc 7 + +instance digitModulus_neZero : NeZero 10 := @Nat.instNeZeroSucc 9 + +abbrev Cell := ℤ × ℤ + +def origin : Cell := (0, 0) + +def snaky : Finset Cell := {(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (4, 1)} + +def orient (r : Fin 8) (p : Cell) : Cell := + match r.val with + | 0 => (p.1, p.2) + | 1 => (p.2, p.1) + | 2 => (p.1, -p.2) + | 3 => (-p.2, p.1) + | 4 => (-p.1, p.2) + | 5 => (p.2, -p.1) + | 6 => (-p.1, -p.2) + | _ => (-p.2, -p.1) + +def placement (r : Fin 8) (t p : Cell) : Cell := orient r p + t + +def basePoint (i : Fin 6) : Cell := ![(0,0),(1,0),(2,0),(3,0),(3,1),(4,1)] i + +def baseEnvelope (i : Fin 6) : Finset Cell := + snaky.image (placement 0 (-basePoint i)) + +def baseRequired (i : Fin 6) : Finset Cell := (baseEnvelope i).erase origin + +structure Term where + child : ℕ + rotation : Fin 8 + xDigit : Fin 10 + yDigit : Fin 10 + deriving DecidableEq, Repr + +def Term.shift (t : Term) : Cell := ((t.xDigit.val : ℤ) - 4, (t.yDigit.val : ℤ) - 4) + +structure Entry where + index : ℕ + terms : List Term + deriving DecidableEq, Repr + +def emptyEntry : Entry := ⟨0, []⟩ + +def entry_6 : Entry := ⟨6, [⟨0, 0, 0, 3⟩]⟩ + +def entry_7 : Entry := ⟨7, [⟨4, 0, 3, 4⟩, ⟨6, 0, 5, 4⟩]⟩ + +def entry_8 : Entry := ⟨8, [⟨0, 4, 8, 3⟩, ⟨6, 4, 3, 4⟩]⟩ + +def entry_9 : Entry := ⟨9, [⟨0, 4, 5, 4⟩, ⟨6, 4, 0, 5⟩]⟩ + +def entry_10 : Entry := ⟨10, [⟨2, 0, 2, 3⟩, ⟨2, 6, 2, 4⟩]⟩ + +def entry_11 : Entry := ⟨11, [⟨6, 4, 2, 5⟩, ⟨6, 6, 2, 3⟩]⟩ + +def entry_12 : Entry := ⟨12, [⟨0, 6, 5, 4⟩, ⟨0, 0, 0, 3⟩]⟩ + +def entry_13 : Entry := ⟨13, [⟨6, 6, 0, 3⟩, ⟨6, 4, 0, 5⟩]⟩ + +def entry_14 : Entry := ⟨14, [⟨0, 6, 5, 4⟩, ⟨3, 6, 1, 4⟩]⟩ + +def entry_15 : Entry := ⟨15, [⟨0, 6, 6, 4⟩, ⟨3, 6, 2, 4⟩]⟩ + +def entry_16 : Entry := ⟨16, [⟨3, 6, 3, 4⟩, ⟨0, 6, 7, 4⟩]⟩ + +def entry_17 : Entry := ⟨17, [⟨0, 6, 5, 4⟩, ⟨3, 0, 3, 3⟩]⟩ + +def entry_18 : Entry := ⟨18, [⟨3, 6, 2, 4⟩, ⟨3, 0, 4, 3⟩]⟩ + +def entry_19 : Entry := ⟨19, [⟨6, 4, 1, 5⟩, ⟨6, 0, 6, 5⟩]⟩ + +def entry_20 : Entry := ⟨20, [⟨6, 4, 0, 5⟩, ⟨6, 0, 5, 5⟩]⟩ + +def entry_21 : Entry := ⟨21, [⟨4, 6, 2, 3⟩, ⟨6, 0, 6, 5⟩]⟩ + +def entry_22 : Entry := ⟨22, [⟨0, 6, 7, 5⟩, ⟨3, 0, 5, 4⟩]⟩ + +def entry_23 : Entry := ⟨23, [⟨0, 6, 6, 4⟩, ⟨0, 0, 1, 3⟩]⟩ + +def entry_24 : Entry := ⟨24, [⟨0, 0, 0, 3⟩, ⟨17, 0, 5, 4⟩]⟩ + +def entry_25 : Entry := ⟨25, [⟨0, 0, 0, 3⟩, ⟨14, 0, 5, 4⟩]⟩ + +def entry_26 : Entry := ⟨26, [⟨0, 4, 6, 4⟩, ⟨6, 0, 6, 5⟩]⟩ + +def entry_27 : Entry := ⟨27, [⟨0, 6, 5, 4⟩, ⟨6, 4, 0, 5⟩]⟩ + +def entry_28 : Entry := ⟨28, [⟨6, 1, 4, 5⟩, ⟨0, 6, 6, 4⟩]⟩ + +def entry_29 : Entry := ⟨29, [⟨1, 4, 7, 3⟩, ⟨6, 3, 4, 5⟩]⟩ + +def entry_30 : Entry := ⟨30, [⟨0, 0, 1, 3⟩, ⟨14, 0, 6, 4⟩]⟩ + +def entry_31 : Entry := ⟨31, [⟨0, 0, 1, 4⟩, ⟨17, 0, 6, 5⟩]⟩ + +def entry_32 : Entry := ⟨32, [⟨0, 4, 8, 3⟩, ⟨6, 3, 4, 5⟩]⟩ + +def entry_33 : Entry := ⟨33, [⟨0, 0, 2, 4⟩, ⟨17, 0, 7, 5⟩]⟩ + +def entry_34 : Entry := ⟨34, [⟨6, 1, 4, 5⟩, ⟨1, 6, 5, 4⟩]⟩ + +def entry_35 : Entry := ⟨35, [⟨0, 0, 2, 4⟩, ⟨14, 0, 7, 5⟩]⟩ + +def entry_36 : Entry := ⟨36, [⟨0, 0, 3, 4⟩, ⟨17, 0, 8, 5⟩]⟩ + +def entry_37 : Entry := ⟨37, [⟨6, 3, 4, 5⟩, ⟨2, 4, 6, 3⟩]⟩ + +def entry_38 : Entry := ⟨38, [⟨3, 0, 3, 3⟩, ⟨16, 0, 2, 4⟩]⟩ + +def entry_39 : Entry := ⟨39, [⟨0, 0, 1, 3⟩, ⟨17, 0, 6, 4⟩]⟩ + +def entry_40 : Entry := ⟨40, [⟨3, 0, 4, 3⟩, ⟨16, 0, 3, 4⟩]⟩ + +def entry_41 : Entry := ⟨41, [⟨6, 3, 3, 5⟩, ⟨1, 4, 6, 3⟩]⟩ + +def entry_42 : Entry := ⟨42, [⟨0, 6, 6, 4⟩, ⟨6, 4, 1, 5⟩]⟩ + +def entry_43 : Entry := ⟨43, [⟨2, 4, 5, 3⟩, ⟨6, 3, 3, 5⟩]⟩ + +def entry_44 : Entry := ⟨44, [⟨4, 4, 1, 5⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_45 : Entry := ⟨45, [⟨6, 4, 0, 5⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_46 : Entry := ⟨46, [⟨6, 6, 0, 3⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_47 : Entry := ⟨47, [⟨6, 3, 3, 5⟩, ⟨6, 2, 7, 3⟩]⟩ + +def entry_48 : Entry := ⟨48, [⟨6, 3, 4, 5⟩, ⟨6, 2, 8, 3⟩]⟩ + +def entry_49 : Entry := ⟨49, [⟨4, 7, 3, 1⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_50 : Entry := ⟨50, [⟨6, 3, 3, 5⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_51 : Entry := ⟨51, [⟨10, 2, 5, 3⟩, ⟨10, 0, 5, 4⟩, ⟨26, 2, 3, 4⟩, ⟨26, 0, 3, 3⟩]⟩ + +def entry_52 : Entry := ⟨52, [⟨0, 0, 0, 3⟩, ⟨0, 4, 7, 3⟩]⟩ + +def entry_53 : Entry := ⟨53, [⟨6, 4, 3, 4⟩, ⟨3, 1, 4, 5⟩]⟩ + +def entry_54 : Entry := ⟨54, [⟨22, 0, 2, 3⟩, ⟨3, 6, 1, 4⟩]⟩ + +def entry_55 : Entry := ⟨55, [⟨7, 4, 0, 5⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_56 : Entry := ⟨56, [⟨7, 4, 0, 5⟩, ⟨7, 6, 0, 3⟩]⟩ + +def entry_57 : Entry := ⟨57, [⟨0, 6, 5, 4⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_58 : Entry := ⟨58, [⟨0, 4, 5, 4⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_59 : Entry := ⟨59, [⟨0, 6, 5, 4⟩, ⟨7, 4, 0, 5⟩]⟩ + +def entry_60 : Entry := ⟨60, [⟨6, 6, 1, 3⟩, ⟨49, 1, 6, 4⟩]⟩ + +def entry_61 : Entry := ⟨61, [⟨6, 0, 5, 4⟩, ⟨14, 1, 4, 5⟩]⟩ + +def entry_62 : Entry := ⟨62, [⟨6, 6, 0, 3⟩, ⟨53, 0, 1, 5⟩]⟩ + +def entry_63 : Entry := ⟨63, [⟨4, 3, 4, 3⟩, ⟨50, 0, 5, 4⟩]⟩ + +def entry_64 : Entry := ⟨64, [⟨6, 6, 3, 4⟩, ⟨49, 1, 8, 5⟩]⟩ + +def entry_65 : Entry := ⟨65, [⟨6, 6, 0, 3⟩, ⟨49, 1, 5, 4⟩]⟩ + +def entry_66 : Entry := ⟨66, [⟨6, 3, 4, 5⟩, ⟨53, 5, 6, 4⟩]⟩ + +def entry_67 : Entry := ⟨67, [⟨6, 1, 4, 5⟩, ⟨9, 2, 5, 4⟩]⟩ + +def entry_68 : Entry := ⟨68, [⟨6, 4, 0, 5⟩, ⟨44, 0, 5, 4⟩]⟩ + +def entry_69 : Entry := ⟨69, [⟨6, 3, 4, 5⟩, ⟨34, 0, 6, 5⟩]⟩ + +def entry_70 : Entry := ⟨70, [⟨4, 3, 4, 3⟩, ⟨41, 0, 5, 4⟩]⟩ + +def entry_71 : Entry := ⟨71, [⟨6, 1, 4, 5⟩, ⟨23, 2, 4, 3⟩]⟩ + +def entry_72 : Entry := ⟨72, [⟨0, 5, 3, 8⟩, ⟨8, 6, 5, 4⟩]⟩ + +def entry_73 : Entry := ⟨73, [⟨4, 3, 3, 4⟩, ⟨50, 0, 4, 5⟩]⟩ + +def entry_74 : Entry := ⟨74, [⟨2, 7, 4, 3⟩, ⟨53, 0, 3, 3⟩]⟩ + +def entry_75 : Entry := ⟨75, [⟨0, 0, 1, 3⟩, ⟨9, 0, 7, 3⟩]⟩ + +def entry_76 : Entry := ⟨76, [⟨0, 7, 5, 7⟩, ⟨14, 0, 7, 5⟩]⟩ + +def entry_77 : Entry := ⟨77, [⟨0, 5, 3, 7⟩, ⟨12, 0, 5, 4⟩]⟩ + +def entry_78 : Entry := ⟨78, [⟨6, 4, 3, 4⟩, ⟨52, 0, 5, 4⟩]⟩ + +def entry_79 : Entry := ⟨79, [⟨6, 1, 5, 5⟩, ⟨48, 0, 3, 4⟩]⟩ + +def entry_80 : Entry := ⟨80, [⟨0, 6, 6, 4⟩, ⟨13, 4, 2, 4⟩]⟩ + +def entry_81 : Entry := ⟨81, [⟨4, 3, 4, 3⟩, ⟨43, 0, 5, 4⟩]⟩ + +def entry_82 : Entry := ⟨82, [⟨6, 1, 4, 5⟩, ⟨36, 0, 1, 3⟩]⟩ + +def entry_83 : Entry := ⟨83, [⟨0, 7, 5, 7⟩, ⟨67, 2, 6, 3⟩]⟩ + +def entry_84 : Entry := ⟨84, [⟨6, 3, 4, 5⟩, ⟨67, 0, 6, 4⟩]⟩ + +def entry_85 : Entry := ⟨85, [⟨9, 0, 6, 3⟩, ⟨8, 4, 5, 4⟩]⟩ + +def entry_86 : Entry := ⟨86, [⟨0, 6, 5, 4⟩, ⟨67, 3, 1, 5⟩]⟩ + +def entry_87 : Entry := ⟨87, [⟨0, 5, 3, 7⟩, ⟨24, 2, 5, 3⟩]⟩ + +def entry_88 : Entry := ⟨88, [⟨0, 6, 6, 4⟩, ⟨67, 3, 2, 5⟩]⟩ + +def entry_89 : Entry := ⟨89, [⟨8, 3, 3, 1⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_90 : Entry := ⟨90, [⟨31, 0, 3, 3⟩, ⟨54, 6, 0, 3⟩, ⟨54, 0, 5, 4⟩, ⟨31, 6, 2, 4⟩]⟩ + +def entry_91 : Entry := ⟨91, [⟨6, 3, 4, 5⟩, ⟨74, 5, 7, 3⟩]⟩ + +def entry_92 : Entry := ⟨92, [⟨6, 1, 4, 5⟩, ⟨33, 0, 2, 3⟩]⟩ + +def entry_93 : Entry := ⟨93, [⟨4, 3, 4, 3⟩, ⟨47, 0, 5, 4⟩]⟩ + +def entry_94 : Entry := ⟨94, [⟨6, 1, 4, 5⟩, ⟨27, 3, 3, 6⟩]⟩ + +def entry_95 : Entry := ⟨95, [⟨0, 5, 3, 7⟩, ⟨29, 0, 2, 5⟩]⟩ + +def entry_96 : Entry := ⟨96, [⟨6, 1, 5, 5⟩, ⟨70, 0, 3, 5⟩]⟩ + +def entry_97 : Entry := ⟨97, [⟨6, 6, 0, 3⟩, ⟨44, 0, 5, 4⟩]⟩ + +def entry_98 : Entry := ⟨98, [⟨6, 6, 2, 3⟩, ⟨44, 0, 7, 4⟩]⟩ + +def entry_99 : Entry := ⟨99, [⟨2, 1, 3, 2⟩, ⟨24, 0, 5, 4⟩]⟩ + +def entry_100 : Entry := ⟨100, [⟨0, 6, 5, 4⟩, ⟨48, 0, 1, 4⟩]⟩ + +def entry_101 : Entry := ⟨101, [⟨0, 7, 4, 6⟩, ⟨24, 0, 5, 4⟩]⟩ + +def entry_102 : Entry := ⟨102, [⟨6, 3, 4, 5⟩, ⟨25, 2, 6, 3⟩]⟩ + +def entry_103 : Entry := ⟨103, [⟨6, 3, 4, 5⟩, ⟨71, 0, 6, 4⟩]⟩ + +def entry_104 : Entry := ⟨104, [⟨6, 0, 5, 4⟩, ⟨75, 0, 3, 4⟩]⟩ + +def entry_105 : Entry := ⟨105, [⟨6, 5, 4, 3⟩, ⟨77, 0, 4, 5⟩]⟩ + +def entry_106 : Entry := ⟨106, [⟨6, 1, 4, 5⟩, ⟨36, 6, 5, 4⟩]⟩ + +def entry_107 : Entry := ⟨107, [⟨6, 6, 0, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_108 : Entry := ⟨108, [⟨4, 6, 1, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_109 : Entry := ⟨109, [⟨4, 6, 1, 3⟩, ⟨55, 0, 5, 4⟩]⟩ + +def entry_110 : Entry := ⟨110, [⟨6, 6, 1, 3⟩, ⟨63, 1, 6, 3⟩]⟩ + +def entry_111 : Entry := ⟨111, [⟨6, 7, 4, 3⟩, ⟨83, 0, 4, 5⟩]⟩ + +def entry_112 : Entry := ⟨112, [⟨4, 1, 5, 4⟩, ⟨93, 0, 3, 5⟩]⟩ + +def entry_113 : Entry := ⟨113, [⟨1, 6, 6, 4⟩, ⟨36, 6, 7, 5⟩]⟩ + +def entry_114 : Entry := ⟨114, [⟨6, 0, 6, 5⟩, ⟨67, 3, 2, 5⟩]⟩ + +def entry_115 : Entry := ⟨115, [⟨6, 2, 7, 3⟩, ⟨70, 7, 2, 5⟩]⟩ + +def entry_116 : Entry := ⟨116, [⟨0, 7, 4, 6⟩, ⟨24, 2, 5, 4⟩]⟩ + +def entry_117 : Entry := ⟨117, [⟨6, 1, 4, 5⟩, ⟨100, 0, 5, 4⟩]⟩ + +def entry_118 : Entry := ⟨118, [⟨4, 7, 3, 1⟩, ⟨61, 1, 5, 4⟩]⟩ + +def entry_119 : Entry := ⟨119, [⟨6, 6, 1, 3⟩, ⟨55, 0, 6, 4⟩]⟩ + +def entry_120 : Entry := ⟨120, [⟨4, 0, 4, 5⟩, ⟨58, 2, 5, 4⟩]⟩ + +def entry_121 : Entry := ⟨121, [⟨9, 3, 4, 5⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_122 : Entry := ⟨122, [⟨6, 6, 3, 3⟩, ⟨105, 1, 4, 5⟩]⟩ + +def entry_123 : Entry := ⟨123, [⟨6, 6, 1, 3⟩, ⟨64, 2, 2, 5⟩]⟩ + +def entry_124 : Entry := ⟨124, [⟨6, 1, 4, 5⟩, ⟨31, 2, 5, 4⟩]⟩ + +def entry_125 : Entry := ⟨125, [⟨3, 0, 4, 3⟩, ⟨31, 2, 4, 5⟩]⟩ + +def entry_126 : Entry := ⟨126, [⟨6, 3, 4, 5⟩, ⟨46, 1, 5, 7⟩]⟩ + +def entry_127 : Entry := ⟨127, [⟨7, 0, 4, 5⟩, ⟨44, 2, 5, 4⟩]⟩ + +def entry_128 : Entry := ⟨128, [⟨9, 6, 1, 5⟩, ⟨57, 0, 6, 5⟩]⟩ + +def entry_129 : Entry := ⟨129, [⟨6, 4, 2, 5⟩, ⟨58, 1, 3, 6⟩]⟩ + +def entry_130 : Entry := ⟨130, [⟨6, 1, 4, 5⟩, ⟨60, 0, 5, 4⟩]⟩ + +def entry_131 : Entry := ⟨131, [⟨45, 3, 4, 5⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_132 : Entry := ⟨132, [⟨6, 3, 4, 5⟩, ⟨89, 0, 5, 6⟩]⟩ + +def entry_133 : Entry := ⟨133, [⟨6, 7, 3, 1⟩, ⟨92, 0, 5, 5⟩]⟩ + +def entry_134 : Entry := ⟨134, [⟨6, 7, 3, 0⟩, ⟨82, 0, 5, 4⟩]⟩ + +def entry_135 : Entry := ⟨135, [⟨7, 0, 4, 5⟩, ⟨75, 4, 2, 5⟩, ⟨44, 0, 5, 4⟩]⟩ + +def entry_136 : Entry := ⟨136, [⟨6, 3, 3, 7⟩, ⟨102, 2, 3, 3⟩]⟩ + +def entry_137 : Entry := ⟨137, [⟨4, 1, 4, 3⟩, ⟨96, 0, 3, 4⟩]⟩ + +def entry_138 : Entry := ⟨138, [⟨27, 0, 5, 4⟩, ⟨10, 1, 4, 7⟩]⟩ + +def entry_139 : Entry := ⟨139, [⟨28, 1, 4, 5⟩, ⟨27, 0, 5, 4⟩]⟩ + +def entry_140 : Entry := ⟨140, [⟨6, 7, 3, 2⟩, ⟨82, 0, 5, 6⟩]⟩ + +def entry_141 : Entry := ⟨141, [⟨7, 0, 4, 5⟩, ⟨78, 2, 1, 3⟩]⟩ + +def entry_142 : Entry := ⟨142, [⟨72, 4, 2, 3⟩, ⟨32, 1, 4, 3⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_143 : Entry := ⟨143, [⟨6, 6, 3, 4⟩, ⟨108, 0, 8, 5⟩]⟩ + +def entry_144 : Entry := ⟨144, [⟨7, 0, 4, 5⟩, ⟨104, 4, 1, 5⟩, ⟨55, 0, 5, 4⟩]⟩ + +def entry_145 : Entry := ⟨145, [⟨0, 5, 4, 5⟩, ⟨91, 0, 3, 4⟩]⟩ + +def entry_146 : Entry := ⟨146, [⟨36, 6, 5, 4⟩, ⟨24, 1, 4, 5⟩]⟩ + +def entry_147 : Entry := ⟨147, [⟨53, 0, 1, 5⟩, ⟨44, 2, 5, 4⟩]⟩ + +def entry_148 : Entry := ⟨148, [⟨7, 1, 5, 4⟩, ⟨46, 1, 4, 5⟩, ⟨94, 0, 5, 3⟩, ⟨97, 1, 4, 5⟩]⟩ + +def entry_149 : Entry := ⟨149, [⟨16, 1, 4, 3⟩, ⟨24, 2, 5, 4⟩]⟩ + +def entry_150 : Entry := ⟨150, [⟨4, 6, 1, 3⟩, ⟨126, 5, 2, 5⟩]⟩ + +def entry_151 : Entry := ⟨151, [⟨2, 1, 4, 3⟩, ⟨101, 2, 6, 3⟩]⟩ + +def entry_152 : Entry := ⟨152, [⟨6, 3, 4, 5⟩, ⟨73, 1, 7, 4⟩]⟩ + +def entry_153 : Entry := ⟨153, [⟨59, 4, 0, 4⟩, ⟨27, 0, 5, 4⟩]⟩ + +def entry_154 : Entry := ⟨154, [⟨7, 6, 4, 3⟩, ⟨104, 0, 7, 5⟩]⟩ + +def entry_155 : Entry := ⟨155, [⟨7, 1, 5, 4⟩, ⟨55, 3, 4, 5⟩]⟩ + +def entry_156 : Entry := ⟨156, [⟨11, 0, 2, 4⟩, ⟨98, 2, 2, 4⟩, ⟨33, 0, 2, 3⟩]⟩ + +def entry_157 : Entry := ⟨157, [⟨6, 3, 4, 5⟩, ⟨57, 1, 5, 6⟩]⟩ + +def entry_158 : Entry := ⟨158, [⟨66, 0, 3, 4⟩, ⟨45, 1, 4, 5⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_159 : Entry := ⟨159, [⟨45, 3, 4, 5⟩, ⟨65, 1, 4, 5⟩, ⟨7, 3, 3, 4⟩]⟩ + +def entry_160 : Entry := ⟨160, [⟨63, 1, 8, 3⟩, ⟨32, 3, 4, 3⟩]⟩ + +def entry_161 : Entry := ⟨161, [⟨15, 1, 4, 5⟩, ⟨86, 0, 5, 4⟩]⟩ + +def entry_162 : Entry := ⟨162, [⟨7, 3, 3, 4⟩, ⟨127, 1, 4, 5⟩, ⟨63, 0, 3, 5⟩, ⟨157, 0, 3, 3⟩]⟩ + +def entry_163 : Entry := ⟨163, [⟨44, 2, 5, 4⟩, ⟨49, 1, 5, 4⟩, ⟨56, 4, 0, 4⟩]⟩ + +def entry_164 : Entry := ⟨164, [⟨6, 1, 4, 5⟩, ⟨110, 0, 5, 4⟩]⟩ + +def entry_165 : Entry := ⟨165, [⟨0, 7, 5, 8⟩, ⟨107, 0, 7, 5⟩]⟩ + +def entry_166 : Entry := ⟨166, [⟨2, 7, 4, 5⟩, ⟨107, 0, 6, 4⟩]⟩ + +def entry_167 : Entry := ⟨167, [⟨57, 0, 5, 4⟩, ⟨57, 4, 0, 4⟩]⟩ + +def entry_168 : Entry := ⟨168, [⟨6, 1, 5, 5⟩, ⟨152, 0, 3, 4⟩]⟩ + +def entry_169 : Entry := ⟨169, [⟨28, 3, 4, 5⟩, ⟨63, 1, 8, 3⟩]⟩ + +def entry_170 : Entry := ⟨170, [⟨4, 6, 1, 3⟩, ⟨127, 2, 5, 4⟩]⟩ + +def entry_171 : Entry := ⟨171, [⟨6, 0, 5, 4⟩, ⟨91, 0, 0, 5⟩]⟩ + +def entry_172 : Entry := ⟨172, [⟨63, 1, 5, 3⟩, ⟨55, 6, 0, 4⟩, ⟨64, 0, 1, 3⟩]⟩ + +def entry_173 : Entry := ⟨173, [⟨63, 1, 5, 3⟩, ⟨64, 6, 4, 5⟩, ⟨55, 6, 0, 4⟩]⟩ + +def entry_174 : Entry := ⟨174, [⟨58, 3, 4, 5⟩, ⟨57, 1, 4, 5⟩, ⟨84, 0, 3, 4⟩]⟩ + +def entry_175 : Entry := ⟨175, [⟨141, 0, 5, 4⟩, ⟨7, 2, 4, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_176 : Entry := ⟨176, [⟨63, 1, 5, 3⟩, ⟨64, 6, 4, 5⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_177 : Entry := ⟨177, [⟨6, 1, 4, 5⟩, ⟨136, 3, 5, 4⟩]⟩ + +def entry_178 : Entry := ⟨178, [⟨37, 0, 3, 4⟩, ⟨68, 1, 4, 5⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_179 : Entry := ⟨179, [⟨6, 6, 0, 3⟩, ⟨148, 5, 5, 4⟩]⟩ + +def entry_180 : Entry := ⟨180, [⟨7, 3, 3, 4⟩, ⟨63, 0, 3, 5⟩, ⟨155, 0, 4, 5⟩, ⟨132, 0, 3, 3⟩]⟩ + +def entry_181 : Entry := ⟨181, [⟨24, 3, 4, 5⟩, ⟨87, 2, 6, 4⟩, ⟨90, 0, 7, 5⟩]⟩ + +def entry_182 : Entry := ⟨182, [⟨12, 2, 7, 3⟩, ⟨139, 0, 7, 4⟩]⟩ + +def entry_183 : Entry := ⟨183, [⟨64, 2, 1, 5⟩, ⟨63, 3, 0, 3⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_184 : Entry := ⟨184, [⟨34, 3, 4, 2⟩, ⟨35, 2, 5, 4⟩]⟩ + +def entry_185 : Entry := ⟨185, [⟨44, 3, 4, 5⟩, ⟨49, 0, 4, 5⟩, ⟨84, 0, 3, 4⟩]⟩ + +def entry_186 : Entry := ⟨186, [⟨7, 6, 0, 3⟩, ⟨141, 2, 5, 4⟩]⟩ + +def entry_187 : Entry := ⟨187, [⟨6, 4, 3, 4⟩, ⟨108, 3, 4, 5⟩]⟩ + +def entry_188 : Entry := ⟨188, [⟨6, 3, 4, 5⟩, ⟨112, 5, 7, 4⟩]⟩ + +def entry_189 : Entry := ⟨189, [⟨12, 0, 5, 4⟩, ⟨86, 4, 1, 4⟩]⟩ + +def entry_190 : Entry := ⟨190, [⟨46, 0, 5, 4⟩, ⟨85, 2, 3, 3⟩, ⟨111, 3, 4, 3⟩]⟩ + +def entry_191 : Entry := ⟨191, [⟨6, 4, 3, 4⟩, ⟨145, 0, 4, 5⟩]⟩ + +def entry_192 : Entry := ⟨192, [⟨64, 1, 3, 1⟩, ⟨103, 0, 3, 4⟩, ⟨55, 3, 4, 5⟩]⟩ + +def entry_193 : Entry := ⟨193, [⟨6, 6, 2, 3⟩, ⟨162, 1, 7, 4⟩]⟩ + +def entry_194 : Entry := ⟨194, [⟨0, 0, 0, 3⟩, ⟨146, 4, 2, 5⟩]⟩ + +def entry_195 : Entry := ⟨195, [⟨6, 6, 0, 3⟩, ⟨162, 1, 5, 4⟩]⟩ + +def entry_196 : Entry := ⟨196, [⟨6, 3, 4, 5⟩, ⟨187, 5, 6, 4⟩]⟩ + +def entry_197 : Entry := ⟨197, [⟨63, 3, 0, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_198 : Entry := ⟨198, [⟨7, 4, 0, 5⟩, ⟨131, 1, 5, 4⟩]⟩ + +def entry_199 : Entry := ⟨199, [⟨55, 1, 4, 5⟩, ⟨64, 3, 5, 1⟩, ⟨84, 0, 3, 4⟩]⟩ + +def entry_200 : Entry := ⟨200, [⟨103, 0, 3, 4⟩, ⟨64, 3, 5, 1⟩, ⟨55, 1, 4, 5⟩]⟩ + +def entry_201 : Entry := ⟨201, [⟨45, 3, 5, 7⟩, ⟨82, 0, 6, 5⟩]⟩ + +def entry_202 : Entry := ⟨202, [⟨150, 0, 5, 4⟩, ⟨7, 0, 4, 5⟩, ⟨108, 0, 5, 4⟩]⟩ + +def entry_203 : Entry := ⟨203, [⟨18, 6, 1, 3⟩, ⟨107, 0, 5, 4⟩, ⟨163, 0, 5, 4⟩]⟩ + +def entry_204 : Entry := ⟨204, [⟨2, 5, 4, 2⟩, ⟨166, 2, 5, 3⟩]⟩ + +def entry_205 : Entry := ⟨205, [⟨4, 1, 4, 3⟩, ⟨168, 0, 3, 4⟩]⟩ + +def entry_206 : Entry := ⟨206, [⟨28, 3, 4, 5⟩, ⟨135, 2, 8, 4⟩]⟩ + +def entry_207 : Entry := ⟨207, [⟨28, 3, 4, 5⟩, ⟨127, 0, 8, 4⟩]⟩ + +def entry_208 : Entry := ⟨208, [⟨7, 4, 0, 5⟩, ⟨127, 0, 5, 4⟩]⟩ + +def entry_209 : Entry := ⟨209, [⟨25, 0, 5, 4⟩, ⟨81, 5, 5, 7⟩]⟩ + +def entry_210 : Entry := ⟨210, [⟨58, 2, 5, 4⟩, ⟨57, 0, 5, 4⟩, ⟨117, 1, 4, 5⟩]⟩ + +def entry_211 : Entry := ⟨211, [⟨49, 5, 5, 4⟩, ⟨6, 6, 0, 3⟩]⟩ + +def entry_212 : Entry := ⟨212, [⟨6, 0, 5, 4⟩, ⟨188, 0, 0, 5⟩]⟩ + +def entry_213 : Entry := ⟨213, [⟨6, 0, 7, 5⟩, ⟨191, 0, 3, 5⟩]⟩ + +def entry_214 : Entry := ⟨214, [⟨7, 3, 3, 4⟩, ⟨108, 3, 4, 5⟩, ⟨95, 0, 5, 2⟩]⟩ + +def entry_215 : Entry := ⟨215, [⟨107, 1, 4, 6⟩, ⟨24, 0, 5, 4⟩]⟩ + +def entry_216 : Entry := ⟨216, [⟨7, 6, 0, 3⟩, ⟨155, 5, 5, 4⟩]⟩ + +def entry_217 : Entry := ⟨217, [⟨111, 1, 1, 3⟩, ⟨55, 4, 0, 4⟩, ⟨64, 0, 1, 3⟩]⟩ + +def entry_218 : Entry := ⟨218, [⟨0, 5, 3, 7⟩, ⟨182, 0, 2, 4⟩]⟩ + +def entry_219 : Entry := ⟨219, [⟨0, 5, 3, 7⟩, ⟨179, 2, 6, 4⟩]⟩ + +def entry_220 : Entry := ⟨220, [⟨56, 4, 0, 4⟩, ⟨63, 1, 5, 3⟩, ⟨144, 2, 5, 4⟩, ⟨154, 6, 5, 4⟩, ⟨155, 1, 5, 4⟩]⟩ + +def entry_221 : Entry := ⟨221, [⟨6, 6, 0, 3⟩, ⟨180, 5, 5, 4⟩]⟩ + +def entry_222 : Entry := ⟨222, [⟨6, 1, 4, 5⟩, ⟨158, 5, 5, 4⟩]⟩ + +def entry_223 : Entry := ⟨223, [⟨63, 1, 5, 3⟩, ⟨135, 2, 5, 4⟩, ⟨128, 0, 3, 3⟩, ⟨111, 3, 4, 3⟩, ⟨127, 0, 5, 4⟩]⟩ + +def entry_224 : Entry := ⟨224, [⟨6, 1, 4, 5⟩, ⟨212, 0, 6, 3⟩]⟩ + +def entry_225 : Entry := ⟨225, [⟨111, 7, 7, 5⟩, ⟨61, 4, 4, 5⟩]⟩ + +def entry_226 : Entry := ⟨226, [⟨10, 6, 0, 3⟩, ⟨203, 0, 5, 4⟩, ⟨33, 0, 2, 3⟩, ⟨193, 0, 2, 4⟩]⟩ + +def entry_227 : Entry := ⟨227, [⟨6, 1, 5, 5⟩, ⟨212, 0, 7, 3⟩]⟩ + +def entry_228 : Entry := ⟨228, [⟨82, 0, 6, 5⟩, ⟨68, 3, 5, 7⟩]⟩ + +def entry_229 : Entry := ⟨229, [⟨171, 0, 7, 3⟩, ⟨45, 1, 4, 5⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_230 : Entry := ⟨230, [⟨10, 6, 3, 4⟩, ⟨193, 0, 5, 5⟩, ⟨203, 0, 8, 5⟩, ⟨33, 0, 5, 4⟩]⟩ + +def entry_231 : Entry := ⟨231, [⟨6, 3, 4, 5⟩, ⟨222, 0, 6, 4⟩]⟩ + +def entry_232 : Entry := ⟨232, [⟨24, 2, 5, 4⟩, ⟨107, 1, 4, 6⟩]⟩ + +def entry_233 : Entry := ⟨233, [⟨32, 3, 3, 1⟩, ⟨133, 0, 6, 4⟩]⟩ + +def entry_234 : Entry := ⟨234, [⟨180, 4, 4, 5⟩, ⟨37, 0, 3, 4⟩, ⟨129, 0, 5, 3⟩, ⟨63, 0, 3, 5⟩]⟩ + +def entry_235 : Entry := ⟨235, [⟨7, 3, 3, 4⟩, ⟨110, 0, 6, 4⟩, ⟨70, 0, 3, 5⟩]⟩ + +def entry_236 : Entry := ⟨236, [⟨38, 1, 4, 5⟩, ⟨122, 7, 3, 4⟩, ⟨181, 0, 2, 3⟩, ⟨30, 1, 4, 3⟩]⟩ + +def entry_237 : Entry := ⟨237, [⟨6, 3, 4, 5⟩, ⟨172, 0, 7, 4⟩]⟩ + +def entry_238 : Entry := ⟨238, [⟨6, 3, 4, 5⟩, ⟨178, 5, 7, 4⟩]⟩ + +def entry_239 : Entry := ⟨239, [⟨0, 4, 7, 3⟩, ⟨174, 4, 3, 5⟩]⟩ + +def entry_240 : Entry := ⟨240, [⟨6, 1, 4, 5⟩, ⟨237, 0, 2, 4⟩]⟩ + +def entry_241 : Entry := ⟨241, [⟨131, 1, 5, 4⟩, ⟨159, 1, 5, 4⟩, ⟨61, 0, 4, 5⟩]⟩ + +def entry_242 : Entry := ⟨242, [⟨6, 1, 4, 5⟩, ⟨190, 0, 5, 4⟩]⟩ + +def entry_243 : Entry := ⟨243, [⟨6, 0, 5, 4⟩, ⟨233, 0, 2, 5⟩]⟩ + +def entry_244 : Entry := ⟨244, [⟨99, 4, 2, 5⟩, ⟨99, 0, 4, 5⟩, ⟨11, 7, 3, 3⟩, ⟨173, 2, 5, 4⟩]⟩ + +def entry_245 : Entry := ⟨245, [⟨64, 0, 1, 3⟩, ⟨175, 4, 0, 4⟩, ⟨143, 6, 4, 5⟩, ⟨186, 6, 0, 4⟩]⟩ + +def entry_246 : Entry := ⟨246, [⟨64, 6, 4, 5⟩, ⟨175, 2, 5, 4⟩, ⟨186, 0, 5, 4⟩, ⟨143, 0, 1, 3⟩]⟩ + +def entry_247 : Entry := ⟨247, [⟨6, 4, 3, 4⟩, ⟨229, 0, 4, 5⟩]⟩ + +def entry_248 : Entry := ⟨248, [⟨186, 0, 7, 4⟩, ⟨143, 0, 3, 3⟩, ⟨175, 2, 7, 4⟩, ⟨64, 6, 6, 5⟩]⟩ + +def entry_249 : Entry := ⟨249, [⟨0, 7, 4, 5⟩, ⟨225, 1, 4, 1⟩]⟩ + +def entry_250 : Entry := ⟨250, [⟨6, 1, 4, 5⟩, ⟨238, 0, 2, 4⟩]⟩ + +def entry_251 : Entry := ⟨251, [⟨6, 2, 5, 4⟩, ⟨239, 4, 3, 6⟩]⟩ + +def entry_252 : Entry := ⟨252, [⟨111, 3, 4, 3⟩, ⟨154, 6, 5, 4⟩, ⟨144, 2, 5, 4⟩, ⟨63, 1, 5, 3⟩, ⟨155, 1, 5, 4⟩]⟩ + +def entry_253 : Entry := ⟨253, [⟨29, 3, 3, 0⟩, ⟨177, 1, 6, 2⟩]⟩ + +def entry_254 : Entry := ⟨254, [⟨96, 7, 4, 5⟩, ⟨108, 0, 8, 5⟩]⟩ + +def entry_255 : Entry := ⟨255, [⟨69, 0, 3, 3⟩, ⟨205, 0, 5, 5⟩, ⟨7, 3, 3, 4⟩]⟩ + +def entry_256 : Entry := ⟨256, [⟨0, 5, 4, 5⟩, ⟨231, 0, 3, 4⟩]⟩ + +def entry_257 : Entry := ⟨257, [⟨4, 1, 5, 4⟩, ⟨235, 0, 4, 5⟩]⟩ + +def entry_258 : Entry := ⟨258, [⟨6, 4, 3, 4⟩, ⟨227, 0, 4, 5⟩]⟩ + +def entry_259 : Entry := ⟨259, [⟨6, 4, 3, 4⟩, ⟨231, 1, 7, 2⟩]⟩ + +def entry_260 : Entry := ⟨260, [⟨0, 5, 4, 6⟩, ⟨231, 0, 3, 5⟩]⟩ + +def entry_261 : Entry := ⟨261, [⟨6, 3, 4, 5⟩, ⟨242, 0, 6, 4⟩]⟩ + +def entry_262 : Entry := ⟨262, [⟨0, 7, 5, 7⟩, ⟨213, 0, 3, 4⟩]⟩ + +def entry_263 : Entry := ⟨263, [⟨144, 6, 0, 4⟩, ⟨143, 0, 1, 3⟩, ⟨175, 0, 5, 4⟩, ⟨55, 6, 0, 4⟩]⟩ + +def entry_264 : Entry := ⟨264, [⟨6, 4, 3, 4⟩, ⟨250, 1, 7, 4⟩]⟩ + +def entry_265 : Entry := ⟨265, [⟨6, 6, 3, 4⟩, ⟨247, 0, 4, 6⟩]⟩ + +def entry_266 : Entry := ⟨266, [⟨6, 3, 3, 5⟩, ⟨242, 0, 5, 4⟩]⟩ + +def entry_267 : Entry := ⟨267, [⟨175, 4, 1, 4⟩, ⟨144, 2, 6, 4⟩, ⟨55, 2, 6, 4⟩, ⟨143, 4, 5, 3⟩]⟩ + +def entry_268 : Entry := ⟨268, [⟨6, 0, 5, 4⟩, ⟨251, 0, 4, 2⟩]⟩ + +def entry_269 : Entry := ⟨269, [⟨28, 3, 3, 6⟩, ⟨202, 0, 7, 5⟩]⟩ + +def entry_270 : Entry := ⟨270, [⟨63, 0, 3, 7⟩, ⟨6, 7, 3, 2⟩]⟩ + +def entry_271 : Entry := ⟨271, [⟨107, 2, 7, 3⟩, ⟨107, 3, 4, 6⟩]⟩ + +def entry_272 : Entry := ⟨272, [⟨1, 1, 3, 1⟩, ⟨249, 0, 4, 5⟩]⟩ + +def entry_273 : Entry := ⟨273, [⟨6, 1, 4, 5⟩, ⟨223, 0, 5, 4⟩]⟩ + +def entry_274 : Entry := ⟨274, [⟨6, 7, 3, 1⟩, ⟨240, 0, 5, 5⟩]⟩ + +def entry_275 : Entry := ⟨275, [⟨63, 1, 5, 3⟩, ⟨198, 4, 0, 4⟩, ⟨44, 2, 5, 4⟩]⟩ + +def entry_276 : Entry := ⟨276, [⟨7, 3, 3, 4⟩, ⟨177, 0, 5, 4⟩, ⟨63, 0, 3, 5⟩]⟩ + +def entry_277 : Entry := ⟨277, [⟨14, 3, 4, 5⟩, ⟨204, 2, 3, 0⟩, ⟨33, 1, 3, 2⟩]⟩ + +def entry_278 : Entry := ⟨278, [⟨63, 3, 3, 3⟩, ⟨162, 1, 8, 4⟩]⟩ + +def entry_279 : Entry := ⟨279, [⟨6, 3, 4, 5⟩, ⟨234, 5, 7, 4⟩]⟩ + +def entry_280 : Entry := ⟨280, [⟨184, 0, 1, 5⟩, ⟨116, 2, 4, 3⟩]⟩ + +def entry_281 : Entry := ⟨281, [⟨36, 4, 5, 4⟩, ⟨163, 2, 5, 4⟩, ⟨189, 0, 4, 5⟩]⟩ + +def entry_282 : Entry := ⟨282, [⟨56, 0, 5, 4⟩, ⟨64, 0, 1, 3⟩, ⟨55, 0, 5, 4⟩, ⟨265, 0, 1, 3⟩]⟩ + +def entry_283 : Entry := ⟨283, [⟨64, 0, 1, 3⟩, ⟨196, 1, 4, 3⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_284 : Entry := ⟨284, [⟨45, 1, 4, 5⟩, ⟨224, 0, 5, 4⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_285 : Entry := ⟨285, [⟨6, 3, 4, 5⟩, ⟨273, 0, 6, 4⟩]⟩ + +def entry_286 : Entry := ⟨286, [⟨6, 7, 3, 0⟩, ⟨261, 0, 3, 4⟩]⟩ + +def entry_287 : Entry := ⟨287, [⟨64, 0, 1, 3⟩, ⟨55, 0, 5, 4⟩, ⟨56, 0, 5, 4⟩, ⟨264, 4, 4, 5⟩]⟩ + +def entry_288 : Entry := ⟨288, [⟨130, 1, 4, 2⟩, ⟨96, 0, 1, 4⟩]⟩ + +def entry_289 : Entry := ⟨289, [⟨6, 1, 4, 5⟩, ⟨279, 0, 2, 4⟩]⟩ + +def entry_290 : Entry := ⟨290, [⟨67, 2, 5, 2⟩, ⟨231, 4, 5, 5⟩]⟩ + +def entry_291 : Entry := ⟨291, [⟨89, 3, 3, 4⟩, ⟨202, 0, 8, 4⟩, ⟨55, 4, 3, 4⟩]⟩ + +def entry_292 : Entry := ⟨292, [⟨39, 0, 3, 4⟩, ⟨219, 3, 3, 4⟩, ⟨79, 1, 4, 3⟩]⟩ + +def entry_293 : Entry := ⟨293, [⟨2, 7, 4, 3⟩, ⟨280, 0, 5, 4⟩]⟩ + +def entry_294 : Entry := ⟨294, [⟨63, 1, 5, 3⟩, ⟨196, 3, 1, 3⟩]⟩ + +def entry_295 : Entry := ⟨295, [⟨63, 1, 5, 3⟩, ⟨64, 2, 1, 5⟩, ⟨55, 0, 5, 4⟩, ⟨265, 4, 4, 3⟩]⟩ + +def entry_296 : Entry := ⟨296, [⟨107, 1, 4, 5⟩, ⟨209, 3, 3, 4⟩, ⟨65, 1, 4, 5⟩]⟩ + +def entry_297 : Entry := ⟨297, [⟨6, 4, 3, 4⟩, ⟨289, 1, 7, 4⟩]⟩ + +def entry_298 : Entry := ⟨298, [⟨24, 2, 7, 3⟩, ⟨24, 6, 3, 3⟩, ⟨107, 4, 3, 4⟩, ⟨195, 0, 7, 4⟩]⟩ + +def entry_299 : Entry := ⟨299, [⟨6, 4, 3, 4⟩, ⟨284, 0, 4, 5⟩]⟩ + +def entry_300 : Entry := ⟨300, [⟨64, 3, 5, 1⟩, ⟨240, 2, 5, 1⟩, ⟨55, 3, 4, 5⟩]⟩ + +def entry_301 : Entry := ⟨301, [⟨59, 0, 5, 4⟩, ⟨57, 0, 5, 4⟩, ⟨258, 4, 4, 5⟩]⟩ + +def entry_302 : Entry := ⟨302, [⟨125, 0, 5, 3⟩, ⟨162, 4, 3, 6⟩]⟩ + +def entry_303 : Entry := ⟨303, [⟨49, 4, 4, 5⟩, ⟨44, 1, 4, 5⟩, ⟨63, 0, 3, 5⟩, ⟨261, 0, 3, 4⟩]⟩ + +def entry_304 : Entry := ⟨304, [⟨55, 4, 3, 4⟩, ⟨202, 0, 8, 4⟩, ⟨131, 3, 3, 4⟩]⟩ + +def entry_305 : Entry := ⟨305, [⟨6, 1, 4, 5⟩, ⟨278, 0, 1, 4⟩]⟩ + +def entry_306 : Entry := ⟨306, [⟨4, 1, 4, 3⟩, ⟨288, 0, 6, 4⟩]⟩ + +def entry_307 : Entry := ⟨307, [⟨0, 7, 4, 6⟩, ⟨273, 0, 5, 5⟩]⟩ + +def entry_308 : Entry := ⟨308, [⟨6, 6, 3, 4⟩, ⟨299, 0, 4, 6⟩]⟩ + +def entry_309 : Entry := ⟨309, [⟨28, 6, 3, 4⟩, ⟨268, 1, 5, 7⟩]⟩ + +def entry_310 : Entry := ⟨310, [⟨6, 1, 4, 5⟩, ⟨281, 0, 5, 3⟩]⟩ + +def entry_311 : Entry := ⟨311, [⟨6, 3, 3, 5⟩, ⟨278, 0, 2, 4⟩]⟩ + +def entry_312 : Entry := ⟨312, [⟨9, 2, 5, 4⟩, ⟨272, 0, 4, 5⟩]⟩ + +def entry_313 : Entry := ⟨313, [⟨162, 4, 4, 5⟩, ⟨148, 5, 6, 3⟩]⟩ + +def entry_314 : Entry := ⟨314, [⟨6, 3, 4, 5⟩, ⟨305, 0, 6, 4⟩]⟩ + +def entry_315 : Entry := ⟨315, [⟨6, 0, 5, 4⟩, ⟨296, 0, 4, 5⟩]⟩ + +def entry_316 : Entry := ⟨316, [⟨6, 6, 3, 4⟩, ⟨306, 0, 5, 8⟩]⟩ + +def entry_317 : Entry := ⟨317, [⟨263, 2, 6, 4⟩, ⟨26, 3, 4, 3⟩, ⟨99, 0, 5, 5⟩]⟩ + +def entry_318 : Entry := ⟨318, [⟨64, 3, 5, 1⟩, ⟨63, 0, 3, 5⟩, ⟨261, 0, 3, 4⟩, ⟨55, 1, 4, 5⟩]⟩ + +def entry_319 : Entry := ⟨319, [⟨39, 2, 3, 4⟩, ⟨109, 4, 0, 5⟩, ⟨266, 1, 4, 5⟩, ⟨122, 4, 4, 5⟩]⟩ + +def entry_320 : Entry := ⟨320, [⟨19, 1, 4, 3⟩, ⟨267, 2, 6, 4⟩, ⟨115, 7, 4, 3⟩]⟩ + +def entry_321 : Entry := ⟨321, [⟨165, 1, 3, 4⟩, ⟨97, 0, 7, 5⟩, ⟨223, 3, 4, 7⟩]⟩ + +def entry_322 : Entry := ⟨322, [⟨96, 0, 1, 4⟩, ⟨205, 1, 5, 2⟩]⟩ + +def entry_323 : Entry := ⟨323, [⟨165, 6, 4, 5⟩, ⟨278, 0, 1, 4⟩, ⟨25, 1, 4, 5⟩]⟩ + +def entry_324 : Entry := ⟨324, [⟨6, 3, 4, 5⟩, ⟨298, 0, 3, 4⟩]⟩ + +def entry_325 : Entry := ⟨325, [⟨25, 0, 6, 5⟩, ⟨313, 1, 6, 4⟩, ⟨24, 2, 6, 3⟩]⟩ + +def entry_326 : Entry := ⟨326, [⟨63, 1, 5, 3⟩, ⟨255, 7, 0, 4⟩]⟩ + +def entry_327 : Entry := ⟨327, [⟨24, 2, 6, 3⟩, ⟨195, 4, 2, 4⟩, ⟨195, 0, 6, 4⟩, ⟨24, 6, 2, 3⟩]⟩ + +def entry_328 : Entry := ⟨328, [⟨49, 0, 4, 5⟩, ⟨44, 3, 4, 5⟩, ⟨285, 0, 3, 4⟩]⟩ + +def entry_329 : Entry := ⟨329, [⟨0, 7, 4, 6⟩, ⟨305, 0, 5, 5⟩]⟩ + +def entry_330 : Entry := ⟨330, [⟨63, 1, 5, 3⟩, ⟨268, 0, 4, 5⟩, ⟨144, 0, 5, 4⟩, ⟨154, 4, 5, 4⟩, ⟨155, 5, 5, 4⟩]⟩ + +def entry_331 : Entry := ⟨331, [⟨113, 0, 1, 4⟩, ⟨15, 0, 3, 4⟩, ⟨298, 4, 4, 5⟩, ⟨90, 2, 5, 4⟩]⟩ + +def entry_332 : Entry := ⟨332, [⟨67, 4, 3, 4⟩, ⟨289, 2, 5, 1⟩]⟩ + +def entry_333 : Entry := ⟨333, [⟨317, 0, 5, 4⟩, ⟨1, 5, 4, 3⟩]⟩ + +def entry_334 : Entry := ⟨334, [⟨67, 6, 3, 2⟩, ⟨289, 0, 5, 5⟩]⟩ + +def entry_335 : Entry := ⟨335, [⟨196, 3, 1, 3⟩, ⟨162, 1, 5, 4⟩]⟩ + +def entry_336 : Entry := ⟨336, [⟨25, 6, 2, 3⟩, ⟨199, 3, 2, 4⟩, ⟨65, 0, 6, 4⟩, ⟨304, 0, 2, 4⟩]⟩ + +def entry_337 : Entry := ⟨337, [⟨107, 3, 3, 7⟩, ⟨230, 2, 1, 5⟩]⟩ + +def entry_338 : Entry := ⟨338, [⟨241, 0, 6, 4⟩, ⟨275, 4, 2, 4⟩, ⟨107, 4, 2, 4⟩]⟩ + +def entry_339 : Entry := ⟨339, [⟨4, 1, 4, 3⟩, ⟨322, 0, 6, 4⟩]⟩ + +def entry_340 : Entry := ⟨340, [⟨25, 3, 3, 6⟩, ⟨300, 4, 4, 6⟩, ⟨24, 3, 3, 6⟩]⟩ + +def entry_341 : Entry := ⟨341, [⟨162, 5, 5, 4⟩, ⟨259, 4, 4, 5⟩, ⟨208, 2, 5, 4⟩, ⟨143, 0, 1, 3⟩]⟩ + +def entry_342 : Entry := ⟨342, [⟨210, 0, 5, 2⟩, ⟨88, 1, 4, 3⟩, ⟨260, 4, 4, 3⟩, ⟨290, 0, 4, 3⟩]⟩ + +def entry_343 : Entry := ⟨343, [⟨0, 5, 4, 5⟩, ⟨250, 0, 5, 4⟩]⟩ + +def entry_344 : Entry := ⟨344, [⟨7, 1, 5, 4⟩, ⟨108, 3, 4, 5⟩, ⟨262, 4, 5, 2⟩]⟩ + +def entry_345 : Entry := ⟨345, [⟨6, 0, 5, 5⟩, ⟨320, 4, 4, 7⟩]⟩ + +def entry_346 : Entry := ⟨346, [⟨60, 1, 4, 3⟩, ⟨255, 0, 1, 4⟩, ⟨276, 0, 1, 4⟩]⟩ + +def entry_347 : Entry := ⟨347, [⟨6, 6, 3, 4⟩, ⟨339, 0, 5, 8⟩]⟩ + +def entry_348 : Entry := ⟨348, [⟨312, 1, 5, 5⟩, ⟨114, 4, 3, 4⟩, ⟨139, 3, 4, 5⟩]⟩ + +def entry_349 : Entry := ⟨349, [⟨14, 1, 4, 5⟩, ⟨17, 1, 4, 5⟩, ⟨332, 0, 3, 4⟩]⟩ + +def entry_350 : Entry := ⟨350, [⟨24, 4, 2, 5⟩, ⟨107, 2, 6, 4⟩, ⟨271, 4, 5, 5⟩, ⟨215, 0, 5, 5⟩]⟩ + +def entry_351 : Entry := ⟨351, [⟨163, 0, 5, 4⟩, ⟨287, 4, 1, 4⟩, ⟨25, 4, 1, 5⟩]⟩ + +def entry_352 : Entry := ⟨352, [⟨214, 0, 4, 5⟩, ⟨91, 0, 3, 4⟩, ⟨63, 0, 3, 5⟩, ⟨344, 0, 4, 5⟩, ⟨180, 4, 4, 5⟩]⟩ + +def entry_353 : Entry := ⟨353, [⟨6, 4, 0, 5⟩, ⟨347, 0, 1, 3⟩]⟩ + +def entry_354 : Entry := ⟨354, [⟨138, 2, 5, 4⟩, ⟨114, 5, 4, 3⟩, ⟨312, 0, 5, 5⟩, ⟨182, 2, 2, 4⟩]⟩ + +def entry_355 : Entry := ⟨355, [⟨12, 2, 7, 3⟩, ⟨167, 0, 7, 4⟩, ⟨342, 0, 6, 6⟩]⟩ + +def entry_356 : Entry := ⟨356, [⟨24, 2, 6, 3⟩, ⟨24, 6, 2, 3⟩, ⟨211, 4, 2, 4⟩, ⟨179, 0, 6, 4⟩]⟩ + +def entry_357 : Entry := ⟨357, [⟨82, 6, 2, 3⟩, ⟨283, 0, 5, 6⟩]⟩ + +def entry_358 : Entry := ⟨358, [⟨6, 0, 5, 4⟩, ⟨346, 0, 4, 6⟩]⟩ + +def entry_359 : Entry := ⟨359, [⟨134, 0, 4, 6⟩, ⟨24, 7, 3, 2⟩, ⟨323, 0, 5, 5⟩]⟩ + +def entry_360 : Entry := ⟨360, [⟨155, 4, 4, 5⟩, ⟨7, 3, 3, 4⟩, ⟨337, 0, 5, 2⟩, ⟨228, 4, 5, 2⟩]⟩ + +def entry_361 : Entry := ⟨361, [⟨6, 4, 3, 4⟩, ⟨352, 0, 4, 5⟩]⟩ + +def entry_362 : Entry := ⟨362, [⟨4, 0, 3, 4⟩, ⟨345, 0, 4, 3⟩]⟩ + +def entry_363 : Entry := ⟨363, [⟨137, 1, 4, 2⟩, ⟨248, 0, 2, 4⟩]⟩ + +def entry_364 : Entry := ⟨364, [⟨63, 0, 3, 5⟩, ⟨314, 2, 3, 1⟩]⟩ + +def entry_365 : Entry := ⟨365, [⟨6, 1, 4, 5⟩, ⟨354, 0, 4, 3⟩]⟩ + +def entry_366 : Entry := ⟨366, [⟨6, 3, 4, 5⟩, ⟨357, 0, 6, 2⟩]⟩ + +def entry_367 : Entry := ⟨367, [⟨6, 2, 5, 4⟩, ⟨361, 4, 4, 6⟩]⟩ + +def entry_368 : Entry := ⟨368, [⟨6, 1, 4, 5⟩, ⟨366, 0, 2, 4⟩]⟩ + +def entry_369 : Entry := ⟨369, [⟨6, 0, 5, 4⟩, ⟨367, 4, 1, 2⟩]⟩ + +def entry_370 : Entry := ⟨370, [⟨199, 3, 1, 4⟩, ⟨286, 1, 5, 4⟩, ⟨24, 6, 1, 3⟩, ⟨319, 0, 5, 3⟩]⟩ + +def entry_371 : Entry := ⟨371, [⟨267, 6, 2, 4⟩, ⟨137, 1, 4, 2⟩]⟩ + +def entry_372 : Entry := ⟨372, [⟨40, 1, 4, 3⟩, ⟨333, 0, 2, 4⟩, ⟨120, 1, 3, 3⟩, ⟨161, 0, 4, 2⟩]⟩ + +def entry_373 : Entry := ⟨373, [⟨156, 2, 7, 4⟩, ⟨226, 4, 3, 5⟩, ⟨80, 0, 5, 4⟩, ⟨327, 0, 5, 5⟩, ⟨156, 6, 3, 4⟩]⟩ + +def entry_374 : Entry := ⟨374, [⟨65, 4, 3, 4⟩, ⟨335, 0, 7, 4⟩, ⟨24, 2, 7, 3⟩, ⟨163, 4, 3, 4⟩]⟩ + +def entry_375 : Entry := ⟨375, [⟨24, 3, 3, 6⟩, ⟨327, 6, 3, 3⟩]⟩ + +def entry_376 : Entry := ⟨376, [⟨162, 1, 5, 4⟩, ⟨285, 3, 1, 3⟩]⟩ + +def entry_377 : Entry := ⟨377, [⟨29, 3, 3, 0⟩, ⟨362, 0, 7, 2⟩]⟩ + +def entry_378 : Entry := ⟨378, [⟨295, 0, 5, 4⟩, ⟨176, 4, 1, 4⟩, ⟨183, 4, 1, 4⟩, ⟨172, 6, 1, 4⟩, ⟨294, 4, 1, 4⟩]⟩ + +def entry_379 : Entry := ⟨379, [⟨63, 0, 3, 5⟩, ⟨64, 1, 3, 1⟩, ⟨55, 3, 4, 5⟩, ⟨368, 0, 5, 4⟩]⟩ + +def entry_380 : Entry := ⟨380, [⟨101, 4, 2, 5⟩, ⟨271, 0, 2, 5⟩, ⟨223, 0, 5, 4⟩, ⟨192, 3, 1, 4⟩]⟩ + +def entry_381 : Entry := ⟨381, [⟨211, 6, 3, 4⟩, ⟨24, 0, 7, 5⟩, ⟨163, 4, 3, 4⟩, ⟨341, 0, 7, 4⟩]⟩ + +def entry_382 : Entry := ⟨382, [⟨124, 1, 5, 3⟩, ⟨2, 7, 4, 3⟩]⟩ + +def entry_383 : Entry := ⟨383, [⟨192, 3, 2, 4⟩, ⟨271, 0, 3, 5⟩, ⟨197, 0, 6, 4⟩, ⟨172, 0, 6, 4⟩, ⟨215, 4, 3, 5⟩]⟩ + +def entry_384 : Entry := ⟨384, [⟨173, 2, 6, 4⟩, ⟨282, 4, 2, 4⟩, ⟨220, 2, 6, 4⟩, ⟨246, 2, 6, 4⟩, ⟨263, 2, 6, 4⟩, ⟨183, 6, 2, 4⟩, ⟨295, 0, 6, 4⟩]⟩ + +def entry_385 : Entry := ⟨385, [⟨63, 1, 5, 3⟩, ⟨64, 2, 1, 5⟩, ⟨55, 0, 5, 4⟩, ⟨369, 4, 1, 5⟩]⟩ + +def entry_386 : Entry := ⟨386, [⟨217, 4, 1, 4⟩, ⟨172, 0, 5, 4⟩, ⟨173, 4, 1, 4⟩, ⟨217, 0, 5, 4⟩, ⟨294, 0, 5, 4⟩, ⟨294, 4, 1, 4⟩]⟩ + +def entry_387 : Entry := ⟨387, [⟨14, 1, 4, 6⟩, ⟨370, 0, 5, 4⟩]⟩ + +def entry_388 : Entry := ⟨388, [⟨6, 3, 4, 5⟩, ⟨374, 0, 3, 4⟩]⟩ + +def entry_389 : Entry := ⟨389, [⟨197, 5, 4, 1⟩, ⟨215, 7, 3, 2⟩, ⟨271, 3, 3, 2⟩, ⟨236, 0, 5, 5⟩, ⟨192, 6, 4, 1⟩]⟩ + +def entry_390 : Entry := ⟨390, [⟨372, 2, 5, 0⟩, ⟨167, 5, 4, 1⟩, ⟨12, 7, 3, 1⟩]⟩ + +def entry_391 : Entry := ⟨391, [⟨6, 5, 5, 1⟩, ⟨388, 0, 3, 5⟩]⟩ + +def entry_392 : Entry := ⟨392, [⟨24, 7, 3, 1⟩, ⟨107, 1, 4, 5⟩, ⟨236, 0, 5, 5⟩, ⟨364, 2, 4, 1⟩]⟩ + +def entry_393 : Entry := ⟨393, [⟨107, 3, 4, 5⟩, ⟨348, 0, 6, 3⟩, ⟨65, 3, 4, 5⟩, ⟨303, 0, 4, 5⟩]⟩ + +def entry_394 : Entry := ⟨394, [⟨226, 4, 1, 4⟩, ⟨226, 0, 5, 4⟩, ⟨327, 4, 3, 4⟩, ⟨327, 6, 3, 3⟩, ⟨226, 6, 1, 3⟩, ⟨226, 2, 5, 3⟩]⟩ + +def entry_395 : Entry := ⟨395, [⟨211, 4, 2, 4⟩, ⟨376, 0, 6, 4⟩, ⟨24, 2, 6, 3⟩, ⟨236, 3, 2, 5⟩]⟩ + +def entry_396 : Entry := ⟨396, [⟨107, 3, 4, 5⟩, ⟨365, 1, 7, 3⟩, ⟨303, 0, 4, 5⟩, ⟨65, 3, 4, 5⟩]⟩ + +def entry_397 : Entry := ⟨397, [⟨24, 3, 4, 5⟩, ⟨374, 0, 3, 4⟩, ⟨65, 5, 5, 1⟩]⟩ + +def entry_398 : Entry := ⟨398, [⟨257, 0, 1, 3⟩, ⟨363, 0, 5, 4⟩, ⟨130, 1, 4, 2⟩, ⟨177, 1, 4, 2⟩]⟩ + +def entry_399 : Entry := ⟨399, [⟨192, 6, 4, 1⟩, ⟨271, 3, 3, 2⟩, ⟨173, 1, 4, 5⟩, ⟨319, 1, 3, 5⟩, ⟨215, 7, 3, 2⟩]⟩ + +def entry_400 : Entry := ⟨400, [⟨283, 4, 2, 4⟩, ⟨252, 4, 2, 4⟩, ⟨176, 4, 2, 4⟩, ⟨197, 0, 6, 4⟩, ⟨283, 0, 6, 4⟩, ⟨245, 4, 2, 4⟩]⟩ + +def entry_401 : Entry := ⟨401, [⟨24, 7, 3, 2⟩, ⟨286, 0, 4, 6⟩, ⟨364, 2, 4, 2⟩, ⟨319, 1, 3, 6⟩]⟩ + +def entry_402 : Entry := ⟨402, [⟨29, 3, 3, 0⟩, ⟨384, 0, 5, 4⟩]⟩ + +def entry_403 : Entry := ⟨403, [⟨202, 1, 4, 5⟩, ⟨180, 0, 4, 5⟩, ⟨314, 4, 5, 4⟩, ⟨63, 0, 3, 5⟩, ⟨388, 0, 3, 4⟩]⟩ + +def entry_404 : Entry := ⟨404, [⟨82, 6, 2, 3⟩, ⟨388, 4, 4, 6⟩]⟩ + +def entry_405 : Entry := ⟨405, [⟨391, 0, 4, 3⟩, ⟨301, 0, 5, 2⟩, ⟨42, 1, 4, 3⟩]⟩ + +def entry_406 : Entry := ⟨406, [⟨295, 1, 4, 5⟩, ⟨172, 7, 4, 1⟩, ⟨245, 3, 4, 5⟩, ⟨197, 5, 4, 1⟩, ⟨236, 0, 5, 5⟩, ⟨176, 3, 4, 5⟩, ⟨364, 2, 4, 1⟩]⟩ + +def entry_407 : Entry := ⟨407, [⟨285, 0, 3, 7⟩, ⟨314, 6, 5, 4⟩]⟩ + +def entry_408 : Entry := ⟨408, [⟨357, 0, 5, 2⟩, ⟨229, 7, 2, 4⟩, ⟨223, 4, 2, 4⟩, ⟨223, 0, 6, 4⟩]⟩ + +def entry_409 : Entry := ⟨409, [⟨136, 6, 4, 3⟩, ⟨384, 0, 5, 4⟩, ⟨133, 4, 4, 3⟩, ⟨110, 3, 4, 3⟩]⟩ + +def entry_410 : Entry := ⟨410, [⟨0, 4, 5, 4⟩, ⟨405, 0, 3, 7⟩]⟩ + +def entry_411 : Entry := ⟨411, [⟨252, 0, 7, 4⟩, ⟨263, 0, 7, 4⟩, ⟨300, 3, 3, 4⟩, ⟨379, 1, 7, 4⟩, ⟨173, 0, 7, 4⟩, ⟨246, 0, 7, 4⟩]⟩ + +def entry_412 : Entry := ⟨412, [⟨0, 0, 0, 3⟩, ⟨403, 4, 3, 6⟩]⟩ + +def entry_413 : Entry := ⟨413, [⟨3, 7, 4, 3⟩, ⟨403, 0, 4, 7⟩]⟩ + +def entry_414 : Entry := ⟨414, [⟨374, 0, 2, 5⟩, ⟨199, 2, 4, 2⟩, ⟨185, 2, 4, 2⟩]⟩ + +def entry_415 : Entry := ⟨415, [⟨177, 1, 4, 2⟩, ⟨164, 1, 4, 2⟩, ⟨205, 1, 5, 2⟩, ⟨384, 0, 3, 4⟩, ⟨371, 0, 5, 4⟩]⟩ + +def entry_416 : Entry := ⟨416, [⟨176, 2, 5, 4⟩, ⟨385, 4, 1, 4⟩, ⟨197, 4, 1, 4⟩, ⟨295, 0, 5, 4⟩, ⟨245, 2, 5, 4⟩, ⟨220, 2, 5, 4⟩]⟩ + +def entry_417 : Entry := ⟨417, [⟨409, 0, 2, 4⟩, ⟨11, 1, 4, 2⟩, ⟨270, 4, 4, 2⟩]⟩ + +def entry_418 : Entry := ⟨418, [⟨68, 4, 1, 3⟩, ⟨62, 6, 1, 3⟩, ⟨147, 6, 1, 3⟩, ⟨413, 0, 4, 2⟩]⟩ + +def entry_419 : Entry := ⟨419, [⟨243, 0, 4, 2⟩, ⟨164, 1, 4, 2⟩, ⟨402, 0, 2, 4⟩, ⟨253, 0, 2, 4⟩, ⟨377, 0, 2, 4⟩]⟩ + +def entry_420 : Entry := ⟨420, [⟨29, 3, 3, 0⟩, ⟨415, 0, 6, 4⟩]⟩ + +def entry_421 : Entry := ⟨421, [⟨24, 6, 2, 3⟩, ⟨397, 1, 5, 3⟩, ⟨25, 6, 2, 3⟩, ⟨241, 4, 2, 4⟩]⟩ + +def entry_422 : Entry := ⟨422, [⟨45, 1, 3, 7⟩, ⟨106, 6, 2, 3⟩, ⟨419, 1, 6, 6⟩]⟩ + +def entry_423 : Entry := ⟨423, [⟨378, 4, 2, 4⟩, ⟨386, 0, 5, 4⟩, ⟨226, 3, 3, 5⟩, ⟨386, 4, 2, 4⟩, ⟨378, 0, 5, 4⟩]⟩ + +def entry_424 : Entry := ⟨424, [⟨55, 1, 4, 5⟩, ⟨394, 0, 6, 4⟩, ⟨216, 3, 4, 5⟩]⟩ + +def entry_425 : Entry := ⟨425, [⟨386, 0, 5, 4⟩, ⟨226, 1, 4, 5⟩, ⟨378, 4, 2, 4⟩, ⟨378, 0, 5, 4⟩, ⟨386, 4, 2, 4⟩]⟩ + +def entry_426 : Entry := ⟨426, [⟨300, 6, 4, 1⟩, ⟨252, 1, 4, 5⟩, ⟨397, 0, 3, 4⟩, ⟨291, 1, 4, 1⟩, ⟨328, 0, 4, 5⟩, ⟨319, 1, 3, 5⟩]⟩ + +def entry_427 : Entry := ⟨427, [⟨45, 1, 3, 7⟩, ⟨106, 6, 2, 3⟩, ⟨420, 1, 6, 4⟩]⟩ + +def entry_428 : Entry := ⟨428, [⟨26, 3, 4, 3⟩, ⟨416, 0, 5, 4⟩, ⟨244, 0, 5, 4⟩, ⟨329, 0, 4, 3⟩]⟩ + +def entry_429 : Entry := ⟨429, [⟨128, 0, 6, 3⟩, ⟨28, 3, 4, 5⟩]⟩ + +def entry_430 : Entry := ⟨430, [⟨277, 7, 1, 3⟩, ⟨338, 4, 3, 4⟩, ⟨336, 1, 4, 3⟩, ⟨375, 2, 4, 3⟩, ⟨277, 6, 3, 1⟩]⟩ + +def entry_431 : Entry := ⟨431, [⟨73, 4, 3, 3⟩, ⟨302, 1, 5, 2⟩, ⟨415, 0, 6, 4⟩, ⟨398, 0, 6, 4⟩]⟩ + +def entry_432 : Entry := ⟨432, [⟨42, 3, 4, 3⟩, ⟨428, 0, 5, 4⟩, ⟨274, 0, 4, 3⟩]⟩ + +def entry_433 : Entry := ⟨433, [⟨63, 0, 3, 5⟩, ⟨7, 3, 3, 4⟩, ⟨427, 0, 5, 2⟩, ⟨422, 0, 5, 2⟩]⟩ + +def entry_434 : Entry := ⟨434, [⟨418, 0, 4, 5⟩, ⟨263, 2, 5, 4⟩, ⟨295, 0, 5, 4⟩, ⟨176, 2, 5, 4⟩, ⟨116, 0, 4, 3⟩]⟩ + +def entry_435 : Entry := ⟨435, [⟨6, 4, 3, 4⟩, ⟨431, 0, 5, 6⟩]⟩ + +def entry_436 : Entry := ⟨436, [⟨51, 1, 5, 4⟩, ⟨60, 3, 4, 3⟩, ⟨274, 4, 4, 3⟩, ⟨428, 0, 5, 4⟩]⟩ + +def entry_437 : Entry := ⟨437, [⟨55, 7, 4, 0⟩, ⟨427, 0, 5, 2⟩, ⟨63, 0, 3, 5⟩, ⟨422, 0, 5, 2⟩]⟩ + +def entry_438 : Entry := ⟨438, [⟨0, 0, 1, 3⟩, ⟨432, 0, 4, 6⟩]⟩ + +def entry_439 : Entry := ⟨439, [⟨176, 2, 5, 4⟩, ⟨295, 0, 5, 4⟩, ⟨263, 2, 5, 4⟩, ⟨418, 0, 4, 5⟩, ⟨149, 0, 4, 3⟩]⟩ + +def entry_440 : Entry := ⟨440, [⟨6, 6, 1, 3⟩, ⟨435, 0, 2, 5⟩]⟩ + +def entry_441 : Entry := ⟨441, [⟨6, 6, 3, 4⟩, ⟨435, 0, 4, 6⟩]⟩ + +def entry_442 : Entry := ⟨442, [⟨63, 0, 3, 5⟩, ⟨7, 1, 5, 4⟩, ⟨433, 0, 4, 5⟩, ⟨201, 0, 3, 2⟩]⟩ + +def entry_443 : Entry := ⟨443, [⟨6, 0, 5, 4⟩, ⟨438, 0, 3, 4⟩]⟩ + +def entry_444 : Entry := ⟨444, [⟨194, 0, 5, 3⟩, ⟨160, 3, 4, 1⟩, ⟨142, 7, 4, 1⟩, ⟨236, 0, 5, 5⟩, ⟨353, 4, 1, 2⟩, ⟨412, 0, 5, 3⟩]⟩ + +def entry_445 : Entry := ⟨445, [⟨9, 4, 3, 4⟩, ⟨432, 0, 5, 7⟩]⟩ + +def entry_446 : Entry := ⟨446, [⟨4, 6, 4, 3⟩, ⟨438, 0, 6, 5⟩]⟩ + +def entry_447 : Entry := ⟨447, [⟨0, 0, 0, 3⟩, ⟨436, 4, 4, 6⟩]⟩ + +def entry_448 : Entry := ⟨448, [⟨9, 4, 1, 3⟩, ⟨436, 0, 3, 6⟩]⟩ + +def entry_449 : Entry := ⟨449, [⟨26, 3, 4, 3⟩, ⟨244, 0, 5, 4⟩, ⟨439, 0, 5, 4⟩, ⟨307, 0, 4, 3⟩]⟩ + +def entry_450 : Entry := ⟨450, [⟨6, 1, 5, 5⟩, ⟨440, 0, 6, 4⟩]⟩ + +def entry_451 : Entry := ⟨451, [⟨1, 5, 4, 3⟩, ⟨449, 0, 5, 4⟩]⟩ + +def entry_452 : Entry := ⟨452, [⟨24, 1, 5, 7⟩, ⟨451, 0, 3, 8⟩, ⟨25, 3, 3, 7⟩]⟩ + +def entry_453 : Entry := ⟨453, [⟨359, 0, 4, 3⟩, ⟨226, 7, 3, 1⟩, ⟨386, 4, 2, 4⟩, ⟨389, 1, 5, 4⟩, ⟨414, 4, 3, 3⟩]⟩ + +def entry_454 : Entry := ⟨454, [⟨58, 0, 6, 3⟩, ⟨436, 0, 3, 6⟩]⟩ + +def entry_455 : Entry := ⟨455, [⟨20, 2, 4, 5⟩, ⟨118, 3, 0, 5⟩, ⟨39, 2, 3, 4⟩]⟩ + +def entry_456 : Entry := ⟨456, [⟨308, 4, 4, 3⟩, ⟨64, 2, 1, 5⟩, ⟨63, 1, 5, 3⟩, ⟨55, 0, 5, 4⟩]⟩ + +def entry_457 : Entry := ⟨457, [⟨28, 7, 3, 2⟩, ⟨454, 0, 5, 4⟩]⟩ + +def entry_458 : Entry := ⟨458, [⟨130, 1, 4, 2⟩, ⟨177, 1, 4, 2⟩, ⟨450, 0, 1, 4⟩]⟩ + +def entry_459 : Entry := ⟨459, [⟨97, 2, 7, 3⟩, ⟨448, 0, 5, 4⟩, ⟨65, 2, 7, 3⟩]⟩ + +def entry_460 : Entry := ⟨460, [⟨183, 6, 1, 4⟩, ⟨173, 2, 5, 4⟩, ⟨295, 0, 5, 4⟩, ⟨282, 4, 1, 4⟩, ⟨246, 2, 5, 4⟩, ⟨263, 2, 5, 4⟩, ⟨220, 2, 5, 4⟩]⟩ + +def entry_461 : Entry := ⟨461, [⟨4, 1, 4, 3⟩, ⟨458, 0, 6, 4⟩]⟩ + +def entry_462 : Entry := ⟨462, [⟨452, 0, 3, 2⟩, ⟨86, 0, 5, 4⟩, ⟨328, 1, 5, 4⟩]⟩ + +def entry_463 : Entry := ⟨463, [⟨170, 0, 6, 3⟩, ⟨76, 1, 3, 2⟩, ⟨447, 0, 5, 4⟩]⟩ + +def entry_464 : Entry := ⟨464, [⟨63, 0, 3, 5⟩, ⟨224, 0, 5, 4⟩, ⟨315, 0, 7, 3⟩, ⟨306, 0, 5, 5⟩, ⟨358, 0, 7, 3⟩, ⟨461, 0, 5, 5⟩]⟩ + +def entry_465 : Entry := ⟨465, [⟨55, 3, 4, 5⟩, ⟨285, 0, 3, 4⟩, ⟨64, 1, 3, 1⟩]⟩ + +def entry_466 : Entry := ⟨466, [⟨395, 4, 3, 4⟩, ⟨360, 4, 2, 6⟩, ⟨417, 1, 5, 4⟩, ⟨325, 4, 3, 4⟩, ⟨324, 4, 3, 5⟩]⟩ + +def entry_467 : Entry := ⟨467, [⟨64, 7, 5, 7⟩, ⟨314, 6, 5, 4⟩, ⟨443, 1, 5, 7⟩]⟩ + +def entry_468 : Entry := ⟨468, [⟨6, 6, 3, 4⟩, ⟨464, 0, 4, 7⟩]⟩ + +def entry_469 : Entry := ⟨469, [⟨55, 5, 4, 3⟩, ⟨443, 1, 5, 7⟩, ⟨314, 6, 5, 4⟩]⟩ + +def entry_470 : Entry := ⟨470, [⟨6, 4, 3, 4⟩, ⟨468, 0, 4, 2⟩]⟩ + +def entry_471 : Entry := ⟨471, [⟨6, 5, 4, 3⟩, ⟨466, 0, 5, 6⟩]⟩ + +def entry_472 : Entry := ⟨472, [⟨6, 5, 5, 0⟩, ⟨466, 0, 6, 3⟩]⟩ + +def entry_473 : Entry := ⟨473, [⟨121, 5, 5, 4⟩, ⟨436, 0, 3, 7⟩, ⟨445, 4, 5, 4⟩]⟩ + +def entry_474 : Entry := ⟨474, [⟨463, 0, 6, 5⟩, ⟨70, 0, 3, 5⟩, ⟨83, 1, 5, 3⟩]⟩ + +def entry_475 : Entry := ⟨475, [⟨63, 1, 5, 3⟩, ⟨261, 1, 4, 3⟩, ⟨457, 0, 2, 5⟩, ⟨269, 2, 2, 5⟩]⟩ + +def entry_476 : Entry := ⟨476, [⟨0, 0, 1, 3⟩, ⟨473, 0, 5, 3⟩]⟩ + +def entry_477 : Entry := ⟨477, [⟨55, 1, 4, 5⟩, ⟨154, 7, 4, 5⟩, ⟨154, 3, 4, 0⟩, ⟨471, 2, 5, 4⟩]⟩ + +def entry_478 : Entry := ⟨478, [⟨25, 3, 4, 5⟩, ⟨165, 2, 4, 5⟩, ⟨190, 0, 7, 4⟩]⟩ + +def entry_479 : Entry := ⟨479, [⟨55, 0, 5, 4⟩, ⟨443, 0, 4, 5⟩, ⟨443, 4, 1, 5⟩]⟩ + +def entry_480 : Entry := ⟨480, [⟨108, 1, 4, 5⟩, ⟨4, 1, 5, 4⟩]⟩ + +def entry_481 : Entry := ⟨481, [⟨303, 1, 5, 4⟩, ⟨429, 2, 1, 4⟩, ⟨309, 1, 1, 4⟩, ⟨206, 2, 1, 4⟩, ⟨169, 2, 1, 4⟩, ⟨207, 2, 1, 4⟩]⟩ + +def entry_482 : Entry := ⟨482, [⟨6, 1, 4, 5⟩, ⟨218, 2, 4, 3⟩]⟩ + +def entry_483 : Entry := ⟨483, [⟨173, 1, 4, 5⟩, ⟨292, 7, 3, 1⟩, ⟨319, 1, 3, 5⟩, ⟨192, 6, 4, 1⟩, ⟨475, 1, 4, 5⟩]⟩ + +def entry_484 : Entry := ⟨484, [⟨25, 4, 1, 5⟩, ⟨107, 2, 5, 4⟩, ⟨349, 3, 1, 5⟩, ⟨163, 2, 5, 4⟩]⟩ + +def entry_485 : Entry := ⟨485, [⟨484, 0, 5, 4⟩, ⟨2, 3, 4, 3⟩]⟩ + +def entry_486 : Entry := ⟨486, [⟨2, 5, 4, 2⟩, ⟨485, 0, 5, 3⟩]⟩ + +def entry_487 : Entry := ⟨487, [⟨2, 3, 4, 3⟩, ⟨481, 0, 5, 4⟩]⟩ + +def entry_488 : Entry := ⟨488, [⟨0, 6, 6, 4⟩, ⟨247, 0, 2, 5⟩]⟩ + +def entry_489 : Entry := ⟨489, [⟨356, 1, 3, 3⟩, ⟨197, 4, 1, 4⟩, ⟨172, 6, 1, 4⟩]⟩ + +def entry_490 : Entry := ⟨490, [⟨64, 1, 3, 1⟩, ⟨471, 0, 5, 1⟩, ⟨470, 1, 5, 1⟩, ⟨111, 0, 3, 1⟩]⟩ + +def entry_491 : Entry := ⟨491, [⟨6, 3, 3, 5⟩, ⟨273, 0, 5, 4⟩]⟩ + +def entry_492 : Entry := ⟨492, [⟨62, 4, 3, 4⟩, ⟨107, 4, 3, 4⟩, ⟨487, 0, 6, 6⟩]⟩ + +def entry_493 : Entry := ⟨493, [⟨225, 0, 1, 4⟩, ⟨455, 0, 5, 3⟩, ⟨236, 1, 5, 5⟩, ⟨221, 0, 5, 4⟩]⟩ + +def entry_494 : Entry := ⟨494, [⟨297, 4, 4, 5⟩, ⟨268, 4, 1, 5⟩, ⟨162, 5, 5, 4⟩]⟩ + +def entry_495 : Entry := ⟨495, [⟨25, 6, 1, 3⟩, ⟨167, 4, 1, 4⟩, ⟨456, 4, 1, 4⟩]⟩ + +def entry_496 : Entry := ⟨496, [⟨25, 0, 7, 5⟩, ⟨107, 6, 3, 4⟩, ⟨163, 6, 3, 4⟩, ⟨494, 0, 7, 4⟩]⟩ + +def entry_497 : Entry := ⟨497, [⟨36, 2, 3, 4⟩, ⟨167, 0, 7, 4⟩, ⟨410, 0, 7, 3⟩]⟩ + +def entry_498 : Entry := ⟨498, [⟨14, 1, 4, 6⟩, ⟨298, 2, 2, 4⟩]⟩ + +def entry_499 : Entry := ⟨499, [⟨493, 0, 5, 4⟩, ⟨25, 1, 4, 5⟩, ⟨478, 0, 2, 4⟩]⟩ + +def entry_500 : Entry := ⟨500, [⟨1, 5, 3, 6⟩, ⟨351, 0, 5, 4⟩]⟩ + +def entry_501 : Entry := ⟨501, [⟨6, 4, 0, 5⟩, ⟨316, 0, 1, 3⟩]⟩ + +def entry_502 : Entry := ⟨502, [⟨215, 6, 2, 3⟩, ⟨232, 0, 4, 3⟩, ⟨192, 7, 1, 4⟩, ⟨173, 0, 5, 4⟩, ⟨271, 2, 2, 3⟩]⟩ + +def entry_503 : Entry := ⟨503, [⟨63, 0, 3, 5⟩, ⟨55, 7, 4, 0⟩, ⟨420, 1, 7, 2⟩, ⟨419, 1, 7, 4⟩]⟩ + +def entry_504 : Entry := ⟨504, [⟨381, 0, 3, 4⟩, ⟨310, 4, 4, 5⟩, ⟨159, 0, 5, 6⟩, ⟨351, 4, 3, 4⟩, ⟨496, 0, 3, 4⟩]⟩ + +def entry_505 : Entry := ⟨505, [⟨173, 1, 4, 5⟩, ⟨499, 0, 5, 4⟩, ⟨183, 1, 4, 5⟩, ⟨282, 1, 4, 5⟩]⟩ + +def entry_506 : Entry := ⟨506, [⟨99, 0, 4, 5⟩, ⟨200, 7, 1, 4⟩, ⟨318, 5, 5, 4⟩, ⟨173, 0, 5, 4⟩]⟩ + +def entry_507 : Entry := ⟨507, [⟨151, 0, 2, 4⟩, ⟨33, 3, 4, 3⟩, ⟨481, 0, 5, 4⟩]⟩ + +def entry_508 : Entry := ⟨508, [⟨6, 0, 5, 4⟩, ⟨393, 0, 1, 5⟩]⟩ + +def entry_509 : Entry := ⟨509, [⟨252, 0, 6, 4⟩, ⟨241, 4, 2, 4⟩, ⟨455, 0, 6, 3⟩, ⟨68, 2, 6, 4⟩]⟩ + +def entry_510 : Entry := ⟨510, [⟨6, 4, 3, 4⟩, ⟨508, 0, 7, 4⟩]⟩ + +def entry_511 : Entry := ⟨511, [⟨15, 1, 4, 5⟩, ⟨331, 0, 5, 3⟩, ⟨380, 4, 2, 4⟩]⟩ + +def entry_512 : Entry := ⟨512, [⟨62, 0, 5, 4⟩, ⟨107, 0, 5, 4⟩, ⟨507, 0, 4, 6⟩]⟩ + +def entry_513 : Entry := ⟨513, [⟨6, 4, 3, 4⟩, ⟨396, 0, 4, 5⟩]⟩ + +def entry_514 : Entry := ⟨514, [⟨57, 0, 5, 4⟩, ⟨443, 4, 1, 5⟩, ⟨510, 0, 1, 5⟩]⟩ + +def entry_515 : Entry := ⟨515, [⟨2, 6, 2, 4⟩, ⟨512, 1, 1, 5⟩]⟩ + +def entry_516 : Entry := ⟨516, [⟨329, 0, 4, 3⟩, ⟨244, 4, 2, 4⟩, ⟨10, 1, 4, 5⟩, ⟨506, 4, 2, 4⟩]⟩ + +def entry_517 : Entry := ⟨517, [⟨496, 0, 2, 3⟩, ⟨140, 0, 4, 2⟩, ⟨193, 1, 4, 2⟩]⟩ + +def entry_518 : Entry := ⟨518, [⟨9, 6, 3, 4⟩, ⟨514, 0, 7, 4⟩]⟩ + +def entry_519 : Entry := ⟨519, [⟨498, 0, 4, 3⟩, ⟨311, 4, 3, 4⟩, ⟨38, 1, 4, 5⟩, ⟨408, 0, 3, 4⟩]⟩ + +def entry_520 : Entry := ⟨520, [⟨254, 0, 2, 3⟩, ⟨200, 5, 6, 4⟩, ⟨271, 6, 5, 3⟩, ⟨215, 2, 5, 3⟩, ⟨252, 4, 2, 4⟩]⟩ + +def entry_521 : Entry := ⟨521, [⟨492, 4, 5, 1⟩, ⟨2, 7, 4, 2⟩]⟩ + +def entry_522 : Entry := ⟨522, [⟨176, 3, 4, 6⟩, ⟨338, 2, 3, 3⟩, ⟨252, 1, 4, 6⟩]⟩ + +def entry_523 : Entry := ⟨523, [⟨303, 1, 5, 4⟩, ⟨25, 4, 1, 5⟩, ⟨107, 2, 5, 4⟩, ⟨511, 4, 1, 6⟩]⟩ + +def entry_524 : Entry := ⟨524, [⟨504, 4, 5, 3⟩, ⟨504, 0, 3, 3⟩, ⟨180, 0, 4, 5⟩, ⟨180, 4, 4, 5⟩, ⟨261, 0, 3, 4⟩]⟩ + +def entry_525 : Entry := ⟨525, [⟨303, 1, 5, 4⟩, ⟨25, 4, 1, 5⟩, ⟨430, 0, 4, 6⟩, ⟨107, 2, 5, 4⟩]⟩ + +def entry_526 : Entry := ⟨526, [⟨359, 0, 4, 3⟩, ⟨416, 4, 2, 4⟩, ⟨327, 5, 4, 3⟩, ⟨489, 0, 5, 4⟩, ⟨399, 3, 2, 4⟩]⟩ + +def entry_527 : Entry := ⟨527, [⟨387, 4, 4, 3⟩, ⟨38, 3, 4, 5⟩, ⟨491, 0, 5, 4⟩, ⟨519, 0, 6, 4⟩]⟩ + +def entry_528 : Entry := ⟨528, [⟨414, 1, 3, 5⟩, ⟨386, 1, 4, 6⟩, ⟨502, 5, 4, 3⟩, ⟨226, 4, 1, 5⟩, ⟨359, 5, 3, 4⟩]⟩ + +def entry_529 : Entry := ⟨529, [⟨55, 4, 3, 4⟩, ⟨441, 0, 4, 3⟩, ⟨63, 3, 3, 3⟩, ⟨64, 6, 7, 5⟩]⟩ + +def entry_530 : Entry := ⟨530, [⟨456, 7, 4, 2⟩, ⟨336, 0, 5, 5⟩, ⟨283, 7, 4, 2⟩, ⟨271, 5, 5, 5⟩]⟩ + +def entry_531 : Entry := ⟨531, [⟨425, 0, 5, 4⟩, ⟨336, 3, 4, 3⟩, ⟨340, 6, 4, 3⟩, ⟨394, 1, 5, 4⟩, ⟨423, 0, 5, 4⟩, ⟨526, 0, 5, 4⟩, ⟨401, 4, 4, 3⟩, ⟨453, 0, 5, 4⟩]⟩ + +def entry_532 : Entry := ⟨532, [⟨504, 4, 5, 3⟩, ⟨6, 7, 3, 0⟩]⟩ + +def entry_533 : Entry := ⟨533, [⟨318, 4, 4, 5⟩, ⟨319, 7, 5, 1⟩, ⟨407, 4, 4, 1⟩, ⟨173, 3, 4, 5⟩, ⟨217, 1, 4, 5⟩]⟩ + +def entry_534 : Entry := ⟨534, [⟨434, 0, 4, 6⟩, ⟨12, 6, 1, 3⟩]⟩ + +def entry_535 : Entry := ⟨535, [⟨444, 0, 4, 5⟩, ⟨426, 0, 4, 5⟩, ⟨25, 0, 5, 4⟩, ⟨321, 4, 4, 2⟩]⟩ + +def entry_536 : Entry := ⟨536, [⟨307, 0, 4, 3⟩, ⟨244, 0, 5, 4⟩, ⟨26, 3, 4, 3⟩, ⟨534, 0, 5, 2⟩]⟩ + +def entry_537 : Entry := ⟨537, [⟨373, 2, 2, 4⟩, ⟨271, 3, 3, 3⟩, ⟨176, 1, 4, 6⟩, ⟨330, 1, 4, 6⟩]⟩ + +def entry_538 : Entry := ⟨538, [⟨63, 3, 3, 3⟩, ⟨470, 0, 4, 5⟩, ⟨64, 6, 7, 5⟩, ⟨55, 4, 3, 4⟩]⟩ + +def entry_539 : Entry := ⟨539, [⟨51, 1, 5, 4⟩, ⟨488, 3, 4, 3⟩, ⟨428, 0, 5, 4⟩, ⟨516, 0, 5, 4⟩]⟩ + +def entry_540 : Entry := ⟨540, [⟨334, 0, 4, 3⟩, ⟨51, 1, 5, 4⟩, ⟨88, 3, 4, 3⟩, ⟨536, 0, 5, 4⟩]⟩ + +def entry_541 : Entry := ⟨541, [⟨236, 0, 5, 5⟩, ⟨142, 7, 4, 1⟩, ⟨160, 3, 4, 1⟩, ⟨194, 0, 5, 3⟩, ⟨501, 4, 1, 2⟩, ⟨412, 0, 5, 3⟩]⟩ + +def entry_542 : Entry := ⟨542, [⟨6, 5, 5, 0⟩, ⟨442, 0, 4, 5⟩]⟩ + +def entry_543 : Entry := ⟨543, [⟨493, 3, 2, 6⟩, ⟨107, 2, 5, 4⟩, ⟨318, 5, 5, 4⟩]⟩ + +def entry_544 : Entry := ⟨544, [⟨263, 2, 7, 4⟩, ⟨9, 6, 3, 4⟩, ⟨451, 1, 8, 3⟩]⟩ + +def entry_545 : Entry := ⟨545, [⟨256, 0, 4, 5⟩, ⟨448, 0, 5, 4⟩, ⟨153, 0, 6, 3⟩, ⟨343, 0, 4, 5⟩]⟩ + +def entry_546 : Entry := ⟨546, [⟨64, 0, 4, 3⟩, ⟨482, 7, 4, 3⟩, ⟨443, 0, 7, 5⟩, ⟨64, 6, 7, 5⟩]⟩ + +def entry_547 : Entry := ⟨547, [⟨443, 0, 7, 5⟩, ⟨510, 4, 7, 5⟩, ⟨131, 3, 3, 4⟩]⟩ + +def entry_548 : Entry := ⟨548, [⟨426, 0, 4, 5⟩, ⟨541, 0, 4, 5⟩, ⟨25, 0, 5, 4⟩, ⟨321, 4, 4, 2⟩]⟩ + +def entry_549 : Entry := ⟨549, [⟨385, 0, 6, 4⟩, ⟨385, 4, 2, 4⟩, ⟨330, 0, 6, 4⟩, ⟨252, 6, 2, 4⟩, ⟨326, 0, 6, 4⟩, ⟨529, 0, 2, 4⟩]⟩ + +def entry_550 : Entry := ⟨550, [⟨424, 0, 4, 6⟩, ⟨172, 7, 4, 2⟩, ⟨215, 1, 5, 5⟩, ⟨456, 7, 4, 2⟩]⟩ + +def entry_551 : Entry := ⟨551, [⟨300, 6, 4, 3⟩, ⟨172, 7, 4, 3⟩, ⟨319, 3, 5, 7⟩, ⟨527, 4, 5, 7⟩, ⟨176, 5, 4, 3⟩]⟩ + +def entry_552 : Entry := ⟨552, [⟨443, 4, 1, 5⟩, ⟨64, 2, 1, 5⟩, ⟨504, 1, 3, 3⟩, ⟨404, 5, 2, 3⟩]⟩ + +def entry_553 : Entry := ⟨553, [⟨63, 0, 3, 5⟩, ⟨261, 4, 5, 4⟩, ⟨471, 0, 5, 1⟩, ⟨442, 0, 4, 5⟩, ⟨504, 0, 3, 3⟩, ⟨180, 0, 4, 5⟩]⟩ + +def entry_554 : Entry := ⟨554, [⟨30, 6, 5, 4⟩, ⟨96, 7, 4, 5⟩, ⟨474, 0, 4, 5⟩]⟩ + +def entry_555 : Entry := ⟨555, [⟨504, 5, 3, 5⟩, ⟨513, 0, 1, 5⟩, ⟨55, 0, 5, 4⟩, ⟨443, 4, 1, 5⟩, ⟨471, 1, 1, 5⟩]⟩ + +def entry_556 : Entry := ⟨556, [⟨34, 1, 4, 2⟩, ⟨549, 0, 3, 4⟩]⟩ + +def entry_557 : Entry := ⟨557, [⟨460, 0, 5, 4⟩, ⟨460, 4, 2, 4⟩, ⟨460, 2, 5, 4⟩, ⟨411, 4, 5, 4⟩, ⟨531, 0, 3, 6⟩, ⟨531, 4, 4, 6⟩, ⟨406, 5, 5, 4⟩]⟩ + +def entry_558 : Entry := ⟨558, [⟨180, 5, 5, 4⟩, ⟨443, 4, 1, 5⟩, ⟨513, 0, 1, 5⟩, ⟨442, 1, 5, 4⟩]⟩ + +def entry_559 : Entry := ⟨559, [⟨228, 4, 5, 2⟩, ⟨7, 3, 3, 4⟩, ⟨155, 4, 4, 5⟩, ⟨538, 5, 4, 5⟩]⟩ + +def entry_560 : Entry := ⟨560, [⟨517, 5, 5, 4⟩, ⟨416, 5, 4, 3⟩, ⟨359, 5, 3, 4⟩, ⟨356, 6, 3, 4⟩, ⟨483, 0, 4, 6⟩]⟩ + +def entry_561 : Entry := ⟨561, [⟨295, 0, 5, 4⟩, ⟨173, 2, 5, 4⟩, ⟨263, 6, 1, 4⟩, ⟨236, 1, 5, 5⟩, ⟨546, 4, 5, 4⟩, ⟨176, 2, 5, 4⟩, ⟨535, 0, 4, 5⟩]⟩ + +def entry_562 : Entry := ⟨562, [⟨6, 7, 3, 0⟩, ⟨559, 0, 4, 5⟩]⟩ + +def entry_563 : Entry := ⟨563, [⟨167, 0, 7, 4⟩, ⟨538, 0, 3, 4⟩, ⟨514, 0, 7, 4⟩, ⟨330, 4, 3, 4⟩, ⟨545, 0, 5, 5⟩]⟩ + +def entry_564 : Entry := ⟨564, [⟨560, 0, 4, 3⟩, ⟨421, 0, 3, 4⟩, ⟨401, 1, 3, 4⟩, ⟨340, 3, 3, 4⟩, ⟨509, 0, 3, 4⟩, ⟨528, 0, 4, 3⟩, ⟨423, 5, 4, 3⟩, ⟨425, 5, 4, 3⟩, ⟨336, 0, 3, 4⟩]⟩ + +def entry_565 : Entry := ⟨565, [⟨443, 4, 4, 5⟩, ⟨131, 3, 3, 4⟩, ⟨538, 0, 3, 4⟩, ⟨459, 0, 5, 5⟩, ⟨144, 4, 3, 4⟩]⟩ + +def entry_566 : Entry := ⟨566, [⟨314, 0, 3, 4⟩, ⟨180, 0, 4, 5⟩, ⟨442, 0, 4, 5⟩, ⟨466, 0, 6, 3⟩, ⟨504, 0, 3, 3⟩]⟩ + +def entry_567 : Entry := ⟨567, [⟨21, 1, 4, 3⟩, ⟨561, 0, 6, 4⟩, ⟨500, 4, 3, 1⟩]⟩ + +def entry_568 : Entry := ⟨568, [⟨538, 4, 6, 4⟩, ⟨547, 0, 2, 4⟩, ⟨275, 0, 6, 4⟩, ⟨565, 0, 2, 4⟩, ⟨330, 0, 6, 4⟩]⟩ + +def entry_569 : Entry := ⟨569, [⟨34, 3, 4, 2⟩, ⟨568, 4, 5, 4⟩]⟩ + +def entry_570 : Entry := ⟨570, [⟨569, 0, 2, 5⟩, ⟨2, 7, 4, 3⟩]⟩ + +def entry_571 : Entry := ⟨571, [⟨293, 0, 4, 3⟩, ⟨570, 0, 4, 3⟩, ⟨382, 0, 4, 3⟩, ⟨556, 4, 2, 4⟩]⟩ + +def entry_572 : Entry := ⟨572, [⟨564, 1, 6, 6⟩, ⟨465, 3, 3, 4⟩, ⟨385, 4, 3, 4⟩, ⟨364, 7, 3, 4⟩, ⟨499, 1, 6, 5⟩]⟩ + +def entry_573 : Entry := ⟨573, [⟨527, 2, 3, 1⟩, ⟨499, 4, 3, 4⟩, ⟨527, 6, 5, 1⟩, ⟨499, 0, 5, 4⟩, ⟨407, 4, 4, 1⟩, ⟨531, 7, 2, 4⟩, ⟨407, 0, 4, 1⟩]⟩ + +def entry_574 : Entry := ⟨574, [⟨497, 0, 2, 4⟩, ⟨539, 4, 4, 6⟩, ⟨355, 0, 2, 4⟩, ⟨390, 3, 2, 4⟩, ⟨544, 0, 2, 4⟩, ⟨462, 1, 4, 5⟩, ⟨563, 4, 5, 4⟩, ⟨540, 4, 4, 6⟩, ⟨518, 0, 2, 4⟩, ⟨495, 4, 2, 4⟩]⟩ + +def entry_575 : Entry := ⟨575, [⟨314, 4, 5, 4⟩, ⟨504, 4, 5, 3⟩, ⟨180, 4, 4, 5⟩, ⟨442, 4, 4, 5⟩, ⟨559, 0, 4, 5⟩]⟩ + +def entry_576 : Entry := ⟨576, [⟨495, 0, 5, 4⟩, ⟨544, 4, 5, 4⟩, ⟨462, 3, 3, 5⟩, ⟨540, 0, 3, 6⟩, ⟨355, 4, 5, 4⟩, ⟨539, 0, 3, 6⟩, ⟨497, 4, 5, 4⟩, ⟨390, 1, 5, 4⟩, ⟨563, 0, 2, 4⟩, ⟨518, 4, 5, 4⟩]⟩ + +def entry_577 : Entry := ⟨577, [⟨64, 7, 5, 4⟩, ⟨64, 1, 3, 1⟩, ⟨443, 1, 5, 4⟩, ⟨443, 7, 3, 1⟩]⟩ + +def entry_578 : Entry := ⟨578, [⟨574, 4, 4, 5⟩, ⟨2, 1, 4, 3⟩]⟩ + +def entry_579 : Entry := ⟨579, [⟨2, 1, 4, 3⟩, ⟨576, 4, 4, 5⟩]⟩ + +def entry_580 : Entry := ⟨580, [⟨2, 7, 4, 2⟩, ⟨579, 0, 3, 3⟩]⟩ + +def entry_581 : Entry := ⟨581, [⟨578, 4, 5, 3⟩, ⟨2, 5, 4, 2⟩]⟩ + +def entry_582 : Entry := ⟨582, [⟨40, 3, 4, 3⟩, ⟨446, 5, 5, 3⟩, ⟨523, 0, 7, 0⟩, ⟨480, 4, 5, 3⟩, ⟨567, 4, 5, 4⟩]⟩ + +def entry_583 : Entry := ⟨583, [⟨25, 5, 4, 3⟩, ⟨525, 0, 5, 4⟩, ⟨582, 0, 2, 8⟩, ⟨221, 3, 3, 7⟩]⟩ + +def entry_584 : Entry := ⟨584, [⟨263, 1, 4, 5⟩, ⟨236, 4, 3, 5⟩, ⟨548, 3, 3, 4⟩, ⟨295, 3, 4, 5⟩, ⟨577, 0, 4, 5⟩, ⟨173, 1, 4, 5⟩]⟩ + +def entry_585 : Entry := ⟨585, [⟨236, 2, 5, 1⟩, ⟨300, 4, 4, 5⟩, ⟨479, 1, 4, 5⟩, ⟨577, 0, 4, 5⟩, ⟨183, 3, 4, 5⟩, ⟨527, 6, 5, 1⟩]⟩ + +def entry_586 : Entry := ⟨586, [⟨465, 4, 4, 5⟩, ⟨558, 1, 4, 5⟩, ⟨385, 1, 4, 5⟩, ⟨379, 4, 4, 5⟩, ⟨524, 0, 4, 5⟩, ⟨469, 2, 4, 5⟩, ⟨467, 2, 4, 5⟩, ⟨527, 4, 5, 5⟩, ⟨553, 0, 4, 5⟩, ⟨552, 1, 4, 5⟩, ⟨555, 1, 4, 5⟩, ⟨564, 0, 6, 4⟩, ⟨583, 0, 5, 2⟩]⟩ + +def entry_587 : Entry := ⟨587, [⟨300, 2, 4, 1⟩, ⟨479, 1, 4, 5⟩, ⟨319, 3, 5, 5⟩, ⟨477, 6, 4, 1⟩, ⟨252, 3, 4, 5⟩, ⟨467, 2, 4, 5⟩]⟩ + +def entry_588 : Entry := ⟨588, [⟨3, 1, 3, 3⟩, ⟨586, 0, 4, 5⟩]⟩ + +def entry_589 : Entry := ⟨589, [⟨4, 1, 4, 3⟩, ⟨588, 0, 4, 5⟩]⟩ + +def entry_590 : Entry := ⟨590, [⟨295, 7, 4, 3⟩, ⟨173, 7, 4, 3⟩, ⟨577, 0, 4, 7⟩, ⟨490, 0, 4, 7⟩, ⟨217, 5, 4, 3⟩]⟩ + +def entry_591 : Entry := ⟨591, [⟨524, 0, 4, 5⟩, ⟨529, 1, 4, 1⟩, ⟨529, 3, 4, 1⟩, ⟨538, 1, 4, 1⟩, ⟨538, 3, 4, 1⟩, ⟨197, 5, 4, 1⟩]⟩ + +def entry_592 : Entry := ⟨592, [⟨588, 0, 4, 5⟩, ⟨108, 7, 3, 0⟩]⟩ + +def entry_593 : Entry := ⟨593, [⟨2, 7, 4, 2⟩, ⟨586, 0, 4, 5⟩]⟩ + +def entry_594 : Entry := ⟨594, [⟨30, 1, 4, 3⟩, ⟨476, 1, 4, 3⟩, ⟨588, 0, 4, 5⟩]⟩ + +def entry_595 : Entry := ⟨595, [⟨460, 4, 2, 4⟩, ⟨460, 2, 5, 4⟩, ⟨586, 1, 5, 4⟩, ⟨411, 4, 5, 4⟩, ⟨551, 1, 2, 4⟩, ⟨406, 5, 5, 4⟩, ⟨572, 0, 2, 4⟩]⟩ + +def entry_596 : Entry := ⟨596, [⟨385, 5, 4, 2⟩, ⟨592, 0, 5, 6⟩, ⟨330, 1, 4, 6⟩, ⟨529, 5, 4, 6⟩, ⟨385, 1, 4, 6⟩, ⟨330, 5, 4, 2⟩]⟩ + +def entry_597 : Entry := ⟨597, [⟨24, 6, 2, 3⟩, ⟨221, 0, 6, 4⟩, ⟨199, 3, 2, 4⟩, ⟨594, 1, 6, 5⟩]⟩ + +def entry_598 : Entry := ⟨598, [⟨594, 0, 5, 6⟩, ⟨456, 5, 4, 2⟩, ⟨254, 1, 3, 2⟩, ⟨554, 1, 3, 2⟩, ⟨465, 0, 4, 6⟩]⟩ + +def entry_599 : Entry := ⟨599, [⟨578, 4, 5, 3⟩, ⟨492, 0, 3, 1⟩, ⟨512, 4, 3, 1⟩, ⟨586, 4, 4, 5⟩, ⟨485, 0, 5, 3⟩, ⟨579, 4, 5, 3⟩]⟩ + +def entry_600 : Entry := ⟨600, [⟨448, 0, 4, 5⟩, ⟨278, 2, 1, 4⟩, ⟨592, 5, 5, 3⟩, ⟨403, 5, 5, 4⟩, ⟨146, 5, 4, 3⟩]⟩ + +def entry_601 : Entry := ⟨601, [⟨437, 6, 4, 1⟩, ⟨553, 0, 4, 5⟩, ⟨592, 0, 5, 5⟩, ⟨236, 4, 3, 5⟩, ⟨469, 4, 4, 1⟩]⟩ + +def entry_602 : Entry := ⟨602, [⟨553, 0, 4, 7⟩, ⟨467, 4, 4, 3⟩, ⟨592, 0, 5, 7⟩, ⟨437, 6, 4, 3⟩, ⟨236, 4, 3, 7⟩]⟩ + +def entry_603 : Entry := ⟨603, [⟨505, 1, 5, 4⟩, ⟨505, 5, 5, 4⟩, ⟨586, 5, 5, 4⟩, ⟨551, 7, 5, 4⟩, ⟨531, 6, 4, 2⟩, ⟨586, 1, 5, 4⟩, ⟨585, 1, 5, 4⟩, ⟨585, 5, 5, 4⟩, ⟨551, 3, 5, 4⟩, ⟨573, 1, 5, 4⟩, ⟨533, 5, 5, 4⟩, ⟨533, 1, 5, 4⟩]⟩ + +def entry_604 : Entry := ⟨604, [⟨597, 0, 3, 4⟩, ⟨375, 2, 4, 3⟩, ⟨597, 1, 4, 3⟩, ⟨375, 3, 3, 4⟩, ⟨350, 3, 4, 3⟩, ⟨350, 2, 3, 4⟩]⟩ + +def entry_605 : Entry := ⟨605, [⟨400, 5, 4, 3⟩, ⟨383, 6, 3, 4⟩, ⟨530, 4, 4, 3⟩, ⟨596, 1, 3, 4⟩, ⟨522, 2, 4, 3⟩, ⟨598, 0, 4, 3⟩, ⟨537, 3, 3, 4⟩, ⟨520, 1, 4, 3⟩, ⟨550, 4, 4, 3⟩]⟩ + +def entry_606 : Entry := ⟨606, [⟨123, 1, 4, 3⟩, ⟨274, 0, 4, 3⟩, ⟨605, 0, 6, 4⟩, ⟨119, 1, 4, 3⟩]⟩ + +def entry_607 : Entry := ⟨607, [⟨420, 3, 1, 2⟩, ⟨419, 3, 1, 4⟩, ⟨589, 0, 5, 5⟩, ⟨314, 0, 3, 4⟩, ⟨571, 1, 7, 3⟩]⟩ + +def entry_608 : Entry := ⟨608, [⟨486, 4, 4, 5⟩, ⟨515, 1, 4, 5⟩, ⟨580, 0, 4, 5⟩, ⟨521, 0, 4, 5⟩, ⟨581, 4, 4, 5⟩, ⟨593, 0, 4, 5⟩, ⟨599, 4, 4, 5⟩, ⟨606, 1, 6, 2⟩]⟩ + +def entry_609 : Entry := ⟨609, [⟨286, 4, 4, 5⟩, ⟨107, 3, 4, 5⟩, ⟨532, 4, 4, 5⟩, ⟨542, 0, 4, 5⟩, ⟨221, 3, 4, 5⟩, ⟨562, 4, 4, 5⟩, ⟨575, 4, 4, 5⟩, ⟨604, 1, 6, 4⟩]⟩ + +def entry_610 : Entry := ⟨610, [⟨221, 2, 5, 4⟩, ⟨286, 5, 5, 4⟩, ⟨107, 2, 5, 4⟩, ⟨472, 1, 5, 4⟩, ⟨566, 1, 5, 4⟩, ⟨532, 5, 5, 4⟩, ⟨542, 1, 5, 4⟩, ⟨609, 0, 2, 6⟩]⟩ + +def entry_611 : Entry := ⟨611, [⟨456, 2, 5, 4⟩, ⟨456, 4, 1, 4⟩, ⟨594, 7, 1, 3⟩, ⟨594, 1, 5, 5⟩]⟩ + +def entry_612 : Entry := ⟨612, [⟨589, 1, 5, 5⟩, ⟨589, 7, 0, 3⟩]⟩ + +def entry_613 : Entry := ⟨613, [⟨607, 5, 5, 4⟩, ⟨503, 3, 1, 4⟩, ⟨592, 7, 1, 3⟩, ⟨592, 5, 5, 3⟩, ⟨607, 7, 1, 4⟩, ⟨612, 4, 1, 4⟩, ⟨612, 0, 5, 4⟩]⟩ + +def entry_614 : Entry := ⟨614, [⟨608, 1, 7, 5⟩, ⟨543, 3, 5, 6⟩, ⟨370, 6, 3, 4⟩, ⟨392, 7, 3, 4⟩, ⟨610, 3, 5, 6⟩, ⟨600, 0, 6, 4⟩, ⟨613, 0, 6, 4⟩]⟩ + +def entry_615 : Entry := ⟨615, [⟨602, 7, 6, 4⟩, ⟨614, 1, 4, 3⟩, ⟨533, 5, 6, 4⟩, ⟨590, 7, 6, 4⟩, ⟨611, 6, 3, 4⟩, ⟨587, 3, 3, 4⟩, ⟨601, 5, 6, 4⟩, ⟨406, 1, 6, 4⟩, ⟨591, 3, 3, 4⟩, ⟨586, 3, 3, 4⟩, ⟨584, 5, 6, 4⟩, ⟨406, 3, 3, 4⟩]⟩ + +def tableChunk_0 : Array Entry := #[entry_6, entry_7, entry_8, entry_9, entry_10, entry_11, entry_12, entry_13, entry_14, entry_15, entry_16, entry_17, entry_18, entry_19, entry_20, entry_21, entry_22, entry_23, entry_24, entry_25] + +def tableChunk_1 : Array Entry := #[entry_26, entry_27, entry_28, entry_29, entry_30, entry_31, entry_32, entry_33, entry_34, entry_35, entry_36, entry_37, entry_38, entry_39, entry_40, entry_41, entry_42, entry_43, entry_44, entry_45] + +def tableChunk_2 : Array Entry := #[entry_46, entry_47, entry_48, entry_49, entry_50, entry_51, entry_52, entry_53, entry_54, entry_55, entry_56, entry_57, entry_58, entry_59, entry_60, entry_61, entry_62, entry_63, entry_64, entry_65] + +def tableChunk_3 : Array Entry := #[entry_66, entry_67, entry_68, entry_69, entry_70, entry_71, entry_72, entry_73, entry_74, entry_75, entry_76, entry_77, entry_78, entry_79, entry_80, entry_81, entry_82, entry_83, entry_84, entry_85] + +def tableChunk_4 : Array Entry := #[entry_86, entry_87, entry_88, entry_89, entry_90, entry_91, entry_92, entry_93, entry_94, entry_95, entry_96, entry_97, entry_98, entry_99, entry_100, entry_101, entry_102, entry_103, entry_104, entry_105] + +def tableChunk_5 : Array Entry := #[entry_106, entry_107, entry_108, entry_109, entry_110, entry_111, entry_112, entry_113, entry_114, entry_115, entry_116, entry_117, entry_118, entry_119, entry_120, entry_121, entry_122, entry_123, entry_124, entry_125] + +def tableChunk_6 : Array Entry := #[entry_126, entry_127, entry_128, entry_129, entry_130, entry_131, entry_132, entry_133, entry_134, entry_135, entry_136, entry_137, entry_138, entry_139, entry_140, entry_141, entry_142, entry_143, entry_144, entry_145] + +def tableChunk_7 : Array Entry := #[entry_146, entry_147, entry_148, entry_149, entry_150, entry_151, entry_152, entry_153, entry_154, entry_155, entry_156, entry_157, entry_158, entry_159, entry_160, entry_161, entry_162, entry_163, entry_164, entry_165] + +def tableChunk_8 : Array Entry := #[entry_166, entry_167, entry_168, entry_169, entry_170, entry_171, entry_172, entry_173, entry_174, entry_175, entry_176, entry_177, entry_178, entry_179, entry_180, entry_181, entry_182, entry_183, entry_184, entry_185] + +def tableChunk_9 : Array Entry := #[entry_186, entry_187, entry_188, entry_189, entry_190, entry_191, entry_192, entry_193, entry_194, entry_195, entry_196, entry_197, entry_198, entry_199, entry_200, entry_201, entry_202, entry_203, entry_204, entry_205] + +def tableChunk_10 : Array Entry := #[entry_206, entry_207, entry_208, entry_209, entry_210, entry_211, entry_212, entry_213, entry_214, entry_215, entry_216, entry_217, entry_218, entry_219, entry_220, entry_221, entry_222, entry_223, entry_224, entry_225] + +def tableChunk_11 : Array Entry := #[entry_226, entry_227, entry_228, entry_229, entry_230, entry_231, entry_232, entry_233, entry_234, entry_235, entry_236, entry_237, entry_238, entry_239, entry_240, entry_241, entry_242, entry_243, entry_244, entry_245] + +def tableChunk_12 : Array Entry := #[entry_246, entry_247, entry_248, entry_249, entry_250, entry_251, entry_252, entry_253, entry_254, entry_255, entry_256, entry_257, entry_258, entry_259, entry_260, entry_261, entry_262, entry_263, entry_264, entry_265] + +def tableChunk_13 : Array Entry := #[entry_266, entry_267, entry_268, entry_269, entry_270, entry_271, entry_272, entry_273, entry_274, entry_275, entry_276, entry_277, entry_278, entry_279, entry_280, entry_281, entry_282, entry_283, entry_284, entry_285] + +def tableChunk_14 : Array Entry := #[entry_286, entry_287, entry_288, entry_289, entry_290, entry_291, entry_292, entry_293, entry_294, entry_295, entry_296, entry_297, entry_298, entry_299, entry_300, entry_301, entry_302, entry_303, entry_304, entry_305] + +def tableChunk_15 : Array Entry := #[entry_306, entry_307, entry_308, entry_309, entry_310, entry_311, entry_312, entry_313, entry_314, entry_315, entry_316, entry_317, entry_318, entry_319, entry_320, entry_321, entry_322, entry_323, entry_324, entry_325] + +def tableChunk_16 : Array Entry := #[entry_326, entry_327, entry_328, entry_329, entry_330, entry_331, entry_332, entry_333, entry_334, entry_335, entry_336, entry_337, entry_338, entry_339, entry_340, entry_341, entry_342, entry_343, entry_344, entry_345] + +def tableChunk_17 : Array Entry := #[entry_346, entry_347, entry_348, entry_349, entry_350, entry_351, entry_352, entry_353, entry_354, entry_355, entry_356, entry_357, entry_358, entry_359, entry_360, entry_361, entry_362, entry_363, entry_364, entry_365] + +def tableChunk_18 : Array Entry := #[entry_366, entry_367, entry_368, entry_369, entry_370, entry_371, entry_372, entry_373, entry_374, entry_375, entry_376, entry_377, entry_378, entry_379, entry_380, entry_381, entry_382, entry_383, entry_384, entry_385] + +def tableChunk_19 : Array Entry := #[entry_386, entry_387, entry_388, entry_389, entry_390, entry_391, entry_392, entry_393, entry_394, entry_395, entry_396, entry_397, entry_398, entry_399, entry_400, entry_401, entry_402, entry_403, entry_404, entry_405] + +def tableChunk_20 : Array Entry := #[entry_406, entry_407, entry_408, entry_409, entry_410, entry_411, entry_412, entry_413, entry_414, entry_415, entry_416, entry_417, entry_418, entry_419, entry_420, entry_421, entry_422, entry_423, entry_424, entry_425] + +def tableChunk_21 : Array Entry := #[entry_426, entry_427, entry_428, entry_429, entry_430, entry_431, entry_432, entry_433, entry_434, entry_435, entry_436, entry_437, entry_438, entry_439, entry_440, entry_441, entry_442, entry_443, entry_444, entry_445] + +def tableChunk_22 : Array Entry := #[entry_446, entry_447, entry_448, entry_449, entry_450, entry_451, entry_452, entry_453, entry_454, entry_455, entry_456, entry_457, entry_458, entry_459, entry_460, entry_461, entry_462, entry_463, entry_464, entry_465] + +def tableChunk_23 : Array Entry := #[entry_466, entry_467, entry_468, entry_469, entry_470, entry_471, entry_472, entry_473, entry_474, entry_475, entry_476, entry_477, entry_478, entry_479, entry_480, entry_481, entry_482, entry_483, entry_484, entry_485] + +def tableChunk_24 : Array Entry := #[entry_486, entry_487, entry_488, entry_489, entry_490, entry_491, entry_492, entry_493, entry_494, entry_495, entry_496, entry_497, entry_498, entry_499, entry_500, entry_501, entry_502, entry_503, entry_504, entry_505] + +def tableChunk_25 : Array Entry := #[entry_506, entry_507, entry_508, entry_509, entry_510, entry_511, entry_512, entry_513, entry_514, entry_515, entry_516, entry_517, entry_518, entry_519, entry_520, entry_521, entry_522, entry_523, entry_524, entry_525] + +def tableChunk_26 : Array Entry := #[entry_526, entry_527, entry_528, entry_529, entry_530, entry_531, entry_532, entry_533, entry_534, entry_535, entry_536, entry_537, entry_538, entry_539, entry_540, entry_541, entry_542, entry_543, entry_544, entry_545] + +def tableChunk_27 : Array Entry := #[entry_546, entry_547, entry_548, entry_549, entry_550, entry_551, entry_552, entry_553, entry_554, entry_555, entry_556, entry_557, entry_558, entry_559, entry_560, entry_561, entry_562, entry_563, entry_564, entry_565] + +def tableChunk_28 : Array Entry := #[entry_566, entry_567, entry_568, entry_569, entry_570, entry_571, entry_572, entry_573, entry_574, entry_575, entry_576, entry_577, entry_578, entry_579, entry_580, entry_581, entry_582, entry_583, entry_584, entry_585] + +def tableChunk_29 : Array Entry := #[entry_586, entry_587, entry_588, entry_589, entry_590, entry_591, entry_592, entry_593, entry_594, entry_595, entry_596, entry_597, entry_598, entry_599, entry_600, entry_601, entry_602, entry_603, entry_604, entry_605] + +def tableChunk_30 : Array Entry := #[entry_606, entry_607, entry_608, entry_609, entry_610, entry_611, entry_612, entry_613, entry_614, entry_615] + +def table : Array Entry := ((((tableChunk_0 ++ (tableChunk_1 ++ tableChunk_2)) ++ ((tableChunk_3 ++ tableChunk_4) ++ (tableChunk_5 ++ tableChunk_6))) ++ (((tableChunk_7 ++ tableChunk_8) ++ (tableChunk_9 ++ tableChunk_10)) ++ ((tableChunk_11 ++ tableChunk_12) ++ (tableChunk_13 ++ tableChunk_14)))) ++ ((((tableChunk_15 ++ tableChunk_16) ++ (tableChunk_17 ++ tableChunk_18)) ++ ((tableChunk_19 ++ tableChunk_20) ++ (tableChunk_21 ++ tableChunk_22))) ++ (((tableChunk_23 ++ tableChunk_24) ++ (tableChunk_25 ++ tableChunk_26)) ++ ((tableChunk_27 ++ tableChunk_28) ++ (tableChunk_29 ++ tableChunk_30))))) + +def entryAt (i : ℕ) : Entry := table[i - 6]?.getD emptyEntry + +def TableValid : Prop := + table.size = 610 ∧ ∀ k, k < table.size → + let e := table[k]?.getD emptyEntry + e.index = k + 6 ∧ e.terms ≠ [] ∧ ∀ t ∈ e.terms, t.child < e.index + +def placementCount : ℕ := (table.toList.map fun e => e.terms.length).sum + +structure RowData where + A : Finset Cell + H : Finset Cell + height : ℕ + deriving DecidableEq + +def emptyRow : RowData := ⟨∅, ∅, 0⟩ + +def baseRow (i : Fin 6) : RowData := ⟨baseRequired i, baseEnvelope i, 1⟩ + +def placeRow (t : Term) (d : RowData) : RowData := + ⟨d.A.image (placement t.rotation t.shift), + d.H.image (placement t.rotation t.shift), d.height⟩ + +def unionA (ds : List RowData) : Finset Cell := (ds.map RowData.A).foldr (· ∪ ·) ∅ + +def unionH (ds : List RowData) : Finset Cell := (ds.map RowData.H).foldr (· ∪ ·) ∅ + +def commonH (ds : List RowData) : Finset Cell := + match ds with + | [] => ∅ + | d :: rest => (rest.map RowData.H).foldr (· ∩ ·) d.H + +def forkRow (ds : List RowData) : RowData := + ⟨(unionA ds ∪ commonH ds).erase origin, + insert origin (unionH ds), 1 + (ds.map RowData.height).foldr max 0⟩ + +def rowAt (i : ℕ) : RowData := + if h : i < 6 then baseRow ⟨i, h⟩ else + forkRow ((entryAt i).terms.map fun t => + placeRow t (if _ : t.child < i then rowAt t.child else emptyRow)) +termination_by i + +def Output (i : ℕ) (p : Cell) (size height : ℕ) (omitted : Set Cell) : Prop := + (rowAt i).A = {p} ∧ (rowAt i).H.card = size ∧ (rowAt i).height = height ∧ + Disjoint (↑(rowAt i).H : Set Cell) omitted + +def AllRows : Prop := ∀ i, i < 616 → + (rowAt i).A ⊆ (rowAt i).H ∧ origin ∈ (rowAt i).H ∧ + origin ∉ (rowAt i).A ∧ (rowAt i).height ≤ 34 + +theorem certificate_correct : + TableValid ∧ placementCount = 1837 ∧ + Output 557 (-1, 0) 118 19 {p | p.1 ≤ -3 ∧ p.2 ≤ -2} ∧ + Output 595 (-1, 0) 222 27 {p | p.1 = -2 ∧ p.2 ≤ -2} ∧ + Output 603 (-1, 0) 275 27 {p | p.1 ≤ -3 ∧ p.2 = 0} ∧ + Output 615 (1, 0) 686 34 {(1, -1)} ∧ + AllRows := by + sorry + +end SnakyCertificate + +end OAI diff --git a/lean/ComparatorChallenges/SnakyConditional.json b/lean/ComparatorChallenges/SnakyConditional.json new file mode 100644 index 0000000000000000000000000000000000000000..f9b55ac90fe1322293863f6ffecc694513a5b962 --- /dev/null +++ b/lean/ComparatorChallenges/SnakyConditional.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SnakyConditional", + "solution_module": "OAI.GameTheory.SnakyConditional.Main", + "theorem_names": [ + "OAI.SnakyConditional.snaky_winning_strategy_with_legal_states" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SnakyConditional.lean b/lean/ComparatorChallenges/SnakyConditional.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a96224d351fbb48555ae55bd8f92589f8d2dc3e --- /dev/null +++ b/lean/ComparatorChallenges/SnakyConditional.lean @@ -0,0 +1,56 @@ +import Mathlib + +namespace OAI.SnakyConditional + +abbrev Cell := ℤ × ℤ +def snaky : Finset Cell := {(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (4, 1)} +def orient (r : Fin 8) (p : Cell) : Cell := + match r.val with + | 0 => (p.1, p.2) + | 1 => (p.2, p.1) + | 2 => (p.1, -p.2) + | 3 => (-p.2, p.1) + | 4 => (-p.1, p.2) + | 5 => (p.2, -p.1) + | 6 => (-p.1, -p.2) + | _ => (-p.2, -p.1) +def placement (r : Fin 8) (t p : Cell) : Cell := orient r p + t +def HasSnaky (M : Finset Cell) : Prop := + ∃ (r : Fin 8) (t : Cell), snaky.image (placement r t) ⊆ M + +namespace OrdinaryStrategy + +variable {α : Type*} [DecidableEq α] + +abbrev Policy (α : Type*) := ℕ → Finset α → Finset α → α +def playState (σ : Policy α) (N : ℕ) (β : ℕ → α) (M₀ B₀ : Finset α) : + ℕ → Finset α × Finset α + | 0 => (M₀, B₀) + | k + 1 => + let state := playState σ N β M₀ B₀ k + (insert (σ (N - k) state.1 state.2) state.1, insert (β k) state.2) +def makerAt (σ : Policy α) (N : ℕ) (β : ℕ → α) (M₀ B₀ : Finset α) (k : ℕ) : α := + let state := playState σ N β M₀ B₀ k + σ (N - k) state.1 state.2 +def LegalRepliesBeforeFinal (σ : Policy α) (N : ℕ) (β : ℕ → α) + (M₀ B₀ : Finset α) : Prop := + ∀ k, k + 1 < N → + β k ∉ insert (makerAt σ N β M₀ B₀ k) (playState σ N β M₀ B₀ k).1 ∧ + β k ∉ (playState σ N β M₀ B₀ k).2 +end OrdinaryStrategy + +open OrdinaryStrategy + +theorem snaky_winning_strategy_with_legal_states : + ∃ σ : Policy Cell, + (∀ r M B, σ r M B ∉ M ∧ σ r M B ∉ B) ∧ + ∀ β : ℕ → Cell, LegalRepliesBeforeFinal σ 35 β ∅ ∅ → + HasSnaky (playState σ 35 β ∅ ∅ 35).1 ∧ + (playState σ 35 β ∅ ∅ 35).1.card = 35 ∧ + Disjoint (playState σ 35 β ∅ ∅ 35).1 (playState σ 35 β ∅ ∅ 34).2 ∧ + ∀ k, k < 35 → + Disjoint (playState σ 35 β ∅ ∅ k).1 (playState σ 35 β ∅ ∅ k).2 ∧ + (playState σ 35 β ∅ ∅ k).2.card = k := by + sorry + +end OAI.SnakyConditional diff --git a/lean/ComparatorChallenges/SnakyTwentyOne.json b/lean/ComparatorChallenges/SnakyTwentyOne.json new file mode 100644 index 0000000000000000000000000000000000000000..5f481d82221109fae8538e6ed23bea2a15d14331 --- /dev/null +++ b/lean/ComparatorChallenges/SnakyTwentyOne.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SnakyTwentyOne", + "solution_module": "OAI.GameTheory.SnakyTwentyOne.Main", + "theorem_names": [ + "OAI.SnakyPrototype.snaky_winning_strategy_21_with_legal_states" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SnakyTwentyOne.lean b/lean/ComparatorChallenges/SnakyTwentyOne.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fe6ab5c77ba9e4a7819c75c4be0b45d1f50d194 --- /dev/null +++ b/lean/ComparatorChallenges/SnakyTwentyOne.lean @@ -0,0 +1,59 @@ +import Mathlib + +namespace OAI + +namespace SnakyPrototype +variable {α : Type*} [DecidableEq α] +abbrev Cell := ℤ × ℤ +def snaky : Finset Cell := {(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (4, 1)} +def orient (r : Fin 8) (p : Cell) : Cell := + match r.val with + | 0 => (p.1, p.2) + | 1 => (p.2, p.1) + | 2 => (p.1, -p.2) + | 3 => (-p.2, p.1) + | 4 => (-p.1, p.2) + | 5 => (p.2, -p.1) + | 6 => (-p.1, -p.2) + | _ => (-p.2, -p.1) +def placement (r : Fin 8) (t p : Cell) : Cell := orient r p + t +def HasSnaky (M : Finset Cell) : Prop := + ∃ (r : Fin 8) (t : Cell), snaky.image (placement r t) ⊆ M +end SnakyPrototype +namespace SnakyPrototype.OrdinaryStrategy +variable {α : Type*} [DecidableEq α] [Infinite α] +abbrev Policy (α : Type*) := ℕ → Finset α → Finset α → α +def playState (σ : Policy α) (N : ℕ) (β : ℕ → α) (M₀ B₀ : Finset α) : + ℕ → Finset α × Finset α + | 0 => (M₀, B₀) + | k + 1 => + let state := playState σ N β M₀ B₀ k + (insert (σ (N - k) state.1 state.2) state.1, insert (β k) state.2) +def makerAt (σ : Policy α) (N : ℕ) (β : ℕ → α) (M₀ B₀ : Finset α) (k : ℕ) : α := + let state := playState σ N β M₀ B₀ k + σ (N - k) state.1 state.2 +def LegalRepliesBeforeFinal (σ : Policy α) (N : ℕ) (β : ℕ → α) + (M₀ B₀ : Finset α) : Prop := + ∀ k, k + 1 < N → + β k ∉ insert (makerAt σ N β M₀ B₀ k) (playState σ N β M₀ B₀ k).1 ∧ + β k ∉ (playState σ N β M₀ B₀ k).2 +end SnakyPrototype.OrdinaryStrategy + +namespace SnakyPrototype +open OrdinaryStrategy + +theorem snaky_winning_strategy_21_with_legal_states : + ∃ σ : Policy Cell, + (∀ r M B, σ r M B ∉ M ∧ σ r M B ∉ B) ∧ + ∀ β : ℕ → Cell, LegalRepliesBeforeFinal σ 21 β ∅ ∅ → + HasSnaky (playState σ 21 β ∅ ∅ 21).1 ∧ + (playState σ 21 β ∅ ∅ 21).1.card = 21 ∧ + Disjoint (playState σ 21 β ∅ ∅ 21).1 (playState σ 21 β ∅ ∅ 20).2 ∧ + ∀ k, k < 21 → + Disjoint (playState σ 21 β ∅ ∅ k).1 (playState σ 21 β ∅ ∅ k).2 ∧ + (playState σ 21 β ∅ ∅ k).2.card = k := by + sorry + +end SnakyPrototype + +end OAI diff --git a/lean/ComparatorChallenges/SoftChannel204.json b/lean/ComparatorChallenges/SoftChannel204.json new file mode 100644 index 0000000000000000000000000000000000000000..2c5073e1883ab2ec41f3ac6bfe9e58172a5c5e68 --- /dev/null +++ b/lean/ComparatorChallenges/SoftChannel204.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SoftChannel204", + "solution_module": "OAI.InformationTheory.SoftChannel.Main", + "theorem_names": [ + "OAI.SoftChannel204.fullMain" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SoftChannel204.lean b/lean/ComparatorChallenges/SoftChannel204.lean new file mode 100644 index 0000000000000000000000000000000000000000..77ee2c34f2fd6372846bbd03fff438cea7e6cfdd --- /dev/null +++ b/lean/ComparatorChallenges/SoftChannel204.lean @@ -0,0 +1,121 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open scoped BigOperators + +namespace SoftChannel204 + +abbrev Cube (n : ℕ) := Fin n → Bool + +def sign (b : Bool) : ℝ := if b then 1 else -1 + +def avg {n : ℕ} (g : Cube n → ℝ) : ℝ := (∑ x, g x) / (2 : ℝ) ^ n + +def L : ℝ := Real.log 2 + +def psi (r : ℝ) : ℝ := + (1 + r) / 2 * Real.log (1 + r) + (1 - r) / 2 * Real.log (1 - r) + +def H (r : ℝ) : ℝ := L - psi r + +def info {n : ℕ} (u : Cube n → ℝ) : ℝ := H (avg u) - avg (H ∘ u) + +def psiInv (s : ℝ) : ℝ := Function.invFunOn psi (Set.Icc 0 1) s + +def kernel {n : ℕ} (ρ : ℝ) (x y : Cube n) : ℝ := + ∏ i, if x i = y i then (1 + ρ) / 2 else (1 - ρ) / 2 + +def noise {n : ℕ} (ρ : ℝ) (u : Cube n → ℝ) (y : Cube n) : ℝ := + ∑ x, kernel ρ y x * u x + +def Closed {n : ℕ} (u : Cube n → ℝ) : Prop := ∀ x, u x ∈ Set.Icc (-1) 1 + +def Interior {n : ℕ} (g : Cube n → ℝ) : Prop := ∀ x, g x ∈ Set.Ioo (-1) 1 + +def softCoordinate {n : ℕ} (i : Fin n) (a : ℝ) (x : Cube n) : ℝ := a * sign (x i) + +def flip {n : ℕ} (i : Fin n) (x : Cube n) : Cube n := Function.update x i (!(x i)) + +def numberOperator {n : ℕ} (g : Cube n → ℝ) (x : Cube n) : ℝ := + (1 / 2 : ℝ) * ∑ i, (g x - g (flip i x)) + +def production {n : ℕ} (g : Cube n → ℝ) : ℝ := + avg (fun x => Real.artanh (g x) * numberOperator g x) + +/-- Defined by this formula on `[0, L)`; no finite endpoint value at `L` is asserted. -/ +def F (s : ℝ) : ℝ := psiInv s * Real.artanh (psiInv s) + +/-- The excess `F s - 2 * s`, used for `s < L`, is extended by zero to negative arguments. -/ +def S (s : ℝ) : ℝ := if s < 0 then 0 else F s - 2 * s + +/-- The reserve is used for `|m| < 1` and `0 ≤ I < H m`. -/ +def reserve (m I : ℝ) : ℝ := + 2 * I + (1 - m ^ 2) * S (L - (H m - I) / (1 - m ^ 2)) + +def hybrid (m I : ℝ) : ℝ := max (reserve m I) (F I) + +def softJoint {n : ℕ} (ρ : ℝ) (u : Cube n → ℝ) (b : Bool) (y : Cube n) : ℝ := + avg (fun x => (1 + sign b * u x) / 2 * kernel ρ x y) + +def boolJoint {n : ℕ} (ρ : ℝ) (f : Cube n → Bool) (b : Bool) (y : Cube n) : ℝ := + avg (fun x => if f x = b then kernel ρ x y else 0) + +def leftMarginal {n : ℕ} (p : Bool → Cube n → ℝ) (b : Bool) : ℝ := ∑ y, p b y + +def rightMarginal {n : ℕ} (p : Bool → Cube n → ℝ) (y : Cube n) : ℝ := ∑ b, p b y + +def mutualInformation {n : ℕ} (p : Bool → Cube n → ℝ) : ℝ := + ∑ b, ∑ y, if 0 < p b y then + p b y * Real.log (p b y / (leftMarginal p b * rightMarginal p y)) else 0 + +def binaryEntropyBits (ε : ℝ) : ℝ := + -(ε * Real.log ε + (1 - ε) * Real.log (1 - ε)) / L + +def SoftContraction : Prop := ∀ (n : ℕ) (u : Cube n → ℝ), Closed u → + ∀ ρ ∈ Set.Icc (-1 : ℝ) 1, + info (noise ρ u) ≤ psi (|ρ| * psiInv (info u)) + +def SoftAttainment : Prop := ∀ (n : ℕ) (i : Fin n) (a : ℝ), |a| ≤ 1 → + ∀ ρ ∈ Set.Icc (-1 : ℝ) 1, + info (noise ρ (softCoordinate i a)) = + psi (|ρ| * psiInv (info (softCoordinate i a))) + +def SoftInformationIdentity : Prop := ∀ (n : ℕ) (u : Cube n → ℝ), Closed u → + ∀ ρ ∈ Set.Icc (-1 : ℝ) 1, + mutualInformation (softJoint ρ u) = info (noise ρ u) + +def RefinedBoolean : Prop := ∀ (n : ℕ) (f : Cube n → Bool) + (ρ : ℝ), ρ ∈ Set.Icc (-1 : ℝ) 1 → + let m := avg (sign ∘ f) + let bound := psi (|ρ| * psiInv (H m)) + mutualInformation (boolJoint ρ f) = info (noise ρ (sign ∘ f)) ∧ + mutualInformation (boolJoint ρ f) ≤ bound ∧ bound ≤ psi |ρ| ∧ + (0 < |m| → |m| < 1 → 0 < |ρ| → bound < psi |ρ|) + +def BooleanAttainment : Prop := ∀ (n : ℕ) (i : Fin n) + (ρ : ℝ), ρ ∈ Set.Icc (-1 : ℝ) 1 → + mutualInformation (boolJoint ρ (fun x => x i)) = psi |ρ| ∧ + mutualInformation (boolJoint ρ (fun x => !(x i))) = psi |ρ| + +def BitsConversion : Prop := ∀ (n : ℕ) (f : Cube n → Bool) + (ε : ℝ), ε ∈ Set.Icc (0 : ℝ) (1/2) → + psi (1 - 2 * ε) / L = 1 - binaryEntropyBits ε ∧ + mutualInformation (boolJoint (1 - 2 * ε) f) / L ≤ 1 - binaryEntropyBits ε + +def SharpProduction : Prop := ∀ (n : ℕ) (g : Cube n → ℝ), Interior g → + hybrid (avg g) (info g) ≤ production g ∧ F (info g) ≤ hybrid (avg g) (info g) + +def FullMain : Prop := SoftContraction ∧ SoftAttainment ∧ SoftInformationIdentity ∧ + RefinedBoolean ∧ BooleanAttainment ∧ BitsConversion ∧ SharpProduction + +theorem fullMain : FullMain := by + sorry + +end SoftChannel204 + +end + +end OAI diff --git a/lean/ComparatorChallenges/SolenoidalSheetPrograms.json b/lean/ComparatorChallenges/SolenoidalSheetPrograms.json new file mode 100644 index 0000000000000000000000000000000000000000..b6b2ddef8554146a0d29ad6edf10f917b27932ad --- /dev/null +++ b/lean/ComparatorChallenges/SolenoidalSheetPrograms.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SolenoidalSheetPrograms", + "solution_module": "OAI.MathematicalPhysics.SheetFlows.SheetProgram", + "theorem_names": [ + "OAI.Solenoidal.sheet_theorem" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SolenoidalSheetPrograms.lean b/lean/ComparatorChallenges/SolenoidalSheetPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..d066e7b2b954137731f96abb9e66efd24fe47b5e --- /dev/null +++ b/lean/ComparatorChallenges/SolenoidalSheetPrograms.lean @@ -0,0 +1,197 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open Set MeasureTheory +open scoped BigOperators + +namespace Solenoidal + +abbrev Plane := Fin 2 → ℝ +abbrev Space := Fin 3 → ℝ +abbrev SpaceTime := ℝ × Space +abbrev Field := ℝ → Space → Space +abbrev Pressure := ℝ → Space → ℝ +abbrev Torus := Fin 3 → AddCircle (10 : ℝ) + +def toTorus (x : Space) : Torus := fun i => (x i : AddCircle (10 : ℝ)) + +def sheet (y : Plane) : Space := ![y 0, y 1, 2] + +structure Rectangle where + lower : Fin 2 → ℚ + upper : Fin 2 → ℚ + positive : ∀ j, lower j < upper j + +namespace Rectangle + +def carrier (R : Rectangle) : Set Plane := + {y | ∀ j, (R.lower j : ℝ) ≤ y j ∧ y j ≤ (R.upper j : ℝ)} + +def center (R : Rectangle) : Plane := + fun j => ((R.lower j : ℝ) + (R.upper j : ℝ)) / 2 + +def halfWidth (R : Rectangle) : Plane := + fun j => ((R.upper j : ℝ) - (R.lower j : ℝ)) / 2 + +def inCodingSquare (R : Rectangle) : Prop := + ∀ j, 2 ≤ R.lower j ∧ R.upper j ≤ 3 + +end Rectangle + +def SeparatelySeparated {N : ℕ} (R : Fin N → Rectangle) : Prop := + ∀ i j, i ≠ j → ∃ δ : ℝ, 0 < δ ∧ + ∀ x ∈ (R i).carrier, ∀ y ∈ (R j).carrier, δ ≤ ‖x - y‖ + +def diagonalMap (P Q : Rectangle) (r : Fin 2 → ℚ) (y : Plane) : Plane := + fun j => Q.center j + (r j : ℝ) * (y j - P.center j) + +structure SheetData (N : ℕ) where + source : Fin N → Rectangle + target : Fin N → Rectangle + source_inside : ∀ i, (source i).inCodingSquare + target_inside : ∀ i, (target i).inCodingSquare + source_separated : SeparatelySeparated source + target_separated : SeparatelySeparated target + ratio : Fin N → Fin 2 → ℚ + ratio_positive : ∀ i j, 0 < ratio i j + image_eq : ∀ i, + diagonalMap (source i) (target i) (ratio i) '' (source i).carrier = + (target i).carrier + +def deck (k : Fin 3 → ℤ) : Space := fun j => 10 * (k j : ℝ) + +def SpatiallyPeriodic {E : Type*} (g : ℝ → Space → E) : Prop := + ∀ t x k, g t (x + deck k) = g t x + +def fundamentalCell : Set Space := + Set.pi Set.univ (fun _ => Set.Ico (0 : ℝ) 10) + +def basis (j : Fin 3) : Space := Pi.single j 1 + +def spatialPartial (u : Field) (j : Fin 3) : Field := + fun t x => fderiv ℝ (u t) x (basis j) + +def timePartial (u : Field) : Field := + fun t x => derivWithin (fun s => u s x) (Set.Ici 0) t + +def divergence (u : Field) (t : ℝ) (x : Space) : ℝ := + ∑ j : Fin 3, spatialPartial u j t x j + +def laplacian (u : Field) : Field := + fun t x => ∑ j : Fin 3, spatialPartial (spatialPartial u j) j t x + +def advection (u : Field) : Field := + fun t x => fderiv ℝ (u t) x (u t x) + +def gradient (p : Pressure) : Field := + fun t x j => fderiv ℝ (p t) x (basis j) + +def DivergenceFree (u : Field) : Prop := ∀ t x, divergence u t x = 0 + +def MeanZero (u : Field) : Prop := + ∀ t, (∫ x in fundamentalCell, u t x) = 0 + +def Smooth (u : Field) : Prop := + ContDiff ℝ (⊤ : ℕ∞) (fun z : SpaceTime => u z.1 z.2) + +def OnePeriodic (u : Field) : Prop := ∀ t x, u (t + 1) x = u t x + +def IntegerCollars (u : Field) : Prop := + ∃ ε : ℝ, 0 < ε ∧ ∀ n : ℤ, ∀ t x, |t - (n : ℝ)| < ε → u t x = 0 + +def cylinder (T : ℝ) : Set SpaceTime := Set.Icc 0 T ×ˢ Set.univ + +structure ClassicalSolution (ν : ℝ) (f u : Field) (p : Pressure) : Prop where + spatial_periodic_u : SpatiallyPeriodic u + spatial_periodic_p : SpatiallyPeriodic p + continuous_u : ∀ T, 0 ≤ T → + ContinuousOn (fun z : SpaceTime => u z.1 z.2) (cylinder T) + differentiable_t : ∀ t, 0 ≤ t → ∀ x, + DifferentiableWithinAt ℝ (fun s => u s x) (Set.Ici 0) t + continuous_t : ∀ T, 0 ≤ T → + ContinuousOn (fun z : SpaceTime => timePartial u z.1 z.2) (cylinder T) + differentiable_x : ∀ t, 0 ≤ t → Differentiable ℝ (u t) + continuous_x : ∀ T, 0 ≤ T → ∀ j, + ContinuousOn (fun z : SpaceTime => spatialPartial u j z.1 z.2) (cylinder T) + differentiable_xx : ∀ t, 0 ≤ t → ∀ j, + Differentiable ℝ (spatialPartial u j t) + continuous_xx : ∀ T, 0 ≤ T → ∀ i j, + ContinuousOn (fun z : SpaceTime => spatialPartial (spatialPartial u i) j z.1 z.2) + (cylinder T) + continuous_p : ∀ T, 0 ≤ T → + ContinuousOn (fun z : SpaceTime => p z.1 z.2) (cylinder T) + differentiable_p : ∀ t, 0 ≤ t → Differentiable ℝ (p t) + continuous_px : ∀ T, 0 ≤ T → + ContinuousOn (fun z : SpaceTime => gradient p z.1 z.2) (cylinder T) + pressure_mean_zero : ∀ t, 0 ≤ t → (∫ x in fundamentalCell, p t x) = 0 + incompressible : ∀ t, 0 ≤ t → ∀ x, divergence u t x = 0 + initial : ∀ x, u 0 x = 0 + equation : ∀ t, 0 ≤ t → ∀ x, + timePartial u t x + advection u t x = + -gradient p t x + ν • laplacian u t x + f t x + +def MaterialFlow (u : Field) (X : ℝ → Space → Space) : Prop := + (∀ a, X 0 a = a) ∧ + (∀ a, ContinuousOn (fun t => X t a) (Set.Ici 0)) ∧ + (∀ a t, 0 ≤ t → + HasDerivWithinAt (fun s => X s a) (u t (X t a)) (Set.Ici 0) t) + +def spacetimeBasis : Fin 4 → SpaceTime := + ![(1, 0), (0, basis 0), (0, basis 1), (0, basis 2)] + +def mixedDerivative (u : Field) : List (Fin 4) → SpaceTime → Space + | [] => fun z => u z.1 z.2 + | j :: α => fun z => fderiv ℝ (mixedDerivative u α) z (spacetimeBasis j) + +def flatten (z : SpaceTime) : Fin 4 → ℝ := ![z.1, z.2 0, z.2 1, z.2 2] + +def NamesReal (c : Nat.Partrec.Code) (r : ℝ) : Prop := + ∀ n : ℕ, ∃ q : ℚ, Encodable.encode q ∈ c.eval n ∧ + |(q : ℝ) - r| ≤ (1 / 2 : ℝ) ^ n + +def ComputableReal (r : ℝ) : Prop := ∃ c, NamesReal c r + +def NamesPoint (c : Nat.Partrec.Code) (z : SpaceTime) : Prop := + ∀ n : ℕ, ∃ q : Fin 4 → ℚ, + @Encodable.encode (Fin 4 → ℚ) Encodable.finArrow q ∈ c.eval n ∧ + ‖(fun j => (q j : ℝ)) - flatten z‖ ≤ (1 / 2 : ℝ) ^ n + +def Effective (u : Field) : Prop := + ∃ e : Nat.Partrec.Code, ∀ α : List (Fin 4), ∀ c : Nat.Partrec.Code, + ∀ z : SpaceTime, NamesPoint c z → ∀ ε : ℚ, 0 < ε → + ∃ q : Fin 3 → ℚ, + @Encodable.encode (Fin 3 → ℚ) Encodable.finArrow q ∈ + e.eval (Encodable.encode (α, c, ε)) ∧ + ‖(fun j => (q j : ℝ)) - mixedDerivative u α z‖ < (ε : ℝ) + +def EffectiveBounds (u : Field) : Prop := + ∃ e : Nat.Partrec.Code, ∀ α : List (Fin 4), ∃ B : ℚ, + Encodable.encode B ∈ e.eval (Encodable.encode α) ∧ 0 ≤ B ∧ + ∀ z : SpaceTime, ‖mixedDerivative u α z‖ ≤ (B : ℝ) + +theorem sheet_theorem {N : ℕ} (D : SheetData N) (ν : ℝ) + (hν : 0 < ν) (hνcomp : ComputableReal ν) : + ∃ f u : Field, ∃ X : ℝ → Space → Space, + SpatiallyPeriodic f ∧ SpatiallyPeriodic u ∧ + Smooth f ∧ Smooth u ∧ Effective f ∧ + MeanZero f ∧ DivergenceFree f ∧ OnePeriodic f ∧ + ClassicalSolution ν f u (fun _ _ => 0) ∧ + (∀ v : Field, ∀ p : Pressure, ClassicalSolution ν f v p → + ∀ t, 0 ≤ t → ∀ x, v t x = u t x ∧ p t x = 0) ∧ + MaterialFlow u X ∧ + (∀ i : Fin N, ∀ y ∈ (D.source i).carrier, + toTorus (X 1 (sheet y)) = + toTorus (sheet (diagonalMap (D.source i) (D.target i) (D.ratio i) y))) ∧ + IntegerCollars u ∧ (∀ t x, advection u t x = 0) ∧ + EffectiveBounds f ∧ EffectiveBounds u ∧ + (N = 0 → f = 0 ∧ u = 0) := by + sorry + +end Solenoidal + +end + +end OAI diff --git a/lean/ComparatorChallenges/SphericalField.json b/lean/ComparatorChallenges/SphericalField.json new file mode 100644 index 0000000000000000000000000000000000000000..338e7b17f345c68ac6dedf9f31dc35d8da995b01 --- /dev/null +++ b/lean/ComparatorChallenges/SphericalField.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SphericalField", + "solution_module": "OAI.Probability.SphericalField.Main", + "theorem_names": [ + "OAI.SphericalPerceptron.spherical_linear_field_formula" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Classical.choice", + "Quot.sound" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SphericalField.lean b/lean/ComparatorChallenges/SphericalField.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9eb09392ed2f2362329c81f139aa4f13dfaaf9e --- /dev/null +++ b/lean/ComparatorChallenges/SphericalField.lean @@ -0,0 +1,557 @@ +import Mathlib + +namespace OAI + +noncomputable section +open MeasureTheory ProbabilityTheory Filter Set +open scoped ENNReal NNReal Topology BigOperators BoundedContinuousFunction + +namespace SphericalPerceptron + +abbrev Time := unitInterval + +abbrev Spin (N : ℕ) := EuclideanSpace ℝ (Fin N) + +def unitSphereLaw (N : ℕ) : Measure (Metric.sphere (0 : Spin N) 1) := + let s := (volume : Measure (Spin N)).toSphere + (s Set.univ)⁻¹ • s + +structure Trial where + toFun : Time → ℝ + monotone : Monotone toFun + measurable : Measurable toFun + nonneg : ∀ t, 0 ≤ toFun t + le_one : ∀ t, toFun t ≤ 1 + +instance : CoeFun Trial (fun _ => Time → ℝ) := ⟨Trial.toFun⟩ + +def timeLaw : Measure Time := Measure.comap Subtype.val volume + +def tailIntegral (m : Trial) (t : Time) : ℝ := + ∫ s in Set.Ici t, m s ∂timeLaw + +def entropy (m : Trial) : ℝ≥0∞ := + (∫⁻ t, (ENNReal.ofReal (tailIntegral m t))⁻¹ - + (ENNReal.ofReal (1 - (t : ℝ)))⁻¹ ∂timeLaw) / 2 + +@[simp] theorem timeLaw_eq_volume : timeLaw = (volume : Measure Time) := rfl + +instance : IsProbabilityMeasure timeLaw := by + rw [timeLaw_eq_volume] + infer_instance + +def finitePointMeasure {S : Type*} [MeasurableSpace S] (n : ℕ) (x : Fin n → S) : Measure S := + ∑ i : Fin n, Measure.dirac (x i) + +@[fun_prop] lemma finitePointMeasure_measurable {S : Type*} [MeasurableSpace S] (n : ℕ) : + Measurable (finitePointMeasure (S := S) n) := by + unfold finitePointMeasure + fun_prop + +def finitePoissonLaw {S : Type*} [MeasurableSpace S] (r : ℝ≥0) (ν : Measure S) : + Measure (Measure S) := + Measure.sum fun n : ℕ => + poissonMeasure r {n} • (Measure.pi fun _ : Fin n => ν).map (finitePointMeasure n) + +instance finitePoissonLaw_probability {S : Type*} [MeasurableSpace S] + (r : ℝ≥0) (ν : Measure S) [IsProbabilityMeasure ν] : + IsProbabilityMeasure (finitePoissonLaw r ν) := by + constructor + rw [finitePoissonLaw,Measure.sum_apply _ MeasurableSet.univ] + have hmass (n : ℕ) : ((Measure.pi fun _ : Fin n => ν).map (finitePointMeasure n)) univ = 1 := by + rw [Measure.map_apply (finitePointMeasure_measurable n) MeasurableSet.univ, + preimage_univ,measure_univ] + simp only [Measure.smul_apply,hmass,smul_eq_mul,mul_one] + have hh := hasSum_one_poissonMeasure r + simp_rw [poissonMeasure_singleton] + rw [← ENNReal.ofReal_tsum_of_nonneg (fun _ => by positivity) hh.summable,hh.tsum_eq] + norm_num + +lemma measureSum_measurable {S : Type*} [MeasurableSpace S] : + Measurable (fun η : ℕ → Measure S => Measure.sum η) := by + apply Measure.measurable_of_measurable_coe + intro s hs + simp only [Measure.sum_apply _ hs] + exact Measurable.tsum fun i => (Measure.measurable_coe hs).comp (measurable_pi_apply i) + +def countablePoissonLaw {S : Type*} [MeasurableSpace S] + (r : ℕ → ℝ≥0) (ν : ℕ → Measure S) : Measure (Measure S) := + (Measure.infinitePi fun i => finitePoissonLaw (r i) (ν i)).map Measure.sum + +instance countablePoissonLaw_probability {S : Type*} [MeasurableSpace S] + (r : ℕ → ℝ≥0) (ν : ℕ → Measure S) [∀ i, IsProbabilityMeasure (ν i)] : + IsProbabilityMeasure (countablePoissonLaw r ν) := by + unfold countablePoissonLaw + infer_instance + +def finiteIntensityMarks {S : Type*} [MeasurableSpace S] [Nonempty S] (κ : Measure S) : Measure S := + if κ univ = 0 then Measure.dirac (Classical.choice ‹Nonempty S›) else (κ univ)⁻¹ • κ + +instance finiteIntensityMarks_probability {S : Type*} [MeasurableSpace S] [Nonempty S] + (κ : Measure S) [IsFiniteMeasure κ] : IsProbabilityMeasure (finiteIntensityMarks κ) := by + by_cases hκ : κ univ = 0 + · simp only [finiteIntensityMarks,ite_eq_left hκ] + infer_instance + · constructor + simp [finiteIntensityMarks,hκ,ENNReal.inv_mul_cancel hκ (measure_ne_top _ _)] + +def poissonRandomMeasureLaw {S : Type*} [MeasurableSpace S] [Nonempty S] + (κ : Measure S) [SFinite κ] : Measure (Measure S) := + countablePoissonLaw (fun i => ((sfiniteSeq κ i) univ).toNNReal) + (fun i => finiteIntensityMarks (sfiniteSeq κ i)) + +instance poissonRandomMeasureLaw_probability {S : Type*} [MeasurableSpace S] [Nonempty S] + (κ : Measure S) [SFinite κ] : IsProbabilityMeasure (poissonRandomMeasureLaw κ) := by + unfold poissonRandomMeasureLaw + infer_instance + +def stableLogIntensity (b : ℝ) : Measure ℝ := + volume.withDensity (fun x => ENNReal.ofReal (b * Real.exp (-b*x))) + +instance stableLogIntensity_sigmaFinite (b : ℝ) : SigmaFinite (stableLogIntensity b) := by + unfold stableLogIntensity + infer_instance + +def normalizedMeasure {S : Type*} [MeasurableSpace S] (μ : Measure S) : Measure S := + (μ univ)⁻¹ • μ + +lemma measurable_measure_withDensity_fixed {S : Type*} [MeasurableSpace S] + {f : S → ℝ≥0∞} (hf : Measurable f) : Measurable (fun μ : Measure S => μ.withDensity f) := by + refine Measure.measurable_of_measurable_coe _ fun s hs => ?_ + simp only [withDensity_apply _ hs,← lintegral_indicator hs] + exact Measure.measurable_lintegral (hf.indicator hs) + +lemma normalizedMeasure_measurable {S : Type*} [MeasurableSpace S] : + Measurable (normalizedMeasure (S := S)) := by + refine Measure.measurable_of_measurable_coe _ fun s hs => ?_ + change Measurable (fun μ : Measure S => (μ univ)⁻¹ * μ s) + exact (Measure.measurable_coe MeasurableSet.univ).inv.mul (Measure.measurable_coe hs) + +section MarkedStable +variable {S : Type*} [MeasurableSpace S] + +def markedStableTotalE (η : Measure (ℝ × S)) : ℝ≥0∞ := + ∫⁻ p, ENNReal.ofReal (Real.exp p.1) ∂η + +@[fun_prop] lemma markedStableTotalE_measurable : Measurable (markedStableTotalE (S := S)) := + Measure.measurable_lintegral (by fun_prop) + +def markedStableTotal (η : Measure (ℝ × S)) : ℝ := (markedStableTotalE η).toReal + +@[fun_prop] lemma markedStableTotal_measurable : Measurable (markedStableTotal (S := S)) := + markedStableTotalE_measurable.ennreal_toReal + +def markedStableMassKernel : Kernel (Measure (ℝ × S)) (ℝ × S) where + toFun η := normalizedMeasure (η.withDensity (fun p => ENNReal.ofReal (Real.exp p.1))) + measurable' := normalizedMeasure_measurable.comp (measurable_measure_withDensity_fixed (by fun_prop)) + +instance markedStableMassKernel_finite : IsFiniteKernel (markedStableMassKernel (S := S)) := by + refine ⟨1, by simp, ?_⟩ + intro η + change (η.withDensity (fun p => ENNReal.ofReal (Real.exp p.1)) univ)⁻¹ * + (η.withDensity (fun p => ENNReal.ofReal (Real.exp p.1)) univ) ≤ 1 + exact ENNReal.inv_mul_le_one _ + +def markedStableCountKernel : Kernel (Measure (ℝ × S)) (ℝ × S) := + markedStableMassKernel.withDensity (fun η p => ENNReal.ofReal (markedStableTotal η*Real.exp (-p.1))) + +end MarkedStable + +@[reducible] def DecoratedCascade (S : Type) [MeasurableSpace S] : ℕ → MeasCat + | 0 => MeasCat.of Unit + | n+1 => MeasCat.of (Measure (ℝ×(S×DecoratedCascade S n))) + +instance decoratedCascadeNonempty (S : Type) [MeasurableSpace S] (n : ℕ) : + Nonempty (DecoratedCascade S n) := by + cases n with + | zero => exact ⟨()⟩ + | succ n => exact ⟨(0 : Measure (ℝ×(S×DecoratedCascade S n)))⟩ + +def decoratedCascadeLaw {S : Type} [MeasurableSpace S] [Nonempty S] + (ν : ProbabilityMeasure S) : (n : ℕ) → (Fin n → ℝ) → ProbabilityMeasure (DecoratedCascade S n) + | 0, _ => ⟨Measure.dirac (),by exact Measure.dirac.isProbabilityMeasure⟩ + | n+1, z => ⟨poissonRandomMeasureLaw ((stableLogIntensity (z 0)).prod + ((ν : Measure S).prod (decoratedCascadeLaw ν n (fun i => z i.succ)))), + by exact poissonRandomMeasureLaw_probability _⟩ + +def decoratedTerminalTotalE {X S : Type} [MeasurableSpace X] [MeasurableSpace S] + (step : X×S → X) (H : X → ℝ) : (n : ℕ) → X×DecoratedCascade S n → ℝ≥0∞ + | 0, p => ENNReal.ofReal (Real.exp (H p.1)) + | n+1, p => ∫⁻ q : ℝ×(S×DecoratedCascade S n), ENNReal.ofReal (Real.exp q.1) * + decoratedTerminalTotalE step H n (step (p.1,q.2.1),q.2.2) ∂markedStableCountKernel p.2 + +def decoratedTerminalTotal {X S : Type} [MeasurableSpace X] [MeasurableSpace S] + (step : X×S → X) (H : X → ℝ) (n : ℕ) (p : X×DecoratedCascade S n) : ℝ := + (decoratedTerminalTotalE step H n p).toReal + +def gaussianShiftStep (σ : ℕ → ℝ) (p : (ℕ → ℝ) × ℝ) : ℕ → ℝ := + fun i => p.1 (i+1)+σ i*p.2 + +def standardGaussianMark : ProbabilityMeasure ℝ := ⟨gaussianReal 0 1,inferInstance⟩ + +def piMarkLaw {ι S : Type} [Fintype ι] [MeasurableSpace S] + (ν : ι → ProbabilityMeasure S) : ProbabilityMeasure (ι → S) := + ⟨Measure.pi (fun i => (ν i : Measure S)),inferInstance⟩ + +def canonicalCoordinateStep (d : ℕ) (σ : ℕ → ℝ) : + (Fin d → ℕ → ℝ)×(Fin d → ℝ) → (Fin d → ℕ → ℝ) := + fun p i => gaussianShiftStep σ (p.1 i,p.2 i) + +def decoratedLeafIntegral {X S : Type} [MeasurableSpace X] [MeasurableSpace S] + (step : X × S → X) (F : X → ℝ≥0∞) : + (n : ℕ) → X × DecoratedCascade S n → ℝ≥0∞ + | 0, p => F p.1 + | n+1, p => ∫⁻ q : ℝ × (S × DecoratedCascade S n), + ENNReal.ofReal (Real.exp q.1) * + decoratedLeafIntegral step F n (step (p.1,q.2.1),q.2.2) + ∂markedStableCountKernel p.2 + +def decoratedFieldFactor {X S : Type} [MeasurableSpace X] [MeasurableSpace S] + (d : ℕ) (step : X × S → X) (field : X → Spin d) (k : ℕ) + (p : X × DecoratedCascade S k) (x : Spin d) : ℝ≥0∞ := + decoratedLeafIntegral step (fun y => ENNReal.ofReal (Real.exp (inner ℝ (field y) x))) k p + +def decoratedAngularFactor {X S : Type} [MeasurableSpace X] [MeasurableSpace S] + (n : ℕ) (step : X × S → X) (field : X → Spin (n+1)) (k : ℕ) + (p : X × DecoratedCascade S k) (r : ℝ) : ℝ≥0∞ := + ∫⁻ u : Metric.sphere (0:Spin (n+1)) 1, + decoratedFieldFactor (n+1) step field k p (r • (u:Spin (n+1))) ∂unitSphereLaw (n+1) + +def coordinateLeafField (d : ℕ) (x : Fin d → ℕ → ℝ) : Spin d := + WithLp.toLp 2 (fun i => x i 0) + +def coordinateCascadeLaw (d k : ℕ) (z : Fin k → ℝ) (r : ℝ≥0) : + Measure ((Fin d → ℝ) × DecoratedCascade (Fin d → ℝ) k) := + (Measure.pi (fun _ : Fin d => gaussianReal 0 r)).prod + (decoratedCascadeLaw (piMarkLaw (fun _ : Fin d => standardGaussianMark)) k z) + +def coordinateAngularLog (n k : ℕ) (σ : ℕ → ℝ) (R : ℝ) + (p : (Fin (n+1) → ℕ → ℝ) × DecoratedCascade (Fin (n+1) → ℝ) k) : ℝ := + Real.log ((decoratedAngularFactor n (canonicalCoordinateStep (n+1) σ) + (coordinateLeafField (n+1)) k p R).toReal / + decoratedTerminalTotal (canonicalCoordinateStep (n+1) σ) (fun _ => 0) k p) + +def normalizedCoordinateSphereLog (n k : ℕ) (σ : ℕ → ℝ) + (p : (Fin (n+1) → ℝ) × DecoratedCascade (Fin (n+1) → ℝ) k) : ℝ := + coordinateAngularLog n k σ (Real.sqrt (n+1:ℕ)) ((fun i _ => p.1 i),p.2) / ((n+1:ℕ):ℝ) + +def expectedCoordinateSphereLog (n k : ℕ) (σ : ℕ → ℝ) (z : Fin k → ℝ) (r : ℝ≥0) : ℝ := + ∫ p, normalizedCoordinateSphereLog n k σ p ∂coordinateCascadeLaw (n+1) k z r + +def weightedStepTrial {I : Type*} [Fintype I] (w : I → ℝ) (q : I → Time) + (hw : ∀ i, 0 ≤ w i) (hw1 : ∑ i, w i = 1) : Trial where + toFun := fun t => ∑ i, if q i ≤ t then w i else 0 + monotone := by + intro s t hst + apply Finset.sum_le_sum + intro i _ + by_cases hi : q i ≤ s + · simp only [ite_eq_left hi,ite_eq_left (hi.trans hst),le_refl] + · rw [ite_eq_right hi] + split_ifs <;> first | exact hw i | rfl + measurable := by + apply Finset.measurable_sum + intro i _ + exact measurable_const.ite (measurableSet_le measurable_const measurable_id) measurable_const + nonneg := by + intro t + apply Finset.sum_nonneg + intro i _ + split_ifs <;> first | exact hw i | rfl + le_one := by + intro t + rw [← hw1] + apply Finset.sum_le_sum + intro i _ + split_ifs <;> first | rfl | exact hw i + +def stepCumulative {k : ℕ} (w : Fin (k+1) → ℝ) (i : Fin k) : ℝ := + ∑ j : Fin (k+1), if j ≤ i.castSucc then w j else 0 + +def stepFieldIncrement (k : ℕ) (h : Fin (k+1) → ℝ) (j : ℕ) : ℝ := + if hj : j < k then + Real.sqrt (2*(h (Fin.rev ⟨j,hj⟩).succ-h (Fin.rev ⟨j,hj⟩).castSucc)) else 0 + +def finiteSphericalFieldValue (n k : ℕ) (w h : Fin (k+1) → ℝ) : ℝ := + expectedCoordinateSphereLog n k (stepFieldIncrement k h) (stepCumulative w) + (Real.toNNReal (2*h 0))-h (Fin.last k) + +def finiteSphericalDualObjective {k : ℕ} (w h : Fin (k+1) → ℝ) + (hw : ∀ i, 0 ≤ w i) (hw1 : ∑ i, w i=1) (q : Fin (k+1) → Time) : ℝ := + (entropy (weightedStepTrial w q hw hw1)).toReal-∑ i, w i*h i*(q i:ℝ) + +def finiteSphericalDualValues {k : ℕ} (w h : Fin (k+1) → ℝ) + (hw : ∀ i, 0 ≤ w i) (hw1 : ∑ i, w i=1) : Set ℝ := + finiteSphericalDualObjective w h hw hw1 '' + {q : Fin (k+1) → Time | Monotone q ∧ (q (Fin.last k):ℝ) < 1} + +structure FiniteFieldModel (f : Time → ℝ) where + depth : ℕ + value : Fin (depth+1) → ℝ + label : Time → Fin (depth+1) + measurable_label : Measurable label + positive : ∀ i, 0 < timeLaw.real (label ⁻¹' {i}) + monotone_value : Monotone value + agrees : (fun u => value (label u)) =ᵐ[timeLaw] f + +def FiniteFieldModel.weight {f : Time → ℝ} (M : FiniteFieldModel f) (i : Fin (M.depth+1)) : ℝ := + timeLaw.real (M.label ⁻¹' {i}) + +def FiniteFieldModel.pressure {f : Time → ℝ} (M : FiniteFieldModel f) (n : ℕ) : ℝ := + finiteSphericalFieldValue n M.depth M.weight M.value + +theorem exists_finiteFieldModel (f : Time → ℝ) (hf : Measurable f) + (hfin : (Set.range f).Finite) : Nonempty (FiniteFieldModel f) := by + classical + let S := hfin.toFinset + let T := S.filter (fun r => 0 < timeLaw.real (f ⁻¹' {r})) + have hae : ∀ᵐ u ∂timeLaw, f u ∈ T := by + have hnull : ∀ r ∈ S, ∀ᵐ u ∂timeLaw, f u=r → 0 < timeLaw.real (f ⁻¹' {r}) := by + intro r hr + by_cases hp : 0 < timeLaw.real (f ⁻¹' {r}) + · exact ae_of_all _ (fun _ _ => hp) + · have hz : timeLaw (f ⁻¹' {r})=0 := by + have hz : (timeLaw (f ⁻¹' {r})).toReal=0 := le_antisymm (le_of_not_gt hp) ENNReal.toReal_nonneg + have hp := (ENNReal.toReal_eq_zero_iff _).mp hz + rcases hp with hp | hp + · exact hp + · exact (measure_ne_top _ _ hp).elim + have hnot : ∀ᵐ u ∂timeLaw, f u ≠ r := by + apply ae_iff.mpr + simpa only [Set.preimage,Set.mem_singleton_iff,not_not] using hz + filter_upwards [hnot] with u hu + exact fun h => (hu h).elim + have hall := (S.eventually_all).mpr hnull + filter_upwards [hall] with u hu + have hmem : f u ∈ S := hfin.mem_toFinset.mpr (mem_range_self u) + exact Finset.mem_filter.mpr ⟨hmem,hu (f u) hmem rfl⟩ + have hT : T.Nonempty := by + obtain ⟨u,hu⟩ := hae.exists + exact ⟨f u,hu⟩ + obtain ⟨d,hd⟩ := Nat.exists_eq_succ_of_ne_zero (Finset.card_ne_zero.mpr hT) + let e := T.orderIsoOfFin hd + let v : Fin (d+1) → ℝ := fun i => e i + have hv : StrictMono v := fun i j hij => e.strictMono hij + have hve : MeasurableEmbedding v := ⟨hv.injective,measurable_of_finite _,fun _ _ => (Set.toFinite _).measurableSet⟩ + let a : Time → Fin (d+1) := fun u => hve.invFun (f u) + have hag : (fun u => v (a u)) =ᵐ[timeLaw] f := by + filter_upwards [hae] with u hu + have hx : f u=v (e.symm ⟨f u,hu⟩) := congrArg Subtype.val (e.apply_symm_apply ⟨f u,hu⟩) |>.symm + dsimp only [a] + rw [hx,hve.leftInverse_invFun] + refine ⟨⟨d,v,a,hve.measurable_invFun.comp hf,?_,hv.monotone,hag⟩⟩ + intro i + have he : a ⁻¹' {i}=ᵐ[timeLaw] f ⁻¹' {v i} := by + filter_upwards [hag] with u hu + apply propext + change (a u=i) ↔ f u=v i + rw [← hu] + exact hv.injective.eq_iff.symm + change 0 < (timeLaw (a ⁻¹' {i})).toReal + rw [measure_congr he] + exact (Finset.mem_filter.mp (e i).2).2 + +structure BoundedField (H : ℝ) where + toFun : Time → ℝ + monotone : Monotone toFun + nonneg : ∀ u, 0 ≤ toFun u + le_bound : ∀ u, toFun u ≤ H + +instance {H : ℝ} : CoeFun (BoundedField H) (fun _ => Time → ℝ) := ⟨BoundedField.toFun⟩ + +lemma BoundedField.measurable {H : ℝ} (f : BoundedField H) : Measurable f := f.monotone.measurable + +def roundLower (N : ℕ) (x : ℝ) : ℝ := (⌊(N+1:ℕ)*x⌋₊:ℝ)/(N+1:ℕ) + +lemma roundLower_nonneg (N : ℕ) (x : ℝ) : 0 ≤ roundLower N x := by unfold roundLower; positivity + +lemma roundLower_monotone (N : ℕ) : Monotone (roundLower N) := by + intro x y hxy + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast Nat.floor_mono (mul_le_mul_of_nonneg_left hxy (by positivity)) + +lemma roundLower_le (N : ℕ) {x : ℝ} (hx : 0 ≤ x) : roundLower N x ≤ x := by + unfold roundLower + rw [div_le_iff₀ (by positivity : (0:ℝ)<(N+1:ℕ))] + simpa only [mul_comm] using Nat.floor_le (mul_nonneg (by positivity) hx) + +def BoundedField.round {H : ℝ} (f : BoundedField H) (N : ℕ) : BoundedField H where + toFun := fun u => roundLower N (f u) + monotone := (roundLower_monotone N).comp f.monotone + nonneg := fun u => roundLower_nonneg N (f u) + le_bound := fun u => (roundLower_le N (f.nonneg u)).trans (f.le_bound u) + +lemma BoundedField.round_finite {H : ℝ} (f : BoundedField H) (N : ℕ) : + (Set.range (f.round N)).Finite := by + let T := (Finset.range (⌊(N+1:ℕ)*H⌋₊+1)).image (fun k : ℕ => (k:ℝ)/(N+1:ℕ)) + apply T.finite_toSet.subset + rintro x ⟨u,rfl⟩ + apply Finset.mem_image.mpr + refine ⟨⌊(N+1:ℕ)*f u⌋₊,?_,rfl⟩ + apply Finset.mem_range.mpr + exact Nat.lt_succ_of_le (Nat.floor_mono (mul_le_mul_of_nonneg_left (f.le_bound u) (by positivity))) + +def BoundedField.roundModel {H : ℝ} (f : BoundedField H) (N : ℕ) : FiniteFieldModel (f.round N) := + Classical.choice (exists_finiteFieldModel _ (f.round N).measurable (f.round_finite N)) + +def quantileTrial (q : Time → Time) : Trial where + toFun := fun t => timeLaw.real {u | q u ≤ t} + monotone := by + intro s t hst + exact measureReal_mono (fun u hu => hu.trans hst) + measurable := by + apply Monotone.measurable + intro s t hst + exact measureReal_mono (fun u hu => hu.trans hst) + nonneg := fun _ => measureReal_nonneg + le_one := by + intro t + exact measureReal_le_one + +def quantileTail (q : Time → Time) (t : ℝ) : ℝ := + ∫ u, 1-max (q u:ℝ) t ∂timeLaw + +lemma quantileTail_integrable (q : Time → Time) (hq : Measurable q) (t : ℝ) : + Integrable (fun u => 1-max (q u:ℝ) t) timeLaw := by + have hm : Measurable (fun u => 1-max (q u:ℝ) t) := + measurable_const.sub ((measurable_subtype_coe.comp hq).max measurable_const) + apply Integrable.mono' (integrable_const (2+|t|)) hm.aestronglyMeasurable + exact ae_of_all _ fun u => by + rw [Real.norm_eq_abs] + have hq0 := (q u).2.1 + have hq1 := (q u).2.2 + have ha : |max (q u:ℝ) t| ≤ 1+|t| := by + rcases le_total (q u:ℝ) t with h | h + · rw [max_eq_right h]; linarith + · rw [max_eq_left h,abs_of_nonneg hq0]; nlinarith [abs_nonneg t] + have hb := abs_sub 1 (max (q u:ℝ) t) + norm_num at hb + linarith + +lemma quantileTail_lower (q : Time → Time) (hq : Measurable q) {B t : ℝ} + (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) (ht : t ≤ B) : + 1-B ≤ quantileTail q t := by + have h := integral_mono_ae (integrable_const (1-B)) (quantileTail_integrable q hq t) + (hb.mono fun u hu => sub_le_sub_left (max_le hu ht) 1) + simpa [quantileTail] using h + +lemma quantileTail_lipschitz (q : Time → Time) (hq : Measurable q) : + LipschitzWith 1 (quantileTail q) := by + apply LipschitzWith.of_dist_le_mul + intro s t + rw [Real.dist_eq,Real.dist_eq,NNReal.coe_one,one_mul] + unfold quantileTail + rw [← integral_sub (quantileTail_integrable q hq s) (quantileTail_integrable q hq t)] + calc + _ ≤ ∫ u, |(1-max (q u:ℝ) s)-(1-max (q u:ℝ) t)| ∂timeLaw := abs_integral_le_integral_abs + _ ≤ ∫ _ : Time, |s-t| ∂timeLaw := by + apply integral_mono ((quantileTail_integrable q hq s).sub (quantileTail_integrable q hq t)).abs (integrable_const _) + intro u + have h := (LipschitzWith.id.const_max (q u:ℝ)).dist_le_mul s t + simp only [Real.dist_eq,NNReal.coe_one,one_mul] at h + change |(1-max (q u:ℝ) s)-(1-max (q u:ℝ) t)| ≤ _ + rw [show (1-max (q u:ℝ) s)-(1-max (q u:ℝ) t)=max (q u:ℝ) t-max (q u:ℝ) s by ring,abs_sub_comm] + exact h + _ = _ := by simp + +def boundedSphericalFieldValue {H : ℝ} (f : BoundedField H) (n : ℕ) : ℝ := + limUnder atTop (fun N => (f.roundModel N).pressure n) + +def BoundedField.toQuantile {B : ℝ} (q : BoundedField B) (hB : B ≤ 1) : Time → Time := + fun u => ⟨q u,q.nonneg u,(q.le_bound u).trans hB⟩ + +lemma BoundedField.toQuantile_measurable {B : ℝ} (q : BoundedField B) (hB : B ≤ 1) : + Measurable (q.toQuantile hB) := q.measurable.subtype_mk + +def quantileA (q : Time → Time) (r : ℝ) : ℝ := + ∫ t in (0:ℝ)..r, 1/(quantileTail q t)^2 + +lemma quantileA_integrand_continuous {B : ℝ} (q : Time → Time) (hq : Measurable q) + (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) : + ContinuousOn (fun t => 1/(quantileTail q t)^2) (Icc 0 B) := by + apply continuousOn_const.div ((quantileTail_lipschitz q hq).continuous.continuousOn.pow 2) + intro t ht + exact pow_ne_zero _ (ne_of_gt ((sub_pos.mpr hB).trans_le (quantileTail_lower q hq hb ht.2))) + +lemma quantileA_integrand_bound {B t : ℝ} (q : Time → Time) (hq : Measurable q) + (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) (ht : t ≤ B) : + 1/(quantileTail q t)^2 ≤ 1/(1-B)^2 := by + have hd := quantileTail_lower q hq hb ht + exact one_div_le_one_div_of_le (sq_pos_of_pos (sub_pos.mpr hB)) + (pow_le_pow_left₀ (sub_nonneg.mpr hB.le) hd 2) + +lemma quantileA_nonneg (q : Time → Time) {r : ℝ} (hr : 0 ≤ r) : 0 ≤ quantileA q r := + intervalIntegral.integral_nonneg hr (fun _ _ => by positivity) + +lemma quantileA_mono {B : ℝ} (q : Time → Time) (hq : Measurable q) + (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) : + MonotoneOn (quantileA q) (Icc 0 B) := by + intro r hr s hs hrs + exact intervalIntegral.integral_mono_interval le_rfl hr.1 hrs + (ae_of_all _ fun _ => by positivity) + (((quantileA_integrand_continuous q hq hB hb).mono (Icc_subset_Icc le_rfl hs.2)).intervalIntegrable_of_Icc hs.1) + +lemma quantileA_bound {B r : ℝ} (q : Time → Time) (hq : Measurable q) + (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) (hr : r ∈ Icc 0 B) : + quantileA q r ≤ B/(1-B)^2 := by + have h := intervalIntegral.integral_mono_on hr.1 + (((quantileA_integrand_continuous q hq hB hb).mono (Icc_subset_Icc le_rfl hr.2)).intervalIntegrable_of_Icc hr.1) + (intervalIntegrable_const (μ := volume) (c := 1/(1-B)^2)) + (fun t ht => quantileA_integrand_bound q hq hB hb (ht.2.trans hr.2)) + have he : (∫ _t in (0:ℝ)..r, 1/(1-B)^2)=r/(1-B)^2 := by simp [div_eq_mul_inv] + rw [he] at h + exact h.trans (div_le_div_of_nonneg_right hr.2 (sq_nonneg _)) + +def BoundedField.stationary {B : ℝ} (q : BoundedField B) (hB : B < 1) : + BoundedField (B/(2*(1-B)^2)) where + toFun := fun u => quantileA (q.toQuantile hB.le) (q u)/2 + monotone := fun u v huv => div_le_div_of_nonneg_right + (quantileA_mono _ (q.toQuantile_measurable hB.le) hB (ae_of_all _ q.le_bound) + ⟨q.nonneg u,q.le_bound u⟩ ⟨q.nonneg v,q.le_bound v⟩ (q.monotone huv)) (by norm_num) + nonneg := fun u => div_nonneg (quantileA_nonneg _ (q.nonneg u)) (by norm_num) + le_bound := by + intro u + have h := (quantileA_bound _ (q.toQuantile_measurable hB.le) hB (ae_of_all _ q.le_bound) + ⟨q.nonneg u,q.le_bound u⟩) + calc + _ ≤ (B/(1-B)^2)/2 := div_le_div_of_nonneg_right h (by norm_num) + _ = _ := by rw [div_div,mul_comm] + +def clippedQuantile (q : Time → Time) (hq : Monotone q) (B : ℝ) (hB0 : 0 ≤ B) : BoundedField B where + toFun := fun u => min (q u:ℝ) B + monotone := fun _ _ huv => min_le_min (hq huv) le_rfl + nonneg := fun u => le_min (q u).2.1 hB0 + le_bound := fun _ => min_le_right _ _ + +def stationaryQuantileField (q : Time → Time) (hq : Monotone q) (B : ℝ) (hB0 : 0 ≤ B) (hB1 : B < 1) : + BoundedField (B/(2*(1-B)^2)) := (clippedQuantile q hq B hB0).stationary hB1 + +def SphericalLinearFieldFormula : Prop := + (∀ (k : ℕ) (w : Fin (k+1) → ℝ) (hw : ∀ i, 0 < w i) (hw1 : ∑ i, w i=1), + (∀ h : Fin (k+1) → ℝ, Monotone h → 0 ≤ h 0 → + ∃ q : Fin (k+1) → Time, Monotone q ∧ (q (Fin.last k):ℝ) < 1 ∧ + IsLeast (finiteSphericalDualValues w h (fun i => (hw i).le) hw1) + (finiteSphericalDualObjective w h (fun i => (hw i).le) hw1 q)) ∧ + (∀ K : Set (Fin (k+1) → ℝ), IsCompact K → + (∀ h ∈ K, Monotone h ∧ 0 ≤ h 0) → + TendstoUniformlyOn (fun n h => finiteSphericalFieldValue n k w h) + (fun h => sInf (finiteSphericalDualValues w h (fun i => (hw i).le) hw1)) atTop K)) ∧ + (∀ (B : ℝ) (hB0 : 0 ≤ B) (hB1 : B < 1) (ε : ℝ), 0 < ε → + ∀ᶠ n : ℕ in atTop, ∀ (q : Time → Time) (hq : Monotone q), + (∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) → + entropy (quantileTrial q) < ∞ ∧ + (∀ᵐ u ∂timeLaw, 2*stationaryQuantileField q hq B hB0 hB1 u=quantileA q (q u)) ∧ + |boundedSphericalFieldValue (stationaryQuantileField q hq B hB0 hB1) n- + ((entropy (quantileTrial q)).toReal- + ∫ u, stationaryQuantileField q hq B hB0 hB1 u*(q u:ℝ) ∂timeLaw)| < ε) + +end SphericalPerceptron + +end + +namespace SphericalPerceptron +theorem spherical_linear_field_formula : SphericalLinearFieldFormula := by + sorry +end SphericalPerceptron + +end OAI diff --git a/lean/ComparatorChallenges/SpinAngle.json b/lean/ComparatorChallenges/SpinAngle.json new file mode 100644 index 0000000000000000000000000000000000000000..b769ed8d7c8d57755e0a3fcbac199ac1344589e0 --- /dev/null +++ b/lean/ComparatorChallenges/SpinAngle.json @@ -0,0 +1,18 @@ +{ + "challenge_module": "ComparatorChallenges.SpinAngle", + "solution_module": "OAI.RepresentationTheory.SpinAngle.TypeAngle", + "theorem_names": [ + "OAI.SpinAngle.TypeAngle.one_sided_type_angle" + ], + "definition_names": [ + "OAI.SpinAngle.TypeAngle.row", + "OAI.SpinAngle.TypeAngle.column", + "OAI.SpinAngle.TypeAngle.phi" + ], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SpinAngle.lean b/lean/ComparatorChallenges/SpinAngle.lean new file mode 100644 index 0000000000000000000000000000000000000000..f88e758fb5e806322a0a16163306c7a45f028e8e --- /dev/null +++ b/lean/ComparatorChallenges/SpinAngle.lean @@ -0,0 +1,539 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open scoped BigOperators ComplexConjugate InnerProductSpace Matrix TensorProduct + +open scoped Matrix.Norms.L2Operator MatrixOrder ComplexOrder + +namespace SpinAngle.Specht + +variable {G : Type*} [Group G] +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + +def cyclic (ρ : Representation ℂ G E) (e : E) : Subrepresentation ρ where + toSubmodule := Submodule.span ℂ (Set.range fun g => ρ g e) + apply_mem_toSubmodule g := by + intro v hv + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨h, rfl⟩ := hv + exact Submodule.subset_span ⟨g * h, by simp⟩ + | zero => simp + | add x y hx hy ihx ihy => + simpa using (Submodule.span ℂ (Set.range fun h => ρ h e)).add_mem ihx ihy + | smul a x hx ih => + simpa using (Submodule.span ℂ (Set.range fun h => ρ h e)).smul_mem a ih + +end SpinAngle.Specht + +namespace SpinAngle.TensorRep +variable {ι n : Type*} [Fintype ι] [DecidableEq ι] [Fintype n] [DecidableEq n] + +def tensor (a : ι → Matrix n n ℂ) : Matrix (ι → n) (ι → n) ℂ := + fun x y => ∏ i, a i (x i) (y i) + +lemma tensor_mul + {ι : Type*} {n : Type*} + [Fintype ι] + [DecidableEq ι] + [Fintype n] + [DecidableEq n] (a b : ι → Matrix n n ℂ) : + tensor (fun i => a i * b i) = tensor a * tensor b := by + ext x y + simp only [tensor, Matrix.mul_apply, ← Finset.prod_mul_distrib] + symm + simpa using (Finset.sum_prod_piFinset (ι := ι) Finset.univ + (fun i j => a i (x i) j * b i j (y i))) + +lemma tensor_one + {ι : Type*} {n : Type*} + [Fintype ι] + [DecidableEq ι] + [Fintype n] + [DecidableEq n] : tensor (fun _ : ι => (1 : Matrix n n ℂ)) = 1 := by + ext x y + classical + by_cases h : x = y + · subst y + simp [tensor] + · obtain ⟨i, hi⟩ := Function.ne_iff.mp h + simp only [tensor, Matrix.one_apply, ite_eq_right h] + apply Finset.prod_eq_zero (Finset.mem_univ i) + simp [hi] + +lemma toEuclideanLin_mul + {ι : Type*} {n : Type*} + [Fintype ι] + [DecidableEq ι] + [Fintype n] + [DecidableEq n] (a b : Matrix n n ℂ) : + Matrix.toEuclideanLin (a * b) = + Matrix.toEuclideanLin a * Matrix.toEuclideanLin b := by + ext v x + change ((a * b) *ᵥ (WithLp.ofLp v)) x = (a *ᵥ (b *ᵥ (WithLp.ofLp v))) x + rw [Matrix.mulVec_mulVec] + +lemma toEuclideanLin_one + {ι : Type*} {n : Type*} + [Fintype ι] + [DecidableEq ι] + [Fintype n] + [DecidableEq n] : Matrix.toEuclideanLin (1 : Matrix n n ℂ) = 1 := by + ext v x + change ((1 : Matrix n n ℂ) *ᵥ (WithLp.ofLp v)) x = v x + simp + +def action : Matrix n n ℂ →* Module.End ℂ (EuclideanSpace ℂ (ι → n)) where + toFun a := Matrix.toEuclideanLin (tensor (fun _ : ι => a)) + map_one' := by rw [tensor_one, toEuclideanLin_one (ι := ι)] + map_mul' a b := by rw [tensor_mul, toEuclideanLin_mul (ι := ι)] + +def rep : Representation ℂ (Matrix.unitaryGroup n ℂ) (EuclideanSpace ℂ (ι → n)) := + action.comp (Matrix.unitaryGroup n ℂ).subtype + +lemma tensor_reindex + {ι : Type*} {n : Type*} + [Fintype ι] + [DecidableEq ι] + [Fintype n] + [DecidableEq n] (a : Matrix n n ℂ) (σ : Equiv.Perm ι) (x y : ι → n) : + tensor (fun _ : ι => a) (x ∘ σ) (y ∘ σ) = tensor (fun _ : ι => a) x y := by + exact Equiv.prod_comp σ (fun i => a (x i) (y i)) + +end SpinAngle.TensorRep + +namespace SpinAngle.Specht +open scoped Classical +variable {G : Type*} [Group G] +namespace PermutationSpace +open scoped Classical + +variable {X : Type*} [Fintype X] [MulAction G X] + +def rep : Representation ℂ G (EuclideanSpace ℂ X) where + toFun g := { + toFun v := WithLp.toLp 2 (fun x => v (g⁻¹ • x)) + map_add' := by intro v w; rfl + map_smul' := by intro a v; rfl } + map_one' := by ext v x; simp + map_mul' := by + intro g h + ext v x + change v ((g * h)⁻¹ • x) = v (h⁻¹ • g⁻¹ • x) + simp [mul_smul] + +variable {H : Type*} [Group H] [Fintype H] + +def alternator (ι : H →* G) (χ : H →* ℂ) : Module.End ℂ (EuclideanSpace ℂ X) := + ∑ h, χ h • rep (ι h) + +omit [Fintype X] in +lemma alternator_apply (ι : H →* G) (χ : H →* ℂ) (v : EuclideanSpace ℂ X) : + alternator ι χ v = ∑ h, χ h • rep (ι h) v := by + simp [alternator, LinearMap.sum_apply] + +lemma rep_alternator + {G : Type*} {H : Type*} {X : Type*} + [Group G] + [Group H] + [Fintype H] + [Fintype X] + [MulAction G X] (ι : H →* G) (χ : H →* ℂ) (a : H) + (v : EuclideanSpace ℂ X) : + rep (ι a) (alternator ι χ v) = χ a⁻¹ • alternator ι χ v := by + rw [alternator_apply, map_sum, Finset.smul_sum] + have he := Equiv.sum_comp (Equiv.mulLeft a) + (fun h => χ a⁻¹ • (χ h • (rep (ι h) v : EuclideanSpace ℂ X))) + rw [← he] + apply Finset.sum_congr rfl + intro h _ + simp only [Equiv.coe_mulLeft, smul_smul, map_mul, map_smul] + rw [show χ a⁻¹ * (χ a * χ h) = χ h by + rw [← mul_assoc, ← map_mul, inv_mul_cancel, map_one, one_mul]] + rfl + +end PermutationSpace + +variable {α : Type*} [Fintype α] + +def complexSign : Equiv.Perm α →* ℂ where + toFun g := ((Equiv.Perm.sign g : ℤˣ) : ℤ) + map_one' := by simp + map_mul' := by intro g h; simp + +@[simp] lemma complexSign_inv (g : Equiv.Perm α) : complexSign g⁻¹ = complexSign g := by + simp [complexSign] + +end SpinAngle.Specht + +namespace SpinAngle.Young + +abbrev Cells (D : YoungDiagram) := {p : ℕ × ℕ // p ∈ D.cells} + +end SpinAngle.Young + +namespace SpinAngle.PolynomialCarrier +open scoped Classical Matrix +open SpinAngle.Specht SpinAngle.Young +variable {ι n : Type*} [Fintype ι] [DecidableEq ι] [Fintype n] [DecidableEq n] + +instance coloringAction : MulAction (Equiv.Perm ι) (ι → n) where + smul g x := x ∘ g.symm + one_smul _ := rfl + mul_smul _ _ _ := rfl + +def reindex (g : Equiv.Perm ι) : (ι → n) ≃ (ι → n) where + toFun x := x ∘ g + invFun x := x ∘ g.symm + left_inv x := by funext i; simp + right_inv x := by funext i; simp + +lemma action_site_commute (a : Matrix n n ℂ) (g : Equiv.Perm ι) + (v : EuclideanSpace ℂ (ι → n)) : + TensorRep.action a (PermutationSpace.rep g v) = + PermutationSpace.rep g (TensorRep.action a v) := by + ext x + change (∑ y, TensorRep.tensor (fun _ : ι => a) x y * v (y ∘ g)) = + ∑ y, TensorRep.tensor (fun _ : ι => a) (x ∘ g) y * v y + rw [← Equiv.sum_comp (reindex (n := n) g) + (fun y => TensorRep.tensor (fun _ : ι => a) (x ∘ g) y * v y)] + apply Finset.sum_congr rfl + intro y _ + change _ = TensorRep.tensor (fun _ : ι => a) (x ∘ g) (y ∘ g) * v (y ∘ g) + rw [TensorRep.tensor_reindex] + +def columnGroup (D : YoungDiagram) : Subgroup (Equiv.Perm (Cells D)) where + carrier := {g | ∀ x, (g x).val.2 = x.val.2} + one_mem' := fun _ => rfl + mul_mem' := by intro g h hg hh x; exact (hg (h x)).trans (hh x) + inv_mem' := by + intro g hg x + simpa using (hg (g⁻¹ x)).symm + +variable (D : YoungDiagram) (q : ℕ) +abbrev TensorSpace := EuclideanSpace ℂ (Cells D → Fin q) + +def alternating : Subrepresentation (TensorRep.rep (ι := Cells D) (n := Fin q)) where + toSubmodule := { + carrier := {v | ∀ g : columnGroup D, + PermutationSpace.rep (g : Equiv.Perm (Cells D)) v = complexSign g.val • v} + zero_mem' := by intro g; simp + add_mem' := by intro x y hx hy g; simp [map_add, hx g, hy g, smul_add] + smul_mem' := by intro c x hx g; simp [map_smul, hx g, smul_comm c] } + apply_mem_toSubmodule a := by + intro v hv g + change PermutationSpace.rep g.val (TensorRep.action (a : Matrix (Fin q) (Fin q) ℂ) v) = _ + rw [← action_site_commute, hv g, map_smul] + rfl + +variable (hq : D.colLen 0 ≤ q) + +def rowColor : Cells D → Fin q := fun x => ⟨x.val.1, by + have hm := D.up_left_mem le_rfl (Nat.zero_le x.val.2) x.property + have hl := YoungDiagram.mem_iff_lt_colLen.mp hm + exact lt_of_lt_of_le hl hq⟩ + +def highest : TensorSpace D q := by + classical + exact PermutationSpace.alternator (columnGroup D).subtype + (complexSign.comp (columnGroup D).subtype) + (EuclideanSpace.single (rowColor D q hq) (1 : ℂ)) + +lemma highest_mem : highest D q hq ∈ alternating D q := by + classical + intro g + change PermutationSpace.rep g.val (PermutationSpace.alternator _ _ _) = _ + have hh := PermutationSpace.rep_alternator (columnGroup D).subtype + (complexSign.comp (columnGroup D).subtype) g (EuclideanSpace.single (rowColor D q hq) (1 : ℂ)) + change PermutationSpace.rep g.val (highest D q hq) = complexSign (g.val⁻¹) • highest D q hq at hh + rw [complexSign_inv] at hh + exact hh + +def ordinary : Subrepresentation (alternating D q).toRepresentation := + cyclic (alternating D q).toRepresentation + (⟨highest D q hq, highest_mem D q hq⟩ : (alternating D q).toSubmodule) + +abbrev Carrier : Type := (ordinary D q hq).toSubmodule + +instance carrierInner : InnerProductSpace ℂ (Carrier D q hq) := + @Submodule.innerProductSpace ℂ (alternating D q).toSubmodule _ _ inferInstance + (ordinary D q hq).toSubmodule + +end SpinAngle.PolynomialCarrier + +namespace SpinAngle.ExternalTensor +open Module +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [NormedAddCommGroup F] [InnerProductSpace ℂ F] + [FiniteDimensional ℂ E] [FiniteDimensional ℂ F] +variable {G H : Type*} [Group G] [Group H] + +def rep (ρ : Representation ℂ G E) (σ : Representation ℂ H F) : + Representation ℂ (G × H) (E ⊗[ℂ] F) := + Representation.tprod (ρ.comp (MonoidHom.fst G H)) (σ.comp (MonoidHom.snd G H)) + +end SpinAngle.ExternalTensor + +namespace SpinAngle.SignedTensor +open scoped Classical Matrix TensorProduct InnerProductSpace +open Module +variable {q : ℕ} +abbrev Spin (q : ℕ) := Fin q × Bool +abbrev Mat (q : ℕ) := Matrix (Fin q) (Fin q) ℂ +abbrev Group (q : ℕ) := Matrix.unitaryGroup (Fin q) ℂ × Matrix.unitaryGroup (Fin q) ℂ + +def block : (Mat q × Mat q) →* Matrix (Spin q) (Spin q) ℂ where + toFun a := Matrix.blockDiagonal (fun b : Bool => cond b a.2 a.1) + map_one' := by + convert (Matrix.blockDiagonal_one (m := Fin q) (o := Bool) (α := ℂ)) using 1 + congr 1 + funext b + cases b <;> rfl + map_mul' a b := by + rw [← Matrix.blockDiagonal_mul] + congr 1 + funext c + cases c <;> rfl + +lemma block_star (a : Mat q × Mat q) : block (star a) = star (block a) := by + change Matrix.blockDiagonal (fun b : Bool => cond b (star a.2) (star a.1)) = (Matrix.blockDiagonal (fun b : Bool => cond b a.2 a.1))ᴴ + rw [Matrix.blockDiagonal_conjTranspose] + congr 1 + funext b + cases b <;> rfl + +def blockGroup : Group q →* Matrix.unitaryGroup (Spin q) ℂ where + toFun g := ⟨block (g.1.val,g.2.val), by + rw [Matrix.mem_unitaryGroup_iff', ← block_star, ← map_mul] + have he : star (g.1.val,g.2.val) * (g.1.val,g.2.val) = 1 := + Prod.ext g.1.property.1 g.2.property.1 + rw [he, map_one]⟩ + map_one' := by + apply Subtype.ext + change block (1 : Mat q × Mat q) = 1 + exact block.map_one + map_mul' g h := by + apply Subtype.ext + change block ((g.1.val,g.2.val) * (h.1.val,h.2.val)) = + block (g.1.val,g.2.val) * block (h.1.val,h.2.val) + exact block.map_mul _ _ + +variable {ι κ τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + [Fintype τ] [DecidableEq τ] + +abbrev Raw := EuclideanSpace ℂ (τ → Spin q) + +def rep : Representation ℂ (Group q) (Raw (q := q) (τ := τ)) := + (TensorRep.rep (ι := τ)).comp blockGroup + +end SpinAngle.SignedTensor + +namespace SpinAngle.EntropyMonomial +variable {ι : Type*} [Fintype ι] + +def entropy (n : ι → ℕ) : ℝ := + (∑ i, n i : ℕ) * Real.log (∑ i, n i : ℕ) - ∑ i, (n i : ℝ) * Real.log (n i) + +end SpinAngle.EntropyMonomial + +namespace SpinAngle.Isotypic +variable {G : Type*} [Group G] +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [NormedAddCommGroup F] [InnerProductSpace ℂ F] + [FiniteDimensional ℂ E] [FiniteDimensional ℂ F] +variable (ρ : Representation ℂ G E) (σ : Representation ℂ G F) + +def space : Subrepresentation σ where + toSubmodule := Submodule.span ℂ (Set.range fun z : ρ.IntertwiningMap σ × E => z.1 z.2) + apply_mem_toSubmodule := by + intro g v hv + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨⟨f,x⟩,rfl⟩ := hv + apply Submodule.subset_span + refine ⟨⟨f,ρ g x⟩, ?_⟩ + exact Representation.IntertwiningMap.isIntertwining ρ σ f g x + | zero => simp + | add x y hx hy ihx ihy => simpa only [map_add] using Submodule.add_mem _ ihx ihy + | smul a x hx ih => simpa only [map_smul] using Submodule.smul_mem _ a ih + +def projection : F →L[ℂ] F := (space ρ σ).toSubmodule.starProjection + +end SpinAngle.Isotypic + +namespace SpinAngle.SignedCarrier +open scoped Classical TensorProduct InnerProductSpace +open SpinAngle.Young SpinAngle.Specht PolynomialCarrier Module SignedTensor +variable (a b : YoungDiagram) (q : ℕ) (ha : a.colLen 0 ≤ q) (hb : b.colLen 0 ≤ q) + +abbrev Carrier := PolynomialCarrier.Carrier a q ha ⊗[ℂ] PolynomialCarrier.Carrier b q hb + +instance carrierNormed : NormedAddCommGroup (Carrier a b q ha hb) := + TensorProduct.instNormedAddCommGroup (𝕜 := ℂ) + (E := PolynomialCarrier.Carrier a q ha) (F := PolynomialCarrier.Carrier b q hb) + +instance carrierInner : InnerProductSpace ℂ (Carrier a b q ha hb) := + TensorProduct.instInnerProductSpace (𝕜 := ℂ) + (E := PolynomialCarrier.Carrier a q ha) (F := PolynomialCarrier.Carrier b q hb) + +instance carrierFinite : FiniteDimensional ℂ (Carrier a b q ha hb) := + inferInstanceAs (FiniteDimensional ℂ (PolynomialCarrier.Carrier a q ha ⊗[ℂ] PolynomialCarrier.Carrier b q hb)) + +abbrev rep : Representation ℂ (Group q) (Carrier a b q ha hb) := + ExternalTensor.rep (E := PolynomialCarrier.Carrier a q ha) + (F := PolynomialCarrier.Carrier b q hb) + (ordinary a q ha).toRepresentation (ordinary b q hb).toRepresentation + +def parts : Fin q ⊕ Fin q → ℕ := Sum.elim (fun i => a.rowLen i) (fun i => b.rowLen i) +def entropy : ℝ := EntropyMonomial.entropy (parts a b q) +def dimension : ℕ := Module.finrank ℂ (Carrier a b q ha hb) + +variable {τ : Type*} [Fintype τ] [DecidableEq τ] + +abbrev typeProjection : Raw (q := q) (τ := τ) →L[ℂ] Raw (q := q) (τ := τ) := + Isotypic.projection (rep a b q ha hb) SignedTensor.rep + +def matrixProjection : Matrix (τ → Spin q) (τ → Spin q) ℂ := + (Matrix.toEuclideanCLM (n := τ → Spin q) (𝕜 := ℂ)).symm (typeProjection a b q ha hb) + +end SpinAngle.SignedCarrier + +namespace SpinAngle + +def missingCellFactor (m b : ℕ) : ℝ := + if b < m then ((m : ℝ) / (m - b : ℕ)) ^ (m - b) else 1 + +def missingCellProductFactor {ι : Type*} [Fintype ι] (m : ℕ) (b : ι → ℕ) : ℝ := + ∏ i, missingCellFactor m (b i) + +variable {R C : Type*} [Fintype R] [DecidableEq R] [Fintype C] [DecidableEq C] + +def occupiedRow (W : Finset (R × C)) (i : R) : Finset C := + Finset.univ.filter (fun j => (i, j) ∈ W) + +def missingInRow (W : Finset (R × C)) (i : R) : ℕ := + Fintype.card C - (occupiedRow W i).card + +end SpinAngle + +namespace SpinAngle.DependentTensor +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +variable {ν : ι → Type*} [∀ i, Fintype (ν i)] [∀ i, DecidableEq (ν i)] + +abbrev Mat (n : Type*) := Matrix n n ℂ + +def tensor (A : ∀ i, Mat (ν i)) : Mat (∀ i, ν i) := fun x y => ∏ i, A i (x i) (y i) + +end SpinAngle.DependentTensor + +namespace SpinAngle.BlockTensor +open DependentTensor +variable {τ J n : Type*} [Fintype τ] [DecidableEq τ] [Fintype J] [DecidableEq J] + [Fintype n] [DecidableEq n] +variable (f : τ → J) + +abbrev Fiber (j : J) := {i : τ // f i = j} + +def splitEquiv : (τ → n) ≃ (∀ j : J, Fiber f j → n) where + toFun x j i := x i.val + invFun y i := y (f i) ⟨i,rfl⟩ + left_inv x := rfl + right_inv y := by + funext j i + rcases i with ⟨i,hi⟩ + subst j + rfl + +def tensor (A : ∀ j, Mat (Fiber f j → n)) : Mat (τ → n) := + fun x y => DependentTensor.tensor A (splitEquiv f x) (splitEquiv f y) + +end SpinAngle.BlockTensor + +namespace SpinAngle.MatrixAnalysis +variable {n : Type*} [Fintype n] [DecidableEq n] + +abbrev Mat (n : Type*) := Matrix n n ℂ + +end SpinAngle.MatrixAnalysis + +namespace SpinAngle + +open SpinAngle.Young + +structure TypeLabel (q : ℕ) where + even : YoungDiagram + odd : YoungDiagram + even_height : even.colLen 0 ≤ q + odd_height : odd.colLen 0 ≤ q + +namespace TypeLabel +variable {q : ℕ} +def size (D : TypeLabel q) : ℕ := Fintype.card (Cells D.even) + Fintype.card (Cells D.odd) +def entropy (D : TypeLabel q) : ℝ := SignedCarrier.entropy D.even D.odd q +def dimension (D : TypeLabel q) : ℕ := SignedCarrier.dimension D.even D.odd q D.even_height D.odd_height + +def projection (D : TypeLabel q) (τ : Type*) [Fintype τ] [DecidableEq τ] : + Matrix (τ → SignedTensor.Spin q) (τ → SignedTensor.Spin q) ℂ := + SignedCarrier.matrixProjection D.even D.odd q D.even_height D.odd_height + +end TypeLabel + +namespace TypeBlocks +universe u +open MatrixAnalysis +variable {q : ℕ} +variable {τ : Type*} {J : Type u} [Fintype τ] [DecidableEq τ] [Fintype J] [DecidableEq J] + +abbrev Fiber (f : τ → J) (j : J) := BlockTensor.Fiber f j + +def projection (f : τ → J) (D : J → TypeLabel q) : Mat (τ → SignedTensor.Spin q) := + BlockTensor.tensor f (fun j => (D j).projection (Fiber f j)) + +def entropy (D : J → TypeLabel q) : ℝ := ∑ j, (D j).entropy +def dimension (D : J → TypeLabel q) : ℕ := ∏ j, (D j).dimension + +end TypeBlocks + +end SpinAngle + + +namespace SpinAngle.TypeAngle + +open scoped BigOperators Matrix.Norms.L2Operator MatrixOrder ComplexOrder + +variable {q : ℕ} [Nonempty (Fin q)] +variable {R C : Type*} +variable [Fintype R] [DecidableEq R] [Fintype C] [DecidableEq C] + +def row (W : Finset (R × C)) (w : W) : R := w.val.1 + +def column (W : Finset (R × C)) (w : W) : C := w.val.2 + +def phi (W : Finset (R × C)) : ℝ := + missingCellProductFactor (Fintype.card C) (missingInRow W) + +theorem one_sided_type_angle (W : Finset (R × C)) + (D : TypeLabel q) (H : C → TypeLabel q) (K : R → TypeLabel q) + (hD : D.size = W.card) + (hH : ∀ j, (H j).size = Fintype.card (TypeBlocks.Fiber (column W) j)) + (hK : ∀ i, (K i).size = Fintype.card (TypeBlocks.Fiber (row W) i)) : + (‖TypeBlocks.projection (column W) H * TypeBlocks.projection (row W) K * D.projection W‖ ^ 2 ≤ + min 1 (Real.exp (TypeBlocks.entropy H + TypeBlocks.entropy K - D.entropy) * + (TypeBlocks.dimension H : ℝ) * (TypeBlocks.dimension K : ℝ) * phi W)) ∧ + (min 1 (Real.exp (TypeBlocks.entropy H + TypeBlocks.entropy K - D.entropy) * + (TypeBlocks.dimension H : ℝ) * (TypeBlocks.dimension K : ℝ) * phi W) ≤ + min 1 (Real.exp (TypeBlocks.entropy H + TypeBlocks.entropy K - D.entropy + + (Fintype.card R * Fintype.card C - W.card : ℕ)) * + (TypeBlocks.dimension H : ℝ) * (TypeBlocks.dimension K : ℝ))) ∧ + TypeBlocks.dimension H * TypeBlocks.dimension K ≤ + (W.card + 1) ^ ((Fintype.card R + Fintype.card C) * q * (q - 1)) := by + sorry + +end SpinAngle.TypeAngle + +end + +end OAI diff --git a/lean/ComparatorChallenges/SplitTangentIntegrability.json b/lean/ComparatorChallenges/SplitTangentIntegrability.json new file mode 100644 index 0000000000000000000000000000000000000000..77167031e980a1afac9c3d6e3b3691e9141d2cbb --- /dev/null +++ b/lean/ComparatorChallenges/SplitTangentIntegrability.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SplitTangentIntegrability", + "solution_module": "OAI.Geometry.SplitTangent.RationalVariation", + "theorem_names": [ + "OAI.SplitTangent.integrability_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SplitTangentIntegrability.lean b/lean/ComparatorChallenges/SplitTangentIntegrability.lean new file mode 100644 index 0000000000000000000000000000000000000000..2814ba164e21d9eea00513eabd2a952c77cbb2cd --- /dev/null +++ b/lean/ComparatorChallenges/SplitTangentIntegrability.lean @@ -0,0 +1,142 @@ +import Mathlib + +namespace OAI + + + +noncomputable section +open scoped Manifold ContDiff LinearAlgebra.Projectivization +open Set Bundle + +universe u +namespace SplitTangent + + +structure ComplexManifold where + dim : ℕ + Carrier : Type u + [topology : TopologicalSpace Carrier] + [charts : ChartedSpace (Fin dim → ℂ) Carrier] + [holomorphicAtlas : IsManifold 𝓘(ℂ, Fin dim → ℂ) ω Carrier] + [hausdorff : T2Space Carrier] + [secondCountable : SecondCountableTopology Carrier] + +attribute [instance] ComplexManifold.topology ComplexManifold.charts + ComplexManifold.holomorphicAtlas ComplexManifold.hausdorff + ComplexManifold.secondCountable + +abbrev Model (X : ComplexManifold.{u}) := Fin X.dim → ℂ +abbrev ModelWithCorners (X : ComplexManifold.{u}) := 𝓘(ℂ, Model X) +abbrev Tangent (X : ComplexManifold.{u}) (x : X.Carrier) := + TangentSpace (ModelWithCorners X) x + +abbrev ProjectiveSpace (N : ℕ) := ℙ ℂ (Fin (N + 1) → ℂ) + + + +def projectiveCoordinates {N : ℕ} (i : Fin (N + 1)) + (p : ProjectiveSpace N) : Fin (N + 1) → ℂ := + fun j => (p.rep i)⁻¹ * p.rep j + + + +structure ProjectiveEmbedding (X : ComplexManifold.{u}) where + N : ℕ + map : X.Carrier → ProjectiveSpace N + injective : Function.Injective map + open_patch : ∀ i, IsOpen {x | (map x).rep i ≠ 0} + holomorphic : ∀ i, ContMDiffOn (ModelWithCorners X) 𝓘(ℂ, Fin (N + 1) → ℂ) ω + (fun x => projectiveCoordinates i (map x)) {x | (map x).rep i ≠ 0} + immersion : ∀ x i, (map x).rep i ≠ 0 → Function.Injective + (mfderiv (ModelWithCorners X) 𝓘(ℂ, Fin (N + 1) → ℂ) + (fun y => projectiveCoordinates i (map y)) x) + + +structure RationalCurve (X : ComplexManifold.{u}) where + finite : ℂ → X.Carrier + infinity : ℂ → X.Carrier + finite_holomorphic : ContMDiff 𝓘(ℂ, ℂ) (ModelWithCorners X) ω finite + infinity_holomorphic : ContMDiff 𝓘(ℂ, ℂ) (ModelWithCorners X) ω infinity + overlap : ∀ z : ℂ, z ≠ 0 → finite z = infinity z⁻¹ + +def RationalCurve.value {X : ComplexManifold.{u}} (g : RationalCurve X) + (z : OnePoint ℂ) : X.Carrier := + z.elim (g.infinity 0) g.finite + +abbrev PairPolynomial (N : ℕ) := MvPolynomial (Fin 2 × Fin (N + 1)) ℂ + + +def Bihomogeneous {N : ℕ} (p : PairPolynomial N) : Prop := + ∃ a b : ℕ, ∀ m ∈ p.support, + (∑ i : Fin (N + 1), m (0, i)) = a ∧ + (∑ i : Fin (N + 1), m (1, i)) = b + +def pairEval {X : ComplexManifold.{u}} (e : ProjectiveEmbedding X) + (p : PairPolynomial e.N) (xy : X.Carrier × X.Carrier) : ℂ := + MvPolynomial.eval + (fun k : Fin 2 × Fin (e.N + 1) => + if k.1 = 0 then (e.map xy.1).rep k.2 else (e.map xy.2).rep k.2) p + + + +def IsZariskiOpenPair {X : ComplexManifold.{u}} (e : ProjectiveEmbedding X) + (U : Set (X.Carrier × X.Carrier)) : Prop := + ∃ equations : Set (PairPolynomial e.N), + (∀ p ∈ equations, Bihomogeneous p) ∧ + U = {xy | ∃ p ∈ equations, pairEval e p xy ≠ 0} + + + +def RationallyConnected {X : ComplexManifold.{u}} (e : ProjectiveEmbedding X) : Prop := + ∃ U : Set (X.Carrier × X.Carrier), IsZariskiOpenPair e U ∧ U.Nonempty ∧ Dense U ∧ + ∀ xy ∈ U, ∃ g : RationalCurve X, ∃ a b : OnePoint ℂ, + g.value a = xy.1 ∧ g.value b = xy.2 + + + +structure TangentSplitting (X : ComplexManifold.{u}) where + projector : ∀ x : X.Carrier, Tangent X x →L[ℂ] Tangent X x + idempotent : ∀ x v, projector x (projector x v) = projector x v + holomorphic : ContMDiff + ((ModelWithCorners X).prod 𝓘(ℂ, Model X)) + ((ModelWithCorners X).prod 𝓘(ℂ, Model X)) ω + (fun v : TangentBundle (ModelWithCorners X) X.Carrier => + (⟨v.proj, projector v.proj v.2⟩ : TangentBundle (ModelWithCorners X) X.Carrier)) + first_positive : ∀ x, 0 < Module.finrank ℂ (LinearMap.range (projector x).toLinearMap) + second_positive : ∀ x, 0 < Module.finrank ℂ (LinearMap.ker (projector x).toLinearMap) + +def TangentSplitting.first {X : ComplexManifold.{u}} (S : TangentSplitting X) (x : X.Carrier) : + Submodule ℂ (Tangent X x) := LinearMap.range (S.projector x).toLinearMap + +def TangentSplitting.second {X : ComplexManifold.{u}} (S : TangentSplitting X) (x : X.Carrier) : + Submodule ℂ (Tangent X x) := LinearMap.ker (S.projector x).toLinearMap + + + +def HolomorphicSectionOn (X : ComplexManifold.{u}) + (V : ∀ x : X.Carrier, Tangent X x) (U : Set X.Carrier) : Prop := + ContMDiffOn (ModelWithCorners X) ((ModelWithCorners X).prod 𝓘(ℂ, Model X)) ω + (fun x => (⟨x, V x⟩ : TangentBundle (ModelWithCorners X) X.Carrier)) U + + +def Integrable (X : ComplexManifold.{u}) (D : ∀ x : X.Carrier, Submodule ℂ (Tangent X x)) : Prop := + ∀ U : Set X.Carrier, IsOpen U → ∀ V W : ∀ x : X.Carrier, Tangent X x, + HolomorphicSectionOn X V U → HolomorphicSectionOn X W U → + (∀ x ∈ U, V x ∈ D x) → (∀ x ∈ U, W x ∈ D x) → + ∀ x ∈ U, VectorField.mlieBracketWithin (ModelWithCorners X) V W U x ∈ D x + + + +def IntegrabilityStatement : Prop := + ∀ (X : ComplexManifold.{u}), ConnectedSpace X.Carrier → CompactSpace X.Carrier → + 2 ≤ X.dim → ∀ e : ProjectiveEmbedding X, RationallyConnected e → + ∀ S : TangentSplitting X, Integrable X S.first ∧ Integrable X S.second + +theorem integrability_main : IntegrabilityStatement.{u} := by + sorry + +end SplitTangent + +end + +end OAI diff --git a/lean/ComparatorChallenges/SquareDifference.json b/lean/ComparatorChallenges/SquareDifference.json new file mode 100644 index 0000000000000000000000000000000000000000..7c49da84f0272854106666839e78c79a8432326e --- /dev/null +++ b/lean/ComparatorChallenges/SquareDifference.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SquareDifference", + "solution_module": "OAI.Combinatorics.SquareDifference.Main", + "theorem_names": [ + "OAI.SquareDifference.power_saving" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SquareDifference.lean b/lean/ComparatorChallenges/SquareDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c2ec26a1bd4115e08ca18aaca7a55052b0e7731 --- /dev/null +++ b/lean/ComparatorChallenges/SquareDifference.lean @@ -0,0 +1,18 @@ +import Mathlib + +namespace OAI + +namespace SquareDifference + +def IsSquareDifferenceFree (A : Finset ℤ) : Prop := + ∀ a ∈ A, ∀ b ∈ A, ∀ m : ℕ, 1 ≤ m → a - b ≠ (m : ℤ) ^ 2 + +theorem power_saving : + ∃ c C : ℝ, 0 < c ∧ ∀ N : ℕ, 1 ≤ N → ∀ A : Finset ℤ, + A ⊆ Finset.Icc 1 (N : ℤ) → SquareDifference.IsSquareDifferenceFree A → + (A.card : ℝ) ≤ C * (N : ℝ) ^ (1 - c) := by + sorry + +end SquareDifference + +end OAI diff --git a/lean/ComparatorChallenges/SquareRootDegree.json b/lean/ComparatorChallenges/SquareRootDegree.json new file mode 100644 index 0000000000000000000000000000000000000000..c3bb73311108ff37b3c2eb155f17ec7712f955a7 --- /dev/null +++ b/lean/ComparatorChallenges/SquareRootDegree.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SquareRootDegree", + "solution_module": "OAI.Combinatorics.BooleanFunctions.Main", + "theorem_names": [ + "OAI.SquareRootDegree.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SquareRootDegree.lean b/lean/ComparatorChallenges/SquareRootDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff65933e4d424357a4c233ad4a215049a80f0757 --- /dev/null +++ b/lean/ComparatorChallenges/SquareRootDegree.lean @@ -0,0 +1,64 @@ +import Mathlib + +namespace OAI + +/-! +Bool encodes a sign: false is +1 and true is -1. The average is uniform, +and degree is ordinary real Fourier degree, not F₂ degree or threshold degree. +-/ + +open scoped BigOperators + +noncomputable section + +namespace SquareRootDegree + +abbrev Cube (ι : Type*) := ι → Bool + +def sign (b : Bool) : ℝ := if b then -1 else 1 + +def average {α : Type*} [Fintype α] (f : α → ℝ) : ℝ := + (Fintype.card α : ℝ)⁻¹ * ∑ x, f x + +def character {ι : Type*} (s : Finset ι) (x : Cube ι) : ℝ := + ∏ i ∈ s, sign (x i) + +def fourierCoeff {ι : Type*} [Fintype ι] (f : Cube ι → ℝ) (s : Finset ι) : ℝ := by + classical + exact average (fun x => f x * character s x) + +def fourierDegree {ι : Type*} [Fintype ι] (f : Cube ι → ℝ) : ℕ := by + classical + exact (Finset.univ.filter (fun s : Finset ι => fourierCoeff f s ≠ 0)).sup Finset.card + +def IsBoolean {α : Type*} (f : α → ℝ) : Prop := + ∀ x, f x = -1 ∨ f x = 1 + +def Nonconstant {α : Type*} (f : α → ℝ) : Prop := + ∃ x y, f x ≠ f y + +def singletonSum {ι : Type*} [Fintype ι] (f : Cube ι → ℝ) : ℝ := + ∑ i, fourierCoeff f {i} + +def absoluteSingletonSum {ι : Type*} [Fintype ι] (f : Cube ι → ℝ) : ℝ := + ∑ i, |fourierCoeff f {i}| + +def SignedViolations : Prop := + ∀ C : ℝ, 0 < C → ∃ n : ℕ, 0 < n ∧ ∃ f : Cube (Fin n) → ℝ, + IsBoolean f ∧ Nonconstant f ∧ C * Real.sqrt (fourierDegree f) < singletonSum f + +def AbsoluteRatios : Set ℝ := + {r | ∃ n : ℕ, 0 < n ∧ ∃ f : Cube (Fin n) → ℝ, + IsBoolean f ∧ 0 < fourierDegree f ∧ + r = absoluteSingletonSum f / Real.sqrt (fourierDegree f)} + +/-- The two clauses of the literal main theorem. Unboundedness above is the +real-valued formulation of the displayed supremum being positive infinity. -/ +theorem main : SignedViolations ∧ ¬ BddAbove AbsoluteRatios := by + sorry + +end SquareRootDegree + +end + +end OAI diff --git a/lean/ComparatorChallenges/StandardMapComponents.json b/lean/ComparatorChallenges/StandardMapComponents.json new file mode 100644 index 0000000000000000000000000000000000000000..4966c42e301900571dbae912c9a7ccde9b015d61 --- /dev/null +++ b/lean/ComparatorChallenges/StandardMapComponents.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StandardMapComponents", + "solution_module": "OAI.Dynamics.StandardMap.ComponentsMain", + "theorem_names": [ + "OAI.StandardMapEntropy.main_components" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StandardMapComponents.lean b/lean/ComparatorChallenges/StandardMapComponents.lean new file mode 100644 index 0000000000000000000000000000000000000000..34c884c2ef7c0e8938c04d09752f27fa45f2384a --- /dev/null +++ b/lean/ComparatorChallenges/StandardMapComponents.lean @@ -0,0 +1,110 @@ +import Mathlib + +namespace OAI + +open MeasureTheory Set Filter +open scoped ENNReal Topology + +namespace StandardMapEntropy + +abbrev Circle := AddCircle (1 : ℝ) +abbrev Torus := Circle × Circle + +lemma sine_periodic : Function.Periodic (fun x : ℝ => Real.sin (2 * Real.pi * x)) 1 := by + intro x + dsimp only + rw [show 2 * Real.pi * (x + 1) = 2 * Real.pi * x + 2 * Real.pi by ring] + exact Real.sin_add_two_pi _ + +noncomputable def sine (x : Circle) : ℝ := sine_periodic.lift x + +noncomputable def standardMap (k : ℝ) (z : Torus) : Torus := + (z.1 + z.2 + (k * sine z.1 : ℝ), z.2 + (k * sine z.1 : ℝ)) + +noncomputable def area : Measure Torus := + (volume : Measure Circle).prod (volume : Measure Circle) + +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +lemma cosine_periodic : Function.Periodic (fun x : ℝ => Real.cos (2*Real.pi*x)) 1 := by + intro x + dsimp only + rw [show 2*Real.pi*(x+1)=2*Real.pi*x+2*Real.pi by ring] + exact Real.cos_add_two_pi _ +noncomputable def cosine (x : Circle) : ℝ := cosine_periodic.lift x + +noncomputable def torusPotential (k : ℝ) (x : Circle) : ℝ := 2+(2*Real.pi*k)*cosine x + +noncomputable def transferStep (v : ℝ) : ℂ →L[ℝ] ℂ := + { toLinearMap := + { toFun := fun z => ⟨v*z.re-z.im,z.re⟩ + map_add' := by intro z w; apply Complex.ext <;> simp; ring + map_smul' := by intro t z; apply Complex.ext <;> simp; ring } + cont := by + exact Complex.equivRealProdCLM.symm.continuous.comp + (((continuous_const.mul Complex.continuous_re).sub Complex.continuous_im).prodMk Complex.continuous_re) } + +noncomputable def wedge (z w : ℂ) : ℝ := z.re * w.im - z.im * w.re + +noncomputable def tangentCoordinates : ℂ →L[ℝ] ℂ := + { toLinearMap := + { toFun := fun z => ⟨z.re, z.re-z.im⟩ + map_add' := by intro z w; apply Complex.ext <;> simp; ring + map_smul' := by intro t z; apply Complex.ext <;> simp; ring } + cont := Complex.equivRealProdCLM.symm.continuous.comp + (Complex.continuous_re.prodMk (Complex.continuous_re.sub Complex.continuous_im)) } + +local instance realTangentCompTriple : + RingHomCompTriple (RingHom.id ℝ) (RingHom.id ℝ) (RingHom.id ℝ) := inferInstance + +noncomputable def standardDerivative (k : ℝ) (z : Torus) : ℂ →L[ℝ] ℂ := + tangentCoordinates.comp ((transferStep (torusPotential k z.1)).comp tangentCoordinates) + +noncomputable def standardDerivativeProduct (k : ℝ) (z : Torus) (steps : ℕ) : ℂ →L[ℝ] ℂ := + Nat.rec (ContinuousLinearMap.id ℝ ℂ) + (fun iteration product => (standardDerivative k ((standardMap k)^[iteration] z)).comp product) steps + +def VectorGrowth (k : ℝ) (z : Torus) (v : ℂ) (l : ℝ) : Prop := + v ≠ 0 ∧ Tendsto (fun n : ℕ => Real.log ‖standardDerivativeProduct k z n v‖ / (n : ℝ)) + atTop (𝓝 l) + +def LyapunovSpectrumAt (k : ℝ) (z : Torus) (l : ℝ) : Prop := + 0 ≤ l ∧ ((l = 0 ∧ ∀ v : ℂ, v ≠ 0 → VectorGrowth k z v 0) ∨ + (0 < l ∧ ∃ s : ℂ, s ≠ 0 ∧ ∀ v : ℂ, v ≠ 0 → + VectorGrowth k z v (if wedge s v = 0 then -l else l))) + +noncomputable def normalizedArea (E : Set Torus) : Measure Torus := + (area E)⁻¹ • area.restrict E + +def IsBernoulli (f : Torus → Torus) (μ : Measure Torus) : Prop := + ∃ (β : Measure ℝ), IsProbabilityMeasure β ∧ + ∃ (encode : Torus → (ℤ → ℝ)) (decode : (ℤ → ℝ) → Torus), + MeasurePreserving encode μ (MeasureTheory.Measure.infinitePi (fun _ : ℤ => β)) ∧ + MeasurePreserving decode (MeasureTheory.Measure.infinitePi (fun _ : ℤ => β)) μ ∧ + (∀ᵐ z ∂μ, decode (encode z) = z) ∧ + (∀ᵐ w ∂MeasureTheory.Measure.infinitePi (fun _ : ℤ => β), encode (decode w) = w) ∧ + (∀ᵐ z ∂μ, encode (f z) = fun i : ℤ => encode z (i+1)) + +def HyperbolicBernoulliComponent (k : ℝ) : Prop := + ∃ E : Set Torus, MeasurableSet E ∧ 0 < area E ∧ + ((standardMap k) ⁻¹' E =ᵐ[area] E) ∧ + Ergodic (standardMap k) (normalizedArea E) ∧ + (∀ᵐ z ∂normalizedArea E, ∃ l : ℝ, 0 < l ∧ LyapunovSpectrumAt k z l) ∧ + ∃ (N : ℕ) (hN : 0 < N) (P : Fin N → Set Torus), + (∀ j, MeasurableSet (P j)) ∧ + ((⋃ j, P j) =ᵐ[area] E) ∧ + (∀ i j, i ≠ j → area (P i ∩ P j) = 0) ∧ + (∀ j : Fin N, (standardMap k '' P j) =ᵐ[area] + P ⟨(j.val+1)%N, Nat.mod_lt _ hN⟩) ∧ + (∀ j, area (P j) = area E / (N : ℝ≥0∞) ∧ 0 < area (P j)) ∧ + (∀ j, IsBernoulli ((standardMap k)^[N]) (normalizedArea (P j))) + +def MainComponentsObligation : Prop := + ∃ k₀ : ℝ, 0 < k₀ ∧ ∀ k : ℝ, k₀ ≤ k → HyperbolicBernoulliComponent k + +theorem main_components : MainComponentsObligation := by + sorry + +end StandardMapEntropy + +end OAI diff --git a/lean/ComparatorChallenges/StandardMapEntropy.json b/lean/ComparatorChallenges/StandardMapEntropy.json new file mode 100644 index 0000000000000000000000000000000000000000..4b5283c5b4e8372fb77b0929bc18ad9a27399591 --- /dev/null +++ b/lean/ComparatorChallenges/StandardMapEntropy.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StandardMapEntropy", + "solution_module": "OAI.Dynamics.StandardMap.EntropyEndpoint", + "theorem_names": [ + "OAI.StandardMapEntropy.main_entropy" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StandardMapEntropy.lean b/lean/ComparatorChallenges/StandardMapEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..d87b5c1ace865734db169f7fc97c205eff124e2f --- /dev/null +++ b/lean/ComparatorChallenges/StandardMapEntropy.lean @@ -0,0 +1,53 @@ +import Mathlib + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal BigOperators + +namespace StandardMapEntropy + +abbrev Circle := AddCircle (1 : ℝ) +abbrev Torus := Circle × Circle + +lemma sine_periodic : Function.Periodic (fun x : ℝ => Real.sin (2 * Real.pi * x)) 1 := by + intro x + dsimp only + rw [show 2 * Real.pi * (x + 1) = 2 * Real.pi * x + 2 * Real.pi by ring] + exact Real.sin_add_two_pi _ + +noncomputable def sine (x : Circle) : ℝ := sine_periodic.lift x + +noncomputable def standardMap (k : ℝ) (z : Torus) : Torus := + (z.1 + z.2 + (k * sine z.1 : ℝ), z.2 + (k * sine z.1 : ℝ)) + +noncomputable def area : Measure Torus := + (volume : Measure Circle).prod (volume : Measure Circle) + +def FinitePartition (r : ℕ) := { p : Torus → Fin (r + 1) // Measurable p } + +def blockAtom {r : ℕ} (f : Torus → Torus) (p : FinitePartition r) + (n : ℕ) (w : Fin n → Fin (r + 1)) : Set Torus := + { z | ∀ i : Fin n, p.val (f^[i.val] z) = w i } + +noncomputable def blockEntropy {r : ℕ} (μ : Measure Torus) (f : Torus → Torus) + (p : FinitePartition r) (n : ℕ) : ℝ := + - ∑ w : Fin n → Fin (r + 1), + (μ (blockAtom f p n w)).toReal * Real.log (μ (blockAtom f p n w)).toReal + +noncomputable def partitionEntropy {r : ℕ} (μ : Measure Torus) (f : Torus → Torus) + (p : FinitePartition r) : ℝ≥0∞ := + ⨅ n : ℕ, ENNReal.ofReal (blockEntropy μ f p (n + 1) / (n + 1 : ℝ)) + +noncomputable def metricEntropy (μ : Measure Torus) (f : Torus → Torus) : ℝ≥0∞ := + ⨆ r : ℕ, ⨆ p : FinitePartition r, partitionEntropy μ f p + +def MainObligation : Prop := + ∃ k₀ : ℝ, 0 < k₀ ∧ ∀ k : ℝ, k₀ ≤ k → 0 < metricEntropy area (standardMap k) + +theorem main_entropy : MainObligation := by + sorry + +end StandardMapEntropy + +end OAI diff --git a/lean/ComparatorChallenges/StandardMapLyapunov.json b/lean/ComparatorChallenges/StandardMapLyapunov.json new file mode 100644 index 0000000000000000000000000000000000000000..07e550720e63351b6b05edd37888fab66ab85b84 --- /dev/null +++ b/lean/ComparatorChallenges/StandardMapLyapunov.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StandardMapLyapunov", + "solution_module": "OAI.Dynamics.StandardMap.EntropyLyapunov", + "theorem_names": [ + "OAI.StandardMapEntropy.main_entropy_complete" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StandardMapLyapunov.lean b/lean/ComparatorChallenges/StandardMapLyapunov.lean new file mode 100644 index 0000000000000000000000000000000000000000..655f44a4c04da275def9e219dbb57d7898b824c0 --- /dev/null +++ b/lean/ComparatorChallenges/StandardMapLyapunov.lean @@ -0,0 +1,110 @@ +import Mathlib + +namespace OAI + +open MeasureTheory Set Filter +open scoped ENNReal BigOperators Topology + +namespace StandardMapEntropy + +abbrev Circle := AddCircle (1 : ℝ) +abbrev Torus := Circle × Circle + +lemma sine_periodic : Function.Periodic (fun x : ℝ => Real.sin (2 * Real.pi * x)) 1 := by + intro x + dsimp only + rw [show 2 * Real.pi * (x + 1) = 2 * Real.pi * x + 2 * Real.pi by ring] + exact Real.sin_add_two_pi _ + +noncomputable def sine (x : Circle) : ℝ := sine_periodic.lift x + +noncomputable def standardMap (k : ℝ) (z : Torus) : Torus := + (z.1 + z.2 + (k * sine z.1 : ℝ), z.2 + (k * sine z.1 : ℝ)) + +noncomputable def area : Measure Torus := + (volume : Measure Circle).prod (volume : Measure Circle) + +def FinitePartition (r : ℕ) := { p : Torus → Fin (r + 1) // Measurable p } + +def blockAtom {r : ℕ} (f : Torus → Torus) (p : FinitePartition r) + (n : ℕ) (w : Fin n → Fin (r + 1)) : Set Torus := + { z | ∀ i : Fin n, p.val (f^[i.val] z) = w i } + +noncomputable def blockEntropy {r : ℕ} (μ : Measure Torus) (f : Torus → Torus) + (p : FinitePartition r) (n : ℕ) : ℝ := + - ∑ w : Fin n → Fin (r + 1), + (μ (blockAtom f p n w)).toReal * Real.log (μ (blockAtom f p n w)).toReal + +noncomputable def partitionEntropy {r : ℕ} (μ : Measure Torus) (f : Torus → Torus) + (p : FinitePartition r) : ℝ≥0∞ := + ⨅ n : ℕ, ENNReal.ofReal (blockEntropy μ f p (n + 1) / (n + 1 : ℝ)) + +noncomputable def metricEntropy (μ : Measure Torus) (f : Torus → Torus) : ℝ≥0∞ := + ⨆ r : ℕ, ⨆ p : FinitePartition r, partitionEntropy μ f p + +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +lemma cosine_periodic : Function.Periodic (fun x : ℝ => Real.cos (2*Real.pi*x)) 1 := by + intro x + dsimp only + rw [show 2*Real.pi*(x+1)=2*Real.pi*x+2*Real.pi by ring] + exact Real.cos_add_two_pi _ +noncomputable def cosine (x : Circle) : ℝ := cosine_periodic.lift x + +noncomputable def torusPotential (k : ℝ) (x : Circle) : ℝ := 2+(2*Real.pi*k)*cosine x + +noncomputable def transferStep (v : ℝ) : ℂ →L[ℝ] ℂ := + { toLinearMap := + { toFun := fun z => ⟨v*z.re-z.im,z.re⟩ + map_add' := by intro z w; apply Complex.ext <;> simp; ring + map_smul' := by intro t z; apply Complex.ext <;> simp; ring } + cont := by + exact Complex.equivRealProdCLM.symm.continuous.comp + (((continuous_const.mul Complex.continuous_re).sub Complex.continuous_im).prodMk Complex.continuous_re) } + +noncomputable def tangentCoordinates : ℂ →L[ℝ] ℂ := + { toLinearMap := + { toFun := fun z => ⟨z.re, z.re-z.im⟩ + map_add' := by intro z w; apply Complex.ext <;> simp; ring + map_smul' := by intro t z; apply Complex.ext <;> simp; ring } + cont := Complex.equivRealProdCLM.symm.continuous.comp + (Complex.continuous_re.prodMk (Complex.continuous_re.sub Complex.continuous_im)) } + +local instance realTangentCompTriple : + RingHomCompTriple (RingHom.id ℝ) (RingHom.id ℝ) (RingHom.id ℝ) := inferInstance + +noncomputable def standardDerivative (k : ℝ) (z : Torus) : ℂ →L[ℝ] ℂ := + tangentCoordinates.comp ((transferStep (torusPotential k z.1)).comp tangentCoordinates) + +noncomputable def standardDerivativeProduct (k : ℝ) (z : Torus) (n : ℕ) : ℂ →L[ℝ] ℂ := + Nat.rec (ContinuousLinearMap.id ℝ ℂ) + (fun i A => (standardDerivative k ((standardMap k)^[i] z)).comp A) n + +noncomputable def wedge (z w : ℂ) : ℝ := z.re * w.im - z.im * w.re + +def VectorGrowth (k : ℝ) (z : Torus) (v : ℂ) (l : ℝ) : Prop := + v ≠ 0 ∧ Tendsto (fun n : ℕ => Real.log ‖standardDerivativeProduct k z n v‖ / (n : ℝ)) + atTop (𝓝 l) + +def LyapunovSpectrumAt (k : ℝ) (z : Torus) (l : ℝ) : Prop := + 0 ≤ l ∧ ((l = 0 ∧ ∀ v : ℂ, v ≠ 0 → VectorGrowth k z v 0) ∨ + (0 < l ∧ ∃ s : ℂ, s ≠ 0 ∧ ∀ v : ℂ, v ≠ 0 → + VectorGrowth k z v (if wedge s v = 0 then -l else l))) + +def PositiveLargestLyapunov (k : ℝ) : Prop := + ∃ E : Set Torus, MeasurableSet E ∧ 0 < area E ∧ + ∀ z ∈ E, ∃ l : ℝ, 0 < l ∧ LyapunovSpectrumAt k z l ∧ + Tendsto + (fun n : ℕ => Real.log ‖standardDerivativeProduct k z n‖ / (n : ℝ)) + atTop (𝓝 l) + +theorem main_entropy_complete : + ∃ k₀ : ℝ, 0 < k₀ ∧ ∀ k : ℝ, k₀ ≤ k → + 0 < metricEntropy area (standardMap k) ∧ + PositiveLargestLyapunov k ∧ + (0 < metricEntropy area (standardMap k) ↔ PositiveLargestLyapunov k) := by + sorry + +end StandardMapEntropy + +end OAI diff --git a/lean/ComparatorChallenges/SteinitzBergstrom.json b/lean/ComparatorChallenges/SteinitzBergstrom.json new file mode 100644 index 0000000000000000000000000000000000000000..aa51c3553f77a52d8f7e084955f1109b64737bd3 --- /dev/null +++ b/lean/ComparatorChallenges/SteinitzBergstrom.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SteinitzBergstrom", + "solution_module": "OAI.Analysis.Steinitz.Main", + "theorem_names": [ + "OAI.EuclideanSteinitzBergstrom.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SteinitzBergstrom.lean b/lean/ComparatorChallenges/SteinitzBergstrom.lean new file mode 100644 index 0000000000000000000000000000000000000000..00107bf2365bb51fb4896ce83faa21dbdc5e2bea --- /dev/null +++ b/lean/ComparatorChallenges/SteinitzBergstrom.lean @@ -0,0 +1,29 @@ +import Mathlib + +namespace OAI + +namespace EuclideanSteinitzBergstrom + +abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d) + +def SignedPrefixBound (C : ℝ) : Prop := + ∀ (d N : ℕ), 1 ≤ d → 1 ≤ N → + ∀ (v : Fin N → Vector d), (∀ i, ‖v i‖ ≤ 1) → + ∃ ε : Fin N → ℝ, (∀ i, ε i = -1 ∨ ε i = 1) ∧ + ∀ k : ℕ, k ≤ N → + ‖∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k), ε i • v i‖ ≤ + C * Real.sqrt d + +def OrderingPrefixBound (C : ℝ) : Prop := + ∀ (d N : ℕ), 1 ≤ d → 1 ≤ N → + ∀ (v : Fin N → Vector d), (∀ i, ‖v i‖ ≤ 1) → (∑ i, v i) = 0 → + ∃ π : Equiv.Perm (Fin N), ∀ k : ℕ, k ≤ N → + ‖∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k), v (π i)‖ ≤ + C * Real.sqrt d + +theorem main : ∃ C : ℝ, SignedPrefixBound C ∧ OrderingPrefixBound C := by + sorry + +end EuclideanSteinitzBergstrom + +end OAI diff --git a/lean/ComparatorChallenges/StrictMeans.json b/lean/ComparatorChallenges/StrictMeans.json new file mode 100644 index 0000000000000000000000000000000000000000..72e96466e0e995a225d8faa5eaa2d1dc5e692585 --- /dev/null +++ b/lean/ComparatorChallenges/StrictMeans.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StrictMeans", + "solution_module": "OAI.Analysis.StrictMeans.Main", + "theorem_names": [ + "OAI.StrictInverseFirstPower.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StrictMeans.lean b/lean/ComparatorChallenges/StrictMeans.lean new file mode 100644 index 0000000000000000000000000000000000000000..176d72980ce8aed7aa8a9bd29dec7207ab6f1e0b --- /dev/null +++ b/lean/ComparatorChallenges/StrictMeans.lean @@ -0,0 +1,45 @@ +import Mathlib + +namespace OAI + +open Set Filter MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower + +def disk : Set ℂ := Metric.ball 0 1 + +def NormalizedUnivalent (f : ℂ → ℂ) : Prop := + DifferentiableOn ℂ f disk ∧ Set.InjOn f disk ∧ f 0 = 0 ∧ deriv f 0 = 1 + +def BoundedNormalizedUnivalent (f : ℂ → ℂ) : Prop := + NormalizedUnivalent f ∧ ∃ R : ℝ, ∀ z ∈ disk, ‖f z‖ ≤ R + +noncomputable def integralMean (p : ℝ) (f : ℂ → ℂ) (r : ℝ) : ℝ := + (2 * Real.pi)⁻¹ * ∫ θ in -Real.pi..Real.pi, + ‖deriv f ((r : ℂ) * Complex.exp ((θ : ℂ) * Complex.I))‖ ^ p + +noncomputable def growthExponent (p : ℝ) (f : ℂ → ℂ) : EReal := + Filter.limsup (fun r : ℝ => + ((Real.log (integralMean p f r) / Real.log (1 / (1 - r)) : ℝ) : EReal)) + (𝓝[<] (1 : ℝ)) + +noncomputable def boundedSpectrum (p : ℝ) : EReal := + ⨆ (f : ℂ → ℂ) (_ : BoundedNormalizedUnivalent f), growthExponent p f + +noncomputable def kraetzerPrediction (p : ℝ) : EReal := + if |p| ≤ 2 then ((p ^ (2 : ℕ) / 4 : ℝ) : EReal) + else ((|p| - 1 : ℝ) : EReal) + +theorem main : + (∃ ε C : ℝ, 0 < ε ∧ ε < 1 / 4 ∧ + ∀ (f : ℂ → ℂ), NormalizedUnivalent f → + ∀ r : ℝ, 1 / 2 ≤ r → r < 1 → + integralMean (-1) f r ≤ C * (1 - r) ^ (-(1 / 4 : ℝ) + ε)) ∧ + boundedSpectrum (-1) < (1 / 4 : EReal) ∧ + (¬ ∀ p : ℝ, boundedSpectrum p = kraetzerPrediction p) := by + sorry + +end StrictInverseFirstPower + +end OAI diff --git a/lean/ComparatorChallenges/StrongKadisonKastler.json b/lean/ComparatorChallenges/StrongKadisonKastler.json new file mode 100644 index 0000000000000000000000000000000000000000..7c89a838dbfde3641d7baccd46cc9091df6027ec --- /dev/null +++ b/lean/ComparatorChallenges/StrongKadisonKastler.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StrongKadisonKastler", + "solution_module": "OAI.Analysis.KadisonKastler.StrongStability", + "theorem_names": [ + "OAI.KadisonKastler.universal_strong_stability" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StrongKadisonKastler.lean b/lean/ComparatorChallenges/StrongKadisonKastler.lean new file mode 100644 index 0000000000000000000000000000000000000000..b827c24d923c399a14b818265bc9d8e8bca97f86 --- /dev/null +++ b/lean/ComparatorChallenges/StrongKadisonKastler.lean @@ -0,0 +1,44 @@ +import Mathlib + +namespace OAI + +/-! Theorem 1.1 of *Universal strong Kadison–Kastler stability*: +one tolerance gives small unitary conjugacies on every complex Hilbert space. -/ + +namespace KadisonKastler + +noncomputable section + +universe u + +variable {H : Type u} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] + +def unitBall (M : VonNeumannAlgebra H) : Set (H →L[ℂ] H) := + {x | x ∈ M ∧ ‖x‖ ≤ 1} + +noncomputable def kkDistance (M N : VonNeumannAlgebra H) : ℝ := + Metric.hausdorffDist (unitBall M) (unitBall N) + +def unitaryConj (v : unitary (H →L[ℂ] H)) (x : H →L[ℂ] H) : H →L[ℂ] H := + (v : H →L[ℂ] H) * x * star (v : H →L[ℂ] H) + +def Conjugates (v : unitary (H →L[ℂ] H)) (M N : VonNeumannAlgebra H) : Prop := + unitaryConj v '' (M : Set (H →L[ℂ] H)) = (N : Set (H →L[ℂ] H)) + +def NearConjugacy (M N : VonNeumannAlgebra H) (ε : ℝ) : Prop := + ∃ v : unitary (H →L[ℂ] H), Conjugates v M N ∧ ‖(v : H →L[ℂ] H) - 1‖ < ε + +def UniversalStrongStability : Prop := + ∀ ε : ℝ, 0 < ε → ∃ δ : ℝ, 0 < δ ∧ + ∀ (H : Type u) [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H], + ∀ M N : VonNeumannAlgebra H, + kkDistance M N < δ → NearConjugacy M N ε + +theorem universal_strong_stability : UniversalStrongStability.{u} := by + sorry + +end + +end KadisonKastler + +end OAI diff --git a/lean/ComparatorChallenges/StrongThinTree.json b/lean/ComparatorChallenges/StrongThinTree.json new file mode 100644 index 0000000000000000000000000000000000000000..2e1aed048e4bdb8768926d55bc5d1abf2264baab --- /dev/null +++ b/lean/ComparatorChallenges/StrongThinTree.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StrongThinTree", + "solution_module": "OAI.Combinatorics.ThinTrees.Main", + "theorem_names": [ + "OAI.StrongThinTree.strongThinTree" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StrongThinTree.lean b/lean/ComparatorChallenges/StrongThinTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..966ebe865ea3f61cb1295836cfa532bf26aca2e0 --- /dev/null +++ b/lean/ComparatorChallenges/StrongThinTree.lean @@ -0,0 +1,43 @@ +import Mathlib + +namespace OAI + +namespace StrongThinTree + +structure MultiGraph (n m : ℕ) where + left : Fin m → Fin n + right : Fin m → Fin n + loopless : ∀ e, left e ≠ right e + +namespace MultiGraph + +def cut {n m : ℕ} (G : MultiGraph n m) (T : Finset (Fin m)) + (S : Finset (Fin n)) : Finset (Fin m) := + T.filter fun e => (G.left e ∈ S ∧ G.right e ∉ S) ∨ + (G.right e ∈ S ∧ G.left e ∉ S) + +def Connected {n m : ℕ} (G : MultiGraph n m) (T : Finset (Fin m)) : Prop := + ∀ S : Finset (Fin n), S.Nonempty → S ≠ Finset.univ → (G.cut T S).Nonempty + +def SpanningTree {n m : ℕ} (G : MultiGraph n m) (T : Finset (Fin m)) : Prop := + G.Connected T ∧ ∀ e ∈ T, ¬ G.Connected (T.erase e) + +def EdgeConnected {n m : ℕ} (G : MultiGraph n m) (k : ℕ) : Prop := + ∀ S : Finset (Fin n), S.Nonempty → S ≠ Finset.univ → + k ≤ (G.cut Finset.univ S).card + +end MultiGraph + +def MainStatement : Prop := + ∃ C : ℝ, 0 < C ∧ ∀ (k : ℕ), 1 ≤ k → ∀ (n m : ℕ), 2 ≤ n → + ∀ G : MultiGraph n m, G.EdgeConnected k → + ∃ T : Finset (Fin m), G.SpanningTree T ∧ + ∀ S : Finset (Fin n), S.Nonempty → S ≠ Finset.univ → + ((G.cut T S).card : ℝ) ≤ (C / (k : ℝ)) * (G.cut Finset.univ S).card + +theorem strongThinTree : MainStatement := by + sorry + +end StrongThinTree + +end OAI diff --git a/lean/ComparatorChallenges/StronglyRayleighDPP.json b/lean/ComparatorChallenges/StronglyRayleighDPP.json new file mode 100644 index 0000000000000000000000000000000000000000..bd232cc35081872254e2c3de7914a70393e9b6e7 --- /dev/null +++ b/lean/ComparatorChallenges/StronglyRayleighDPP.json @@ -0,0 +1,19 @@ +{ + "challenge_module": "ComparatorChallenges.StronglyRayleighDPP", + "solution_module": "OAI.Probability.StrongRayleigh.Main", + "theorem_names": [ + "OAI.Problem336AdditiveD139.finite_strongly_rayleigh_response", + "OAI.Problem336AdditiveD139.strongly_rayleigh_group_factor", + "OAI.Problem336AdditiveD139.finite_positive_contraction_dpp_is_strongly_rayleigh", + "OAI.Problem336AdditiveD139.countable_positive_contraction_dpp_exists_unique", + "OAI.Problem336AdditiveD139.invariant_positive_contraction_dpp_factor", + "OAI.Problem336AdditiveD139.translation_invariant_kernel_dpp_factor" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StronglyRayleighDPP.lean b/lean/ComparatorChallenges/StronglyRayleighDPP.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5cab657dc116acf07acffa602fa1f1ac1f3f67e --- /dev/null +++ b/lean/ComparatorChallenges/StronglyRayleighDPP.lean @@ -0,0 +1,185 @@ +import Mathlib + +namespace OAI + +universe u_1 u_2 u_3 u_4 u_5 u_6 u_7 u_8 u_9 u_10 u_11 u_12 +universe u_13 u_14 u_15 u_16 u_17 u_18 u_19 u_20 + +noncomputable section + +open MeasureTheory +open scoped BigOperators ENNReal Topology ComplexConjugate + +namespace Problem336AdditiveD139 + +abbrev UnitLabel := Set.Icc (0 : ℝ) 1 + +def leftTranslate {Γ : Type u_1} {α : Type u_2} [Group Γ] (g : Γ) (a : Γ → α) : Γ → α := + fun h => a (g⁻¹ * h) + +def iidUnitLabels (Γ : Type u_3) [MeasurableSpace Γ] : Measure (Γ → UnitLabel) := + Measure.infinitePi (fun _ : Γ => (volume : Measure UnitLabel)) + +def InvariantBinaryLaw {Γ : Type u_4} [Group Γ] + (μ : ProbabilityMeasure (Γ → Bool)) : Prop := + ∀ g : Γ, + Measure.map (leftTranslate g) (μ : Measure (Γ → Bool)) = + (μ : Measure (Γ → Bool)) + +def HasEquivariantIIDFactor {Γ : Type u_5} [Group Γ] [MeasurableSpace Γ] + (μ : ProbabilityMeasure (Γ → Bool)) : Prop := + ∃ Phi : (Γ → UnitLabel) → (Γ → Bool), + Measurable Phi ∧ + (∀ (g : Γ) (u : Γ → UnitLabel), + Phi (leftTranslate g u) = leftTranslate g (Phi u)) ∧ + Measure.map Phi (iidUnitLabels Γ) = (μ : Measure (Γ → Bool)) + +def finiteGeneratingValue {F : Type u_6} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) (z : F → ℂ) : ℂ := by + classical + exact ∑ x : F → Bool, + (((μ : Measure (F → Bool)) {x}).toReal : ℂ) * + ∏ i : F, if x i = true then z i else 1 + +def StronglyRayleighFinite {F : Type u_7} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) : Prop := + ∀ z : F → ℂ, (∀ i : F, 0 < (z i).im) → finiteGeneratingValue μ z ≠ 0 + +def marginalMass {I : Type u_8} (μ : ProbabilityMeasure (I → Bool)) + (S : Finset I) (x : S → Bool) : ℝ := + ((μ : Measure (I → Bool)) {a | ∀ i : S, a i.1 = x i}).toReal + +def marginalGeneratingValue {I : Type u_9} (μ : ProbabilityMeasure (I → Bool)) + (S : Finset I) (z : S → ℂ) : ℂ := by + classical + exact ∑ x : S → Bool, + (marginalMass μ S x : ℂ) * + ∏ i : S, if x i = true then z i else 1 + +def StronglyRayleighCountable {I : Type u_10} + (μ : ProbabilityMeasure (I → Bool)) : Prop := + ∀ S : Finset I, ∀ z : S → ℂ, + (∀ i : S, 0 < (z i).im) → marginalGeneratingValue μ S z ≠ 0 + +def boolReal (b : Bool) : ℝ := if b = true then 1 else 0 + +def tiltPartition {F : Type u_11} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) (h : F → ℝ) : ℝ := by + classical + exact ∑ x : F → Bool, + Real.exp (∑ j : F, h j * boolReal (x j)) * + ((μ : Measure (F → Bool)) {x}).toReal + +def tiltMean {F : Type u_12} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) (h : F → ℝ) (i : F) : ℝ := by + classical + exact (∑ x : F → Bool, + Real.exp (∑ j : F, h j * boolReal (x j)) * + ((μ : Measure (F → Bool)) {x}).toReal * boolReal (x i)) / + tiltPartition μ h + +def tiltSecondMoment {F : Type u_13} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) (h : F → ℝ) (i j : F) : ℝ := by + classical + exact (∑ x : F → Bool, + Real.exp (∑ k : F, h k * boolReal (x k)) * + ((μ : Measure (F → Bool)) {x}).toReal * + boolReal (x i) * boolReal (x j)) / + tiltPartition μ h + +def tiltCovariance {F : Type u_14} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) (h : F → ℝ) (i j : F) : ℝ := + tiltSecondMoment μ h i j - tiltMean μ h i * tiltMean μ h j + +def coordinatePerturb {F : Type u_15} (h : F → ℝ) (j : F) (r : ℝ) : F → ℝ := by + classical + exact fun k => h k + if k = j then r else 0 + +def PositiveContractionFinite {F : Type u_16} [Fintype F] + (K : F → F → ℂ) : Prop := + (∀ i j, K i j = conj (K j i)) ∧ + ∀ c : F → ℂ, + 0 ≤ (∑ i : F, ∑ j : F, conj (c i) * K i j * c j).re ∧ + (∑ i : F, ∑ j : F, conj (c i) * K i j * c j).re ≤ + ∑ i : F, Complex.normSq (c i) + +def IsFiniteDeterminantalLaw {F : Type u_17} [Fintype F] + (μ : ProbabilityMeasure (F → Bool)) (K : F → F → ℂ) : Prop := by + classical + exact ∀ A : Finset F, + (((μ : Measure (F → Bool)) {x | ∀ i ∈ A, x i = true}).toReal : ℂ) = + Matrix.det (fun i j : A => K i.1 j.1) + +def PositiveContractionKernel {I : Type u_18} + (K : I → I → ℂ) : Prop := + (∀ i j, K i j = conj (K j i)) ∧ + ∀ (S : Finset I) (c : S → ℂ), + 0 ≤ (∑ i : S, ∑ j : S, conj (c i) * K i.1 j.1 * c j).re ∧ + (∑ i : S, ∑ j : S, conj (c i) * K i.1 j.1 * c j).re ≤ + ∑ i : S, Complex.normSq (c i) + +def IsDeterminantalLaw {I : Type u_19} + (μ : ProbabilityMeasure (I → Bool)) (K : I → I → ℂ) : Prop := by + classical + exact ∀ A : Finset I, + (((μ : Measure (I → Bool)) {x | ∀ i ∈ A, x i = true}).toReal : ℂ) = + Matrix.det (fun i j : A => K i.1 j.1) + +def TranslationInvariantKernel {Γ : Type u_20} [Group Γ] + (K : Γ → Γ → ℂ) : Prop := + ∀ g h k : Γ, K (g * h) (g * k) = K h k + +theorem finite_strongly_rayleigh_response : + ∀ (F : Type u_1) [Fintype F] [Nonempty F] (μ : ProbabilityMeasure (F → Bool)), + StronglyRayleighFinite μ → + (∀ (i j : F) (h : F → ℝ), + HasDerivAt (fun r : ℝ => tiltMean μ (coordinatePerturb h j r) i) + (tiltCovariance μ h i j) 0) ∧ + (∀ (i : F) (h : F → ℝ), + (∑ j : F, |tiltCovariance μ h i j|) ≤ + 2 * tiltMean μ h i * (1 - tiltMean μ h i) ∧ + 2 * tiltMean μ h i * (1 - tiltMean μ h i) ≤ (1 : ℝ) / 2) ∧ + (∀ (i : F) (h h' : F → ℝ) (D : ℝ), + 0 ≤ D → (∀ j : F, |h j - h' j| ≤ D) → + |tiltMean μ h i - tiltMean μ h' i| ≤ D / 2) := by + sorry + +theorem strongly_rayleigh_group_factor : + ∀ (Γ : Type u_2) [Group Γ] [Countable Γ] [MeasurableSpace Γ], + ∀ μ : ProbabilityMeasure (Γ → Bool), + StronglyRayleighCountable μ → InvariantBinaryLaw μ → HasEquivariantIIDFactor μ := by + sorry + +theorem finite_positive_contraction_dpp_is_strongly_rayleigh : + ∀ (F : Type u_3) [Fintype F] [Nonempty F] (K : F → F → ℂ), + PositiveContractionFinite K → + (∃ μ : ProbabilityMeasure (F → Bool), IsFiniteDeterminantalLaw μ K) ∧ + ∀ μ : ProbabilityMeasure (F → Bool), IsFiniteDeterminantalLaw μ K → + StronglyRayleighFinite μ := by + sorry + +theorem countable_positive_contraction_dpp_exists_unique : + ∀ (I : Type u_4) [Countable I] (K : I → I → ℂ), + PositiveContractionKernel K → + ∃! μ : ProbabilityMeasure (I → Bool), IsDeterminantalLaw μ K := by + sorry + +theorem invariant_positive_contraction_dpp_factor : + ∀ (Γ : Type u_5) [Group Γ] [Countable Γ] [MeasurableSpace Γ] + (K : Γ → Γ → ℂ) (μ : ProbabilityMeasure (Γ → Bool)), + PositiveContractionKernel K → IsDeterminantalLaw μ K → + InvariantBinaryLaw μ → HasEquivariantIIDFactor μ := by + sorry + +theorem translation_invariant_kernel_dpp_factor : + ∀ (Γ : Type u_6) [Group Γ] [Countable Γ] [MeasurableSpace Γ] (K : Γ → Γ → ℂ), + PositiveContractionKernel K → TranslationInvariantKernel K → + ∃ μ : ProbabilityMeasure (Γ → Bool), + IsDeterminantalLaw μ K ∧ InvariantBinaryLaw μ ∧ HasEquivariantIIDFactor μ := by + sorry + +end Problem336AdditiveD139 + +end + +end OAI diff --git a/lean/ComparatorChallenges/StructuralCrouzeix.json b/lean/ComparatorChallenges/StructuralCrouzeix.json new file mode 100644 index 0000000000000000000000000000000000000000..40f6557d32d962f5fe44891a756eae44959dd320 --- /dev/null +++ b/lean/ComparatorChallenges/StructuralCrouzeix.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.StructuralCrouzeix", + "solution_module": "OAI.Analysis.StructuralCrouzeix.Endpoint", + "theorem_names": [ + "OAI.StructuralCrouzeixReference.challenge" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/StructuralCrouzeix.lean b/lean/ComparatorChallenges/StructuralCrouzeix.lean new file mode 100644 index 0000000000000000000000000000000000000000..c78218e5b4965049ee2cc9e032ee9784a2340fc8 --- /dev/null +++ b/lean/ComparatorChallenges/StructuralCrouzeix.lean @@ -0,0 +1,216 @@ +import Mathlib + +namespace OAI + +universe u_61 u_63 u_67 u_83 u_84 u_181 + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder + +namespace CompleteCrouzeix + + + +def numericalRange {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) : Set ℂ := + {z | ∃ x : EuclideanSpace ℂ (Fin n), ‖x‖ = 1 ∧ + inner ℂ x (Matrix.toEuclideanCLM (n := Fin n) (𝕜 := ℂ) A x) = z} + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open Set Filter Metric Complex +open scoped Topology + + +structure DiskCoordinate (U : Set ℂ) (a : ℂ) where + outer : Set ℂ + outer_open : IsOpen outer + closure_subset : closure U ⊆ outer + toDisk : ℂ → ℂ + fromDisk : ℂ → ℂ + analytic_to : AnalyticOnNhd ℂ toDisk outer + injective_to : InjOn toDisk outer + noncritical_to : ∀ z ∈ outer, deriv toDisk z ≠ 0 + image_open : IsOpen (toDisk '' outer) + analytic_from : AnalyticOnNhd ℂ fromDisk (toDisk '' outer) + inverse_map : MapsTo fromDisk (toDisk '' outer) outer + left_inverse : ∀ z ∈ outer, fromDisk (toDisk z) = z + right_inverse : ∀ w ∈ toDisk '' outer, toDisk (fromDisk w) = w + closedDisk_subset : closedBall 0 1 ⊆ toDisk '' outer + image_domain : toDisk '' U = ball 0 1 + base_zero : toDisk a = 0 + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open Set Filter Metric Complex +open scoped Topology + + +def exteriorMap (a b : ℂ) (h : ℂ → ℂ) (t : ℂ) : ℂ := a*t+b+h t⁻¹ + +structure ExteriorCoordinate (U : Set ℂ) where + radius : ℝ + radius_gt : 1 < radius + leading : ℂ + constant : ℂ + regular : ℂ → ℂ + leading_ne : leading ≠ 0 + analytic_regular : AnalyticOnNhd ℂ regular (ball 0 radius) + injective : InjOn (exteriorMap leading constant regular) {t | radius⁻¹ < ‖t‖} + noncritical : ∀ t, radius⁻¹ < ‖t‖ → deriv (exteriorMap leading constant regular) t ≠ 0 + boundary_image : exteriorMap leading constant regular '' sphere 0 1 = frontier U + interior_iff : ∀ t, radius⁻¹ < ‖t‖ → + (exteriorMap leading constant regular t ∈ U ↔ t ∈ ball 0 1) + outside : ∀ t, 1 < ‖t‖ → exteriorMap leading constant regular t ∉ closure U + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open Polynomial Finset +variable {A : Type u_61} [Ring A] [Algebra ℂ A] + +def scalarJetEval (β : ℂ) (N : A) (s : ℕ) (f : ℂ → ℂ) : A := + ∑ i ∈ range s, (iteratedDeriv i f β / (i.factorial : ℂ)) • N ^ i + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open Module Set +open scoped DirectSum +variable {V : Type u_63} [AddCommGroup V] [Module ℂ V] [instFiniteDimensionalℂV : FiniteDimensional ℂ V] + +noncomputable def primaryEquiv (T : Module.End ℂ V) : + V ≃ₗ[ℂ] ⨁ β : ℂ, T.maxGenEigenspace β := by + classical + exact (LinearEquiv.ofBijective (DirectSum.coeLinearMap T.maxGenEigenspace) + (DirectSum.isInternal_submodule_of_iSupIndep_of_iSup_eq_top + T.independent_maxGenEigenspace T.iSup_maxGenEigenspace_eq_top)).symm + +noncomputable def primaryNilpotent (T : Module.End ℂ V) (β : ℂ) : + Module.End ℂ (T.maxGenEigenspace β) := + (T - algebraMap ℂ (Module.End ℂ V) β).restrict + (fun x hx => T.mapsTo_maxGenEigenspace_of_comm + (Algebra.mul_sub_algebraMap_commutes T β) β (show x ∈ T.maxGenEigenspace β from hx)) + +noncomputable def primaryEval (T : Module.End ℂ V) (f : ℂ → ℂ) : Module.End ℂ V := + (primaryEquiv T).symm.toLinearMap ∘ₗ + (DirectSum.lmap fun β => scalarJetEval β (primaryNilpotent T β) (finrank ℂ V) f) ∘ₗ + (primaryEquiv T).toLinearMap + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open Filter Topology Set Module +variable {n : Type u_67} [Fintype n] [DecidableEq n] + +noncomputable def matrixAnalyticEval (A : Matrix n n ℂ) (f : ℂ → ℂ) : Matrix n n ℂ := + Matrix.toLinAlgEquiv'.symm (primaryEval (Matrix.toLinAlgEquiv' A) f) + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open scoped ENNReal NNReal Matrix.Norms.L2Operator MatrixOrder Kronecker +variable {n : Type u_83} {m : Type u_84} [Fintype n] [DecidableEq n] [instFintypeM : Fintype m] [instDecidableEqM : DecidableEq m] + +def completeAnalyticEval (D : Matrix n n ℂ) (F : ℂ → Matrix m m ℂ) : + Matrix (n×m) (n×m) ℂ := + fun i j => matrixAnalyticEval D (fun z => F z i.2 j.2) i.1 j.1 + +end CompleteCrouzeix + +namespace CompleteCrouzeix +open scoped Matrix MatrixOrder +variable {n : Type u_181} [Fintype n] [DecidableEq n] [Nonempty n] + +def MetricFeasible (T : Matrix n n ℂ) (τ : ℝ) (H : Matrix n n ℂ) : Prop := + 1 ≤ H ∧ H ≤ algebraMap ℝ (Matrix n n ℂ) τ ∧ Tᴴ * H * T ≤ H + +end CompleteCrouzeix + +end + +noncomputable section +open Set Filter Metric Complex MeasureTheory +open scoped Matrix Topology ComplexConjugate ComplexOrder MatrixOrder + Matrix.Norms.L2Operator Kronecker + +namespace StructuralCrouzeix +open CompleteCrouzeix + +def RegularAnalyticBoundaryAt (U : Set ℂ) (p : ℂ) : Prop := + ∃ χ : ℂ → ℂ, χ 0 = p ∧ AnalyticAt ℂ χ 0 ∧ deriv χ 0 ≠ 0 ∧ + (∀ᶠ z : ℂ in 𝓝 0, χ z ∈ frontier U ↔ z.im = 0) + +structure IsAdmissible (U : Set ℂ) : Prop where + isOpen : IsOpen U + bounded : Bornology.IsBounded U + convex : Convex ℝ U + nonempty : U.Nonempty + jordan : Nonempty (Circle ≃ₜ ↥(frontier U)) + regular : ∀ p ∈ frontier U, RegularAnalyticBoundaryAt U p + +def IsMinimizing {n : ℕ} (T : Matrix (Fin n) (Fin n) ℂ) + (τ : ℝ) (H : Matrix (Fin n) (Fin n) ℂ) : Prop := + MetricFeasible T τ H ∧ + ∀ (σ : ℝ) (J : Matrix (Fin n) (Fin n) ℂ), + MetricFeasible T σ J → τ ≤ σ + +def StrictlyFeasible {n : ℕ} (T : Matrix (Fin n) (Fin n) ℂ) : Prop := + ∃ (τ : ℝ) (H : Matrix (Fin n) (Fin n) ℂ), H.IsHermitian ∧ + (H - 1).PosDef ∧ + (algebraMap ℝ (Matrix (Fin n) (Fin n) ℂ) τ - H).PosDef ∧ + (H - Tᴴ * H * T).PosDef + +def analyticSupNorm {m : ℕ} (U : Set ℂ) + (v : ℂ → Matrix (Fin m) (Fin m) ℂ) : ℝ := + sSup ((fun z => ‖v z‖) '' closure U) + +def boundaryPoint {U : Set ℂ} (G : ExteriorCoordinate U) (t : UnitAddCircle) : ℂ := + exteriorMap G.leading G.constant G.regular (t.toCircle : ℂ) + +def FullEndpoint : Prop := + ∀ (U : Set ℂ), IsAdmissible U → + (∀ a ∈ U, Nonempty (DiskCoordinate U a)) ∧ + Nonempty (ExteriorCoordinate U) ∧ + ∀ (a : ℂ), a ∈ U → ∀ (f : DiskCoordinate U a) (G : ExteriorCoordinate U), + ∀ (n : ℕ), 0 < n → ∀ (A : Matrix (Fin n) (Fin n) ℂ), + numericalRange A ⊆ U → + let T := matrixAnalyticEval A f.toDisk + StrictlyFeasible T ∧ + ∃ κ : ℝ, 1 ≤ κ ∧ κ ≤ 2 ∧ + (∃ H : Matrix (Fin n) (Fin n) ℂ, IsMinimizing T (κ ^ 2) H) ∧ + ∀ H : Matrix (Fin n) (Fin n) ℂ, IsMinimizing T (κ ^ 2) H → + let S := CFC.sqrt H + let A' := S * A * S⁻¹ + let D := S * T * S⁻¹ + H.PosDef ∧ IsUnit S ∧ + D = matrixAnalyticEval A' f.toDisk ∧ + Dᴴ * D ≤ 1 ∧ spectralRadius ℂ D < 1 ∧ + ‖S‖ * ‖S⁻¹‖ = κ ∧ + (∀ R : Matrix (Fin n) (Fin n) ℂ, IsUnit R → + (R * T * R⁻¹)ᴴ * (R * T * R⁻¹) ≤ 1 → + κ ≤ ‖R‖ * ‖R⁻¹‖) ∧ + ∃ Λ : C(UnitAddCircle, Matrix (Fin n) (Fin n) ℂ), + (∀ t, (Λ t).PosSemidef) ∧ + (∫ t, Λ t ∂AddCircle.haarAddCircle) = 1 ∧ + ∀ (m : ℕ), 0 < m → + ∀ v : ℂ → Matrix (Fin m) (Fin m) ℂ, + AnalyticOnNhd ℂ v (closure U) → + completeAnalyticEval A' v = + (∫ t, Λ t ⊗ₖ v (boundaryPoint G t) ∂AddCircle.haarAddCircle) ∧ + ‖completeAnalyticEval A v‖ ≤ κ * analyticSupNorm U v + +end StructuralCrouzeix +end + +namespace StructuralCrouzeixReference + +/-- Intrinsic structural representation and admissibility of the unit disk. -/ +theorem challenge : StructuralCrouzeix.FullEndpoint ∧ + StructuralCrouzeix.IsAdmissible (Metric.ball (0 : ℂ) 1) := by + sorry + +end StructuralCrouzeixReference + +end OAI diff --git a/lean/ComparatorChallenges/SubpolynomialLp.json b/lean/ComparatorChallenges/SubpolynomialLp.json new file mode 100644 index 0000000000000000000000000000000000000000..26e824aed6a0a0a43652b8b19b16179f22806d1e --- /dev/null +++ b/lean/ComparatorChallenges/SubpolynomialLp.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SubpolynomialLp", + "solution_module": "OAI.Analysis.LpDimension.Main", + "theorem_names": [ + "OAI.SubpolynomialLp.source_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SubpolynomialLp.lean b/lean/ComparatorChallenges/SubpolynomialLp.lean new file mode 100644 index 0000000000000000000000000000000000000000..80804d689abf7b2abc02514cc8cce08969ec286b --- /dev/null +++ b/lean/ComparatorChallenges/SubpolynomialLp.lean @@ -0,0 +1,50 @@ +import Mathlib + +namespace OAI + +noncomputable section +open MeasureTheory Filter +open scoped BigOperators Topology +universe u + +namespace SubpolynomialLp + +def coordinateDistance (p : ℝ) {d : ℕ} (x y : Fin d → ℝ) : ℝ := + (∑ a, |x a - y a| ^ p) ^ (1 / p) + +/-- The universal property used in the definition of d_p(n,D). -/ +def GoodDimension (p : ℝ) (n : ℕ) (D : ℝ) (d : ℕ) : Prop := + ∀ (Ω : Type u) (mΩ : MeasurableSpace Ω) (μ : @Measure Ω mΩ) + (x : Fin n → @Lp Ω ℝ mΩ _ (ENNReal.ofReal p) μ), + Function.Injective x → + ∃ (y : Fin n → Fin d → ℝ) (s : ℝ), 0 < s ∧ + ∀ i j, s * ‖x i - x j‖ ≤ coordinateDistance p (y i) (y j) ∧ + coordinateDistance p (y i) (y j) ≤ D * s * ‖x i - x j‖ + +/-- The least universal coordinate dimension. The theorem also asserts that +this least dimension has the defining property, ruling out an empty infimum. -/ +def dimension (p : ℝ) (n : ℕ) (D : ℝ) : ℕ := + sInf {d : ℕ | GoodDimension.{u} p n D d} + +def gamma (p : ℝ) : ℝ := if p < 2 then 2 - p else 1 - 2 / p + +/-- The universal coordinate dimension bounds and their logarithmic limits. -/ +theorem source_main (p : ℝ) (hp : 1 < p) (hp2 : p ≠ 2) : + (∀ D : ℝ, 1 < D → ∃ C : ℝ, ∀ n : ℕ, 2 ≤ n → + GoodDimension.{u} p n D (dimension.{u} p n D) ∧ + Real.log (n : ℝ) / Real.log (1 + 2 * D) ≤ (dimension.{u} p n D : ℝ) ∧ + (dimension.{u} p n D : ℝ) ≤ Real.exp (C * Real.log (n : ℝ) ^ gamma p)) ∧ + (∀ n : ℕ, 9 ≤ n → + GoodDimension.{u} p n 1 (dimension.{u} p n 1) ∧ + ((n - 1) / 4) ^ 2 ≤ dimension.{u} p n 1 ∧ + dimension.{u} p n 1 ≤ n.choose 2) ∧ + (∀ D : ℝ, 1 ≤ D → + Tendsto (fun n : ℕ => Real.log (dimension.{u} p n D : ℝ) / Real.log (n : ℝ)) + atTop (𝓝 (if 1 < D then 0 else 2))) := by + sorry + +end SubpolynomialLp + +end + +end OAI diff --git a/lean/ComparatorChallenges/SubsphereCurrent.json b/lean/ComparatorChallenges/SubsphereCurrent.json new file mode 100644 index 0000000000000000000000000000000000000000..c846f4f1c2e86afe8cf5cdabf05ec729fe83880f --- /dev/null +++ b/lean/ComparatorChallenges/SubsphereCurrent.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SubsphereCurrent", + "solution_module": "OAI.Probability.Subsphere.Main", + "theorem_names": [ + "OAI.SubsphereCurrent.full_current_main_scope" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SubsphereCurrent.lean b/lean/ComparatorChallenges/SubsphereCurrent.lean new file mode 100644 index 0000000000000000000000000000000000000000..07dc7ebfeea2de825724ed30cb6fab0b550db216 --- /dev/null +++ b/lean/ComparatorChallenges/SubsphereCurrent.lean @@ -0,0 +1,448 @@ +import Mathlib + +namespace OAI + +open MeasureTheory ProbabilityTheory Set Filter +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe u +namespace SubsphereCurrent +abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d) +abbrev UnitSphere (d : ℕ) := Metric.sphere (0 : Vector d) 1 +abbrev State (M : ℕ) := Fin (2 ^ M) +abbrev Samples (d T : ℕ) := Fin T → Vector d + +def uniformSphere (d : ℕ) : Measure (UnitSphere d) := + let σ := (volume : Measure (Vector d)).toSphere + (σ Set.univ)⁻¹ • σ + +def sampleLaw (d T : ℕ) : Measure (Samples d T) := + Measure.pi fun _ => stdGaussian (Vector d) + +def observationReference (d : ℕ) : Measure (Vector d × ℝ) := + (stdGaussian (Vector d)).prod volume + +structure KernelLearner (d M T : ℕ) where + initial : PMF (Bool × State M) + transition : ℕ → State M → (Vector d × ℝ) → PMF (Bool × State M) + output : ℕ → State M → Measure (UnitSphere d) + output_probability : ∀ t q, IsProbabilityMeasure (output t q) + +namespace KernelLearner +abbrev RunStatus (M : ℕ) := Sum (State M) (ℕ × State M) + +def tagged (M t : ℕ) (a : Bool × State M) : RunStatus M := + if a.1 then .inr (t, a.2) else .inl a.2 + +def run {d M T : ℕ} (L : KernelLearner d M T) (s : UnitSphere d) + (x : Samples d T) : ℕ → PMF (RunStatus M) + | 0 => L.initial.map (tagged M 0) + | n + 1 => (L.run s x n).bind fun status => + match status with + | .inr done => PMF.pure (.inr done) + | .inl q => if hn : n < T then + (L.transition (n + 1) q (x ⟨n, hn⟩, ⟪x ⟨n, hn⟩, s.val⟫)).map (tagged M (n + 1)) + else PMF.pure (.inl q) + +def terminal {d M T : ℕ} (L : KernelLearner d M T) (s : UnitSphere d) + (x : Samples d T) : PMF (ℕ × State M) := + (L.run s x T).map fun status => + match status with + | .inl q => (T, q) + | .inr done => done + +def estimateLaw {d M T : ℕ} (L : KernelLearner d M T) (s : UnitSphere d) + (x : Samples d T) : Measure (UnitSphere d) := + (L.terminal s x).toMeasure.bind fun a => L.output a.1 a.2 + +def angularError {d : ℕ} (s u : UnitSphere d) : ℝ := + Real.arccos ⟪u.val, s.val⟫ + +def conditionalSuccess {d M T : ℕ} (L : KernelLearner d M T) (ε : ℝ) + (s : UnitSphere d) (x : Samples d T) : ℝ≥0∞ := + L.estimateLaw s x {u | angularError s u ≤ ε} + +def CompletedRules {d M T : ℕ} (L : KernelLearner d M T) : Prop := + ∀ t q dest, AEMeasurable (fun obs => L.transition t q obs dest) (observationReference d) + +end KernelLearner + +structure SeededLearner (d M T : ℕ) (Ω : Type u) where + rules : Ω → KernelLearner d M T + +namespace SeededLearner + +structure Admissible {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] + (L : SeededLearner d M T Ω) (ρ : Measure Ω) : Prop where + completed_rules : ∀ᵐ ω ∂ρ, (L.rules ω).CompletedRules + fixed_experiment : ∀ s ε, AEMeasurable + (fun z : Ω × Samples d T => (L.rules z.1).conditionalSuccess ε s z.2) + (ρ.prod (sampleLaw d T)) + uniform_experiment : ∀ ε, AEMeasurable + (fun z : UnitSphere d × (Ω × Samples d T) => + (L.rules z.2.1).conditionalSuccess ε z.1 z.2.2) + ((uniformSphere d).prod (ρ.prod (sampleLaw d T))) + +def success {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] + (L : SeededLearner d M T Ω) (ρ : Measure Ω) (ε : ℝ) (s : UnitSphere d) : ℝ≥0∞ := + ∫⁻ z : Ω × Samples d T, (L.rules z.1).conditionalSuccess ε s z.2 + ∂(ρ.prod (sampleLaw d T)) + +def uniformSuccess {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω] + (L : SeededLearner d M T Ω) (ρ : Measure Ω) (ε : ℝ) : ℝ≥0∞ := + ∫⁻ z : UnitSphere d × (Ω × Samples d T), + (L.rules z.2.1).conditionalSuccess ε z.1 z.2.2 + ∂((uniformSphere d).prod (ρ.prod (sampleLaw d T))) +end SeededLearner + +def ExplicitPrecision : Prop := + ∀ M : ℕ → ℕ, + Asymptotics.IsLittleO atTop (fun d => (M d : ℝ)) (fun d => (d : ℝ) ^ 2) → + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ, + 0 < ε → ε ≤ 1 / 10 → + ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ → + ∀ L : SeededLearner d (M d) T Ω, L.Admissible ρ → + ((2 / 3 : ℝ≥0∞) ≤ L.uniformSuccess ρ ε ∨ + ∀ s, (2 / 3 : ℝ≥0∞) ≤ L.success ρ ε s) → + (2 : ℝ)⁻¹ ^ 16 * (d : ℝ) * Real.logb 2 (1 / ε) ≤ (T : ℝ) +end SubsphereCurrent +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe u v +namespace SubsphereCurrent.Affine + +abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d) +abbrev Sphere (E : Type*) [NormedAddCommGroup E] := Metric.sphere (0 : E) 1 + +def sphereLaw (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] : Measure (Sphere E) := + let σ := (volume : Measure E).toSphere + (σ Set.univ)⁻¹ • σ + +structure Test (d n : ℕ) where + space : Submodule ℝ (Vector d) + dimension : Module.finrank ℝ space = n + center : Vector d + perpendicular : center ∈ spaceᗮ + radius : ℝ + radius_positive : 0 < radius + unit : ‖center‖^2 + radius^2 = 1 + +def Test.point {d n : ℕ} (A : Test d n) (s : Sphere A.space) : Vector d := + A.center + A.radius • s.val.val + +end SubsphereCurrent.Affine +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe v +namespace SubsphereCurrent.Weighted +abbrev Vector (d : ℕ) := Affine.Vector d +abbrev Sphere (d : ℕ) := Metric.sphere (0 : Vector d) 1 +abbrev Rows (d k : ℕ) := Fin k → Vector d +abbrev Observation (d k : ℕ) := Rows d k × (Fin k → ℝ) + +def onTest {d n : ℕ} (A : Affine.Test d n) (s : Affine.Sphere A.space) : Sphere d := by + refine ⟨A.point s,mem_sphere_zero_iff_norm.mpr ?_⟩ + have hs : ‖(s.val : Vector d)‖ = 1 := by + rw [Submodule.norm_coe] + exact mem_sphere_zero_iff_norm.mp s.property + have ho : ⟪A.center, (s.val : Vector d)⟫ = 0 := + Submodule.inner_left_of_mem_orthogonal s.val.property A.perpendicular + have hz : ‖A.point s‖^2 = 1 := by + rw [Affine.Test.point,norm_add_sq_real,real_inner_smul_right,ho,mul_zero,norm_smul, + Real.norm_eq_abs,abs_of_pos A.radius_positive,hs,mul_one] + nlinarith [A.unit] + nlinarith [norm_nonneg (A.point s)] + +def norm (d n : ℕ) (g : Sphere d → ℝ≥0∞) : ℝ≥0∞ := + ⨆ A : Affine.Test d n, (ENNReal.ofReal A.radius)^((d : ℝ)/16) * + ∫⁻ s : Affine.Sphere A.space, g (onTest A s) ∂Affine.sphereLaw A.space + +def blockInput {d k : ℕ} {V : Type*} [Fintype V] + (κ : V → Observation d k → ℝ≥0∞) (g : V → Sphere d → ℝ≥0∞) + (s : Sphere d) : ℝ≥0∞ := + ∫⁻ X : Rows d k, ∑ v, κ v (X,fun i => ⟪X i,s.val⟫)*g v s + ∂Measure.pi (fun _ => stdGaussian (Vector d)) + +def terminalInput {d : ℕ} (π : Measure (Sphere d)) (ε : ℝ) (s : Sphere d) : ℝ≥0∞ := + π {u | Real.arccos ⟪u.val,s.val⟫ ≤ ε} + +end SubsphereCurrent.Weighted +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe v +namespace SubsphereCurrent.Weighted + +def RadiusWeightedFullEstimate : Prop := + ∃ C : ℝ, 1 ≤ C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + (∀ W : ℝ, 1 ≤ W → ∀ (V : Type v) [Fintype V] [Nonempty V], + (Fintype.card V : ℝ) ≤ W → + ∀ κ : V → Observation d (d/16) → ℝ≥0∞, + (∀ v, Measurable (κ v)) → (∀ obs, ∑ v, κ v obs ≤ 1) → + ∀ g : V → Sphere d → ℝ≥0∞, + (∀ v, Measurable (g v)) → (∀ v s, g v s ≤ 1) → + ∀ n : ℕ, (d : ℝ)/2 ≤ n → n ≤ d → + norm d n (blockInput κ g) ≤ + (ENNReal.ofReal W)^(1/((d/16 : ℕ) : ℝ))*ENNReal.ofReal (C^d)*(⨆ v, norm d (n-2) (g v))) ∧ + (∀ n : ℕ, (d : ℝ)/2 ≤ n → n ≤ d → + ∀ π : Measure (Sphere d), IsProbabilityMeasure π → + ∀ ε : ℝ, 0 < ε → + norm d n (terminalInput π ε) ≤ ENNReal.ofReal (C^d)*(ENNReal.ofReal ε)^((d : ℝ)/16)) + +end SubsphereCurrent.Weighted +end + +open MeasureTheory ProbabilityTheory Set Filter +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe u +namespace SubsphereCurrent + +def HalfPrecision : Prop := + ∃ c : ℝ, 0 < c ∧ ∀ M : ℕ → ℕ, + Asymptotics.IsLittleO atTop (fun d => (M d : ℝ)) (fun d => (d : ℝ)^2) → + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ, + 0 < ε → ε ≤ 1/10 → + ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ → + ∀ L : SeededLearner d (M d) T Ω, L.Admissible ρ → + (1/2 : ℝ≥0∞) ≤ L.uniformSuccess ρ ε → + c * (d : ℝ) * Real.logb 2 (1/ε) ≤ (T : ℝ) +end SubsphereCurrent +end + +open MeasureTheory ProbabilityTheory Set Filter +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe u v +namespace SubsphereCurrent +namespace Fixed + +abbrev Vector (m : ℕ) := EuclideanSpace ℝ (Fin m) +abbrev Sphere (E : Type*) [NormedAddCommGroup E] := Metric.sphere (0 : E) 1 + +def sphereLaw (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] : Measure (Sphere E) := + let σ := (volume : Measure E).toSphere + (σ Set.univ)⁻¹ • σ + +def rowsLaw (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (T : ℕ) : + Measure (Fin T → E) := Measure.pi fun _ => stdGaussian E + +structure Stream (E J : Type*) [MeasurableSpace E] (T : ℕ) where + initial : PMF J + transition : ℕ → J → (E × ℝ) → PMF J + output : J → Measure E + output_probability : ∀ q, IsProbabilityMeasure (output q) + +namespace Stream +variable {E J : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [MeasurableSpace E] [MeasurableSpace J] [Fintype J] [MeasurableSingletonClass J] + {T : ℕ} + +def run (L : Stream E J T) (s : E) (x : Fin T → E) : ℕ → PMF J + | 0 => L.initial + | n+1 => (L.run s x n).bind fun q => if hn : n < T then + L.transition (n+1) q (x ⟨n,hn⟩, ⟪x ⟨n,hn⟩,s⟫) + else PMF.pure q + +def estimateLaw (L : Stream E J T) (s : E) (x : Fin T → E) : Measure E := + (L.run s x T).toMeasure.bind L.output + +def euclideanSuccess (L : Stream E J T) (η : ℝ) (s : E) (x : Fin T → E) : ℝ≥0∞ := + L.estimateLaw s x {y | ‖y-s‖ ≤ η} + +def angularSuccess (L : Stream E J T) (ε : ℝ) (s : E) (x : Fin T → E) : ℝ≥0∞ := + L.estimateLaw s x {y | Real.arccos ⟪y,s⟫ ≤ ε} + +def BorelRules (L : Stream E J T) : Prop := + ∀ n q a, Measurable (fun obs => L.transition n q obs a) + +def suffix (L : Stream E J T) (n k : ℕ) (v : J) : Stream E J k where + initial := PMF.pure v + transition t := L.transition (n+t) + output := L.output + output_probability := L.output_probability + +end Stream + +def DimensionEstimate : Prop := + ∃ C : ℝ, 2 ≤ C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ j m : ℕ, + (d : ℝ)/2 + 2*j ≤ m → m ≤ d → + ∀ η : ℝ, 0 < η → + ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ → + ∀ L : Ω → Stream (Vector m) (Fin (2^(d^2))) (j*(d/32)), + (∀ᵐ ω ∂ρ, (L ω).BorelRules) → + AEMeasurable (fun z : Sphere (Vector m) × (Ω × (Fin (j*(d/32)) → Vector m)) => + (L z.2.1).euclideanSuccess η z.1.val z.2.2) + ((sphereLaw (Vector m)).prod (ρ.prod (rowsLaw (Vector m) (j*(d/32))))) → + (∫⁻ z : Sphere (Vector m) × (Ω × (Fin (j*(d/32)) → Vector m)), + (L z.2.1).euclideanSuccess η z.1.val z.2.2 + ∂(sphereLaw (Vector m)).prod (ρ.prod (rowsLaw (Vector m) (j*(d/32))))) + ≤ ENNReal.ofReal ((C^(j+1)*η)^((d : ℝ)/32)) + +end Fixed +end SubsphereCurrent +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +universe u v +namespace SubsphereCurrent.Affine + +def AllAffineFullEstimate : Prop := + ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ k : ℕ, + (d+1)/2 + 2*k ≤ d → ∀ W : ℝ, 1 ≤ W → + ∀ (J : Type v) [Fintype J] [Nonempty J] [MeasurableSpace J] [MeasurableSingletonClass J], + (Fintype.card J : ℝ) ≤ W → W^(1/((d/8 : ℕ) : ℝ)) ≤ (2 : ℝ)^d → + ∀ ε : ℝ, 0 < ε → ε ≤ 1/10 → + ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ → + ∀ L : Ω → Fixed.Stream (Vector d) J (k*(d/16)), + (∀ᵐ ω ∂ρ, (L ω).BorelRules ∧ ∀ q, ∀ᵐ y ∂(L ω).output q, ‖y‖ = 1) → + ∀ ell : ℕ, ell ≤ k → ∀ v : J, ∀ n : ℕ, (d+1)/2 + 2*ell ≤ n → + ∀ A : Test d n, + (∫⁻ z : Sphere A.space × (Ω × (Fin (ell*(d/16)) → Vector d)), + ((L z.2.1).suffix ((k-ell)*(d/16)) (ell*(d/16)) v).angularSuccess ε (A.point z.1) z.2.2 + ∂(sphereLaw A.space).prod (ρ.prod (Fixed.rowsLaw (Vector d) (ell*(d/16))))) + ≤ ENNReal.ofReal (((16 * ((1000 : ℝ)^32)^ell * ε)/A.radius)^(2*(d/32))) + +end SubsphereCurrent.Affine +end + +open MeasureTheory ProbabilityTheory Set Filter +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +namespace SubsphereRegression +section +open scoped Pointwise +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] +def sphereLaw : Measure (Metric.sphere (0 : E) 1) := + let σ := (volume : Measure E).toSphere + (σ Set.univ)⁻¹ • σ +end +section +open scoped Pointwise +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +def ambientSphereLaw : Measure E := (sphereLaw (E := E)).map Subtype.val +end +end SubsphereRegression +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +namespace SubsphereCurrent.Mixture +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] +abbrev Orthogonal (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] := + unitary (E →L[ℝ] E) + +instance orthogonal_compact : CompactSpace (Orthogonal E) := by + apply isCompact_iff_compactSpace.mp + apply (isCompact_closedBall (0 : E →L[ℝ] E) 1).of_isClosed_subset isClosed_unitary + intro u hu + rw [Metric.mem_closedBall,dist_zero_right] + apply u.opNorm_le_bound (by norm_num) + intro x + simp only [u.norm_map_of_mem_unitary hu,one_mul,le_refl] + +noncomputable def orthogonalLaw : Measure (Orthogonal E) := + Measure.haarMeasure ⟨⟨Set.univ,isCompact_univ⟩,by simp⟩ +end SubsphereCurrent.Mixture +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +namespace SubsphereCurrent.Mixture +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + +def blockIso (V : Submodule ℝ E) (u : Orthogonal V) (w : Orthogonal Vᗮ) : E ≃ₗᵢ[ℝ] E := + (V.orthogonalDecomposition.trans + ((Unitary.linearIsometryEquiv u).withLpProdCongr 2 (Unitary.linearIsometryEquiv w))).trans + V.orthogonalDecomposition.symm +end SubsphereCurrent.Mixture +end + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal RealInnerProductSpace +noncomputable section +namespace SubsphereCurrent.Mixture +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + +def directionLaw (V N : Submodule ℝ E) : Measure E := + ((orthogonalLaw (E := Vᗮ)).prod (SubsphereRegression.ambientSphereLaw (E := N))).map + (fun z => blockIso V 1 z.1 (z.2 : E)) + +def directionJointLaw (V N : Submodule ℝ E) (t : ℕ) : Measure (Fin t → E) := + ((orthogonalLaw (E := Vᗮ)).prod + (Measure.pi (fun _ : Fin t => SubsphereRegression.ambientSphereLaw (E := N)))).map + (fun z i => blockIso V 1 z.1 (z.2 i : E)) + +def latitudeSpace (V : Submodule ℝ E) (e : Metric.sphere (0 : V) 1) : Submodule ℝ E := + (ℝ ∙ (e.val : E))ᗮ + +def latitudeLaw (V : Submodule ℝ E) (e : Metric.sphere (0 : V) 1) (a delta : ℝ) : Measure E := + ((betaMeasure a delta).prod ((orthogonalLaw (E := V)).prod + (SubsphereRegression.ambientSphereLaw (E := latitudeSpace V e)))).map + (fun z => blockIso V z.2.1 1 + (Real.sqrt (1-z.1) • (e.val : E) + Real.sqrt z.1 • (z.2.2 : E))) + +def MixtureEstimate (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] : Prop := + (∀ (V N : Submodule ℝ E), V ≤ N → 1 ≤ Module.finrank ℝ V → + Module.finrank ℝ V < Module.finrank ℝ N → Module.finrank ℝ N < Module.finrank ℝ E → + ∀ e : Metric.sphere (0 : V) 1, + directionLaw V N ≤ (2 : ℝ≥0∞) ^ Module.finrank ℝ E • + (SubsphereRegression.ambientSphereLaw + latitudeLaw V e + (((Module.finrank ℝ N : ℝ)-(Module.finrank ℝ V : ℝ))/2) + (((Module.finrank ℝ E : ℝ)-(Module.finrank ℝ N : ℝ))/2))) ∧ + (∀ N : Submodule ℝ E, 1 ≤ Module.finrank ℝ N → + directionLaw ⊥ N = SubsphereRegression.ambientSphereLaw) ∧ + (∀ (V : Submodule ℝ E) (t : ℕ), 1 ≤ Module.finrank ℝ E → + directionJointLaw V ⊤ t = + Measure.pi (fun _ : Fin t => SubsphereRegression.ambientSphereLaw)) + +end SubsphereCurrent.Mixture +end + +noncomputable section +universe u v w +namespace SubsphereCurrent + +def CurrentMainScope : Prop := + ExplicitPrecision.{u} ∧ + Weighted.RadiusWeightedFullEstimate.{v} ∧ + HalfPrecision.{u} ∧ + Affine.AllAffineFullEstimate.{u,v} ∧ + Fixed.DimensionEstimate.{u} ∧ + (∀ (E : Type w) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E], Mixture.MixtureEstimate E) + +end SubsphereCurrent +end + +noncomputable section +universe u v w +namespace SubsphereCurrent + +theorem full_current_main_scope : CurrentMainScope.{u,v,w} := by + sorry + +end SubsphereCurrent +end + +end OAI diff --git a/lean/ComparatorChallenges/Superstring.json b/lean/ComparatorChallenges/Superstring.json new file mode 100644 index 0000000000000000000000000000000000000000..dcc1c93d8fdf75eba9175ffb8167c52760320ddf --- /dev/null +++ b/lean/ComparatorChallenges/Superstring.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.Superstring", + "solution_module": "OAI.Computability.Superstring.Main", + "theorem_names": [ + "OAI.Superstring.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/Superstring.lean b/lean/ComparatorChallenges/Superstring.lean new file mode 100644 index 0000000000000000000000000000000000000000..48130dac7cd12c22ba5c1382390ecb5eb6783e48 --- /dev/null +++ b/lean/ComparatorChallenges/Superstring.lean @@ -0,0 +1,43 @@ +import Mathlib + +namespace OAI + +namespace Superstring + +abbrev Symbol := List Bool +abbrev Word := List Symbol +abbrev Instance := List Word + +/-- Prefix markers encode the list spine, including its final boundary. -/ +def encodeList {α : Type} (enc : α → List Bool) : List α → List Bool + | [] => [true] + | a :: as => false :: (enc a ++ encodeList enc as) + +def encodeSymbol : Symbol → List Bool := encodeList (fun b => [b]) +def encodeWord : Word → List Bool := encodeList encodeSymbol +def encodeInstance : Instance → List Bool := encodeList encodeWord + +/-- Ordinary contiguous substring containment, including the empty word. -/ +def IsCommonSuperstring (S : Instance) (T : Word) : Prop := + ∀ s ∈ S, s <:+: T + +/-- The optimum in symbols, not in bits. -/ +noncomputable def opt (S : Instance) : ℕ := + sInf {n : ℕ | ∃ T : Word, IsCommonSuperstring S T ∧ T.length = n} + +/-- A deterministic finite-stack-machine implementation, with a polynomial bound +on bit-level running time in the explicitly encoded input length. -/ +def HasPolynomialImplementation (f : Instance → Word) : Prop := + ∃ M : Turing.TM2ComputableInPolyTime encodeInstance encodeWord f, + ∀ k : M.tm.K, Finite (M.tm.Γ k) + +/-- The deterministic algorithm with its exact finite-alphabet bit-machine +certificate, contiguous coverage, and factor-two bound in symbols. -/ +theorem main : ∃ f : Instance → Word, + HasPolynomialImplementation f ∧ + ∀ S, IsCommonSuperstring S (f S) ∧ (f S).length ≤ 2 * opt S := by + sorry + +end Superstring + +end OAI diff --git a/lean/ComparatorChallenges/SurfaceImmersion.json b/lean/ComparatorChallenges/SurfaceImmersion.json new file mode 100644 index 0000000000000000000000000000000000000000..978a4861affb2453dbf30ca444ca88771ab282ef --- /dev/null +++ b/lean/ComparatorChallenges/SurfaceImmersion.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SurfaceImmersion", + "solution_module": "OAI.Geometry.SurfaceImmersion.Main", + "theorem_names": [ + "OAI.ClosedSurfaceR4.FiniteOrderSmoothing.smooth_isometric_immersion" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SurfaceImmersion.lean b/lean/ComparatorChallenges/SurfaceImmersion.lean new file mode 100644 index 0000000000000000000000000000000000000000..23d433d80697f1031dd1236e63c38e2436b50acb --- /dev/null +++ b/lean/ComparatorChallenges/SurfaceImmersion.lean @@ -0,0 +1,49 @@ +import Mathlib + +namespace OAI + +noncomputable section +open Bundle Manifold +open scoped ContDiff + +namespace ClosedSurfaceR4 + +abbrev Plane := EuclideanSpace ℝ (Fin 2) +abbrev Space := EuclideanSpace ℝ (Fin 4) +abbrev planeModel := 𝓘(ℝ, Plane) +abbrev spaceModel := 𝓘(ℝ, Space) + +section + +variable (M : Type*) [TopologicalSpace M] [T2Space M] + [SecondCountableTopology M] [CompactSpace M] + [ChartedSpace Plane M] [IsManifold planeModel ∞ M] + +abbrev SmoothMetric := + Bundle.ContMDiffRiemannianMetric planeModel ∞ Plane + (fun p : M => TangentSpace planeModel p) + +def IsSmoothIsometricImmersion (g : SmoothMetric M) (F : M → Space) : Prop := + ContMDiff planeModel spaceModel ∞ F ∧ + ∀ (p : M) (v w : TangentSpace planeModel p), + inner ℝ (mfderiv planeModel spaceModel F p v) + (mfderiv planeModel spaceModel F p w) = g.inner p v w + +end + +namespace FiniteOrderSmoothing + +variable {M : Type*} [TopologicalSpace M] [ChartedSpace Plane M] + [IsManifold planeModel ∞ M] [CompactSpace M] [T2Space M] [SecondCountableTopology M] + +/-- Every compact smooth Riemannian surface admits a smooth isometric immersion into Euclidean four-space. -/ +theorem smooth_isometric_immersion (g : SmoothMetric M) : + ∃ F : M → Space, IsSmoothIsometricImmersion M g F := by + sorry + +end FiniteOrderSmoothing +end ClosedSurfaceR4 + +end + +end OAI diff --git a/lean/ComparatorChallenges/SwitchChain.json b/lean/ComparatorChallenges/SwitchChain.json new file mode 100644 index 0000000000000000000000000000000000000000..67753efda0a4d807a0aa2c0caf9fbcfa7e869055 --- /dev/null +++ b/lean/ComparatorChallenges/SwitchChain.json @@ -0,0 +1,16 @@ +{ + "challenge_module": "ComparatorChallenges.SwitchChain", + "solution_module": "OAI.Probability.SwitchChain.Main", + "theorem_names": [ + "OAI.Problem315.switch_chain_main", + "OAI.Problem315.switch_chain_tv_bound", + "OAI.Problem315.switch_connectivity" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SwitchChain.lean b/lean/ComparatorChallenges/SwitchChain.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a275cf5c0cccff2921b091799299cd7795c1d2f --- /dev/null +++ b/lean/ComparatorChallenges/SwitchChain.lean @@ -0,0 +1,171 @@ +import Mathlib + +namespace OAI + +noncomputable section + +open scoped BigOperators + +namespace Problem315 + +def graphDegree {n : Nat} (G : SimpleGraph (Fin n)) (v : Fin n) : Nat := by + classical + exact (Finset.univ.filter (fun w => G.Adj v w)).card + +def Realizes (n : Nat) (d : Fin n → Nat) (G : SimpleGraph (Fin n)) : Prop := + ∀ v, graphDegree G v = d v + +abbrev GraphState (n : Nat) (d : Fin n → Nat) := + {G : SimpleGraph (Fin n) // Realizes n d G} + +def Graphical (n : Nat) (d : Fin n → Nat) : Prop := + Nonempty (GraphState n d) + +abbrev FourSet (n : Nat) := {S : Finset (Fin n) // S.card = 4} + +def IsPerfectMatchingOn {n : Nat} (S : Finset (Fin n)) + (M : SimpleGraph (Fin n)) : Prop := + ∀ v, (v ∈ S → ∃! w, M.Adj v w) ∧ + (v ∉ S → ∀ w, ¬ M.Adj v w) + +abbrev PerfectMatching {n : Nat} (S : FourSet n) := + {M : SimpleGraph (Fin n) // IsPerfectMatchingOn S.1 M} + +abbrev SwitchProposal (n : Nat) := + Σ S : FourSet n, + {p : PerfectMatching S × PerfectMatching S // p.1 ≠ p.2} + +def removedMatching {n : Nat} (p : SwitchProposal n) : SimpleGraph (Fin n) := + p.2.val.1.val + +def addedMatching {n : Nat} (p : SwitchProposal n) : SimpleGraph (Fin n) := + p.2.val.2.val + +def validSwitch {n : Nat} (G : SimpleGraph (Fin n)) + (p : SwitchProposal n) : Prop := + (∀ ⦃u v⦄, (removedMatching p).Adj u v → G.Adj u v) ∧ + (∀ ⦃u v⦄, (addedMatching p).Adj u v → ¬ G.Adj u v) + +def replaceEdges {n : Nat} (G M N : SimpleGraph (Fin n)) : + SimpleGraph (Fin n) where + Adj u v := (G.Adj u v ∧ ¬ M.Adj u v) ∨ N.Adj u v + symm := by + constructor + intro u v h + rcases h with h | h + · left + exact ⟨G.symm.symm u v h.1, fun hm => h.2 (M.symm.symm v u hm)⟩ + · right + exact N.symm.symm u v h + loopless := by + constructor + intro v h + rcases h with h | h + · exact G.loopless.irrefl v h.1 + · exact N.loopless.irrefl v h + +def proposalResult {n : Nat} (G : SimpleGraph (Fin n)) + (p : SwitchProposal n) : SimpleGraph (Fin n) := by + classical + exact + if validSwitch G p then + replaceEdges G (removedMatching p) (addedMatching p) + else G + +def allGraphStates (n : Nat) (d : Fin n → Nat) : + Finset (GraphState n d) := by + classical + exact Finset.univ + +def allProposals (n : Nat) : Finset (SwitchProposal n) := by + classical + exact Finset.univ + +def stateCount (n : Nat) (d : Fin n → Nat) : Nat := + (allGraphStates n d).card + +def switchKernel (n : Nat) (d : Fin n → Nat) + (G H : GraphState n d) : ℝ := by + classical + exact + (if G = H then (1 : ℝ) / 2 else 0) + + (((allProposals n).filter + (fun p => proposalResult G.val p = H.val)).card : ℝ) / + (12 * (Nat.choose n 4 : ℝ)) + +def kernelPow (n : Nat) (d : Fin n → Nat) : + Nat → GraphState n d → GraphState n d → ℝ := by + classical + intro t + induction t with + | zero => + exact fun G H => if G = H then 1 else 0 + | succ t previous => + exact fun G H => + Finset.sum (allGraphStates n d) + (fun K => previous G K * switchKernel n d K H) + +def uniformAverage (n : Nat) (d : Fin n → Nat) + (f : GraphState n d → ℝ) : ℝ := + Finset.sum (allGraphStates n d) (fun G => f G) / + (stateCount n d : ℝ) + +def uniformInner (n : Nat) (d : Fin n → Nat) + (f g : GraphState n d → ℝ) : ℝ := + uniformAverage n d (fun G => f G * g G) + +def uniformVariance (n : Nat) (d : Fin n → Nat) + (f : GraphState n d → ℝ) : ℝ := + uniformAverage n d + (fun G => (f G - uniformAverage n d f) ^ 2) + +def markovApply (n : Nat) (d : Fin n → Nat) + (f : GraphState n d → ℝ) (G : GraphState n d) : ℝ := + Finset.sum (allGraphStates n d) + (fun H => switchKernel n d G H * f H) + +def dirichletEnergy (n : Nat) (d : Fin n → Nat) + (f : GraphState n d → ℝ) : ℝ := + uniformInner n d f (fun G => f G - markovApply n d f G) + +def hasSpectralGapAtLeast (n : Nat) (d : Fin n → Nat) (γ : ℝ) : Prop := + ∀ f : GraphState n d → ℝ, + γ * uniformVariance n d f ≤ dirichletEnergy n d f + +def tvDistanceFrom (n : Nat) (d : Fin n → Nat) + (t : Nat) (G : GraphState n d) : ℝ := + (1 / 2 : ℝ) * + Finset.sum (allGraphStates n d) + (fun H => + |kernelPow n d t G H - (1 : ℝ) / (stateCount n d : ℝ)|) + +def MixedAt (n : Nat) (d : Fin n → Nat) (t : Nat) : Prop := + ∀ G : GraphState n d, tvDistanceFrom n d t G ≤ (1 : ℝ) / 4 + +def mixingTime (n : Nat) (d : Fin n → Nat) + (h : ∃ t : Nat, MixedAt n d t) : Nat := by + classical + exact Nat.find h + +def SwitchStep (n : Nat) (d : Fin n → Nat) + (G H : GraphState n d) : Prop := + ∃ p : SwitchProposal n, + validSwitch G.val p ∧ proposalResult G.val p = H.val + +theorem switch_chain_main : + ∀ (n : Nat) (d : Fin n → Nat), 4 ≤ n → (∀ v, d v ≤ n - 1) → Graphical n d → ((∃ h : (∃ t : Nat, MixedAt n d t), mixingTime n d h ≤ 2 * n ^ 8) ∧ (stateCount n d = 1 → (MixedAt n d 0 ∧ ∀ h : (∃ t : Nat, MixedAt n d t), mixingTime n d h = 0)) ∧ (1 < stateCount n d → hasSpectralGapAtLeast n d ((1 : ℝ) / (24 * (n : ℝ) ^ 2 * (Nat.choose n 4 : ℝ))))) := by + sorry + +theorem switch_chain_tv_bound : + ∀ (n : Nat) (d : Fin n → Nat), 4 ≤ n → (∀ v, d v ≤ n - 1) → Graphical n d → 1 < stateCount n d → ∀ (t : Nat) (G : GraphState n d), tvDistanceFrom n d t G ≤ Real.sqrt (stateCount n d : ℝ) / 2 * Real.exp (- (t : ℝ) / (24 * (n : ℝ) ^ 2 * (Nat.choose n 4 : ℝ))) := by + sorry + +theorem switch_connectivity : + ∀ (n : Nat) (d : Fin n → Nat), 4 ≤ n → (∀ v, d v ≤ n - 1) → Graphical n d → ∀ G H : GraphState n d, Relation.ReflTransGen (SwitchStep n d) G H := by + sorry + +end Problem315 + +end + +end OAI diff --git a/lean/ComparatorChallenges/SymmetricDomains.json b/lean/ComparatorChallenges/SymmetricDomains.json new file mode 100644 index 0000000000000000000000000000000000000000..9e4a05aa5b757aefb19be7dfb92c33feafb5db4c --- /dev/null +++ b/lean/ComparatorChallenges/SymmetricDomains.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SymmetricDomains", + "solution_module": "OAI.Analysis.SymmetricDomains.Main", + "theorem_names": [ + "OAI.Release061.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SymmetricDomains.lean b/lean/ComparatorChallenges/SymmetricDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..05d033b97fd40b6b643588da4a63194d9685bcf1 --- /dev/null +++ b/lean/ComparatorChallenges/SymmetricDomains.lean @@ -0,0 +1,62 @@ +import Mathlib + +namespace OAI + +namespace Release061 + +abbrev Affine (n : ℕ) := Fin n → ℂ + +def realCoordinates {n : ℕ} (z : Affine n) : Fin n ⊕ Fin n → ℝ := + Sum.elim (fun j => (z j).re) (fun j => (z j).im) + +def IsAffineAlgebraic {n : ℕ} (V : Set (Affine n)) : Prop := + ∃ P : Set (MvPolynomial (Fin n) ℂ), + V = {z | ∀ p ∈ P, MvPolynomial.eval z p = 0} + +inductive IsSemialgebraic {n : ℕ} : Set (Affine n) → Prop + | zero (p : MvPolynomial (Fin n ⊕ Fin n) ℝ) : + IsSemialgebraic {z | MvPolynomial.eval (realCoordinates z) p = 0} + | positive (p : MvPolynomial (Fin n ⊕ Fin n) ℝ) : + IsSemialgebraic {z | 0 < MvPolynomial.eval (realCoordinates z) p} + | compl {S : Set (Affine n)} : IsSemialgebraic S → IsSemialgebraic Sᶜ + | union {S T : Set (Affine n)} : + IsSemialgebraic S → IsSemialgebraic T → IsSemialgebraic (S ∪ T) + +def HolomorphicOnSubset {n m : ℕ} (S : Set (Affine n)) (f : S → Affine m) : Prop := + ∀ p : S, ∃ W : Set (Affine n), IsOpen W ∧ (p : Affine n) ∈ W ∧ + ∃ F : Affine n → Affine m, AnalyticOnNhd ℂ F W ∧ + ∀ q : S, (q : Affine n) ∈ W → F q = f q + +structure Biholomorph {n m : ℕ} (S : Set (Affine n)) (T : Set (Affine m)) where + toHomeomorph : S ≃ₜ T + holomorphic_toFun : HolomorphicOnSubset S (fun p => (toHomeomorph p : Affine m)) + holomorphic_invFun : HolomorphicOnSubset T (fun q => (toHomeomorph.symm q : Affine n)) + +def IsSmooth {n : ℕ} (S : Set (Affine n)) : Prop := + ∀ p : S, ∃ (m : ℕ) (W : Set (Affine n)), W ⊆ S ∧ + IsOpen ((Subtype.val : S → Affine n) ⁻¹' W) ∧ (p : Affine n) ∈ W ∧ + ∃ D : Set (Affine m), IsOpen D ∧ Nonempty (Biholomorph W D) + +def IsBoundedSymmetricDomain {n : ℕ} (D : Set (Affine n)) : Prop := + IsOpen D ∧ IsConnected D ∧ Bornology.IsBounded D ∧ + ∀ p : D, ∃ σ : Biholomorph D D, + Function.Involutive σ.toHomeomorph ∧ σ.toHomeomorph p = p ∧ + ∃ W : Set D, IsOpen W ∧ p ∈ W ∧ + ∀ q ∈ W, σ.toHomeomorph q = q → q = p + +theorem main {n : ℕ} (V U : Set (Affine n)) + (hV : IsAffineAlgebraic V) (hUV : U ⊆ V) + (hopen : IsOpen ((Subtype.val : V → Affine n) ⁻¹' U)) + (hconn : IsConnected U) (hsa : IsSemialgebraic U) + (hbounded : Bornology.IsBounded U) + (Γ : Type*) [Group Γ] [TopologicalSpace Γ] [DiscreteTopology Γ] + [MulAction Γ U] [ProperSMul Γ U] + [CompactSpace (Quotient (MulAction.orbitRel Γ U))] + (hhol : ∀ γ : Γ, HolomorphicOnSubset U (fun p => (γ • p : U).val)) : + IsSmooth U ∧ ∃ (m : ℕ) (D : Set (Affine m)), + IsBoundedSymmetricDomain D ∧ Nonempty (Biholomorph U D) := by + sorry + +end Release061 + +end OAI diff --git a/lean/ComparatorChallenges/SymmetricMahlerEquality.json b/lean/ComparatorChallenges/SymmetricMahlerEquality.json new file mode 100644 index 0000000000000000000000000000000000000000..66a8a1cce3bf09078a04b4f9a2da2174e8d9c3d1 --- /dev/null +++ b/lean/ComparatorChallenges/SymmetricMahlerEquality.json @@ -0,0 +1,17 @@ +{ + "challenge_module": "ComparatorChallenges.SymmetricMahlerEquality", + "solution_imports": [ + "OAI.Analysis.Mahler.Classification" + ], + "solution_module": "OAI.Analysis.Mahler.Classification", + "theorem_names": [ + "OAI.SymmetricMahler.symmetric_mahler_equality" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SymmetricMahlerEquality.lean b/lean/ComparatorChallenges/SymmetricMahlerEquality.lean new file mode 100644 index 0000000000000000000000000000000000000000..223abd8a20127f566a3e39b33c536f84d36abd86 --- /dev/null +++ b/lean/ComparatorChallenges/SymmetricMahlerEquality.lean @@ -0,0 +1,54 @@ +import Mathlib + +namespace OAI + +namespace SymmetricMahler + +section + +open Real Complex Set Finset +variable {I : Type*} [Fintype I] + +def coordinatePolar (K : Set (I → ℝ)) : Set (I → ℝ) := + {p | ∀ v ∈ K, (∑ i, p i*v i) ≤ 1} + +end + +noncomputable section + +open Set MeasureTheory Metric + +def hannerProduct {k l : ℕ} (A : Set (Fin k → ℝ)) (B : Set (Fin l → ℝ)) : + Set (Fin (k + l) → ℝ) := + {z | ∃ x ∈ A, ∃ y ∈ B, z = Fin.append x y} + +def hannerJoin {k l : ℕ} (A : Set (Fin k → ℝ)) (B : Set (Fin l → ℝ)) : + Set (Fin (k + l) → ℝ) := + convexHull ℝ + (((fun x : Fin k → ℝ => Fin.append x 0) '' A) ∪ + ((fun y : Fin l → ℝ => Fin.append 0 y) '' B)) + +inductive IsHanner : {n : ℕ} → Set (Fin n → ℝ) → Prop + | interval (a : ℝ) (ha : 0 < a) : + IsHanner (Icc (fun _ : Fin 1 => -a) (fun _ : Fin 1 => a)) + | product {k l : ℕ} {A : Set (Fin k → ℝ)} {B : Set (Fin l → ℝ)} + (hA : IsHanner A) (hB : IsHanner B) : IsHanner (hannerProduct A B) + | join {k l : ℕ} {A : Set (Fin k → ℝ)} {B : Set (Fin l → ℝ)} + (hA : IsHanner A) (hB : IsHanner B) : IsHanner (hannerJoin A B) + +def IsLinearHanner {n : ℕ} (K : Set (Fin n → ℝ)) : Prop := + ∃ H : Set (Fin n → ℝ), IsHanner H ∧ + ∃ T : (Fin n → ℝ) ≃ₗ[ℝ] (Fin n → ℝ), K = T '' H + +theorem symmetric_mahler_equality {n : ℕ} (hn : 1 ≤ n) + {K : Set (Fin n → ℝ)} (hK : IsCompact K) (hconv : Convex ℝ K) + (hsym : ∀ x ∈ K, -x ∈ K) (hint : (interior K).Nonempty) : + ((volume K).toReal * (volume (coordinatePolar K)).toReal = + (4 : ℝ)^n / (Nat.factorial n : ℝ)) ↔ IsLinearHanner K := by + sorry + +end + +end SymmetricMahler + +end OAI diff --git a/lean/ComparatorChallenges/SymmetricPolar.json b/lean/ComparatorChallenges/SymmetricPolar.json new file mode 100644 index 0000000000000000000000000000000000000000..9fb1ac5bb143503a4fda4c4055d2a890951a62e0 --- /dev/null +++ b/lean/ComparatorChallenges/SymmetricPolar.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.SymmetricPolar", + "solution_module": "OAI.Geometry.PolarProducts.Main", + "theorem_names": [ + "OAI.SymmetricPolar.symmetric_polar_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/SymmetricPolar.lean b/lean/ComparatorChallenges/SymmetricPolar.lean new file mode 100644 index 0000000000000000000000000000000000000000..56be6f5aed669656141c77a4e505d3d96924d6af --- /dev/null +++ b/lean/ComparatorChallenges/SymmetricPolar.lean @@ -0,0 +1,49 @@ +import Mathlib + +namespace OAI + +open Set +open scoped ContDiff ENNReal + +namespace SymmetricPolar + +abbrev Position (n : ℕ) := EuclideanSpace ℝ (Fin n) +abbrev Phase (n : ℕ) := Position n × Position n + +def IsSymmetricConvexBody {n : ℕ} (K : Set (Position n)) : Prop := + IsCompact K ∧ Convex ℝ K ∧ (interior K).Nonempty ∧ + ∀ x, x ∈ K ↔ -x ∈ K + +def polar {n : ℕ} (K : Set (Position n)) : Set (Position n) := + {p | ∀ q ∈ K, inner (𝕜 := ℝ) q p ≤ 1} + +def polarProduct {n : ℕ} (K : Set (Position n)) : Set (Phase n) := + interior K ×ˢ interior (polar K) + +def capacityBall (n : ℕ) (c : ℝ) : Set (Phase n) := + {z | Real.pi * (‖z.1‖ ^ 2 + ‖z.2‖ ^ 2) < c} + +noncomputable def omega0 {n : ℕ} (v w : Phase n) : ℝ := + inner (𝕜 := ℝ) v.1 w.2 - inner (𝕜 := ℝ) w.1 v.2 + +def HasSymplecticEmbedding {n : ℕ} (U V : Set (Phase n)) : Prop := + ∃ e : Phase n → Phase n, + ContDiffOn ℝ ∞ e U ∧ + Topology.IsEmbedding (fun z : U => e z) ∧ + MapsTo e U V ∧ + ∀ z ∈ U, ∀ v w : Phase n, + omega0 (fderiv ℝ e z v) (fderiv ℝ e z w) = omega0 v w + +noncomputable def gromovWidth {n : ℕ} (U : Set (Phase n)) : ℝ≥0∞ := + sSup (ENNReal.ofReal '' {c : ℝ | 0 < c ∧ HasSymplecticEmbedding (capacityBall n c) U}) + +theorem symmetric_polar_main {n : ℕ} (hn : 2 ≤ n) + (K : Set (Position n)) (hK : IsSymmetricConvexBody K) : + gromovWidth (polarProduct K) = 4 ∧ + ∀ c : ℝ, 0 < c → c < 4 → + HasSymplecticEmbedding (capacityBall n c) (polarProduct K) := by + sorry + +end SymmetricPolar + +end OAI diff --git a/lean/ComparatorChallenges/Tachikawa.json b/lean/ComparatorChallenges/Tachikawa.json new file mode 100644 index 0000000000000000000000000000000000000000..713243b57a351b5d2c9a3f3d92cce6c65c67d050 --- /dev/null +++ b/lean/ComparatorChallenges/Tachikawa.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.Tachikawa", + "solution_module": "OAI.RingTheory.Tachikawa.Counterexample", + "theorem_names": [ + "OAI.Tachikawa.main_theorem" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/Tachikawa.lean b/lean/ComparatorChallenges/Tachikawa.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6966a6372659a10f77b45bd4a594e5c45b2bbef --- /dev/null +++ b/lean/ComparatorChallenges/Tachikawa.lean @@ -0,0 +1,39 @@ +import Mathlib + +namespace OAI + +namespace Tachikawa + +noncomputable section + +abbrev k := FractionRing (MvPolynomial (Fin 3) (ZMod 2)) + +def SymmetricOver (K A : Type) [Field K] [Ring A] [Algebra K A] : Prop := + ∃ e : A ≃ₗ[K] Module.Dual K A, + (∀ a b c : A, e (a * b) c = e b (c * a)) ∧ + (∀ a b c : A, e (a * b) c = e a (b * c)) + +def Counterexample : Prop := + ∃ (A : Type) (rA : Ring A), + letI := rA + ∃ (aA : Algebra k A), + letI := aA + Module.Finite k A ∧ SymmetricOver k A ∧ + ∃ (M : Type) (gM : AddCommGroup M), + letI := gM + ∃ (mA : Module A M) (mk : Module k M), + letI := mA + letI := mk + IsScalarTower k A M ∧ Module.Finite k M ∧ + ¬ Module.Projective A M ∧ + ∀ n : ℕ, 0 < n → + Subsingleton (CategoryTheory.Abelian.Ext (ModuleCat.of A M) (ModuleCat.of A M) n) + +theorem main_theorem : Counterexample := by + sorry + +end + +end Tachikawa + +end OAI diff --git a/lean/ComparatorChallenges/TalagrandDiscreteConvexity.json b/lean/ComparatorChallenges/TalagrandDiscreteConvexity.json new file mode 100644 index 0000000000000000000000000000000000000000..a56f93e0f5992c8aaaf87d4c71fa150998797e64 --- /dev/null +++ b/lean/ComparatorChallenges/TalagrandDiscreteConvexity.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TalagrandDiscreteConvexity", + "solution_module": "OAI.Combinatorics.DiscreteConvexity.Main", + "theorem_names": [ + "OAI.TalagrandDiscreteConvexity.talagrand_discrete_convexity" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TalagrandDiscreteConvexity.lean b/lean/ComparatorChallenges/TalagrandDiscreteConvexity.lean new file mode 100644 index 0000000000000000000000000000000000000000..d14e2fa6853931776b1268503eccb6ecbb07154b --- /dev/null +++ b/lean/ComparatorChallenges/TalagrandDiscreteConvexity.lean @@ -0,0 +1,57 @@ +import Mathlib.Data.Fintype.Powerset +import Mathlib.Data.Finset.Union +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset + +namespace OAI + +namespace TalagrandDiscreteConvexity + +open scoped BigOperators + +abbrev Family (α : Type*) := Finset (Finset α) + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable section + +/-- Independent Bernoulli coordinates, including every absent coordinate. -/ +def bernoulliMass (p : ℝ) (s : Finset α) : ℝ := + p ^ s.card * (1 - p) ^ (Finset.univ \ s).card + +/-- The probability of an arbitrary family, with no monotonicity condition. -/ +def familyMeasure (p : ℝ) (D : Family α) : ℝ := + ∑ s ∈ D, bernoulliMass p s + +/-- Each distinct generator is charged once at the original density. -/ +def cost (p : ℝ) (G : Family α) : ℝ := ∑ I ∈ G, p ^ I.card + +/-- Every covered set contains a generator. -/ +def Covers (G A : Family α) : Prop := ∀ S ∈ A, ∃ I ∈ G, I ⊆ S + +/-- An actual finite containment cover with total cost at most one half. -/ +def Small (p : ℝ) (A : Family α) : Prop := + ∃ G : Family α, Covers G A ∧ cost p G ≤ 1 / 2 + +/-- Exactly `k` entries, with no distinctness or disjointness restriction. -/ +def unionTuple {k : ℕ} (f : Fin k → Finset α) : Finset α := + Finset.univ.biUnion f + +/-- All subsets contained in no union of `k` members of the given family. -/ +def exceptional (k : ℕ) (D : Family α) : Family α := by + classical + exact Finset.univ.filter (fun S => + ∀ f : Fin k → Finset α, (∀ j, f j ∈ D) → ¬ S ⊆ unionTuple f) + +/-- Smallness at the original density for every positive ground-set size. -/ +theorem talagrand_discrete_convexity (N : ℕ) (_hN : 1 ≤ N) + (p : ℝ) (hp0 : 0 < p) (hp1 : p < 1) (D : Family (Fin N)) + (hD : 1 - 1 / (2 : ℝ) ^ 75 ≤ familyMeasure p D) : + Small p (exceptional ((2 : ℕ) ^ 75) D) := by + sorry + +end + +end TalagrandDiscreteConvexity + +end OAI diff --git a/lean/ComparatorChallenges/TalagrandExpectationThreshold.json b/lean/ComparatorChallenges/TalagrandExpectationThreshold.json new file mode 100644 index 0000000000000000000000000000000000000000..c1ac413a6bc6b61094952222b99d304269688e1b --- /dev/null +++ b/lean/ComparatorChallenges/TalagrandExpectationThreshold.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TalagrandExpectationThreshold", + "solution_module": "OAI.Combinatorics.ExpectationThreshold.Main", + "theorem_names": [ + "OAI.TalagrandThreshold.talagrand_expectation_threshold_equivalence" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TalagrandExpectationThreshold.lean b/lean/ComparatorChallenges/TalagrandExpectationThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..377c9c9fc595ae20a590bdd54bc78ce8c665fbb2 --- /dev/null +++ b/lean/ComparatorChallenges/TalagrandExpectationThreshold.lean @@ -0,0 +1,60 @@ +import Mathlib.Data.Fintype.Powerset +import Mathlib.Data.Finset.Union +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise + +namespace OAI + +namespace TalagrandThreshold + +open scoped BigOperators + +abbrev Family (α : Type*) := Finset (Finset α) + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable section + +def cost (p : ℝ) (G : Family α) : ℝ := ∑ S ∈ G, p ^ S.card + +def Covers (G F : Family α) : Prop := ∀ H ∈ F, ∃ S ∈ G, S ⊆ H + +def Small (p : ℝ) (F : Family α) : Prop := + ∃ G : Family α, Covers G F ∧ cost p G ≤ 1 / 2 + +def fracCost (p : ℝ) (g : Finset α → ℝ) : ℝ := + ∑ S : Finset α, g S * p ^ S.card + +def FractionalCover (F : Family α) (g : Finset α → ℝ) : Prop := + (∀ S, 0 ≤ g S ∧ g S ≤ 1) ∧ + ∀ H ∈ F, 1 ≤ ∑ S ∈ H.powerset, g S + +def FractionalSmall (p : ℝ) (F : Family α) : Prop := + ∃ g : Finset α → ℝ, FractionalCover F g ∧ fracCost p g ≤ 1 / 2 + +def Increasing (F : Family α) : Prop := + ∀ H ∈ F, ∀ K : Finset α, H ⊆ K → K ∈ F + +def integralFeasible (F : Family α) : Set ℝ := + {p | 0 ≤ p ∧ p ≤ 1 ∧ Small p F} + +def fractionalFeasible (F : Family α) : Set ℝ := + {p | 0 ≤ p ∧ p ≤ 1 ∧ FractionalSmall p F} + +def q (F : Family α) : ℝ := sSup (integralFeasible F) + +def qf (F : Family α) : ℝ := sSup (fractionalFeasible F) + +end + +theorem talagrand_expectation_threshold_equivalence [Nonempty α] + (F : Family α) (_hF : F.Nonempty) (hproper : F ≠ Finset.univ) + (hIncreasing : Increasing F) : + qf F ≤ ((25 : ℝ) * (512 : ℝ) ^ 4) * q F := by + sorry + +end TalagrandThreshold + +end OAI diff --git a/lean/ComparatorChallenges/TamingCompatibility.json b/lean/ComparatorChallenges/TamingCompatibility.json new file mode 100644 index 0000000000000000000000000000000000000000..d46322e905c8a9352677dcfb190ce348a9b81f45 --- /dev/null +++ b/lean/ComparatorChallenges/TamingCompatibility.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TamingCompatibility", + "solution_module": "OAI.Geometry.TamingCompatibility.Main", + "theorem_names": [ + "OAI.TamingCompatibility.taming_implies_compatibility" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TamingCompatibility.lean b/lean/ComparatorChallenges/TamingCompatibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..29c1972e51832260b92e9fe40714d816246c647a --- /dev/null +++ b/lean/ComparatorChallenges/TamingCompatibility.lean @@ -0,0 +1,68 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped Manifold ContDiff + +namespace TamingCompatibility + +abbrev Space := EuclideanSpace ℝ (Fin 4) +abbrev Model := 𝓘(ℝ, Space) + +variable {X : Type*} [TopologicalSpace X] [ChartedSpace Space X] + [IsManifold Model ∞ X] + +abbrev TwoForm (X : Type*) [TopologicalSpace X] [ChartedSpace Space X] := + (x : X) → (TangentSpace Model x) [⋀^Fin 2]→L[ℝ] ℝ + +structure AlmostComplexStructure (X : Type*) [TopologicalSpace X] + [ChartedSpace Space X] [IsManifold Model ∞ X] where + endomorphism : (x : X) → TangentSpace Model x →L[ℝ] TangentSpace Model x + square : ∀ x v, endomorphism x (endomorphism x v) = -v + smooth : ContMDiff Model.tangent Model.tangent ∞ + (fun p : TangentBundle Model X => + (⟨p.proj, endomorphism p.proj p.2⟩ : TangentBundle Model X)) + +def eval (α : TwoForm X) (x : X) (u v : TangentSpace Model x) : ℝ := + α x ![u, v] + +noncomputable def pullback (α : TwoForm X) (f : Space → X) : + Space → Space [⋀^Fin 2]→L[ℝ] ℝ := + fun y => (α (f y)).compContinuousLinearMap (mfderiv Model Model f y) + +def IsSmooth (α : TwoForm X) : Prop := + ∀ (f : Space → X) (U : Set Space), IsOpen U → + ContMDiffOn Model Model ∞ f U → ContDiffOn ℝ ∞ (pullback α f) U + +def IsClosed (α : TwoForm X) : Prop := + ∀ (f : Space → X) (U : Set Space), IsOpen U → + ContMDiffOn Model Model ∞ f U → ∀ y ∈ U, + extDerivWithin (pullback α f) U y = 0 + +def IsNondegenerate (α : TwoForm X) : Prop := + ∀ x v, (∀ w, eval α x v w = 0) → v = 0 + +def IsSymplectic (α : TwoForm X) : Prop := + IsSmooth α ∧ IsClosed α ∧ IsNondegenerate α + +def Tames (α : TwoForm X) (J : AlmostComplexStructure X) : Prop := + ∀ x v, v ≠ 0 → 0 < eval α x v (J.endomorphism x v) + +def IsInvariant (α : TwoForm X) (J : AlmostComplexStructure X) : Prop := + ∀ x u v, eval α x (J.endomorphism x u) (J.endomorphism x v) = eval α x u v + +def Compatible (α : TwoForm X) (J : AlmostComplexStructure X) : Prop := + Tames α J ∧ IsInvariant α J + +theorem taming_implies_compatibility + [T2Space X] [SecondCountableTopology X] [CompactSpace X] [ConnectedSpace X] + (J : AlmostComplexStructure X) + (h : ∃ α : TwoForm X, IsSymplectic α ∧ Tames α J) : + ∃ η : TwoForm X, IsSymplectic η ∧ Compatible η J := by + sorry + +end TamingCompatibility +end + +end OAI diff --git a/lean/ComparatorChallenges/ThomasonModelStructures.json b/lean/ComparatorChallenges/ThomasonModelStructures.json new file mode 100644 index 0000000000000000000000000000000000000000..0e8d03b29c37ff03d7dbd8c48c3fd682e1c3f563 --- /dev/null +++ b/lean/ComparatorChallenges/ThomasonModelStructures.json @@ -0,0 +1,15 @@ +{ + "challenge_module": "ComparatorChallenges.ThomasonModelStructures", + "solution_module": "OAI.CategoryTheory.Thomason.RankedFaithfulness", + "theorem_names": [ + "OAI.Thomason.main", + "OAI.Thomason.nerveDetection_allDimensions" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThomasonModelStructures.lean b/lean/ComparatorChallenges/ThomasonModelStructures.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a89b56b5d5a4084951baec9e6af544463bb032a --- /dev/null +++ b/lean/ComparatorChallenges/ThomasonModelStructures.lean @@ -0,0 +1,2473 @@ +import Mathlib + +/-! Definitions for the Thomason model structures and their Street-nerve detection statement. -/ + +noncomputable section +universe u v w + +section +namespace OAI.Thomason + + +structure OmegaCategory where + Cell : Type u + source : ℕ → Cell → Cell + target : ℕ → Cell → Cell + source_source (i j : ℕ) (x : Cell) : source i (source j x) = source (min i j) x + target_target (i j : ℕ) (x : Cell) : target i (target j x) = target (min i j) x + source_target (i j : ℕ) (x : Cell) : + source i (target j x) = if i < j then source i x else target j x + target_source (i j : ℕ) (x : Cell) : + target i (source j x) = if i < j then target i x else source j x + comp (k : ℕ) (x y : Cell) : target k x = source k y → Cell + source_comp_le (i k : ℕ) (hik : i ≤ k) (x y : Cell) + (h : target k x = source k y) : source i (comp k x y h) = source i x + target_comp_le (i k : ℕ) (hik : i ≤ k) (x y : Cell) + (h : target k x = source k y) : target i (comp k x y h) = target i y + source_comp_gt (i k : ℕ) (hki : k < i) (x y : Cell) + (h : target k x = source k y) + (hs : target k (source i x) = source k (source i y)) : + source i (comp k x y h) = comp k (source i x) (source i y) hs + target_comp_gt (i k : ℕ) (hki : k < i) (x y : Cell) + (h : target k x = source k y) + (ht : target k (target i x) = source k (target i y)) : + target i (comp k x y h) = comp k (target i x) (target i y) ht + unit_left (k : ℕ) (x : Cell) (h : target k (source k x) = source k x) : + comp k (source k x) x h = x + unit_right (k : ℕ) (x : Cell) (h : target k x = source k (target k x)) : + comp k x (target k x) h = x + assoc (k : ℕ) (x y z : Cell) + (hxy : target k x = source k y) (hyz : target k y = source k z) + (hxy_z : target k (comp k x y hxy) = source k z) + (hx_yz : target k x = source k (comp k y z hyz)) : + comp k (comp k x y hxy) z hxy_z = comp k x (comp k y z hyz) hx_yz + interchange (k l : ℕ) (hkl : k < l) (a b c d : Cell) + (hab : target l a = source l b) (hcd : target l c = source l d) + (hac : target k a = source k c) (hbd : target k b = source k d) + (hab_cd : target k (comp l a b hab) = source k (comp l c d hcd)) + (hac_bd : target l (comp k a c hac) = source l (comp k b d hbd)) : + comp k (comp l a b hab) (comp l c d hcd) hab_cd = + comp l (comp k a c hac) (comp k b d hbd) hac_bd + finite_dimension (x : Cell) : ∃ k, source k x = x + + +end OAI.Thomason +end + +section +namespace OAI.Thomason.OmegaCategory +variable (C : OmegaCategory.{u}) + +@[ext] +structure Functor (C : OAI.Thomason.OmegaCategory.{u}) (D : OAI.Thomason.OmegaCategory.{v}) where + map : C.Cell → D.Cell + map_source (k : ℕ) (x : C.Cell) : map (C.source k x) = D.source k (map x) + map_target (k : ℕ) (x : C.Cell) : map (C.target k x) = D.target k (map x) + map_comp (k : ℕ) (x y : C.Cell) (h : C.target k x = C.source k y) + (h' : D.target k (map x) = D.source k (map y)) : + map (C.comp k x y h) = D.comp k (map x) (map y) h' + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory.Functor +variable (C : OmegaCategory.{u}) +variable {C : OmegaCategory.{u}} {D : OmegaCategory.{v}} {B : OmegaCategory.{w}} + +noncomputable def id (C : OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.Functor C C where + map x := x + map_source _ _ := rfl + map_target _ _ := rfl + map_comp _ _ _ _ _ := rfl + +noncomputable def comp (F : OAI.Thomason.OmegaCategory.Functor C D) (G : OAI.Thomason.OmegaCategory.Functor D B) : OAI.Thomason.OmegaCategory.Functor C B := by + classical + have proof_map_composable_0 {C : OAI.Thomason.OmegaCategory.{u}} {D : OAI.Thomason.OmegaCategory.{v}} (F : OAI.Thomason.OmegaCategory.Functor C D) {k : ℕ} {x y : C.Cell} + (h : C.target k x = C.source k y) : + D.target k (F.map x) = D.source k (F.map y) := by + rw [← F.map_target, ← F.map_source, h] + exact { + map x := G.map (F.map x) + map_source k x := by rw [F.map_source, G.map_source] + map_target k x := by rw [F.map_target, G.map_target] + map_comp k x y h h' := by + rw [F.map_comp k x y h (proof_map_composable_0 F h), G.map_comp] + } + + +end OAI.Thomason.OmegaCategory.Functor +end + +section +namespace OAI.Thomason.OmegaCategory +variable (C : OmegaCategory.{u}) + +noncomputable instance : CategoryTheory.Category OAI.Thomason.OmegaCategory.{u} where + Hom C D := OAI.Thomason.OmegaCategory.Functor C D + id := OAI.Thomason.OmegaCategory.Functor.id + comp := OAI.Thomason.OmegaCategory.Functor.comp + +noncomputable def IsTruncated (n : ℕ) : Prop := ∀ x : C.Cell, C.source n x = x + +noncomputable def NCategory (n : ℕ) := {C : OAI.Thomason.OmegaCategory.{u} // C.IsTruncated n} + +noncomputable instance (n : ℕ) : CategoryTheory.Category (OAI.Thomason.OmegaCategory.NCategory.{u} n) where + Hom C D := OAI.Thomason.OmegaCategory.Functor C.val D.val + id C := OAI.Thomason.OmegaCategory.Functor.id C.val + comp := OAI.Thomason.OmegaCategory.Functor.comp + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason + + +structure DirectedComplex where + Chain : ℕ → Type u + group : ∀ p, AddCommGroup (Chain p) + d : (p : ℕ) → Chain (p+1) →+ Chain p + d_d (p : ℕ) (x : Chain (p+2)) : d p (d (p+1) x) = 0 + augmentation : Chain 0 →+ ℤ + augmentation_d (x : Chain 1) : augmentation (d 0 x) = 0 + positive : (p : ℕ) → AddSubmonoid (Chain p) + +end OAI.Thomason +end + +attribute [instance] OAI.Thomason.DirectedComplex.group + +section +namespace OAI.Thomason.DirectedComplex + + +@[ext] +structure Hom (K : OAI.Thomason.DirectedComplex.{u}) (L : OAI.Thomason.DirectedComplex.{v}) where + map (p : ℕ) : K.Chain p →+ L.Chain p + map_d (p : ℕ) (x : K.Chain (p+1)) : map p (K.d p x) = L.d p (map (p+1) x) + map_augmentation (x : K.Chain 0) : L.augmentation (map 0 x) = K.augmentation x + map_positive (p : ℕ) (x : K.Chain p) : x ∈ K.positive p → map p x ∈ L.positive p + + +end OAI.Thomason.DirectedComplex +end + +section +namespace OAI.Thomason.DirectedComplex.Hom +variable {K : DirectedComplex.{u}} {L : DirectedComplex.{v}} {M : DirectedComplex.{w}} + +noncomputable def id (K : OAI.Thomason.DirectedComplex.{u}) : OAI.Thomason.DirectedComplex.Hom K K where + map _ := AddMonoidHom.id _ + map_d _ _ := rfl + map_augmentation _ := rfl + map_positive _ _ h := h + +noncomputable def comp (f : OAI.Thomason.DirectedComplex.Hom K L) (g : OAI.Thomason.DirectedComplex.Hom L M) : OAI.Thomason.DirectedComplex.Hom K M where + map p := (g.map p).comp (f.map p) + map_d p x := by simp only [AddMonoidHom.comp_apply, f.map_d, g.map_d] + map_augmentation x := by simp only [AddMonoidHom.comp_apply, + g.map_augmentation, f.map_augmentation] + map_positive p x hx := g.map_positive p _ (f.map_positive p x hx) + + +end OAI.Thomason.DirectedComplex.Hom +end + +section +namespace OAI.Thomason.DirectedComplex + + +noncomputable instance : CategoryTheory.Category OAI.Thomason.DirectedComplex.{u} where + Hom := OAI.Thomason.DirectedComplex.Hom + id := OAI.Thomason.DirectedComplex.Hom.id + comp := OAI.Thomason.DirectedComplex.Hom.comp + +@[ext] +structure Table (K : OAI.Thomason.DirectedComplex.{u}) where + row : (p : ℕ) → Bool → K.Chain p + positive (p : ℕ) (b : Bool) : row p b ∈ K.positive p + boundary (p : ℕ) (b : Bool) : + K.d p (row (p+1) b) = row p true - row p false + augmentation (b : Bool) : K.augmentation (row 0 b) = 1 + bounded : ∃ k, ∀ p, k < p → ∀ b, row p b = 0 + + +end OAI.Thomason.DirectedComplex +end + +section +namespace OAI.Thomason.DirectedComplex.Table +variable {K : DirectedComplex.{u}} + +noncomputable def truncate (k : ℕ) (e : Bool) (x : OAI.Thomason.DirectedComplex.Table K) : OAI.Thomason.DirectedComplex.Table K where + row p b := if p < k then x.row p b else if p = k then x.row p e else 0 + positive p b := by + split_ifs <;> first | exact x.positive _ _ | exact (K.positive _).zero_mem + boundary p b := by + by_cases hp : p < k + · by_cases hp' : p+1 < k + · simp only [hp, hp', ite_eq_left] + exact x.boundary p b + · have he : p+1 = k := by omega + simp only [ite_eq_left hp, ite_eq_right hp', ite_eq_left he] + exact x.boundary p e + · by_cases he : p = k + · have hp' : ¬p+1 < k := by omega + have he' : ¬p+1 = k := by omega + simp only [ite_eq_right hp, ite_eq_right hp', ite_eq_right he', ite_eq_left he, map_zero, sub_self] + · have hp' : ¬p+1 < k := by omega + have he' : ¬p+1 = k := by omega + simp only [hp, hp', he', he, ite_false, map_zero, sub_self] + augmentation b := by + by_cases hk : k = 0 + · subst k + simpa using x.augmentation e + · have hk' : 0 < k := Nat.pos_of_ne_zero hk + simpa only [hk', ite_eq_left] using x.augmentation b + bounded := by + refine ⟨k, ?_⟩ + intro p hp b + simp only [show ¬p < k by omega, show ¬p = k by omega, ite_false] + +noncomputable def comp (k : ℕ) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) : OAI.Thomason.DirectedComplex.Table K := by + classical + have proof_truncate_row_3 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (e : Bool) (x : OAI.Thomason.DirectedComplex.Table K) (p : ℕ) (b : Bool) : + (OAI.Thomason.DirectedComplex.Table.truncate k e x).row p b = + if p < k then x.row p b else if p = k then x.row p e else 0 := rfl + have proof_lower_rows_eq_1 {K : OAI.Thomason.DirectedComplex.{u}} {k : ℕ} {x y : OAI.Thomason.DirectedComplex.Table K} + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) {p : ℕ} (hp : p < k) (b : Bool) : + x.row p b = y.row p b := by + have hr := congrArg (fun z : OAI.Thomason.DirectedComplex.Table K => z.row p b) h + simpa only [OAI.Thomason.DirectedComplex.Table.truncate, hp, ite_eq_left] using hr + have proof_matching_row_eq_2 {K : OAI.Thomason.DirectedComplex.{u}} {k : ℕ} {x y : OAI.Thomason.DirectedComplex.Table K} + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) : x.row k true = y.row k false := by + have hr := congrArg (fun z : OAI.Thomason.DirectedComplex.Table K => z.row k false) h + simpa [OAI.Thomason.DirectedComplex.Table.truncate] using hr + exact { + row p b := if p < k then x.row p b else if p = k then + (if b then y.row p true else x.row p false) else x.row p b + y.row p b + positive p b := by + split_ifs <;> first + | exact x.positive _ _ + | exact y.positive _ _ + | exact (K.positive _).add_mem (x.positive _ _) (y.positive _ _) + boundary p b := by + by_cases hp : p < k + · by_cases hp' : p+1 < k + · simp only [ite_eq_left hp, ite_eq_left hp'] + exact x.boundary p b + · have he : p+1 = k := by omega + simp only [ite_eq_left hp, ite_eq_right hp', ite_eq_left he] + cases b with + | false => exact x.boundary p false + | true => + change K.d p (y.row (p+1) true) = x.row p true - x.row p false + rw [y.boundary, proof_lower_rows_eq_1 h hp true, proof_lower_rows_eq_1 h hp false] + · by_cases he : p = k + · subst p + have hp' : ¬k+1 < k := by omega + have he' : ¬k+1 = k := by omega + simp only [ite_eq_right (Nat.lt_irrefl k), ite_eq_right hp', ite_eq_right he', + ↓reduceIte, map_add, x.boundary, y.boundary] + rw [proof_matching_row_eq_2 h] + abel_nf + exact add_comm _ _ + · have hp' : ¬p+1 < k := by omega + have he' : ¬p+1 = k := by omega + simp only [ite_eq_right hp, ite_eq_right hp', ite_eq_right he', ite_eq_right he, map_add, + x.boundary, y.boundary] + abel + augmentation b := by + by_cases hk : 0 < k + · simp only [ite_eq_left hk] + exact x.augmentation b + · have he : 0 = k := by omega + simp only [ite_eq_right hk, ite_eq_left he] + cases b <;> first | exact x.augmentation _ | exact y.augmentation _ + bounded := by + obtain ⟨nx, hx⟩ := x.bounded + obtain ⟨ny, hy⟩ := y.bounded + refine ⟨max nx ny, ?_⟩ + intro p hp b + have hx' := hx p (lt_of_le_of_lt (le_max_left _ _) hp) + have hy' := hy p (lt_of_le_of_lt (le_max_right _ _) hp) + split_ifs <;> simp only [hx', hy', zero_add] + } + + +end OAI.Thomason.DirectedComplex.Table +end + +section +namespace OAI.Thomason.DirectedComplex + + +noncomputable def nu (K : OAI.Thomason.DirectedComplex.{u}) : OAI.Thomason.OmegaCategory.{u} := by + classical + have proof_truncate_row_3 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (e : Bool) (x : OAI.Thomason.DirectedComplex.Table K) (p : ℕ) (b : Bool) : + (OAI.Thomason.DirectedComplex.Table.truncate k e x).row p b = + if p < k then x.row p b else if p = k then x.row p e else 0 := rfl + have proof_truncate_truncate_5 {K : OAI.Thomason.DirectedComplex.{u}} (i j : ℕ) (e f : Bool) (x : OAI.Thomason.DirectedComplex.Table K) : + OAI.Thomason.DirectedComplex.Table.truncate i e (OAI.Thomason.DirectedComplex.Table.truncate j f x) = + if i < j then OAI.Thomason.DirectedComplex.Table.truncate i e x else OAI.Thomason.DirectedComplex.Table.truncate j f x := by + ext p b + by_cases hij : i < j + · simp only [hij, ite_eq_left, OAI.Thomason.DirectedComplex.Table.truncate] + by_cases hpi : p < i + · have hpj : p < j := lt_trans hpi hij + simp [hpi, hpj] + · by_cases hpe : p = i + · subst p + simp [hij] + · simp [hpi, hpe] + · simp only [hij, ite_false, OAI.Thomason.DirectedComplex.Table.truncate] + by_cases hpj : p < j + · have hpi : p < i := by omega + simp [hpj, hpi] + · by_cases hpje : p = j + · subst p + by_cases hji : j < i + · simp [hji] + · have hi : i = j := by omega + subst i + simp [] + · by_cases hpi : p < i + · simp [hpi, hpj, hpje] + · by_cases hpie : p = i + · subst p + simp [hij] + · simp [hpi, hpie, hpj, hpje] + have proof_truncate_truncate_same_4 {K : OAI.Thomason.DirectedComplex.{u}} (i j : ℕ) (e : Bool) (x : OAI.Thomason.DirectedComplex.Table K) : + OAI.Thomason.DirectedComplex.Table.truncate i e (OAI.Thomason.DirectedComplex.Table.truncate j e x) = OAI.Thomason.DirectedComplex.Table.truncate (min i j) e x := by + rw [proof_truncate_truncate_5] + split_ifs with h + · rw [min_eq_left (le_of_lt h)] + · rw [min_eq_right (le_of_not_gt h)] + have proof_comp_row_14 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) (p : ℕ) (b : Bool) : + (OAI.Thomason.DirectedComplex.Table.comp k x y h).row p b = if p < k then x.row p b else if p = k then + (if b then y.row p true else x.row p false) else x.row p b + y.row p b := rfl + have proof_source_comp_le_6 {K : OAI.Thomason.DirectedComplex.{u}} (i k : ℕ) (hik : i ≤ k) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) : + OAI.Thomason.DirectedComplex.Table.truncate i false (OAI.Thomason.DirectedComplex.Table.comp k x y h) = OAI.Thomason.DirectedComplex.Table.truncate i false x := by + ext p b + by_cases hpi : p < i + · have hpk : p < k := lt_of_lt_of_le hpi hik + simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hpi, hpk] + · by_cases hpe : p = i + · subst p + by_cases hik' : i < k + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hik'] + · have he : i = k := by omega + subst i + simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp] + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hpi, hpe] + have proof_lower_rows_eq_1 {K : OAI.Thomason.DirectedComplex.{u}} {k : ℕ} {x y : OAI.Thomason.DirectedComplex.Table K} + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) {p : ℕ} (hp : p < k) (b : Bool) : + x.row p b = y.row p b := by + have hr := congrArg (fun z : OAI.Thomason.DirectedComplex.Table K => z.row p b) h + simpa only [OAI.Thomason.DirectedComplex.Table.truncate, hp, ite_eq_left] using hr + have proof_target_comp_le_7 {K : OAI.Thomason.DirectedComplex.{u}} (i k : ℕ) (hik : i ≤ k) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) : + OAI.Thomason.DirectedComplex.Table.truncate i true (OAI.Thomason.DirectedComplex.Table.comp k x y h) = OAI.Thomason.DirectedComplex.Table.truncate i true y := by + ext p b + by_cases hpi : p < i + · have hpk : p < k := lt_of_lt_of_le hpi hik + simp only [OAI.Thomason.DirectedComplex.Table.truncate, ite_eq_left hpi, OAI.Thomason.DirectedComplex.Table.comp, ite_eq_left hpk] + exact proof_lower_rows_eq_1 h hpk b + · by_cases hpe : p = i + · subst p + by_cases hik' : i < k + · simpa [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hik'] using proof_lower_rows_eq_1 h hik' true + · have he : i = k := by omega + subst i + simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp] + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hpi, hpe] + have proof_truncate_comp_gt_8 {K : OAI.Thomason.DirectedComplex.{u}} (i k : ℕ) (hki : k < i) (e : Bool) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) + (h' : OAI.Thomason.DirectedComplex.Table.truncate k true (OAI.Thomason.DirectedComplex.Table.truncate i e x) = OAI.Thomason.DirectedComplex.Table.truncate k false (OAI.Thomason.DirectedComplex.Table.truncate i e y)) : + OAI.Thomason.DirectedComplex.Table.truncate i e (OAI.Thomason.DirectedComplex.Table.comp k x y h) = OAI.Thomason.DirectedComplex.Table.comp k (OAI.Thomason.DirectedComplex.Table.truncate i e x) (OAI.Thomason.DirectedComplex.Table.truncate i e y) h' := by + ext p b + by_cases hpk : p < k + · have hpi : p < i := lt_trans hpk hki + simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hpk, hpi] + · by_cases hpe : p = k + · subst p + simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hki] + · by_cases hpi : p < i + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hpk, hpe, hpi] + · by_cases hpie : p = i + · subst p + have hik : ¬i < k := by omega + have hie : ¬i = k := by omega + simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hik, hie] + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hpk, hpe, hpi, hpie] + have proof_unit_left_9 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (x : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true (OAI.Thomason.DirectedComplex.Table.truncate k false x) = OAI.Thomason.DirectedComplex.Table.truncate k false x) : + OAI.Thomason.DirectedComplex.Table.comp k (OAI.Thomason.DirectedComplex.Table.truncate k false x) x h = x := by + ext p b + by_cases hp : p < k + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hp] + · by_cases he : p = k + · subst p + cases b <;> simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp] + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hp, he] + have proof_unit_right_10 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (x : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false (OAI.Thomason.DirectedComplex.Table.truncate k true x)) : + OAI.Thomason.DirectedComplex.Table.comp k x (OAI.Thomason.DirectedComplex.Table.truncate k true x) h = x := by + ext p b + by_cases hp : p < k + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hp] + · by_cases he : p = k + · subst p + cases b <;> simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp] + · simp [OAI.Thomason.DirectedComplex.Table.truncate, OAI.Thomason.DirectedComplex.Table.comp, hp, he] + have proof_assoc_11 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (x y z : OAI.Thomason.DirectedComplex.Table K) + (hxy : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) + (hyz : OAI.Thomason.DirectedComplex.Table.truncate k true y = OAI.Thomason.DirectedComplex.Table.truncate k false z) + (hxy_z : OAI.Thomason.DirectedComplex.Table.truncate k true (OAI.Thomason.DirectedComplex.Table.comp k x y hxy) = OAI.Thomason.DirectedComplex.Table.truncate k false z) + (hx_yz : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false (OAI.Thomason.DirectedComplex.Table.comp k y z hyz)) : + OAI.Thomason.DirectedComplex.Table.comp k (OAI.Thomason.DirectedComplex.Table.comp k x y hxy) z hxy_z = OAI.Thomason.DirectedComplex.Table.comp k x (OAI.Thomason.DirectedComplex.Table.comp k y z hyz) hx_yz := by + ext p b + by_cases hp : p < k + · simp [OAI.Thomason.DirectedComplex.Table.comp, hp] + · by_cases he : p = k + · subst p + cases b <;> simp [OAI.Thomason.DirectedComplex.Table.comp] + · simp [OAI.Thomason.DirectedComplex.Table.comp, hp, he, add_assoc] + have proof_interchange_12 {K : OAI.Thomason.DirectedComplex.{u}} (k l : ℕ) (hkl : k < l) (a b c d : OAI.Thomason.DirectedComplex.Table K) + (hab : OAI.Thomason.DirectedComplex.Table.truncate l true a = OAI.Thomason.DirectedComplex.Table.truncate l false b) + (hcd : OAI.Thomason.DirectedComplex.Table.truncate l true c = OAI.Thomason.DirectedComplex.Table.truncate l false d) + (hac : OAI.Thomason.DirectedComplex.Table.truncate k true a = OAI.Thomason.DirectedComplex.Table.truncate k false c) + (hbd : OAI.Thomason.DirectedComplex.Table.truncate k true b = OAI.Thomason.DirectedComplex.Table.truncate k false d) + (hab_cd : OAI.Thomason.DirectedComplex.Table.truncate k true (OAI.Thomason.DirectedComplex.Table.comp l a b hab) = OAI.Thomason.DirectedComplex.Table.truncate k false (OAI.Thomason.DirectedComplex.Table.comp l c d hcd)) + (hac_bd : OAI.Thomason.DirectedComplex.Table.truncate l true (OAI.Thomason.DirectedComplex.Table.comp k a c hac) = OAI.Thomason.DirectedComplex.Table.truncate l false (OAI.Thomason.DirectedComplex.Table.comp k b d hbd)) : + OAI.Thomason.DirectedComplex.Table.comp k (OAI.Thomason.DirectedComplex.Table.comp l a b hab) (OAI.Thomason.DirectedComplex.Table.comp l c d hcd) hab_cd = + OAI.Thomason.DirectedComplex.Table.comp l (OAI.Thomason.DirectedComplex.Table.comp k a c hac) (OAI.Thomason.DirectedComplex.Table.comp k b d hbd) hac_bd := by + ext p e + by_cases hpk : p < k + · have hpl : p < l := lt_trans hpk hkl + simp [OAI.Thomason.DirectedComplex.Table.comp, hpk, hpl] + · by_cases hpe : p = k + · subst p + cases e <;> simp [OAI.Thomason.DirectedComplex.Table.comp, hkl] + · by_cases hpl : p < l + · simp [OAI.Thomason.DirectedComplex.Table.comp, hpk, hpe, hpl] + · by_cases hple : p = l + · subst p + have hlk : ¬l < k := by omega + have hlke : ¬l = k := by omega + cases e <;> simp [OAI.Thomason.DirectedComplex.Table.comp, hlk, hlke] + · simp only [OAI.Thomason.DirectedComplex.Table.comp, ite_eq_right hpk, ite_eq_right hpe, ite_eq_right hpl, ite_eq_right hple] + abel + have proof_finite_dimension_13 {K : OAI.Thomason.DirectedComplex.{u}} (x : OAI.Thomason.DirectedComplex.Table K) : ∃ k, OAI.Thomason.DirectedComplex.Table.truncate k false x = x := by + obtain ⟨k, hk⟩ := x.bounded + have ht : x.row k true = x.row k false := by + have hb := x.boundary k false + rw [hk (k+1) (by omega) false, map_zero] at hb + exact sub_eq_zero.mp hb.symm + refine ⟨k, ?_⟩ + ext p b + by_cases hp : p < k + · simp [OAI.Thomason.DirectedComplex.Table.truncate, hp] + · by_cases he : p = k + · subst p + cases b <;> simp [OAI.Thomason.DirectedComplex.Table.truncate, ht] + · have hkp : k < p := by omega + simp [OAI.Thomason.DirectedComplex.Table.truncate, hp, he, hk p hkp b] + exact { + Cell := OAI.Thomason.DirectedComplex.Table K + source k := OAI.Thomason.DirectedComplex.Table.truncate k false + target k := OAI.Thomason.DirectedComplex.Table.truncate k true + source_source i j x := proof_truncate_truncate_same_4 i j false x + target_target i j x := proof_truncate_truncate_same_4 i j true x + source_target i j x := proof_truncate_truncate_5 i j false true x + target_source i j x := proof_truncate_truncate_5 i j true false x + comp := OAI.Thomason.DirectedComplex.Table.comp + source_comp_le := proof_source_comp_le_6 + target_comp_le := proof_target_comp_le_7 + source_comp_gt i k hki x y h hs := proof_truncate_comp_gt_8 i k hki false x y h hs + target_comp_gt i k hki x y h ht := proof_truncate_comp_gt_8 i k hki true x y h ht + unit_left := proof_unit_left_9 + unit_right := proof_unit_right_10 + assoc := proof_assoc_11 + interchange := proof_interchange_12 + finite_dimension := proof_finite_dimension_13 + } + + +end OAI.Thomason.DirectedComplex +end + +section +namespace OAI.Thomason.DirectedComplex.Hom +variable {K : DirectedComplex.{u}} {L : DirectedComplex.{v}} {M : DirectedComplex.{w}} + +noncomputable def table (f : OAI.Thomason.DirectedComplex.Hom K L) (x : OAI.Thomason.DirectedComplex.Table K) : OAI.Thomason.DirectedComplex.Table L where + row p b := f.map p (x.row p b) + positive p b := f.map_positive p _ (x.positive p b) + boundary p b := by rw [← f.map_d, x.boundary, map_sub] + augmentation b := by rw [f.map_augmentation, x.augmentation] + bounded := by + obtain ⟨k, hk⟩ := x.bounded + refine ⟨k, ?_⟩ + intro p hp b + rw [hk p hp b, map_zero] + +noncomputable def nu (f : OAI.Thomason.DirectedComplex.Hom K L) : OAI.Thomason.OmegaCategory.Functor K.nu L.nu := by + classical + have proof_table_row_17 {K : OAI.Thomason.DirectedComplex.{u}} {L : OAI.Thomason.DirectedComplex.{v}} (f : OAI.Thomason.DirectedComplex.Hom K L) (x : OAI.Thomason.DirectedComplex.Table K) (p : ℕ) (b : Bool) : + (f.table x).row p b = f.map p (x.row p b) := rfl + have proof_truncate_row_3 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (e : Bool) (x : OAI.Thomason.DirectedComplex.Table K) (p : ℕ) (b : Bool) : + (OAI.Thomason.DirectedComplex.Table.truncate k e x).row p b = + if p < k then x.row p b else if p = k then x.row p e else 0 := rfl + have proof_table_truncate_15 {K : OAI.Thomason.DirectedComplex.{u}} {L : OAI.Thomason.DirectedComplex.{v}} (f : OAI.Thomason.DirectedComplex.Hom K L) (k : ℕ) (b : Bool) (x : OAI.Thomason.DirectedComplex.Table K) : + f.table (OAI.Thomason.DirectedComplex.Table.truncate k b x) = OAI.Thomason.DirectedComplex.Table.truncate k b (f.table x) := by + ext p e + simp only [OAI.Thomason.DirectedComplex.Hom.table, OAI.Thomason.DirectedComplex.Table.truncate] + split_ifs <;> simp only [map_zero] + have proof_comp_row_14 {K : OAI.Thomason.DirectedComplex.{u}} (k : ℕ) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) (p : ℕ) (b : Bool) : + (OAI.Thomason.DirectedComplex.Table.comp k x y h).row p b = if p < k then x.row p b else if p = k then + (if b then y.row p true else x.row p false) else x.row p b + y.row p b := rfl + have proof_table_comp_16 {K : OAI.Thomason.DirectedComplex.{u}} {L : OAI.Thomason.DirectedComplex.{v}} (f : OAI.Thomason.DirectedComplex.Hom K L) (k : ℕ) (x y : OAI.Thomason.DirectedComplex.Table K) + (h : OAI.Thomason.DirectedComplex.Table.truncate k true x = OAI.Thomason.DirectedComplex.Table.truncate k false y) + (h' : OAI.Thomason.DirectedComplex.Table.truncate k true (f.table x) = OAI.Thomason.DirectedComplex.Table.truncate k false (f.table y)) : + f.table (OAI.Thomason.DirectedComplex.Table.comp k x y h) = OAI.Thomason.DirectedComplex.Table.comp k (f.table x) (f.table y) h' := by + ext p e + simp only [OAI.Thomason.DirectedComplex.Hom.table, OAI.Thomason.DirectedComplex.Table.comp] + split_ifs <;> simp only [map_add] + exact { + map := f.table + map_source k x := (proof_table_truncate_15 f k Bool.false x) + map_target k x := (proof_table_truncate_15 f k Bool.true x) + map_comp := (proof_table_comp_16 f) + } + + +end OAI.Thomason.DirectedComplex.Hom +end + +section +namespace OAI.Thomason.DirectedComplex + + +noncomputable def nuFunctor : CategoryTheory.Functor OAI.Thomason.DirectedComplex.{u} OAI.Thomason.OmegaCategory.{u} where + obj := OAI.Thomason.DirectedComplex.nu + map := OAI.Thomason.DirectedComplex.Hom.nu + map_id K := by + change OAI.Thomason.DirectedComplex.Hom.nu (OAI.Thomason.DirectedComplex.Hom.id K) = OAI.Thomason.OmegaCategory.Functor.id K.nu + ext x + rfl + map_comp f g := by + change OAI.Thomason.DirectedComplex.Hom.nu (OAI.Thomason.DirectedComplex.Hom.comp f g) = OAI.Thomason.OmegaCategory.Functor.comp f.nu g.nu + ext x + rfl + + +end OAI.Thomason.DirectedComplex +end + +section +namespace OAI.Thomason.NormalizedChains +variable {E : Type u} [PartialOrder E] + +noncomputable abbrev Word (E : Type u) [PartialOrder E] := + {l : List E // l.Pairwise (· < ·)} + +noncomputable abbrev Chains (E : Type u) [PartialOrder E] := OAI.Thomason.NormalizedChains.Word E →₀ ℤ + +noncomputable def bracket (l : List E) : OAI.Thomason.NormalizedChains.Chains E := by + classical + exact if h : l.Pairwise (· < ·) then Finsupp.single ⟨l, h⟩ 1 else 0 + +noncomputable def prepend (a : E) : OAI.Thomason.NormalizedChains.Chains E →ₗ[ℤ] OAI.Thomason.NormalizedChains.Chains E := + Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (a :: l.val)) + +noncomputable def wordBoundary : List E → OAI.Thomason.NormalizedChains.Chains E + | [] => 0 + | a :: l => OAI.Thomason.NormalizedChains.bracket l - OAI.Thomason.NormalizedChains.prepend a (wordBoundary l) + +noncomputable def boundary : OAI.Thomason.NormalizedChains.Chains E →ₗ[ℤ] OAI.Thomason.NormalizedChains.Chains E := + Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.wordBoundary l.val) + + +end OAI.Thomason.NormalizedChains +end + +section +namespace OAI.Thomason.NormalizedChains +variable {E : Type u} [PartialOrder E] +omit [PartialOrder E] +variable {M : Type v} [AddCommGroup M] + +noncomputable def faces (H : List E → M) : List E → M + | [] => 0 + | a :: l => H l - faces (fun m => H (a :: m)) l + + +end OAI.Thomason.NormalizedChains +end + +section +namespace OAI.Thomason.NormalizedChains +variable {E : Type u} [PartialOrder E] + +noncomputable def grade (k : ℕ) : Submodule ℤ (OAI.Thomason.NormalizedChains.Chains E) := + Finsupp.supported ℤ ℤ {w : OAI.Thomason.NormalizedChains.Word E | w.val.length = k} + +noncomputable def emptyWord : OAI.Thomason.NormalizedChains.Word E := ⟨[], List.Pairwise.nil⟩ + +noncomputable def emptyCoefficient : OAI.Thomason.NormalizedChains.Chains E →ₗ[ℤ] ℤ := Finsupp.lapply OAI.Thomason.NormalizedChains.emptyWord + +noncomputable def Positive (c : OAI.Thomason.NormalizedChains.Chains E) : Prop := ∀ l, 0 ≤ c l + +noncomputable def positiveGrade (p : ℕ) : AddSubmonoid (OAI.Thomason.NormalizedChains.grade (E := E) (p+1)) where + carrier := {c | Positive c.val} + zero_mem' _ := le_rfl + add_mem' ha hb w := add_nonneg (ha w) (hb w) + +noncomputable def complex (E : Type u) [PartialOrder E] : OAI.Thomason.DirectedComplex.{u} := by + classical + have proof_mem_grade_iff_20 {E : Type u} [instLocal1 : PartialOrder.{u} E] (k : ℕ) (c : OAI.Thomason.NormalizedChains.Chains E) : + c ∈ OAI.Thomason.NormalizedChains.grade k ↔ ∀ w, c w ≠ 0 → w.val.length = k := by + simp only [OAI.Thomason.NormalizedChains.grade, Finsupp.mem_supported, Set.subset_def, Finsupp.mem_support_iff, + Finset.mem_coe, Set.mem_ofPred_eq] + have proof_linearCombination_mem_grade_21 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type u} [PartialOrder D] + (H : OAI.Thomason.NormalizedChains.Word E → OAI.Thomason.NormalizedChains.Chains D) (k j : ℕ) + (hH : ∀ w, w.val.length = k → H w ∈ OAI.Thomason.NormalizedChains.grade j) + {c : OAI.Thomason.NormalizedChains.Chains E} (hc : c ∈ OAI.Thomason.NormalizedChains.grade k) : + Finsupp.linearCombination ℤ H c ∈ OAI.Thomason.NormalizedChains.grade j := by + rw [Finsupp.linearCombination_apply, Finsupp.sum] + apply Submodule.sum_mem + intro w hw + exact Submodule.smul_mem _ _ (hH w ((proof_mem_grade_iff_20 k c).mp hc w + (Finsupp.mem_support_iff.mp hw))) + have proof_bracket_of_pairwise_22 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = Finsupp.single ⟨l, h⟩ 1 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_bracket_of_not_pairwise_23 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : ¬l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = 0 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_bracket_mem_grade_24 {E : Type u} [instLocal1 : PartialOrder.{u} E] (l : List E) : OAI.Thomason.NormalizedChains.bracket l ∈ OAI.Thomason.NormalizedChains.grade l.length := by + classical + by_cases h : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_22 h] + exact Finsupp.single_mem_supported ℤ 1 rfl + · rw [proof_bracket_of_not_pairwise_23 h] + exact Submodule.zero_mem _ + have proof_wordBoundary_nil_25 {E : Type u} [instLocal1 : PartialOrder.{u} E] : OAI.Thomason.NormalizedChains.wordBoundary ([] : List E) = 0 := rfl + have proof_wordBoundary_cons_26 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.wordBoundary (a :: l) = OAI.Thomason.NormalizedChains.bracket l - OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.wordBoundary l) := rfl + have proof_prepend_bracket_27 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.bracket (a :: l) := by + classical + by_cases h : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_22 h] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (a :: l.val)) + (Finsupp.single (⟨l, h⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp + · have h' : ¬(a :: l).Pairwise (· < ·) := fun hw => h hw.tail + simp [proof_bracket_of_not_pairwise_23 h, proof_bracket_of_not_pairwise_23 h'] + have proof_prepend_mem_grade_28 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) {k : ℕ} {c : OAI.Thomason.NormalizedChains.Chains E} (hc : c ∈ OAI.Thomason.NormalizedChains.grade k) : + OAI.Thomason.NormalizedChains.prepend a c ∈ OAI.Thomason.NormalizedChains.grade (k+1) := by + apply proof_linearCombination_mem_grade_21 _ k (k+1) _ hc + intro w hw + simpa only [List.length_cons, hw] using proof_bracket_mem_grade_24 (a :: w.val) + have proof_wordBoundary_mem_grade_29 {E : Type u} [instLocal1 : PartialOrder.{u} E] (l : List E) : OAI.Thomason.NormalizedChains.wordBoundary l ∈ OAI.Thomason.NormalizedChains.grade (l.length-1) := by + induction l with + | nil => exact Submodule.zero_mem _ + | cons a l ih => + cases l with + | nil => simpa [proof_wordBoundary_nil_25, proof_wordBoundary_cons_26, proof_prepend_bracket_27, OAI.Thomason.NormalizedChains.wordBoundary] using proof_bracket_mem_grade_24 ([] : List E) + | cons b l => + rw [proof_wordBoundary_cons_26] + apply Submodule.sub_mem + · simpa [proof_wordBoundary_nil_25, proof_wordBoundary_cons_26, proof_prepend_bracket_27] using proof_bracket_mem_grade_24 (b :: l) + · simpa [proof_wordBoundary_nil_25, proof_wordBoundary_cons_26, proof_prepend_bracket_27] using proof_prepend_mem_grade_28 a ih + have proof_boundary_mem_grade_18 {E : Type u} [instLocal1 : PartialOrder.{u} E] {k : ℕ} {c : OAI.Thomason.NormalizedChains.Chains E} (hc : c ∈ OAI.Thomason.NormalizedChains.grade (k+1)) : + OAI.Thomason.NormalizedChains.boundary c ∈ OAI.Thomason.NormalizedChains.grade k := by + apply proof_linearCombination_mem_grade_21 _ (k+1) k _ hc + intro w hw + simpa only [hw, Nat.add_sub_cancel] using proof_wordBoundary_mem_grade_29 w.val + have proof_prepend_prepend_self_30 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (c : OAI.Thomason.NormalizedChains.Chains E) : OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.prepend a c) = 0 := by + classical + induction c using Finsupp.induction with + | zero => simp [] + | @single_add l z c _ _ ih => + simp only [map_add, ih, add_zero] + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_22 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + rw [hz] + simp only [map_smul, proof_prepend_bracket_27] + have h : ¬(a :: a :: l.val).Pairwise (· < ·) := by simp [] + simp [proof_bracket_of_not_pairwise_23 h] + have proof_wordBoundary_repeated_31 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.wordBoundary (a :: a :: l) = 0 := by + simp [proof_prepend_bracket_27, OAI.Thomason.NormalizedChains.wordBoundary, map_sub, proof_prepend_prepend_self_30] + have proof_wordBoundary_eq_zero_of_not_pairwise_32 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} + (h : l.Pairwise (· ≤ ·)) (hn : ¬l.Pairwise (· < ·)) : OAI.Thomason.NormalizedChains.wordBoundary l = 0 := by + induction l with + | nil => exact (hn (by simp)).elim + | cons a l ih => + by_cases hl : l.Pairwise (· < ·) + · cases l with + | nil => exact (hn (by simp)).elim + | cons b l => + have hab : a ≤ b := (List.pairwise_cons.mp h).1 b (by simp) + have hab' : ¬a < b := by + intro hab' + exact hn (List.Pairwise.cons_cons_of_trans hab' hl) + have heq : a = b := (lt_or_eq_of_le hab).resolve_left hab' + subst b + exact proof_wordBoundary_repeated_31 a l + · simp [OAI.Thomason.NormalizedChains.wordBoundary, proof_bracket_of_not_pairwise_23 hl, ih h.tail hl] + have proof_boundary_bracket_33 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.wordBoundary l := by + classical + by_cases hs : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_22 hs] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.wordBoundary l.val) + (Finsupp.single (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp [] + · simp [proof_bracket_of_not_pairwise_23 hs, proof_wordBoundary_eq_zero_of_not_pairwise_32 h hs] + have proof_faces_nil_34 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] (H : List E → M) : OAI.Thomason.NormalizedChains.faces H [] = 0 := rfl + have proof_faces_cons_35 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] (H : List E → M) (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.faces H (a :: l) = H l - OAI.Thomason.NormalizedChains.faces (fun m => H (a :: m)) l := rfl + have proof_faces_hom_36 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] {M' : Type u} [AddCommGroup M'] (q : M →+ M') + (H : List E → M) (l : List E) : + q (OAI.Thomason.NormalizedChains.faces H l) = OAI.Thomason.NormalizedChains.faces (fun m => q (H m)) l := by + induction l generalizing H with + | nil => simp only [OAI.Thomason.NormalizedChains.faces, map_zero] + | cons a l ih => simp only [OAI.Thomason.NormalizedChains.faces, map_sub, ih] + have proof_faces_bracket_37 {E : Type u} [instLocal1 : PartialOrder.{u} E] (l : List E) : OAI.Thomason.NormalizedChains.faces OAI.Thomason.NormalizedChains.bracket l = OAI.Thomason.NormalizedChains.wordBoundary l := by + induction l with + | nil => rfl + | cons a l ih => + rw [proof_faces_cons_35, proof_wordBoundary_cons_26] + have h := proof_faces_hom_36 (OAI.Thomason.NormalizedChains.prepend a).toAddMonoidHom OAI.Thomason.NormalizedChains.bracket l + simp only [LinearMap.toAddMonoidHom_coe, proof_prepend_bracket_27] at h + rw [← h, ih] + have proof_faces_congr_38 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] {H K : List E → M} {l : List E} + (h : ∀ m, m.Sublist l → H m = K m) : OAI.Thomason.NormalizedChains.faces H l = OAI.Thomason.NormalizedChains.faces K l := by + induction l generalizing H K with + | nil => rfl + | cons a l ih => + rw [proof_faces_cons_35, proof_faces_cons_35, h l (List.sublist_cons_self a l)] + congr 1 + exact ih (fun m hm => h (a :: m) (List.Sublist.cons_cons a hm)) + have proof_faces_sub_39 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] (H K : List E → M) (l : List E) : + OAI.Thomason.NormalizedChains.faces (fun m => H m - K m) l = OAI.Thomason.NormalizedChains.faces H l - OAI.Thomason.NormalizedChains.faces K l := by + induction l generalizing H K with + | nil => simp [proof_faces_nil_34] + | cons a l ih => simp only [proof_faces_cons_35, ih]; abel + have proof_faces_faces_40 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] (H : List E → M) (l : List E) : + OAI.Thomason.NormalizedChains.faces (OAI.Thomason.NormalizedChains.faces H) l = 0 := by + induction l generalizing H with + | nil => rfl + | cons a l ih => + simp only [proof_faces_cons_35] + rw [proof_faces_sub_39, ih] + simp [] + have proof_boundary_wordBoundary_41 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.wordBoundary l) = 0 := by + rw [← proof_faces_bracket_37] + change OAI.Thomason.NormalizedChains.boundary.toAddMonoidHom (OAI.Thomason.NormalizedChains.faces OAI.Thomason.NormalizedChains.bracket l) = 0 + rw [proof_faces_hom_36] + have hc : OAI.Thomason.NormalizedChains.faces (fun m => OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.bracket m)) l = OAI.Thomason.NormalizedChains.faces OAI.Thomason.NormalizedChains.wordBoundary l := by + apply proof_faces_congr_38 + intro m hm + exact proof_boundary_bracket_33 (h.sublist hm) + change OAI.Thomason.NormalizedChains.faces (fun m => OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.bracket m)) l = 0 + rw [hc] + change OAI.Thomason.NormalizedChains.faces (fun m => OAI.Thomason.NormalizedChains.wordBoundary m) l = 0 + simp_rw [← proof_faces_bracket_37] + exact proof_faces_faces_40 OAI.Thomason.NormalizedChains.bracket l + have proof_boundary_boundary_19 {E : Type u} [instLocal1 : PartialOrder.{u} E] (c : OAI.Thomason.NormalizedChains.Chains E) : OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.boundary c) = 0 := by + classical + induction c using Finsupp.induction with + | zero => simp [] + | @single_add l z c _ _ ih => + simp only [map_add, ih, add_zero] + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_22 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + rw [hz] + simp only [map_smul] + rw [proof_boundary_bracket_33 (l.property.imp fun h => le_of_lt h), + proof_boundary_wordBoundary_41 (l.property.imp fun h => le_of_lt h), smul_zero] + exact { + Chain p := OAI.Thomason.NormalizedChains.grade (E := E) (p+1) + group _ := inferInstance + d p := + { toFun := fun c => ⟨OAI.Thomason.NormalizedChains.boundary c.val, proof_boundary_mem_grade_18 c.property⟩ + map_zero' := Subtype.ext (map_zero _) + map_add' := fun x y => Subtype.ext (map_add _ x.val y.val) } + d_d p x := Subtype.ext (proof_boundary_boundary_19 x.val) + augmentation := + { toFun := fun c => OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.boundary c.val) + map_zero' := by simp [] + map_add' := by intros; simp [] } + augmentation_d x := by + change OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.boundary x.val)) = 0 + rw [proof_boundary_boundary_19, map_zero] + positive := OAI.Thomason.NormalizedChains.positiveGrade + } + + +end OAI.Thomason.NormalizedChains +end + +section +namespace OAI.Thomason.NormalizedChains +variable {E : Type u} [PartialOrder E] +variable {D : Type v} [PartialOrder D] {B : Type w} [PartialOrder B] + +noncomputable def map (f : E →o D) : OAI.Thomason.NormalizedChains.Chains E →ₗ[ℤ] OAI.Thomason.NormalizedChains.Chains D := + Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (l.val.map f)) + + +end OAI.Thomason.NormalizedChains +end + +section +namespace OAI.Thomason.NormalizedChains +variable {E : Type u} [PartialOrder E] + +noncomputable def complexMap {D : Type v} [PartialOrder D] (f : E →o D) : + OAI.Thomason.DirectedComplex.Hom (OAI.Thomason.NormalizedChains.complex E) (OAI.Thomason.NormalizedChains.complex D) := by + classical + have proof_mem_grade_iff_20 {E : Type u} [instLocal1 : PartialOrder.{u} E] (k : ℕ) (c : OAI.Thomason.NormalizedChains.Chains E) : + c ∈ OAI.Thomason.NormalizedChains.grade k ↔ ∀ w, c w ≠ 0 → w.val.length = k := by + simp only [OAI.Thomason.NormalizedChains.grade, Finsupp.mem_supported, Set.subset_def, Finsupp.mem_support_iff, + Finset.mem_coe, Set.mem_ofPred_eq] + have proof_linearCombination_mem_grade_46 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [PartialOrder D] + (H : OAI.Thomason.NormalizedChains.Word E → OAI.Thomason.NormalizedChains.Chains D) (k j : ℕ) + (hH : ∀ w, w.val.length = k → H w ∈ OAI.Thomason.NormalizedChains.grade j) + {c : OAI.Thomason.NormalizedChains.Chains E} (hc : c ∈ OAI.Thomason.NormalizedChains.grade k) : + Finsupp.linearCombination ℤ H c ∈ OAI.Thomason.NormalizedChains.grade j := by + rw [Finsupp.linearCombination_apply, Finsupp.sum] + apply Submodule.sum_mem + intro w hw + exact Submodule.smul_mem _ _ (hH w ((proof_mem_grade_iff_20 k c).mp hc w + (Finsupp.mem_support_iff.mp hw))) + have proof_bracket_of_pairwise_47 {E : Type v} [instLocal1 : PartialOrder.{v} E] {l : List E} (h : l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = Finsupp.single ⟨l, h⟩ 1 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_bracket_of_not_pairwise_48 {E : Type v} [instLocal1 : PartialOrder.{v} E] {l : List E} (h : ¬l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = 0 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_bracket_mem_grade_49 {E : Type v} [instLocal1 : PartialOrder.{v} E] (l : List E) : OAI.Thomason.NormalizedChains.bracket l ∈ OAI.Thomason.NormalizedChains.grade l.length := by + classical + by_cases h : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_47 h] + exact Finsupp.single_mem_supported ℤ 1 rfl + · rw [proof_bracket_of_not_pairwise_48 h] + exact Submodule.zero_mem _ + have proof_map_mem_grade_42 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [PartialOrder D] (f : E →o D) {k : ℕ} + {c : OAI.Thomason.NormalizedChains.Chains E} (hc : c ∈ OAI.Thomason.NormalizedChains.grade k) : OAI.Thomason.NormalizedChains.map f c ∈ OAI.Thomason.NormalizedChains.grade k := by + apply proof_linearCombination_mem_grade_46 _ k k _ hc + intro w hw + simpa only [List.length_map, hw] using proof_bracket_mem_grade_49 (w.val.map f) + have proof_bracket_of_pairwise_22 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = Finsupp.single ⟨l, h⟩ 1 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_bracket_of_not_pairwise_23 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : ¬l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = 0 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_prepend_bracket_27 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.bracket (a :: l) := by + classical + by_cases h : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_22 h] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (a :: l.val)) + (Finsupp.single (⟨l, h⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp + · have h' : ¬(a :: l).Pairwise (· < ·) := fun hw => h hw.tail + simp [proof_bracket_of_not_pairwise_23 h, proof_bracket_of_not_pairwise_23 h'] + have proof_prepend_prepend_self_30 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (c : OAI.Thomason.NormalizedChains.Chains E) : OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.prepend a c) = 0 := by + classical + induction c using Finsupp.induction with + | zero => simp [] + | @single_add l z c _ _ ih => + simp only [map_add, ih, add_zero] + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_22 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + rw [hz] + simp only [map_smul, proof_prepend_bracket_27] + have h : ¬(a :: a :: l.val).Pairwise (· < ·) := by simp [] + simp [proof_bracket_of_not_pairwise_23 h] + have proof_wordBoundary_nil_25 {E : Type u} [instLocal1 : PartialOrder.{u} E] : OAI.Thomason.NormalizedChains.wordBoundary ([] : List E) = 0 := rfl + have proof_wordBoundary_cons_26 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.wordBoundary (a :: l) = OAI.Thomason.NormalizedChains.bracket l - OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.wordBoundary l) := rfl + have proof_wordBoundary_repeated_31 {E : Type u} [instLocal1 : PartialOrder.{u} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.wordBoundary (a :: a :: l) = 0 := by + simp [proof_prepend_bracket_27, OAI.Thomason.NormalizedChains.wordBoundary, map_sub, proof_prepend_prepend_self_30] + have proof_wordBoundary_eq_zero_of_not_pairwise_32 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} + (h : l.Pairwise (· ≤ ·)) (hn : ¬l.Pairwise (· < ·)) : OAI.Thomason.NormalizedChains.wordBoundary l = 0 := by + induction l with + | nil => exact (hn (by simp)).elim + | cons a l ih => + by_cases hl : l.Pairwise (· < ·) + · cases l with + | nil => exact (hn (by simp)).elim + | cons b l => + have hab : a ≤ b := (List.pairwise_cons.mp h).1 b (by simp) + have hab' : ¬a < b := by + intro hab' + exact hn (List.Pairwise.cons_cons_of_trans hab' hl) + have heq : a = b := (lt_or_eq_of_le hab).resolve_left hab' + subst b + exact proof_wordBoundary_repeated_31 a l + · simp [OAI.Thomason.NormalizedChains.wordBoundary, proof_bracket_of_not_pairwise_23 hl, ih h.tail hl] + have proof_boundary_bracket_33 {E : Type u} [instLocal1 : PartialOrder.{u} E] {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.wordBoundary l := by + classical + by_cases hs : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_22 hs] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.wordBoundary l.val) + (Finsupp.single (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp [] + · simp [proof_bracket_of_not_pairwise_23 hs, proof_wordBoundary_eq_zero_of_not_pairwise_32 h hs] + have proof_faces_nil_34 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] (H : List E → M) : OAI.Thomason.NormalizedChains.faces H [] = 0 := rfl + have proof_faces_cons_35 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] (H : List E → M) (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.faces H (a :: l) = H l - OAI.Thomason.NormalizedChains.faces (fun m => H (a :: m)) l := rfl + have proof_faces_hom_36 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] {M' : Type u} [AddCommGroup M'] (q : M →+ M') + (H : List E → M) (l : List E) : + q (OAI.Thomason.NormalizedChains.faces H l) = OAI.Thomason.NormalizedChains.faces (fun m => q (H m)) l := by + induction l generalizing H with + | nil => simp only [OAI.Thomason.NormalizedChains.faces, map_zero] + | cons a l ih => simp only [OAI.Thomason.NormalizedChains.faces, map_sub, ih] + have proof_faces_bracket_37 {E : Type u} [instLocal1 : PartialOrder.{u} E] (l : List E) : OAI.Thomason.NormalizedChains.faces OAI.Thomason.NormalizedChains.bracket l = OAI.Thomason.NormalizedChains.wordBoundary l := by + induction l with + | nil => rfl + | cons a l ih => + rw [proof_faces_cons_35, proof_wordBoundary_cons_26] + have h := proof_faces_hom_36 (OAI.Thomason.NormalizedChains.prepend a).toAddMonoidHom OAI.Thomason.NormalizedChains.bracket l + simp only [LinearMap.toAddMonoidHom_coe, proof_prepend_bracket_27] at h + rw [← h, ih] + have proof_faces_nil_50 {E : Type v} {M : Type v} [instLocal2 : AddCommGroup.{v} M] (H : List E → M) : OAI.Thomason.NormalizedChains.faces H [] = 0 := rfl + have proof_faces_cons_51 {E : Type v} {M : Type v} [instLocal2 : AddCommGroup.{v} M] (H : List E → M) (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.faces H (a :: l) = H l - OAI.Thomason.NormalizedChains.faces (fun m => H (a :: m)) l := rfl + have proof_wordBoundary_nil_52 {E : Type v} [instLocal1 : PartialOrder.{v} E] : OAI.Thomason.NormalizedChains.wordBoundary ([] : List E) = 0 := rfl + have proof_wordBoundary_cons_53 {E : Type v} [instLocal1 : PartialOrder.{v} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.wordBoundary (a :: l) = OAI.Thomason.NormalizedChains.bracket l - OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.wordBoundary l) := rfl + have proof_faces_hom_54 {E : Type v} {M : Type v} [instLocal2 : AddCommGroup.{v} M] {M' : Type v} [AddCommGroup M'] (q : M →+ M') + (H : List E → M) (l : List E) : + q (OAI.Thomason.NormalizedChains.faces H l) = OAI.Thomason.NormalizedChains.faces (fun m => q (H m)) l := by + induction l generalizing H with + | nil => simp [proof_faces_nil_50] + | cons a l ih => simp only [proof_faces_cons_51, map_sub, ih] + have proof_prepend_bracket_55 {E : Type v} [instLocal1 : PartialOrder.{v} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.bracket (a :: l) := by + classical + by_cases h : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_47 h] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (a :: l.val)) + (Finsupp.single (⟨l, h⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp + · have h' : ¬(a :: l).Pairwise (· < ·) := fun hw => h hw.tail + simp [proof_bracket_of_not_pairwise_48 h, proof_bracket_of_not_pairwise_48 h'] + have proof_faces_bracket_56 {E : Type v} [instLocal1 : PartialOrder.{v} E] (l : List E) : OAI.Thomason.NormalizedChains.faces OAI.Thomason.NormalizedChains.bracket l = OAI.Thomason.NormalizedChains.wordBoundary l := by + induction l with + | nil => rfl + | cons a l ih => + rw [proof_faces_cons_51, proof_wordBoundary_cons_53] + have h := proof_faces_hom_54 (OAI.Thomason.NormalizedChains.prepend a).toAddMonoidHom OAI.Thomason.NormalizedChains.bracket l + simp only [LinearMap.toAddMonoidHom_coe, proof_prepend_bracket_55] at h + rw [← h, ih] + have proof_faces_hom_57 {E : Type u} {M : Type u} [instLocal2 : AddCommGroup.{u} M] {M' : Type v} [AddCommGroup M'] (q : M →+ M') + (H : List E → M) (l : List E) : + q (OAI.Thomason.NormalizedChains.faces H l) = OAI.Thomason.NormalizedChains.faces (fun m => q (H m)) l := by + induction l generalizing H with + | nil => simp only [OAI.Thomason.NormalizedChains.faces, map_zero] + | cons a l ih => simp only [OAI.Thomason.NormalizedChains.faces, map_sub, ih] + have proof_faces_map_58 {E : Type v} {M : Type v} [instLocal2 : AddCommGroup.{v} M] {D : Type u} (f : D → E) (H : List E → M) (l : List D) : + OAI.Thomason.NormalizedChains.faces H (l.map f) = OAI.Thomason.NormalizedChains.faces (fun m => H (m.map f)) l := by + induction l generalizing H with + | nil => rfl + | cons a l ih => simp only [List.map_cons, OAI.Thomason.NormalizedChains.faces, ih] + have proof_faces_nil_59 {E : Type u} {M : Type v} [instLocal2 : AddCommGroup.{v} M] (H : List E → M) : OAI.Thomason.NormalizedChains.faces H [] = 0 := rfl + have proof_faces_cons_60 {E : Type u} {M : Type v} [instLocal2 : AddCommGroup.{v} M] (H : List E → M) (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.faces H (a :: l) = H l - OAI.Thomason.NormalizedChains.faces (fun m => H (a :: m)) l := rfl + have proof_faces_congr_61 {E : Type u} {M : Type v} [instLocal2 : AddCommGroup.{v} M] {H K : List E → M} {l : List E} + (h : ∀ m, m.Sublist l → H m = K m) : OAI.Thomason.NormalizedChains.faces H l = OAI.Thomason.NormalizedChains.faces K l := by + induction l generalizing H K with + | nil => rfl + | cons a l ih => + rw [proof_faces_cons_60, proof_faces_cons_60, h l (List.sublist_cons_self a l)] + congr 1 + exact ih (fun m hm => h (a :: m) (List.Sublist.cons_cons a hm)) + have proof_pairwise_of_map_62 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [instLocal3 : PartialOrder.{v} D] {l : List E} (h : l.Pairwise (· ≤ ·)) (f : E → D) + (hf : (l.map f).Pairwise (· < ·)) : l.Pairwise (· < ·) := by + apply (h.and (List.pairwise_map.mp hf)).imp + intro a b hab + exact lt_of_le_of_ne hab.1 (fun he => (ne_of_lt hab.2) (congrArg f he)) + have proof_map_bracket_63 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [instLocal3 : PartialOrder.{v} D] (f : E →o D) {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.map f (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.bracket (l.map f) := by + classical + by_cases hs : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_22 hs] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (l.val.map f)) + (Finsupp.single (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp + · have hf : ¬(l.map f).Pairwise (· < ·) := fun hm => hs (proof_pairwise_of_map_62 h f hm) + simp [proof_bracket_of_not_pairwise_23 hs, proof_bracket_of_not_pairwise_48 hf] + have proof_map_wordBoundary_64 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [instLocal3 : PartialOrder.{v} D] (f : E →o D) {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.map f (OAI.Thomason.NormalizedChains.wordBoundary l) = OAI.Thomason.NormalizedChains.wordBoundary (l.map f) := by + rw [← proof_faces_bracket_37, ← proof_faces_bracket_56] + change (OAI.Thomason.NormalizedChains.map f).toAddMonoidHom (OAI.Thomason.NormalizedChains.faces OAI.Thomason.NormalizedChains.bracket l) = _ + rw [proof_faces_hom_57, proof_faces_map_58] + apply proof_faces_congr_61 + intro m hm + exact proof_map_bracket_63 f (h.sublist hm) + have proof_prepend_prepend_self_65 {E : Type v} [instLocal1 : PartialOrder.{v} E] (a : E) (c : OAI.Thomason.NormalizedChains.Chains E) : OAI.Thomason.NormalizedChains.prepend a (OAI.Thomason.NormalizedChains.prepend a c) = 0 := by + classical + induction c using Finsupp.induction with + | zero => simp [] + | @single_add l z c _ _ ih => + simp only [map_add, ih, add_zero] + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_47 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + rw [hz] + simp only [map_smul, proof_prepend_bracket_55] + have h : ¬(a :: a :: l.val).Pairwise (· < ·) := by simp [] + simp [proof_bracket_of_not_pairwise_48 h] + have proof_wordBoundary_repeated_66 {E : Type v} [instLocal1 : PartialOrder.{v} E] (a : E) (l : List E) : + OAI.Thomason.NormalizedChains.wordBoundary (a :: a :: l) = 0 := by + simp [proof_prepend_bracket_55, OAI.Thomason.NormalizedChains.wordBoundary, map_sub, proof_prepend_prepend_self_65] + have proof_wordBoundary_eq_zero_of_not_pairwise_67 {E : Type v} [instLocal1 : PartialOrder.{v} E] {l : List E} + (h : l.Pairwise (· ≤ ·)) (hn : ¬l.Pairwise (· < ·)) : OAI.Thomason.NormalizedChains.wordBoundary l = 0 := by + induction l with + | nil => exact (hn (by simp)).elim + | cons a l ih => + by_cases hl : l.Pairwise (· < ·) + · cases l with + | nil => exact (hn (by simp)).elim + | cons b l => + have hab : a ≤ b := (List.pairwise_cons.mp h).1 b (by simp) + have hab' : ¬a < b := by + intro hab' + exact hn (List.Pairwise.cons_cons_of_trans hab' hl) + have heq : a = b := (lt_or_eq_of_le hab).resolve_left hab' + subst b + exact proof_wordBoundary_repeated_66 a l + · simp [OAI.Thomason.NormalizedChains.wordBoundary, proof_bracket_of_not_pairwise_48 hl, ih h.tail hl] + have proof_boundary_bracket_68 {E : Type v} [instLocal1 : PartialOrder.{v} E] {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.wordBoundary l := by + classical + by_cases hs : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_47 hs] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.wordBoundary l.val) + (Finsupp.single (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp [] + · simp [proof_bracket_of_not_pairwise_48 hs, proof_wordBoundary_eq_zero_of_not_pairwise_67 h hs] + have proof_map_boundary_43 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [instLocal3 : PartialOrder.{v} D] (f : E →o D) (c : OAI.Thomason.NormalizedChains.Chains E) : + OAI.Thomason.NormalizedChains.map f (OAI.Thomason.NormalizedChains.boundary c) = OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.map f c) := by + classical + induction c using Finsupp.induction with + | zero => simp [] + | @single_add l z c _ _ ih => + simp only [map_add, ih] + congr 1 + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_22 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + have hl := l.property.imp fun h => le_of_lt h + rw [hz] + simp only [map_smul] + rw [proof_boundary_bracket_33 hl, proof_map_wordBoundary_64 f hl, proof_map_bracket_63 f hl, + proof_boundary_bracket_68 (List.pairwise_map.mpr (hl.imp fun hh => f.monotone hh))] + have proof_emptyCoefficient_bracket_69 {E : Type v} [instLocal1 : PartialOrder.{v} E] (l : List E) : + OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.bracket l) = if l = [] then 1 else 0 := by + classical + by_cases hl : l = [] + · subst l + simp [OAI.Thomason.NormalizedChains.emptyCoefficient, proof_bracket_of_pairwise_47 List.Pairwise.nil, OAI.Thomason.NormalizedChains.emptyWord] + · by_cases hs : l.Pairwise (· < ·) + · have hw : (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) ≠ OAI.Thomason.NormalizedChains.emptyWord := by + intro he + exact hl (congrArg Subtype.val he) + simp [OAI.Thomason.NormalizedChains.emptyCoefficient, proof_bracket_of_pairwise_47 hs, hw, hl] + · simp [proof_bracket_of_not_pairwise_48 hs, hl] + have proof_emptyCoefficient_bracket_70 {E : Type u} [instLocal1 : PartialOrder.{u} E] (l : List E) : + OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.bracket l) = if l = [] then 1 else 0 := by + classical + by_cases hl : l = [] + · subst l + simp [OAI.Thomason.NormalizedChains.emptyCoefficient, proof_bracket_of_pairwise_22 List.Pairwise.nil, OAI.Thomason.NormalizedChains.emptyWord] + · by_cases hs : l.Pairwise (· < ·) + · have hw : (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) ≠ OAI.Thomason.NormalizedChains.emptyWord := by + intro he + exact hl (congrArg Subtype.val he) + simp [OAI.Thomason.NormalizedChains.emptyCoefficient, proof_bracket_of_pairwise_22 hs, hw, hl] + · simp [proof_bracket_of_not_pairwise_23 hs, hl] + have proof_emptyCoefficient_map_44 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [PartialOrder D] (f : E →o D) (c : OAI.Thomason.NormalizedChains.Chains E) : + OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.map f c) = OAI.Thomason.NormalizedChains.emptyCoefficient c := by + classical + induction c using Finsupp.induction with + | zero => simp [] + | @single_add l z c _ _ ih => + simp only [map_add, ih] + congr 1 + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_22 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + rw [hz] + simp only [map_smul, proof_map_bracket_63 _ (l.property.imp fun h => le_of_lt h), + proof_emptyCoefficient_bracket_69, proof_emptyCoefficient_bracket_70, List.map_eq_nil_iff] + have proof_linearCombination_positive_71 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [PartialOrder D] + (H : OAI.Thomason.NormalizedChains.Word E → OAI.Thomason.NormalizedChains.Chains D) (hH : ∀ w, OAI.Thomason.NormalizedChains.Positive (H w)) + {c : OAI.Thomason.NormalizedChains.Chains E} (hc : OAI.Thomason.NormalizedChains.Positive c) : + OAI.Thomason.NormalizedChains.Positive (Finsupp.linearCombination ℤ H c) := by + intro w + rw [Finsupp.linearCombination_apply, Finsupp.sum] + simp only [Finset.sum_apply, Finsupp.coe_finsetSum] + apply Finset.sum_nonneg + intro i _ + exact mul_nonneg (hc i) (hH i w) + have proof_bracket_positive_72 {E : Type v} [instLocal1 : PartialOrder.{v} E] (l : List E) : OAI.Thomason.NormalizedChains.Positive (OAI.Thomason.NormalizedChains.bracket l) := by + classical + intro w + by_cases h : l.Pairwise (· < ·) + · simp [proof_bracket_of_pairwise_47 h, Finsupp.single_apply] + split <;> omega + · simp [proof_bracket_of_not_pairwise_48 h] + have proof_map_positive_45 {E : Type u} [instLocal1 : PartialOrder.{u} E] {D : Type v} [PartialOrder D] (f : E →o D) + {c : OAI.Thomason.NormalizedChains.Chains E} (hc : OAI.Thomason.NormalizedChains.Positive c) : OAI.Thomason.NormalizedChains.Positive (OAI.Thomason.NormalizedChains.map f c) := + proof_linearCombination_positive_71 _ (fun w => proof_bracket_positive_72 (w.val.map f)) hc + exact { + map p := + { toFun := fun c => ⟨OAI.Thomason.NormalizedChains.map f c.val, proof_map_mem_grade_42 f c.property⟩ + map_zero' := Subtype.ext (map_zero _) + map_add' := fun x y => Subtype.ext (map_add _ x.val y.val) } + map_d p x := Subtype.ext (proof_map_boundary_43 f x.val) + map_augmentation x := by + change OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.boundary (OAI.Thomason.NormalizedChains.map f x.val)) = OAI.Thomason.NormalizedChains.emptyCoefficient (OAI.Thomason.NormalizedChains.boundary x.val) + rw [← proof_map_boundary_43, proof_emptyCoefficient_map_44] + map_positive p x hx := proof_map_positive_45 f hx + } + + +end OAI.Thomason.NormalizedChains +end + +section +namespace OAI.Thomason.NormalizedChains +variable {E : Type u} [PartialOrder E] +open CategoryTheory + +noncomputable def simplexComplexes : SimplexCategory ⥤ OAI.Thomason.DirectedComplex.{0} := by + classical + have proof_bracket_of_pairwise_75 {E : Type 0} [instLocal1 : PartialOrder.{0} E] {l : List E} (h : l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = Finsupp.single ⟨l, h⟩ 1 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_pairwise_of_map_76 {E : Type 0} [instLocal1 : PartialOrder.{0} E] {D : Type 0} [instLocal3 : PartialOrder.{0} D] {l : List E} (h : l.Pairwise (· ≤ ·)) (f : E → D) + (hf : (l.map f).Pairwise (· < ·)) : l.Pairwise (· < ·) := by + apply (h.and (List.pairwise_map.mp hf)).imp + intro a b hab + exact lt_of_le_of_ne hab.1 (fun he => (ne_of_lt hab.2) (congrArg f he)) + have proof_bracket_of_not_pairwise_77 {E : Type 0} [instLocal1 : PartialOrder.{0} E] {l : List E} (h : ¬l.Pairwise (· < ·)) : + OAI.Thomason.NormalizedChains.bracket l = 0 := by + classical + simp [OAI.Thomason.NormalizedChains.bracket, h] + have proof_map_bracket_78 {E : Type 0} [instLocal1 : PartialOrder.{0} E] {D : Type 0} [instLocal3 : PartialOrder.{0} D] (f : E →o D) {l : List E} (h : l.Pairwise (· ≤ ·)) : + OAI.Thomason.NormalizedChains.map f (OAI.Thomason.NormalizedChains.bracket l) = OAI.Thomason.NormalizedChains.bracket (l.map f) := by + classical + by_cases hs : l.Pairwise (· < ·) + · rw [proof_bracket_of_pairwise_75 hs] + change Finsupp.linearCombination ℤ (fun l : OAI.Thomason.NormalizedChains.Word E => OAI.Thomason.NormalizedChains.bracket (l.val.map f)) + (Finsupp.single (⟨l, hs⟩ : OAI.Thomason.NormalizedChains.Word E) 1) = _ + rw [Finsupp.linearCombination_single] + simp + · have hf : ¬(l.map f).Pairwise (· < ·) := fun hm => hs (proof_pairwise_of_map_76 h f hm) + simp [proof_bracket_of_not_pairwise_77 hs, proof_bracket_of_not_pairwise_77 hf] + have proof_map_id_79 {E : Type 0} [instLocal1 : PartialOrder.{0} E] (c : OAI.Thomason.NormalizedChains.Chains E) : OAI.Thomason.NormalizedChains.map (OrderHom.id) c = c := by + classical + induction c using Finsupp.induction with + | zero => simp + | @single_add l z c _ _ ih => + simp only [map_add, ih] + congr 1 + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_75 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + rw [hz, map_smul, proof_map_bracket_78 _ (l.property.imp fun h => le_of_lt h)] + simp + have proof_complexMap_id_73 {E : Type 0} [instLocal1 : PartialOrder.{0} E] : OAI.Thomason.NormalizedChains.complexMap (OrderHom.id : E →o E) = + OAI.Thomason.DirectedComplex.Hom.id (OAI.Thomason.NormalizedChains.complex E) := by + ext p x + apply Subtype.ext + exact proof_map_id_79 x.val + have proof_map_comp_80 {E : Type 0} [instLocal1 : PartialOrder.{0} E] {D : Type 0} [instLocal3 : PartialOrder.{0} D] {B : Type 0} [instLocal5 : PartialOrder.{0} B] (f : E →o D) (g : D →o B) (c : OAI.Thomason.NormalizedChains.Chains E) : + OAI.Thomason.NormalizedChains.map (g.comp f) c = OAI.Thomason.NormalizedChains.map g (OAI.Thomason.NormalizedChains.map f c) := by + classical + induction c using Finsupp.induction with + | zero => simp + | @single_add l z c _ _ ih => + simp only [map_add, ih] + congr 1 + have hz : Finsupp.single l z = z • OAI.Thomason.NormalizedChains.bracket l.val := by + rw [proof_bracket_of_pairwise_75 l.property] + simp only [Finsupp.smul_single, smul_eq_mul, mul_one] + have hl := l.property.imp fun h => le_of_lt h + rw [hz] + simp only [map_smul] + rw [proof_map_bracket_78 _ hl, proof_map_bracket_78 _ hl, + proof_map_bracket_78 _ (List.pairwise_map.mpr (hl.imp fun hh => f.monotone hh))] + simp [List.map_map] + have proof_complexMap_comp_74 {E : Type 0} [instLocal1 : PartialOrder.{0} E] {D : Type 0} [PartialOrder D] {B : Type 0} [PartialOrder B] + (f : E →o D) (g : D →o B) : OAI.Thomason.NormalizedChains.complexMap (g.comp f) = + OAI.Thomason.DirectedComplex.Hom.comp (OAI.Thomason.NormalizedChains.complexMap f) (OAI.Thomason.NormalizedChains.complexMap g) := by + ext p x + apply Subtype.ext + exact proof_map_comp_80 f g x.val + exact { + obj m := OAI.Thomason.NormalizedChains.complex (Fin (m.len+1)) + map f := OAI.Thomason.NormalizedChains.complexMap f.toOrderHom + map_id _ := proof_complexMap_id_73 + map_comp f g := proof_complexMap_comp_74 f.toOrderHom g.toOrderHom + } + + +end OAI.Thomason.NormalizedChains +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def orientals : SimplexCategory ⥤ OAI.Thomason.OmegaCategory.{0} := + OAI.Thomason.NormalizedChains.simplexComplexes ⋙ OAI.Thomason.DirectedComplex.nuFunctor + + +end OAI.Thomason +end + +section +namespace OAI.Thomason.OmegaCategory + + +noncomputable def ulift (C : OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.{max u v} where + Cell := ULift.{v} C.Cell + source k x := ⟨C.source k x.down⟩ + target k x := ⟨C.target k x.down⟩ + source_source i j x := congrArg ULift.up (C.source_source i j x.down) + target_target i j x := congrArg ULift.up (C.target_target i j x.down) + source_target i j x := by + simpa only [apply_ite] using congrArg (ULift.up (α := C.Cell)) (C.source_target i j x.down) + target_source i j x := by + simpa only [apply_ite] using congrArg (ULift.up (α := C.Cell)) (C.target_source i j x.down) + comp k x y h := ⟨C.comp k x.down y.down (congrArg ULift.down h)⟩ + source_comp_le i k hik x y h := + congrArg ULift.up (C.source_comp_le i k hik x.down y.down (congrArg ULift.down h)) + target_comp_le i k hik x y h := + congrArg ULift.up (C.target_comp_le i k hik x.down y.down (congrArg ULift.down h)) + source_comp_gt i k hki x y h hs := + congrArg ULift.up (C.source_comp_gt i k hki x.down y.down + (congrArg ULift.down h) (congrArg ULift.down hs)) + target_comp_gt i k hki x y h ht := + congrArg ULift.up (C.target_comp_gt i k hki x.down y.down + (congrArg ULift.down h) (congrArg ULift.down ht)) + unit_left k x h := congrArg ULift.up (C.unit_left k x.down (congrArg ULift.down h)) + unit_right k x h := congrArg ULift.up (C.unit_right k x.down (congrArg ULift.down h)) + assoc k x y z hxy hyz hxy_z hx_yz := + congrArg ULift.up (C.assoc k x.down y.down z.down + (congrArg ULift.down hxy) (congrArg ULift.down hyz) + (congrArg ULift.down hxy_z) (congrArg ULift.down hx_yz)) + interchange k l hkl a b c d hab hcd hac hbd h₁ h₂ := + congrArg ULift.up (C.interchange k l hkl a.down b.down c.down d.down + (congrArg ULift.down hab) (congrArg ULift.down hcd) + (congrArg ULift.down hac) (congrArg ULift.down hbd) + (congrArg ULift.down h₁) (congrArg ULift.down h₂)) + finite_dimension x := by + obtain ⟨k, hk⟩ := C.finite_dimension x.down + exact ⟨k, congrArg ULift.up hk⟩ + +noncomputable def uliftUp (C : OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.Functor C (OAI.Thomason.OmegaCategory.ulift.{u,v} C) where + map := ULift.up + map_source _ _ := rfl + map_target _ _ := rfl + map_comp _ _ _ _ _ := rfl + +noncomputable def uliftDown (C : OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.Functor (OAI.Thomason.OmegaCategory.ulift.{u,v} C) C where + map := ULift.down + map_source _ _ := rfl + map_target _ _ := rfl + map_comp _ _ _ _ _ := rfl + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory +open CategoryTheory + +noncomputable def uliftFunctor : OAI.Thomason.OmegaCategory.{u} ⥤ OAI.Thomason.OmegaCategory.{max u v} where + obj := OAI.Thomason.OmegaCategory.ulift + map {C D} F := OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.uliftDown C) F) (OAI.Thomason.OmegaCategory.uliftUp D) + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def raisedOrientals : SimplexCategory ⥤ OAI.Thomason.OmegaCategory.{u} := + OAI.Thomason.orientals ⋙ OAI.Thomason.OmegaCategory.uliftFunctor.{0,u} + + +end OAI.Thomason +end + +section +namespace OAI.Thomason.OmegaCategory + + +structure Presentation where + Generator : Type u + dimension : Generator → ℕ + relations : (C : OAI.Thomason.OmegaCategory.{u}) → (Generator → C.Cell) → Prop + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory.Presentation +variable (P : Presentation.{u}) + +structure Interpretation (C : OAI.Thomason.OmegaCategory.{u}) where + map : P.Generator → C.Cell + bounded : ∀ g, C.source (P.dimension g) (map g) = map g + satisfies : P.relations C map + + +end OAI.Thomason.OmegaCategory.Presentation +end + +section +namespace OAI.Thomason.OmegaCategory + + +inductive CellTerm (G : Type u) where + | gen : G → CellTerm G + | source : ℕ → CellTerm G → CellTerm G + | target : ℕ → CellTerm G → CellTerm G + | comp : ℕ → CellTerm G → CellTerm G → CellTerm G + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory.CellTerm + + +noncomputable def composeOrLeft (C : OAI.Thomason.OmegaCategory.{v}) (k : ℕ) (x y : C.Cell) : C.Cell := by + classical + exact if h : C.target k x = C.source k y then C.comp k x y h else x + +noncomputable def eval {G : Type u} (C : OAI.Thomason.OmegaCategory.{v}) (f : G → C.Cell) : OAI.Thomason.OmegaCategory.CellTerm G → C.Cell + | gen g => f g + | source k x => C.source k (eval C f x) + | target k x => C.target k (eval C f x) + | comp k x y => OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft C k (eval C f x) (eval C f y) + + +end OAI.Thomason.OmegaCategory.CellTerm +end + +section +namespace OAI.Thomason.OmegaCategory.Presentation +variable (P : Presentation.{u}) + +noncomputable def Equiv (x y : OAI.Thomason.OmegaCategory.CellTerm P.Generator) : Prop := + ∀ (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C), x.eval C I.map = y.eval C I.map + +inductive Valid : OAI.Thomason.OmegaCategory.CellTerm P.Generator → Prop + | gen (g) : Valid (.gen g) + | source (k x) : Valid x → Valid (.source k x) + | target (k x) : Valid x → Valid (.target k x) + | comp (k x y) : Valid x → Valid y → P.Equiv (.target k x) (.source k y) → Valid (.comp k x y) + +noncomputable abbrev ValidTerm := {x : OAI.Thomason.OmegaCategory.CellTerm P.Generator // P.Valid x} + +noncomputable instance termSetoid : Setoid P.ValidTerm := by + classical + have proof_refl_81 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} (x : OAI.Thomason.OmegaCategory.CellTerm P.Generator) : P.Equiv x x := fun _ _ => rfl + have proof_symm_82 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (h : P.Equiv x y) : P.Equiv y x := fun C I => (h C I).symm + have proof_trans_83 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {z : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (h : P.Equiv x y) (h' : P.Equiv y z) : P.Equiv x z := + fun C I => (h C I).trans (h' C I) + exact { + r x y := P.Equiv x.val y.val + iseqv := ⟨fun _ => proof_refl_81 _, fun h => (proof_symm_82 h), fun h h' => (proof_trans_83 h h')⟩ + } + +noncomputable abbrev Cells := Quotient P.termSetoid + +noncomputable def evaluate (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) : P.Cells → C.Cell := + Quotient.lift (fun x : P.ValidTerm => x.val.eval C I.map) (fun _ _ h => h C I) + + +end OAI.Thomason.OmegaCategory.Presentation +end + +section +namespace OAI.Thomason.OmegaCategory.CellTerm + + +noncomputable def dimension {G : Type u} (d : G → ℕ) : OAI.Thomason.OmegaCategory.CellTerm G → ℕ + | gen g => d g + | source k _ => k + | target k _ => k + | comp k x y => max (k+1) (max (dimension d x) (dimension d y)) + + +end OAI.Thomason.OmegaCategory.CellTerm +end + +section +namespace OAI.Thomason.OmegaCategory.Presentation +variable (P : Presentation.{u}) + +noncomputable def sourceTerm (k : ℕ) (x : P.ValidTerm) : P.ValidTerm := ⟨.source k x.val, OAI.Thomason.OmegaCategory.Presentation.Valid.source (P := P) k x.val x.property⟩ + +noncomputable def source (k : ℕ) : P.Cells → P.Cells := by + classical + have proof_source_84 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (k : ℕ) (h : P.Equiv x y) : P.Equiv (.source k x) (.source k y) := + fun C I => congrArg (C.source k) (h C I) + exact + Quotient.map (P.sourceTerm k) (fun _ _ h => (proof_source_84 k h)) + +noncomputable def targetTerm (k : ℕ) (x : P.ValidTerm) : P.ValidTerm := ⟨.target k x.val, OAI.Thomason.OmegaCategory.Presentation.Valid.target (P := P) k x.val x.property⟩ + +noncomputable def target (k : ℕ) : P.Cells → P.Cells := by + classical + have proof_target_85 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (k : ℕ) (h : P.Equiv x y) : P.Equiv (.target k x) (.target k y) := + fun C I => congrArg (C.target k) (h C I) + exact + Quotient.map (P.targetTerm k) (fun _ _ h => (proof_target_85 k h)) + +noncomputable def compTerm (k : ℕ) (x y : P.ValidTerm) : P.ValidTerm := by + classical + exact if h : P.Equiv (.target k x.val) (.source k y.val) then + ⟨.comp k x.val y.val, OAI.Thomason.OmegaCategory.Presentation.Valid.comp (P := P) k x.val y.val x.property y.property h⟩ else x + +noncomputable def comp (k : ℕ) (x y : P.Cells) (_ : P.target k x = P.source k y) : P.Cells := by + classical + have proof_trans_83 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {z : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (h : P.Equiv x y) (h' : P.Equiv y z) : P.Equiv x z := + fun C I => (h C I).trans (h' C I) + have proof_symm_82 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (h : P.Equiv x y) : P.Equiv y x := fun C I => (h C I).symm + have proof_target_85 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (k : ℕ) (h : P.Equiv x y) : P.Equiv (.target k x) (.target k y) := + fun C I => congrArg (C.target k) (h C I) + have proof_source_84 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (k : ℕ) (h : P.Equiv x y) : P.Equiv (.source k x) (.source k y) := + fun C I => congrArg (C.source k) (h C I) + have proof_composable_congr_87 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {x' : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y' : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (k : ℕ) (hx : P.Equiv x x') (hy : P.Equiv y y') : + P.Equiv (.target k x) (.source k y) ↔ P.Equiv (.target k x') (.source k y') := + ⟨fun h => (proof_trans_83 + (proof_symm_82 (proof_target_85 k hx)) + (proof_trans_83 h (proof_source_84 k hy))), + fun h => (proof_trans_83 (proof_target_85 k hx) + (proof_trans_83 h + (proof_symm_82 (proof_source_84 k hy))))⟩ + have proof_comp_88 {P : OAI.Thomason.OmegaCategory.Presentation.{u}} {x : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {x' : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} {y' : OAI.Thomason.OmegaCategory.CellTerm.{u} (OAI.Thomason.OmegaCategory.Presentation.Generator.{u} P)} (k : ℕ) (hx : P.Equiv x x') (hy : P.Equiv y y') : + P.Equiv (.comp k x y) (.comp k x' y') := by + intro C I + exact congrArg₂ (OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft C k) (hx C I) (hy C I) + have proof_compTerm_equiv_86 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (k : ℕ) {x y x' y' : P.ValidTerm} + (hx : P.Equiv x.val x'.val) (hy : P.Equiv y.val y'.val) : + P.Equiv (P.compTerm k x y).val (P.compTerm k x' y').val := by + classical + have he := proof_composable_congr_87 k hx hy + by_cases h : P.Equiv (.target k x.val) (.source k y.val) + · simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left h, dite_eq_left (he.mp h)] + exact proof_comp_88 k hx hy + · simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_right h, dite_eq_right (mt he.mpr h)] + exact hx + exact + Quotient.map₂ (P.compTerm k) (fun _ _ hx _ _ hy => (proof_compTerm_equiv_86 P k hx hy)) x y + +noncomputable abbrev category : OAI.Thomason.OmegaCategory.{u} := by + classical + have proof_cells_ext_89 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {x y : P.Cells} + (h : ∀ (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C), P.evaluate C I x = P.evaluate C I y) : x = y := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + exact Quotient.sound h + have proof_evaluate_source_90 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.source k x) = C.source k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_target_91 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.target k x) = C.target k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_composable_94 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + C.target k (P.evaluate C I x) = C.source k (P.evaluate C I y) := by + rw [← proof_evaluate_target_91, ← proof_evaluate_source_90, h] + have proof_evaluate_comp_92 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + P.evaluate C I (P.comp k x y h) = + C.comp k (P.evaluate C I x) (P.evaluate C I y) (proof_evaluate_composable_94 P C I k x y h) := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + have hm : P.Equiv (.target k x.val) (.source k y.val) := Quotient.exact h + change (P.compTerm k x y).val.eval C I.map = _ + have hm' : C.target k (x.val.eval C I.map) = C.source k (y.val.eval C I.map) := hm C I + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left hm, OAI.Thomason.OmegaCategory.CellTerm.eval, OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft, dite_eq_left hm'] + rfl + have proof_source_source_self_95 (C : OAI.Thomason.OmegaCategory.{u}) (k : ℕ) (x : C.Cell) : + C.source k (C.source k x) = C.source k x := by + simp [C.source_source] + have proof_source_target_self_96 (C : OAI.Thomason.OmegaCategory.{u}) (k : ℕ) (x : C.Cell) : + C.source k (C.target k x) = C.target k x := by + simp [C.source_target] + have proof_source_composable_97 (C : OAI.Thomason.OmegaCategory.{u}) {k i : ℕ} (hki : k < i) {x y : C.Cell} + (h : C.target k x = C.source k y) : + C.target k (C.source i x) = C.source k (C.source i y) := by + rw [C.target_source, ite_eq_left hki, C.source_source, min_eq_left (le_of_lt hki)] + exact h + have proof_source_fixed_upwards_98 (C : OAI.Thomason.OmegaCategory.{u}) {i j : ℕ} (hij : i ≤ j) {x : C.Cell} + (h : C.source i x = x) : C.source j x = x := by + rw [← h, C.source_source, min_eq_right hij] + have proof_eval_dimension_93 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {x : OAI.Thomason.OmegaCategory.CellTerm P.Generator} (hx : P.Valid x) + (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) : + C.source (x.dimension P.dimension) (x.eval C I.map) = x.eval C I.map := by + induction hx with + | gen g => exact I.bounded g + | source k x hx ih => exact (proof_source_source_self_95 C k + (OAI.Thomason.OmegaCategory.CellTerm.eval C (OAI.Thomason.OmegaCategory.Presentation.Interpretation.map I) x)) + | target k x hx ih => exact (proof_source_target_self_96 C k + (OAI.Thomason.OmegaCategory.CellTerm.eval C (OAI.Thomason.OmegaCategory.Presentation.Interpretation.map I) x)) + | comp k x y hx hy h ihx ihy => + have hm := h C I + change C.target k (x.eval C I.map) = C.source k (y.eval C I.map) at hm + simp only [OAI.Thomason.OmegaCategory.CellTerm.dimension, OAI.Thomason.OmegaCategory.CellTerm.eval, OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft, dite_eq_left hm] + have hkn : k < max (k+1) (max (x.dimension P.dimension) (y.dimension P.dimension)) := by omega + rw [C.source_comp_gt _ k hkn _ _ hm (proof_source_composable_97 C hkn hm)] + congr 1 + · exact (proof_source_fixed_upwards_98 C (by omega) ihx) + · exact (proof_source_fixed_upwards_98 C (by omega) ihy) + exact { + Cell := P.Cells + source := P.source + target := P.target + comp := P.comp + source_source i j x := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_source_90, C.source_source] + target_target i j x := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_target_91, C.target_target] + source_target i j x := by + apply (proof_cells_ext_89 P) + intro C I + by_cases hij : i < j <;> simp [proof_evaluate_source_90, proof_evaluate_target_91, hij, C.source_target] + target_source i j x := by + apply (proof_cells_ext_89 P) + intro C I + by_cases hij : i < j <;> simp [proof_evaluate_source_90, proof_evaluate_target_91, hij, C.target_source] + source_comp_le i k hik x y h := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_source_90, proof_evaluate_comp_92] + exact C.source_comp_le i k hik _ _ _ + target_comp_le i k hik x y h := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_target_91, proof_evaluate_comp_92] + exact C.target_comp_le i k hik _ _ _ + source_comp_gt i k hki x y h hs := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_source_90, proof_evaluate_comp_92] + exact C.source_comp_gt i k hki _ _ _ _ + target_comp_gt i k hki x y h hs := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_target_91, proof_evaluate_comp_92] + exact C.target_comp_gt i k hki _ _ _ _ + unit_left k x h := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_source_90, proof_evaluate_comp_92] + exact C.unit_left k _ _ + unit_right k x h := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_target_91, proof_evaluate_comp_92] + exact C.unit_right k _ _ + assoc k x y z hxy hyz hxy_z hx_yz := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_comp_92] + exact C.assoc k _ _ _ _ _ _ _ + interchange k l hkl a b c d hab hcd hac hbd hab_cd hac_bd := by + apply (proof_cells_ext_89 P) + intro C I + simp only [proof_evaluate_comp_92] + exact C.interchange k l hkl _ _ _ _ _ _ _ _ _ _ + finite_dimension x := by + induction x using Quotient.inductionOn with | h x => + refine ⟨x.val.dimension P.dimension, ?_⟩ + apply (proof_cells_ext_89 P) + intro C I + exact (proof_eval_dimension_93 P (Subtype.property x) C I) + } + + +end OAI.Thomason.OmegaCategory.Presentation +end + +section +namespace OAI.Thomason.OmegaCategory +open CategoryTheory Limits +variable {J : Type u} [Category.{u} J] + +noncomputable abbrev colimitPresentation (F : J ⥤ OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.Presentation.{u} where + Generator := (j : J) × (F.obj j).Cell + dimension g := Classical.choose ((F.obj g.1).finite_dimension g.2) + relations C f := ∃ ι : ∀ j, OAI.Thomason.OmegaCategory.Functor (F.obj j) C, + (∀ j x, f ⟨j, x⟩ = (ι j).map x) ∧ + (∀ ⦃j j'⦄ (a : j ⟶ j'), OAI.Thomason.OmegaCategory.Functor.comp (F.map a) (ι j') = ι j) + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory.Presentation +variable (P : Presentation.{u}) + +noncomputable def generator (g : P.Generator) : P.Cells := Quotient.mk _ ⟨.gen g, .gen g⟩ + + +end OAI.Thomason.OmegaCategory.Presentation +end + +section +namespace OAI.Thomason.OmegaCategory +open CategoryTheory Limits +variable {J : Type u} [Category.{u} J] + +noncomputable def colimitInclusion (F : J ⥤ OAI.Thomason.OmegaCategory.{u}) (j : J) : + OAI.Thomason.OmegaCategory.Functor (F.obj j) (OAI.Thomason.OmegaCategory.colimitPresentation F).category := by + classical + have proof_cells_ext_89 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {x y : P.Cells} + (h : ∀ (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C), P.evaluate C I x = P.evaluate C I y) : x = y := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + exact Quotient.sound h + have proof_evaluate_source_90 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.source k x) = C.source k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_target_91 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.target k x) = C.target k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_composable_94 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + C.target k (P.evaluate C I x) = C.source k (P.evaluate C I y) := by + rw [← proof_evaluate_target_91, ← proof_evaluate_source_90, h] + have proof_evaluate_comp_92 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + P.evaluate C I (P.comp k x y h) = + C.comp k (P.evaluate C I x) (P.evaluate C I y) (proof_evaluate_composable_94 P C I k x y h) := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + have hm : P.Equiv (.target k x.val) (.source k y.val) := Quotient.exact h + change (P.compTerm k x y).val.eval C I.map = _ + have hm' : C.target k (x.val.eval C I.map) = C.source k (y.val.eval C I.map) := hm C I + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left hm, OAI.Thomason.OmegaCategory.CellTerm.eval, OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft, dite_eq_left hm'] + rfl + have proof_evaluate_generator_99 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) + (I : P.Interpretation C) (g : P.Generator) : P.evaluate C I (P.generator g) = I.map g := rfl + exact { + map x := (OAI.Thomason.OmegaCategory.colimitPresentation F).generator ⟨j, x⟩ + map_source k x := by + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.colimitPresentation F)) + intro C I + rcases I.satisfies with ⟨ι, hi, _⟩ + simp only [proof_evaluate_source_90, proof_evaluate_generator_99, hi] + exact (ι j).map_source k x + map_target k x := by + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.colimitPresentation F)) + intro C I + rcases I.satisfies with ⟨ι, hi, _⟩ + simp only [proof_evaluate_target_91, proof_evaluate_generator_99, hi] + exact (ι j).map_target k x + map_comp k x y h h' := by + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.colimitPresentation F)) + intro C I + rcases I.satisfies with ⟨ι, hi, _⟩ + simp only [proof_evaluate_comp_92, proof_evaluate_generator_99, hi] + exact (ι j).map_comp k x y h _ + } + +noncomputable def presentedCocone (F : J ⥤ OAI.Thomason.OmegaCategory.{u}) : Cocone F := by + classical + have proof_cells_ext_89 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {x y : P.Cells} + (h : ∀ (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C), P.evaluate C I x = P.evaluate C I y) : x = y := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + exact Quotient.sound h + exact { + pt := (OAI.Thomason.OmegaCategory.colimitPresentation F).category + ι := { + app := OAI.Thomason.OmegaCategory.colimitInclusion F + naturality := by + intro j j' a + apply OAI.Thomason.OmegaCategory.Functor.ext + funext x + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.colimitPresentation F)) + intro C I + rcases I.satisfies with ⟨ι, hi, hw⟩ + change I.map ⟨j', (F.map a).map x⟩ = I.map ⟨j, x⟩ + rw [hi, hi] + exact congrArg (fun h : OAI.Thomason.OmegaCategory.Functor (F.obj j) C => h.map x) (hw a) } + } + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory.Presentation +variable (P : Presentation.{u}) + +noncomputable def lift (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) : OAI.Thomason.OmegaCategory.Functor P.category C := by + classical + have proof_evaluate_source_90 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.source k x) = C.source k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_target_91 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.target k x) = C.target k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_composable_94 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + C.target k (P.evaluate C I x) = C.source k (P.evaluate C I y) := by + rw [← proof_evaluate_target_91, ← proof_evaluate_source_90, h] + have proof_evaluate_comp_92 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + P.evaluate C I (P.comp k x y h) = + C.comp k (P.evaluate C I x) (P.evaluate C I y) (proof_evaluate_composable_94 P C I k x y h) := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + have hm : P.Equiv (.target k x.val) (.source k y.val) := Quotient.exact h + change (P.compTerm k x y).val.eval C I.map = _ + have hm' : C.target k (x.val.eval C I.map) = C.source k (y.val.eval C I.map) := hm C I + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left hm, OAI.Thomason.OmegaCategory.CellTerm.eval, OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft, dite_eq_left hm'] + rfl + exact { + map := P.evaluate C I + map_source := (proof_evaluate_source_90 P C I) + map_target := (proof_evaluate_target_91 P C I) + map_comp k x y h _ := (proof_evaluate_comp_92 P C I k x y h) + } + + +end OAI.Thomason.OmegaCategory.Presentation +end + +section +namespace OAI.Thomason.OmegaCategory +open CategoryTheory Limits +variable {J : Type u} [Category.{u} J] + +noncomputable def colimitInterpretation (F : J ⥤ OAI.Thomason.OmegaCategory.{u}) (s : Cocone F) : + (OAI.Thomason.OmegaCategory.colimitPresentation F).Interpretation s.pt where + map g := (s.ι.app g.1).map g.2 + bounded g := by + exact ((s.ι.app g.1).map_source _ g.2).symm.trans + (congrArg (s.ι.app g.1).map (Classical.choose_spec ((F.obj g.1).finite_dimension g.2))) + satisfies := ⟨fun j => s.ι.app j, fun _ _ => rfl, fun {_ _} a => s.w a⟩ + +noncomputable def presentedCoconeIsColimit (F : J ⥤ OAI.Thomason.OmegaCategory.{u}) : + IsColimit (OAI.Thomason.OmegaCategory.presentedCocone F) := by + classical + have proof_mk_comp_101 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (k : ℕ) (x y : P.ValidTerm) + (h : P.Equiv (.target k x.val) (.source k y.val)) + (h' : P.target k (Quotient.mk _ x) = P.source k (Quotient.mk _ y)) : + P.comp k (Quotient.mk _ x) (Quotient.mk _ y) h' = + Quotient.mk _ ⟨.comp k x.val y.val, OAI.Thomason.OmegaCategory.Presentation.Valid.comp (P := P) k x.val y.val x.property y.property h⟩ := by + change Quotient.mk _ (P.compTerm k x y) = _ + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left h] + have proof_map_composable_102 {C : OAI.Thomason.OmegaCategory.{u}} {D : OAI.Thomason.OmegaCategory.{u}} (F : OAI.Thomason.OmegaCategory.Functor C D) {k : ℕ} {x y : C.Cell} + (h : C.target k x = C.source k y) : + D.target k (F.map x) = D.source k (F.map y) := by + rw [← F.map_target, ← F.map_source, h] + have proof_functor_ext_100 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {C : OAI.Thomason.OmegaCategory.{u}} {F G : OAI.Thomason.OmegaCategory.Functor P.category C} + (h : ∀ g, F.map (P.generator g) = G.map (P.generator g)) : F = G := by + apply OAI.Thomason.OmegaCategory.Functor.ext + funext x + induction x using Quotient.inductionOn with | h x => + rcases x with ⟨x, hx⟩ + induction hx with + | gen g => exact h g + | source k x hx ih => + change F.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_source, G.map_source, ih] + | target k x hx ih => + change F.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_target, G.map_target, ih] + | comp k x y hx hy hm ihx ihy => + have hc : P.category.target k (Quotient.mk _ ⟨x, hx⟩) = + P.category.source k (Quotient.mk _ ⟨y, hy⟩) := Quotient.sound hm + rw [← (proof_mk_comp_101 P k ⟨x, hx⟩ ⟨y, hy⟩ hm hc)] + change F.map (P.category.comp k _ _ hc) = G.map (P.category.comp k _ _ hc) + rw [F.map_comp k _ _ hc (proof_map_composable_102 F hc), G.map_comp k _ _ hc (proof_map_composable_102 G hc)] + congr 1 + exact { + desc s := (OAI.Thomason.OmegaCategory.colimitPresentation F).lift s.pt (OAI.Thomason.OmegaCategory.colimitInterpretation F s) + fac s j := by + apply OAI.Thomason.OmegaCategory.Functor.ext + funext x + rfl + uniq s m hm := by + apply (proof_functor_ext_100 (OAI.Thomason.OmegaCategory.colimitPresentation F)) + intro ⟨j, x⟩ + exact congrArg (fun f : OAI.Thomason.OmegaCategory.Functor (F.obj j) s.pt => f.map x) (hm j) + } + +noncomputable instance hasColimits : HasColimitsOfSize.{u,u} OAI.Thomason.OmegaCategory.{u} where + has_colimits_of_shape := fun _ _ => { has_colimit := fun F => ⟨⟨OAI.Thomason.OmegaCategory.presentedCocone F, OAI.Thomason.OmegaCategory.presentedCoconeIsColimit F⟩⟩ } + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable instance omegaHasSimplicialColimits : + Limits.HasColimitsOfSize.{0,u} OAI.Thomason.OmegaCategory.{u} := + Limits.hasColimitsOfSizeShrink.{0,u} OAI.Thomason.OmegaCategory.{u} + +noncomputable def categorification : SSet.{u} ⥤ OAI.Thomason.OmegaCategory.{u} := + (uliftYoneda.{u} : SimplexCategory ⥤ (SimplexCategoryᵒᵖ ⥤ Type u)).leftKanExtension OAI.Thomason.raisedOrientals.{u} + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonLeft : SSet.{u} ⥤ OAI.Thomason.OmegaCategory.{u} := + (SSet.sd ⋙ SSet.sd) ⋙ OAI.Thomason.categorification + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def streetNerve (C : OAI.Thomason.OmegaCategory.{u}) : SSet.{u} where + obj m := OAI.Thomason.OmegaCategory.Functor (OAI.Thomason.orientals.obj m.unop) C + map f := ↾fun x => OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.orientals.map f.unop) x + map_id m := by + apply ConcreteCategory.hom_ext + intro x + change OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.orientals.map (𝟙 m.unop)) x = x + rw [OAI.Thomason.orientals.map_id] + rfl + map_comp f g := by + apply ConcreteCategory.hom_ext + intro x + change OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.orientals.map (g.unop ≫ f.unop)) x = + OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.orientals.map g.unop) + (OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.orientals.map f.unop) x) + rw [OAI.Thomason.orientals.map_comp] + rfl + +noncomputable def streetNerveMap {C D : OAI.Thomason.OmegaCategory.{u}} (F : OAI.Thomason.OmegaCategory.Functor C D) : + OAI.Thomason.streetNerve C ⟶ OAI.Thomason.streetNerve D where + app _ := ↾fun x => OAI.Thomason.OmegaCategory.Functor.comp x F + naturality _ _ _ := rfl + +noncomputable def streetNerveFunctor : OAI.Thomason.OmegaCategory.{u} ⥤ SSet.{u} where + obj := OAI.Thomason.streetNerve + map := OAI.Thomason.streetNerveMap + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonRight : OAI.Thomason.OmegaCategory.{u} ⥤ SSet.{u} := + OAI.Thomason.streetNerveFunctor ⋙ (SSet.ex ⋙ SSet.ex) + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def streetYonedaEquiv (C : OAI.Thomason.OmegaCategory.{u}) (m : SimplexCategoryᵒᵖ) : + ((Presheaf.restrictedULiftYoneda.{0} OAI.Thomason.raisedOrientals).obj C).obj m ≃ + (OAI.Thomason.streetNerve C).obj m where + toFun F := OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.uliftUp _) F.down + invFun F := ULift.up (OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.uliftDown _) F) + left_inv _ := rfl + right_inv _ := rfl + +noncomputable def streetYonedaIso : Presheaf.restrictedULiftYoneda.{0} OAI.Thomason.raisedOrientals.{u} ≅ + OAI.Thomason.streetNerveFunctor.{u} := + NatIso.ofComponents (fun C => + NatIso.ofComponents (fun m => (OAI.Thomason.streetYonedaEquiv C m).toIso) (by intros; rfl)) + (by intros; rfl) + +noncomputable def categorificationAdjunction : OAI.Thomason.categorification.{u} ⊣ OAI.Thomason.streetNerveFunctor.{u} := + (Presheaf.uliftYonedaAdjunction.{0} + ((uliftYoneda.{u} : SimplexCategory ⥤ (SimplexCategoryᵒᵖ ⥤ Type u)).leftKanExtension OAI.Thomason.raisedOrientals.{u}) + ((uliftYoneda.{u} : SimplexCategory ⥤ (SimplexCategoryᵒᵖ ⥤ Type u)).leftKanExtensionUnit OAI.Thomason.raisedOrientals.{u})).ofNatIsoRight OAI.Thomason.streetYonedaIso + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonAdjunction : OAI.Thomason.thomasonLeft.{u} ⊣ OAI.Thomason.thomasonRight.{u} := + (SSet.sdExAdjunction.comp SSet.sdExAdjunction).comp OAI.Thomason.categorificationAdjunction + + +end OAI.Thomason +end + +section +namespace OAI.Thomason.OmegaCategory + + +noncomputable abbrev truncationPresentation (n : ℕ) (C : OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.Presentation.{u} where + Generator := C.Cell + dimension _ := n + relations D f := D.IsTruncated n ∧ ∃ F : OAI.Thomason.OmegaCategory.Functor C D, f = F.map + +noncomputable def truncationUnit (n : ℕ) (C : OAI.Thomason.OmegaCategory.{u}) : + OAI.Thomason.OmegaCategory.Functor C (OAI.Thomason.OmegaCategory.truncationPresentation n C).category := by + classical + have proof_cells_ext_89 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {x y : P.Cells} + (h : ∀ (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C), P.evaluate C I x = P.evaluate C I y) : x = y := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + exact Quotient.sound h + have proof_evaluate_source_90 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.source k x) = C.source k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_target_91 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.target k x) = C.target k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_evaluate_composable_94 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + C.target k (P.evaluate C I x) = C.source k (P.evaluate C I y) := by + rw [← proof_evaluate_target_91, ← proof_evaluate_source_90, h] + have proof_evaluate_comp_92 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) + (x y : P.Cells) (h : P.target k x = P.source k y) : + P.evaluate C I (P.comp k x y h) = + C.comp k (P.evaluate C I x) (P.evaluate C I y) (proof_evaluate_composable_94 P C I k x y h) := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + have hm : P.Equiv (.target k x.val) (.source k y.val) := Quotient.exact h + change (P.compTerm k x y).val.eval C I.map = _ + have hm' : C.target k (x.val.eval C I.map) = C.source k (y.val.eval C I.map) := hm C I + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left hm, OAI.Thomason.OmegaCategory.CellTerm.eval, OAI.Thomason.OmegaCategory.CellTerm.composeOrLeft, dite_eq_left hm'] + rfl + have proof_evaluate_generator_99 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) + (I : P.Interpretation C) (g : P.Generator) : P.evaluate C I (P.generator g) = I.map g := rfl + exact { + map := (OAI.Thomason.OmegaCategory.truncationPresentation n C).generator + map_source k x := by + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro D I + rcases I.satisfies with ⟨_, F, hF⟩ + simp only [proof_evaluate_source_90, proof_evaluate_generator_99, hF] + exact F.map_source k x + map_target k x := by + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro D I + rcases I.satisfies with ⟨_, F, hF⟩ + simp only [proof_evaluate_target_91, proof_evaluate_generator_99, hF] + exact F.map_target k x + map_comp k x y h h' := by + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro D I + rcases I.satisfies with ⟨_, F, hF⟩ + simp only [proof_evaluate_comp_92, proof_evaluate_generator_99, hF] + exact F.map_comp k x y h _ + } + +noncomputable def truncation (n : ℕ) (C : OAI.Thomason.OmegaCategory.{u}) : OAI.Thomason.OmegaCategory.NCategory.{u} n := by + classical + have proof_cells_ext_89 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {x y : P.Cells} + (h : ∀ (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C), P.evaluate C I x = P.evaluate C I y) : x = y := by + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + exact Quotient.sound h + have proof_evaluate_source_90 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (C : OAI.Thomason.OmegaCategory.{u}) (I : P.Interpretation C) (k : ℕ) (x : P.Cells) : + P.evaluate C I (P.source k x) = C.source k (P.evaluate C I x) := by + induction x using Quotient.inductionOn + rfl + have proof_truncation_isTruncated_103 (n : ℕ) (C : OAI.Thomason.OmegaCategory.{u}) : + (OAI.Thomason.OmegaCategory.truncationPresentation n C).category.IsTruncated n := by + intro x + apply (proof_cells_ext_89 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro D I + rw [proof_evaluate_source_90] + exact I.satisfies.1 _ + exact + ⟨(OAI.Thomason.OmegaCategory.truncationPresentation n C).category, proof_truncation_isTruncated_103 n C⟩ + +noncomputable def truncationLift {n : ℕ} {C : OAI.Thomason.OmegaCategory.{u}} (D : OAI.Thomason.OmegaCategory.NCategory.{u} n) + (F : OAI.Thomason.OmegaCategory.Functor C D.val) : OAI.Thomason.OmegaCategory.Functor (OAI.Thomason.OmegaCategory.truncation n C).val D.val := + (OAI.Thomason.OmegaCategory.truncationPresentation n C).lift D.val { + map := F.map + bounded := fun x => D.property (F.map x) + satisfies := ⟨D.property, F, rfl⟩ } + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason.OmegaCategory +open CategoryTheory + +noncomputable def truncationFunctor (n : ℕ) : OAI.Thomason.OmegaCategory.{u} ⥤ OAI.Thomason.OmegaCategory.NCategory.{u} n := by + classical + have proof_mk_comp_101 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (k : ℕ) (x y : P.ValidTerm) + (h : P.Equiv (.target k x.val) (.source k y.val)) + (h' : P.target k (Quotient.mk _ x) = P.source k (Quotient.mk _ y)) : + P.comp k (Quotient.mk _ x) (Quotient.mk _ y) h' = + Quotient.mk _ ⟨.comp k x.val y.val, OAI.Thomason.OmegaCategory.Presentation.Valid.comp (P := P) k x.val y.val x.property y.property h⟩ := by + change Quotient.mk _ (P.compTerm k x y) = _ + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left h] + have proof_map_composable_102 {C : OAI.Thomason.OmegaCategory.{u}} {D : OAI.Thomason.OmegaCategory.{u}} (F : OAI.Thomason.OmegaCategory.Functor C D) {k : ℕ} {x y : C.Cell} + (h : C.target k x = C.source k y) : + D.target k (F.map x) = D.source k (F.map y) := by + rw [← F.map_target, ← F.map_source, h] + have proof_functor_ext_100 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {C : OAI.Thomason.OmegaCategory.{u}} {F G : OAI.Thomason.OmegaCategory.Functor P.category C} + (h : ∀ g, F.map (P.generator g) = G.map (P.generator g)) : F = G := by + apply OAI.Thomason.OmegaCategory.Functor.ext + funext x + induction x using Quotient.inductionOn with | h x => + rcases x with ⟨x, hx⟩ + induction hx with + | gen g => exact h g + | source k x hx ih => + change F.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_source, G.map_source, ih] + | target k x hx ih => + change F.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_target, G.map_target, ih] + | comp k x y hx hy hm ihx ihy => + have hc : P.category.target k (Quotient.mk _ ⟨x, hx⟩) = + P.category.source k (Quotient.mk _ ⟨y, hy⟩) := Quotient.sound hm + rw [← (proof_mk_comp_101 P k ⟨x, hx⟩ ⟨y, hy⟩ hm hc)] + change F.map (P.category.comp k _ _ hc) = G.map (P.category.comp k _ _ hc) + rw [F.map_comp k _ _ hc (proof_map_composable_102 F hc), G.map_comp k _ _ hc (proof_map_composable_102 G hc)] + congr 1 + have proof_truncation_functor_ext_104 {n : ℕ} {C D : OAI.Thomason.OmegaCategory.{u}} + {F G : OAI.Thomason.OmegaCategory.Functor (OAI.Thomason.OmegaCategory.truncation n C).val D} + (h : OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) F = OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) G) : F = G := by + apply (proof_functor_ext_100 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro x + exact congrArg (fun H : OAI.Thomason.OmegaCategory.Functor C D => H.map x) h + exact { + obj := OAI.Thomason.OmegaCategory.truncation n + map {C D} F := OAI.Thomason.OmegaCategory.truncationLift (OAI.Thomason.OmegaCategory.truncation n D) (OAI.Thomason.OmegaCategory.Functor.comp F (OAI.Thomason.OmegaCategory.truncationUnit n D)) + map_id C := by + apply proof_truncation_functor_ext_104 + rfl + map_comp F G := by + apply proof_truncation_functor_ext_104 + rfl + } + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def categorificationFinite (n : ℕ) : SSet.{u} ⥤ OAI.Thomason.OmegaCategory.NCategory.{u} n := + OAI.Thomason.categorification ⋙ OAI.Thomason.OmegaCategory.truncationFunctor n + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonLeftFinite (n : ℕ) : SSet.{u} ⥤ OAI.Thomason.OmegaCategory.NCategory.{u} n := + (SSet.sd ⋙ SSet.sd) ⋙ OAI.Thomason.categorificationFinite n + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def streetNerveFinite (n : ℕ) : OAI.Thomason.OmegaCategory.NCategory.{u} n ⥤ SSet.{u} where + obj C := OAI.Thomason.streetNerve C.val + map := OAI.Thomason.streetNerveMap + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonRightFinite (n : ℕ) : OAI.Thomason.OmegaCategory.NCategory.{u} n ⥤ SSet.{u} := + OAI.Thomason.streetNerveFinite n ⋙ (SSet.ex ⋙ SSet.ex) + + +end OAI.Thomason +end + +section +namespace OAI.Thomason.OmegaCategory +open CategoryTheory + +noncomputable def nCategoryInclusion (n : ℕ) : OAI.Thomason.OmegaCategory.NCategory.{u} n ⥤ OAI.Thomason.OmegaCategory.{u} where + obj C := C.val + map F := F + +noncomputable def truncationHomEquiv (n : ℕ) (C : OAI.Thomason.OmegaCategory.{u}) (D : OAI.Thomason.OmegaCategory.NCategory.{u} n) : + ((OAI.Thomason.OmegaCategory.truncationFunctor n).obj C ⟶ D) ≃ (C ⟶ (OAI.Thomason.OmegaCategory.nCategoryInclusion n).obj D) := by + classical + have proof_mk_comp_101 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (k : ℕ) (x y : P.ValidTerm) + (h : P.Equiv (.target k x.val) (.source k y.val)) + (h' : P.target k (Quotient.mk _ x) = P.source k (Quotient.mk _ y)) : + P.comp k (Quotient.mk _ x) (Quotient.mk _ y) h' = + Quotient.mk _ ⟨.comp k x.val y.val, OAI.Thomason.OmegaCategory.Presentation.Valid.comp (P := P) k x.val y.val x.property y.property h⟩ := by + change Quotient.mk _ (P.compTerm k x y) = _ + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left h] + have proof_map_composable_102 {C : OAI.Thomason.OmegaCategory.{u}} {D : OAI.Thomason.OmegaCategory.{u}} (F : OAI.Thomason.OmegaCategory.Functor C D) {k : ℕ} {x y : C.Cell} + (h : C.target k x = C.source k y) : + D.target k (F.map x) = D.source k (F.map y) := by + rw [← F.map_target, ← F.map_source, h] + have proof_functor_ext_100 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {C : OAI.Thomason.OmegaCategory.{u}} {F G : OAI.Thomason.OmegaCategory.Functor P.category C} + (h : ∀ g, F.map (P.generator g) = G.map (P.generator g)) : F = G := by + apply OAI.Thomason.OmegaCategory.Functor.ext + funext x + induction x using Quotient.inductionOn with | h x => + rcases x with ⟨x, hx⟩ + induction hx with + | gen g => exact h g + | source k x hx ih => + change F.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_source, G.map_source, ih] + | target k x hx ih => + change F.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_target, G.map_target, ih] + | comp k x y hx hy hm ihx ihy => + have hc : P.category.target k (Quotient.mk _ ⟨x, hx⟩) = + P.category.source k (Quotient.mk _ ⟨y, hy⟩) := Quotient.sound hm + rw [← (proof_mk_comp_101 P k ⟨x, hx⟩ ⟨y, hy⟩ hm hc)] + change F.map (P.category.comp k _ _ hc) = G.map (P.category.comp k _ _ hc) + rw [F.map_comp k _ _ hc (proof_map_composable_102 F hc), G.map_comp k _ _ hc (proof_map_composable_102 G hc)] + congr 1 + have proof_truncation_functor_ext_104 {n : ℕ} {C D : OAI.Thomason.OmegaCategory.{u}} + {F G : OAI.Thomason.OmegaCategory.Functor (OAI.Thomason.OmegaCategory.truncation n C).val D} + (h : OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) F = OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) G) : F = G := by + apply (proof_functor_ext_100 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro x + exact congrArg (fun H : OAI.Thomason.OmegaCategory.Functor C D => H.map x) h + exact { + toFun F := OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) F + invFun := OAI.Thomason.OmegaCategory.truncationLift D + left_inv F := by + apply proof_truncation_functor_ext_104 + rfl + right_inv _ := rfl + } + +noncomputable def truncationAdjunction (n : ℕ) : OAI.Thomason.OmegaCategory.truncationFunctor.{u} n ⊣ OAI.Thomason.OmegaCategory.nCategoryInclusion n := by + classical + have proof_mk_comp_101 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) (k : ℕ) (x y : P.ValidTerm) + (h : P.Equiv (.target k x.val) (.source k y.val)) + (h' : P.target k (Quotient.mk _ x) = P.source k (Quotient.mk _ y)) : + P.comp k (Quotient.mk _ x) (Quotient.mk _ y) h' = + Quotient.mk _ ⟨.comp k x.val y.val, OAI.Thomason.OmegaCategory.Presentation.Valid.comp (P := P) k x.val y.val x.property y.property h⟩ := by + change Quotient.mk _ (P.compTerm k x y) = _ + simp only [OAI.Thomason.OmegaCategory.Presentation.compTerm, dite_eq_left h] + have proof_map_composable_102 {C : OAI.Thomason.OmegaCategory.{u}} {D : OAI.Thomason.OmegaCategory.{u}} (F : OAI.Thomason.OmegaCategory.Functor C D) {k : ℕ} {x y : C.Cell} + (h : C.target k x = C.source k y) : + D.target k (F.map x) = D.source k (F.map y) := by + rw [← F.map_target, ← F.map_source, h] + have proof_functor_ext_100 (P : OAI.Thomason.OmegaCategory.Presentation.{u}) {C : OAI.Thomason.OmegaCategory.{u}} {F G : OAI.Thomason.OmegaCategory.Functor P.category C} + (h : ∀ g, F.map (P.generator g) = G.map (P.generator g)) : F = G := by + apply OAI.Thomason.OmegaCategory.Functor.ext + funext x + induction x using Quotient.inductionOn with | h x => + rcases x with ⟨x, hx⟩ + induction hx with + | gen g => exact h g + | source k x hx ih => + change F.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.source k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_source, G.map_source, ih] + | target k x hx ih => + change F.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) = + G.map (P.category.target k (Quotient.mk _ ⟨x, hx⟩)) + rw [F.map_target, G.map_target, ih] + | comp k x y hx hy hm ihx ihy => + have hc : P.category.target k (Quotient.mk _ ⟨x, hx⟩) = + P.category.source k (Quotient.mk _ ⟨y, hy⟩) := Quotient.sound hm + rw [← (proof_mk_comp_101 P k ⟨x, hx⟩ ⟨y, hy⟩ hm hc)] + change F.map (P.category.comp k _ _ hc) = G.map (P.category.comp k _ _ hc) + rw [F.map_comp k _ _ hc (proof_map_composable_102 F hc), G.map_comp k _ _ hc (proof_map_composable_102 G hc)] + congr 1 + have proof_truncation_functor_ext_104 {n : ℕ} {C D : OAI.Thomason.OmegaCategory.{u}} + {F G : OAI.Thomason.OmegaCategory.Functor (OAI.Thomason.OmegaCategory.truncation n C).val D} + (h : OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) F = OAI.Thomason.OmegaCategory.Functor.comp (OAI.Thomason.OmegaCategory.truncationUnit n C) G) : F = G := by + apply (proof_functor_ext_100 (OAI.Thomason.OmegaCategory.truncationPresentation n C)) + intro x + exact congrArg (fun H : OAI.Thomason.OmegaCategory.Functor C D => H.map x) h + exact + Adjunction.mkOfHomEquiv { + homEquiv := OAI.Thomason.OmegaCategory.truncationHomEquiv n + homEquiv_naturality_left_symm := by + intro C' C D F G + apply proof_truncation_functor_ext_104 + rfl + homEquiv_naturality_right := by + intro C D D' F G + rfl } + + +end OAI.Thomason.OmegaCategory +end + +section +namespace OAI.Thomason +open CategoryTheory Opposite + +noncomputable def categorificationFiniteAdjunction (n : ℕ) : + OAI.Thomason.categorificationFinite.{u} n ⊣ OAI.Thomason.streetNerveFinite.{u} n := + OAI.Thomason.categorificationAdjunction.comp (OAI.Thomason.OmegaCategory.truncationAdjunction n) + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonFiniteAdjunction (n : ℕ) : + OAI.Thomason.thomasonLeftFinite.{u} n ⊣ OAI.Thomason.thomasonRightFinite.{u} n := + (SSet.sdExAdjunction.comp SSet.sdExAdjunction).comp (OAI.Thomason.categorificationFiniteAdjunction n) + + +end OAI.Thomason +end + +section +namespace OAI.Thomason.WeakHomotopy +open scoped Topology Topology.Homotopy +variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] + +noncomputable def loopMap (N : Type w) (f : C(X, Y)) (x : X) : GenLoop N X x → GenLoop N Y (f x) := + fun p => ⟨f.comp p.val, fun y hy => congrArg f (p.property y hy)⟩ + +noncomputable def groupMap (N : Type w) (f : C(X, Y)) (x : X) : + HomotopyGroup N X x → HomotopyGroup N Y (f x) := by + classical + have proof_loopMap_homotopic_105 {X : Type u} {Y : Type v} [instLocal2 : TopologicalSpace.{u} X] [instLocal3 : TopologicalSpace.{v} Y] (N : Type w) (f : C(X, Y)) (x : X) + {p q : GenLoop N X x} (h : GenLoop.Homotopic p q) : + GenLoop.Homotopic (OAI.Thomason.WeakHomotopy.loopMap N f x p) (OAI.Thomason.WeakHomotopy.loopMap N f x q) := + h.comp_continuousMap f + exact + Quotient.map (OAI.Thomason.WeakHomotopy.loopMap N f x) (fun _ _ h => proof_loopMap_homotopic_105 N f x h) + +noncomputable def componentsMap (f : C(X, Y)) : ZerothHomotopy X → ZerothHomotopy Y := + ZerothHomotopy.lift (fun x => ZerothHomotopy.mk (f x)) + (fun _ _ p => ZerothHomotopy.sound (p.map f.continuous)) + +noncomputable def Equivalence (f : C(X, Y)) : Prop := + Function.Bijective (OAI.Thomason.WeakHomotopy.componentsMap f) ∧ + ∀ (n : ℕ) (x : X), Function.Bijective (OAI.Thomason.WeakHomotopy.groupMap (Fin (n+1)) f x) + + +end OAI.Thomason.WeakHomotopy +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def simplicialWeakEquivalences : MorphismProperty SSet.{u} := + fun _ _ f => OAI.Thomason.WeakHomotopy.Equivalence (SSet.toTop.map f).hom + +noncomputable def simplicialFibrations : MorphismProperty SSet.{u} := (SSet.modelCategoryQuillen.J).rlp + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory Limits HomotopicalAlgebra + +structure KanQuillenModel where + model : ModelCategory SSet.{u} + weak_eq : model.categoryWithWeakEquivalences.weakEquivalences = OAI.Thomason.simplicialWeakEquivalences + fib_eq : model.categoryWithFibrations.fibrations = OAI.Thomason.simplicialFibrations + cof_eq : model.categoryWithCofibrations.cofibrations = MorphismProperty.monomorphisms SSet + +noncomputable def LeftProperFor {C : Type v} [Category.{u} C] + (W Cof : MorphismProperty C) : Prop := + ∀ {A B X Y : C} (i : A ⟶ B) (f : A ⟶ X) (g : B ⟶ Y) (j : X ⟶ Y), + IsPushout i f g j → Cof i → W f → W g + +noncomputable def RightProperFor {C : Type v} [Category.{u} C] + (W Fib : MorphismProperty C) : Prop := + ∀ {A B X Y : C} (f : A ⟶ B) (g : A ⟶ X) (p : B ⟶ Y) (q : X ⟶ Y), + IsPullback f g p q → Fib q → W p → W g + +noncomputable def FibrantFor {C : Type v} [Category.{u} C] (Fib : MorphismProperty C) (Y : C) : Prop := + ∃ (T : C) (_ : IsTerminal T) (p : Y ⟶ T), Fib p + +noncomputable def boundaryImages {C : Type v} [Category.{u} C] (L : SSet.{u} ⥤ C) : MorphismProperty C := + .ofHoms (fun n : ℕ => L.map (SSet.boundary n).ι) + +noncomputable def hornImages {C : Type v} [Category.{u} C] (L : SSet.{u} ⥤ C) : MorphismProperty C := + ⨆ n : ℕ, .ofHoms (fun i : Fin (n+2) => L.map (SSet.horn (n+1) i).ι) + +structure ExactModelEndpoint {C : Type v} [Category.{u} C] + (L : SSet.{u} ⥤ C) (R : C ⥤ SSet.{u}) (adj : L ⊣ R) where + model : ModelCategory C + weak_eq : model.categoryWithWeakEquivalences.weakEquivalences = + OAI.Thomason.simplicialWeakEquivalences.inverseImage R + fib_eq : model.categoryWithFibrations.fibrations = OAI.Thomason.simplicialFibrations.inverseImage R + cof_eq : model.categoryWithCofibrations.cofibrations = + ((OAI.Thomason.simplicialFibrations.inverseImage R) ⊓ (OAI.Thomason.simplicialWeakEquivalences.inverseImage R)).llp + generating_cofibrations : (OAI.Thomason.boundaryImages L).rlp = + model.categoryWithFibrations.fibrations ⊓ model.categoryWithWeakEquivalences.weakEquivalences + generating_trivial_cofibrations : (OAI.Thomason.hornImages L).rlp = model.categoryWithFibrations.fibrations + weak_factorization_one : MorphismProperty.IsWeakFactorizationSystem + (model.categoryWithCofibrations.cofibrations ⊓ model.categoryWithWeakEquivalences.weakEquivalences) + model.categoryWithFibrations.fibrations + weak_factorization_two : MorphismProperty.IsWeakFactorizationSystem + model.categoryWithCofibrations.cofibrations + (model.categoryWithFibrations.fibrations ⊓ model.categoryWithWeakEquivalences.weakEquivalences) + complete : HasLimitsOfSize.{u,u} C + cocomplete : HasColimitsOfSize.{u,u} C + locallyPresentable : IsLocallyPresentable.{u} C + leftProper : OAI.Thomason.LeftProperFor model.categoryWithWeakEquivalences.weakEquivalences + model.categoryWithCofibrations.cofibrations + rightProper : OAI.Thomason.RightProperFor model.categoryWithWeakEquivalences.weakEquivalences + model.categoryWithFibrations.fibrations + leftQuillen : ∀ {K K' : SSet.{u}} (f : K ⟶ K'), Mono f → + model.categoryWithCofibrations.cofibrations (L.map f) ∧ + (OAI.Thomason.simplicialWeakEquivalences f → model.categoryWithWeakEquivalences.weakEquivalences (L.map f)) + quillenEquivalence : ∀ (K : SSet.{u}) (Y : C), + OAI.Thomason.FibrantFor model.categoryWithFibrations.fibrations Y → + ∀ f : L.obj K ⟶ Y, + model.categoryWithWeakEquivalences.weakEquivalences f ↔ + OAI.Thomason.simplicialWeakEquivalences (adj.homEquiv K Y f) + +noncomputable def FullMain : Prop := + Nonempty OAI.Thomason.KanQuillenModel.{u} ∧ + Nonempty (OAI.Thomason.ExactModelEndpoint OAI.Thomason.thomasonLeft.{u} OAI.Thomason.thomasonRight OAI.Thomason.thomasonAdjunction) ∧ + ∀ n : ℕ, 1 ≤ n → + Nonempty (OAI.Thomason.ExactModelEndpoint (OAI.Thomason.thomasonLeftFinite.{u} n) (OAI.Thomason.thomasonRightFinite n) + (OAI.Thomason.thomasonFiniteAdjunction n)) + + +end OAI.Thomason +end + +section +namespace OAI.Thomason +open CategoryTheory + +noncomputable def thomasonWeakEquivalences : MorphismProperty OAI.Thomason.OmegaCategory.{u} := + OAI.Thomason.simplicialWeakEquivalences.inverseImage OAI.Thomason.thomasonRight + +noncomputable def thomasonWeakEquivalencesFinite (n : ℕ) : + MorphismProperty (OAI.Thomason.OmegaCategory.NCategory.{u} n) := + OAI.Thomason.simplicialWeakEquivalences.inverseImage (OAI.Thomason.thomasonRightFinite n) + + +end OAI.Thomason +end + +section +namespace OAI + + +theorem Thomason.main : OAI.Thomason.FullMain.{u} := by + sorry + +theorem Thomason.nerveDetection_allDimensions : + OAI.Thomason.thomasonWeakEquivalences.{u} = + OAI.Thomason.simplicialWeakEquivalences.inverseImage OAI.Thomason.streetNerveFunctor ∧ + ∀ n : ℕ, OAI.Thomason.thomasonWeakEquivalencesFinite.{u} n = + OAI.Thomason.simplicialWeakEquivalences.inverseImage (OAI.Thomason.streetNerveFinite n) := by + sorry + +end OAI +end + +end diff --git a/lean/ComparatorChallenges/ThompsonNonamenability.json b/lean/ComparatorChallenges/ThompsonNonamenability.json new file mode 100644 index 0000000000000000000000000000000000000000..97cbe571f91d4afb329c4006dbc493974e5696e1 --- /dev/null +++ b/lean/ComparatorChallenges/ThompsonNonamenability.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThompsonNonamenability", + "solution_module": "OAI.GroupTheory.Thompson.Main", + "theorem_names": [ + "OAI.ThompsonNonamenability.thompson_F_nonamenable_composition" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThompsonNonamenability.lean b/lean/ComparatorChallenges/ThompsonNonamenability.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a364bdc7a964d0ae8665a0f97517e878c9109f6 --- /dev/null +++ b/lean/ComparatorChallenges/ThompsonNonamenability.lean @@ -0,0 +1,89 @@ +import Mathlib.Topology.Homeomorph.Lemmas +import Mathlib.Topology.Instances.Real.Lemmas +import Mathlib.Analysis.Normed.Lp.lpSpace +import Mathlib.Analysis.Normed.Operator.Basic + +namespace OAI + +noncomputable section + +open scoped ENNReal + +universe uG + +namespace ThompsonNonamenability + +abbrev UnitInterval := Set.Icc (0 : ℝ) 1 + +def unitIntervalZero : UnitInterval := ⟨0, le_rfl, zero_le_one⟩ +def unitIntervalOne : UnitInterval := ⟨1, zero_le_one, le_rfl⟩ + +structure IntervalHomeomorph where + toHomeomorph : UnitInterval ≃ₜ UnitInterval + +namespace IntervalHomeomorph + +instance : CoeFun IntervalHomeomorph (fun _ => UnitInterval → UnitInterval) := + ⟨fun f => f.toHomeomorph⟩ + +end IntervalHomeomorph + +def IsDyadic (x : ℝ) : Prop := + ∃ (k : ℤ) (n : ℕ), x = (k : ℝ) / (2 : ℝ) ^ n + +structure DyadicPLWitness (f : IntervalHomeomorph) where + pieceCount : ℕ + positive : 0 < pieceCount + knots : Fin (pieceCount + 1) → UnitInterval + strictMono_knots : StrictMono knots + first : knots 0 = unitIntervalZero + last : knots (Fin.last pieceCount) = unitIntervalOne + dyadic : ∀ i, IsDyadic (knots i : ℝ) + cover : ∀ x : UnitInterval, ∃ i : Fin pieceCount, + knots i.castSucc ≤ x ∧ x ≤ knots i.succ + exponent : Fin pieceCount → ℤ + affine : ∀ (i : Fin pieceCount) (x : UnitInterval), + knots i.castSucc ≤ x → x ≤ knots i.succ → + (f x : ℝ) = (f (knots i.castSucc) : ℝ) + + (2 : ℝ) ^ exponent i * ((x : ℝ) - (knots i.castSucc : ℝ)) + +def HasDyadicPLPieces (f : IntervalHomeomorph) : Prop := Nonempty (DyadicPLWitness f) + +def F := {f : IntervalHomeomorph // StrictMono f ∧ HasDyadicPLPieces f} + +abbrev BoundedReal (G : Type uG) := lp (fun _ : G => ℝ) ∞ + +variable {G : Type uG} [Group G] + +def leftPull (h : G) : BoundedReal G →ₗ[ℝ] BoundedReal G where + toFun f := ⟨fun g => f (h * g), memℓp_infty ⟨‖f‖, by + rintro y ⟨g, rfl⟩ + exact lp.norm_apply_le_norm ENNReal.top_ne_zero f (h * g)⟩⟩ + map_add' f g := by + apply lp.ext + funext x + rfl + map_smul' r f := by + apply lp.ext + funext x + rfl + +structure InvariantMean (G : Type uG) [Group G] where + toLinearMap : BoundedReal G →ₗ[ℝ] ℝ + positive : ∀ f : BoundedReal G, (∀ g, 0 ≤ f g) → 0 ≤ toLinearMap f + normalized : toLinearMap 1 = 1 + left_invariant : ∀ (h : G) (f : BoundedReal G), + toLinearMap (leftPull h f) = toLinearMap f + +theorem thompson_F_nonamenable_composition : + ∃ group : Group F, letI := group; + (∀ (h g : F) (x : UnitInterval), + (h * g).val.toHomeomorph x = h.val.toHomeomorph (g.val.toHomeomorph x)) ∧ + ¬ Nonempty (InvariantMean F) := by + sorry + +end ThompsonNonamenability + +end + +end OAI diff --git a/lean/ComparatorChallenges/ThorpFirstReciprocal.json b/lean/ComparatorChallenges/ThorpFirstReciprocal.json new file mode 100644 index 0000000000000000000000000000000000000000..5d5173313846359c1d59f1e7ec8526b81893c909 --- /dev/null +++ b/lean/ComparatorChallenges/ThorpFirstReciprocal.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThorpFirstReciprocal", + "solution_module": "OAI.Probability.ThorpShuffle.FirstMain", + "theorem_names": [ + "OAI.Thorp.Current.first_reciprocal_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThorpFirstReciprocal.lean b/lean/ComparatorChallenges/ThorpFirstReciprocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4fa8c4ecf08f945b9eb90ef36207c5b357ab8ff --- /dev/null +++ b/lean/ComparatorChallenges/ThorpFirstReciprocal.lean @@ -0,0 +1,233 @@ +import Mathlib + +namespace OAI + +noncomputable section + +universe uG uV uE uX uH uI uβ uα + +open scoped BigOperators Classical ComplexConjugate InnerProductSpace +open Filter Topology + +namespace Thorp + +abbrev Position (d : ℕ) := Fin d → Bool + +namespace Block + +variable {I : Type uI} {β : Type uβ} {α : Type uα} + +def perm (p : I → Equiv.Perm β) : Equiv.Perm (I × β) where + toFun x := (x.1, p x.1 x.2) + invFun x := (x.1, (p x.1)⁻¹ x.2) + left_inv x := by simp + right_inv x := by simp + +def hom : (I → Equiv.Perm β) →* Equiv.Perm (I × β) where + toFun := perm + map_one' := by ext ⟨i,b⟩ <;> rfl + map_mul' p q := by ext ⟨i,b⟩ <;> rfl + +def embedding (e : α ≃ I × β) : (I → Equiv.Perm β) →* Equiv.Perm α := + (e.symm.permCongrHom).toMonoidHom.comp hom + +end Block + +namespace Fourier + +variable {G : Type uG} [Group G] [Fintype G] +variable {V : Type uV} [AddCommGroup V] [Module ℂ V] + +def integrated (ρ : Representation ℂ G V) (f : G → ℂ) : Module.End ℂ V := + ∑ g, f g • ρ g + +end Fourier + +namespace Young + +abbrev Cells (D : YoungDiagram) := {p : ℕ × ℕ // p ∈ D.cells} + +def rowCellsEquiv (D : YoungDiagram) : Cells D ≃ (i : Fin (D.colLen 0)) × Fin (D.rowLen i) where + toFun x := ⟨⟨x.val.1, YoungDiagram.mem_iff_lt_colLen.mp (D.up_left_mem le_rfl (Nat.zero_le _) x.property)⟩, + ⟨x.val.2, YoungDiagram.mem_iff_lt_rowLen.mp x.property⟩⟩ + invFun x := ⟨(x.1, x.2), YoungDiagram.mem_iff_lt_rowLen.mpr x.2.isLt⟩ + left_inv x := rfl + right_inv x := by cases x; rfl + +def ofPartition {n : ℕ} (p : Nat.Partition n) : YoungDiagram := + YoungDiagram.ofRowLens (p.parts.sort (· ≥ ·)) (Multiset.pairwise_sort _ _).sortedGE + +def longest (D : YoungDiagram) : ℕ := max (D.rowLen 0) (D.colLen 0) + +end Young + +namespace Specht + +variable {G : Type uG} [Group G] +variable {E : Type uE} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + +def cyclic (ρ : Representation ℂ G E) (e : E) : Subrepresentation ρ where + toSubmodule := Submodule.span ℂ (Set.range fun g => ρ g e) + apply_mem_toSubmodule g := by + intro v hv + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨h, rfl⟩ := hv + exact Submodule.subset_span ⟨g * h, by simp⟩ + | zero => simp + | add x y hx hy ihx ihy => + simpa using (Submodule.span ℂ (Set.range fun h => ρ h e)).add_mem ihx ihy + | smul a x hx ih => + simpa using (Submodule.span ℂ (Set.range fun h => ρ h e)).smul_mem a ih + +namespace PermutationSpace + +variable {X : Type uX} [Fintype X] [MulAction G X] + +def rep : Representation ℂ G (EuclideanSpace ℂ X) where + toFun g := { + toFun v := WithLp.toLp 2 (fun x => v (g⁻¹ • x)) + map_add' := by intro v w; rfl + map_smul' := by intro a v; rfl } + map_one' := by ext v x; simp + map_mul' := by + intro g h + ext v x + change v ((g * h)⁻¹ • x) = v (h⁻¹ • g⁻¹ • x) + simp [mul_smul] + +variable {H : Type uH} [Group H] [Fintype H] + +def alternator (ι : H →* G) (χ : H →* ℂ) : Module.End ℂ (EuclideanSpace ℂ X) := + ∑ h, χ h • rep (ι h) + +end PermutationSpace + +variable {α : Type uα} [Fintype α] + +def Tabloid (r : α → ℕ) := {f : α → ℕ // ∃ g : Equiv.Perm α, f = r ∘ g} + +instance tabloidFinite (r : α → ℕ) : Finite (Tabloid r) := by + apply Finite.of_surjective (fun g : Equiv.Perm α => (⟨r ∘ g, g, rfl⟩ : Tabloid r)) + rintro ⟨f, g, rfl⟩ + exact ⟨g, rfl⟩ + +instance tabloidFintype (r : α → ℕ) : Fintype (Tabloid r) := Fintype.ofFinite _ + +instance tabloidAction (r : α → ℕ) : MulAction (Equiv.Perm α) (Tabloid r) where + smul g f := ⟨f.val ∘ ⇑(g⁻¹ : Equiv.Perm α), by + obtain ⟨h, hh⟩ := f.property + refine ⟨h * g⁻¹, ?_⟩ + funext x + simp only [Function.comp_apply, hh, Equiv.Perm.mul_apply]⟩ + one_smul f := by apply Subtype.ext; funext x; rfl + mul_smul g h f := by + apply Subtype.ext + funext x + change f.val ((g * h)⁻¹ x) = f.val (h⁻¹ (g⁻¹ x)) + rw [mul_inv_rev, Equiv.Perm.mul_apply] + +def baseTabloid (r : α → ℕ) : Tabloid r := ⟨r, 1, by funext x; rfl⟩ + +def fiberGroup (c : α → ℕ) : Subgroup (Equiv.Perm α) where + carrier := {g | ∀ x, c (g x) = c x} + one_mem' := by intro x; rfl + mul_mem' := by intro g h hg hh x; exact (hg (h x)).trans (hh x) + inv_mem' := by + intro g hg x + have hh := hg (g⁻¹ x) + change c (g (g.symm x)) = c (g.symm x) at hh + rw [g.apply_symm_apply] at hh + exact hh.symm + +def complexSign : Equiv.Perm α →* ℂ where + toFun g := ((Equiv.Perm.sign g : ℤˣ) : ℤ) + map_one' := by simp + map_mul' := by intro g h; simp + +variable (D : YoungDiagram) (t : α ≃ Thorp.Young.Cells D) + +def tableauRow (x : α) : ℕ := (t x).val.1 + +def tableauCol (x : α) : ℕ := (t x).val.2 + +def tabloidRep : Representation ℂ (Equiv.Perm α) (EuclideanSpace ℂ (Tabloid (tableauRow D t))) := + PermutationSpace.rep + +def columnAlternator : Module.End ℂ (EuclideanSpace ℂ (Tabloid (tableauRow D t))) := + PermutationSpace.alternator (fiberGroup (tableauCol D t)).subtype + (complexSign.comp (fiberGroup (tableauCol D t)).subtype) + +def polytabloid : EuclideanSpace ℂ (Tabloid (tableauRow D t)) := + columnAlternator D t (EuclideanSpace.single (baseTabloid (tableauRow D t)) (1 : ℂ)) + +def module : Subrepresentation (tabloidRep D t) := cyclic (tabloidRep D t) (polytabloid D t) + +abbrev Shape (α : Type uα) [Fintype α] := Nat.Partition (Fintype.card α) + +def canonicalTableau (p : Shape α) : α ≃ Thorp.Young.Cells (Thorp.Young.ofPartition p) := by + have card_cells_eq_sum (D : YoungDiagram) : Fintype.card (Thorp.Young.Cells D) = D.rowLens.sum := by + rw [Fintype.card_congr (Thorp.Young.rowCellsEquiv D), Fintype.card_sigma] + simp only [Fintype.card_fin, YoungDiagram.rowLens] + rw [← List.sum_toFinset _ List.nodup_range, List.toFinset_range, Finset.sum_range] + have rowLens_ofPartition {n : ℕ} (p : Nat.Partition n) : + (Thorp.Young.ofPartition p).rowLens = p.parts.sort (· ≥ ·) := by + apply YoungDiagram.rowLens_ofRowLens_eq_self + intro x hx + exact p.parts_pos ((Multiset.mem_sort _).mp hx) + have card_ofPartition {n : ℕ} (p : Nat.Partition n) : Fintype.card (Thorp.Young.Cells (Thorp.Young.ofPartition p)) = n := by + rw [card_cells_eq_sum, rowLens_ofPartition] + simpa only [← Multiset.sum_coe, Multiset.sort_eq] using p.parts_sum + exact Fintype.equivOfCardEq (card_ofPartition p).symm + +abbrev Space (p : Shape α) := (module (Thorp.Young.ofPartition p) (canonicalTableau p)).toSubmodule + +def degree (p : Shape α) : ℕ := Module.finrank ℂ (Space p) + +open Thorp.Young + +abbrev NShape (n : ℕ) := Shape (Fin n) + +def defect {n : ℕ} (p : NShape n) : ℕ := n - longest (ofPartition p) + +end Specht + +namespace Current + +def reciprocalFirst (n : ℕ) : ℝ := + ∑ p : Specht.NShape n, (Specht.degree p : ℝ)⁻¹ + +def exceptionalFirst (n : ℕ) : ℝ := + ∑ p : Specht.NShape n, if 0 < Specht.defect p then (Specht.degree p : ℝ)⁻¹ else 0 + +def C1 : ℝ := sSup (Set.range (fun n : {n : ℕ // 1 ≤ n} => reciprocalFirst n.val)) + +theorem first_reciprocal_main : + (BddAbove (Set.range (fun n : {n : ℕ // 1 ≤ n} => reciprocalFirst n.val)) ∧ + (∀ n : ℕ, 1 ≤ n → reciprocalFirst n ≤ C1) ∧ + Tendsto exceptionalFirst atTop (nhds 0)) ∧ + (∀ (d : ℕ) (_hd : 3 ≤ d) + (e : Position d ≃ Fin 8 × Fin (2 ^ (d - 3))) + {E : Type uE} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [FiniteDimensional ℂ E] + (ρ : Representation ℂ (Equiv.Perm (Position d)) E) + [Representation.IsIrreducible ρ] + (_ : ∀ g x y, ⟪ρ g x, ρ g y⟫_ℂ = ⟪x, y⟫_ℂ) + (ν : Equiv.Perm (Position d) → ℝ) + (_ : ∀ g, 0 ≤ ν g) (_ : ∑ g, ν g = 1) + (_ : ∀ (i : Fin 8) (g : Equiv.Perm (Position d)), + ∑ h : Equiv.Perm (Fin (2 ^ (d - 3))), + ν (g * Block.embedding e (Pi.mulSingle i h)) ≤ + 4 * (Fintype.card (Equiv.Perm (Fin (2 ^ (d - 3)))) : ℝ) / + Fintype.card (Equiv.Perm (Position d))), + ‖LinearMap.toContinuousLinearMap (Fourier.integrated ρ (fun g => (ν g : ℂ)))‖ ≤ + Real.sqrt (32 * C1) * (Module.finrank ℂ E : ℝ) ^ (-5 / 16 : ℝ)) := by + sorry + +end Current + +end Thorp + +end + +end OAI diff --git a/lean/ComparatorChallenges/ThorpRemaining.json b/lean/ComparatorChallenges/ThorpRemaining.json new file mode 100644 index 0000000000000000000000000000000000000000..a534616c5bce54866a396706b83e07a2ec52a5ce --- /dev/null +++ b/lean/ComparatorChallenges/ThorpRemaining.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThorpRemaining", + "solution_module": "OAI.Probability.ThorpResults.FullDevelopment", + "theorem_names": [ + "OAI.ThorpResults.remaining_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThorpRemaining.lean b/lean/ComparatorChallenges/ThorpRemaining.lean new file mode 100644 index 0000000000000000000000000000000000000000..2dcc131fab907ff7d2b56a76e7852b54b2247f47 --- /dev/null +++ b/lean/ComparatorChallenges/ThorpRemaining.lean @@ -0,0 +1,550 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section +open scoped BigOperators +open Filter + +namespace Thorp + +abbrev Position (d : ℕ) := Fin d → Bool +abbrev State (d : ℕ) := Equiv.Perm (Position d) + +def Coins : ℕ → Type + | 0 => Unit + | d + 1 => Position d → Bool + +instance coinsFintype (d : ℕ) : Fintype (Coins d) := by + cases d <;> simp only [Coins] <;> infer_instance + +instance coinsInhabited (d : ℕ) : Inhabited (Coins d) := by + cases d <;> simp only [Coins] <;> infer_instance + +def pairSwitch (d : ℕ) (c : Position d → Bool) : Equiv.Perm (Bool × Position d) where + toFun p := (p.1 ^^ c p.2, p.2) + invFun p := (p.1 ^^ c p.2, p.2) + left_inv p := by + rcases p with ⟨b, s⟩ + cases b <;> cases h : c s <;> simp [h] + right_inv p := by + rcases p with ⟨b, s⟩ + cases b <;> cases h : c s <;> simp [h] + +def rotate (d : ℕ) : State d := + Equiv.piCongrLeft (fun _ : Fin d => Bool) (finRotate d).symm + +def step : (d : ℕ) → Coins d → State d + | 0, _ => Equiv.refl _ + | d + 1, c => + (((Fin.consEquiv (fun _ : Fin (d + 1) => Bool)).symm.trans + (pairSwitch d c)).trans + (Fin.consEquiv (fun _ : Fin (d + 1) => Bool))).trans (rotate (d + 1)) + +abbrev History (d t : ℕ) := Fin t → Coins d + +def run (d t : ℕ) (ω : History d t) : State d := + ((List.ofFn fun i : Fin t => step d (ω i)).reverse).prod + +def fairMass {Ω : Type u} {α : Type v} [Fintype Ω] (f : Ω → α) (a : α) : ℝ := by + classical + exact (∑ ω : Ω, if f ω = a then (1 : ℝ) else 0) / Fintype.card Ω + +def law (d t : ℕ) : State d → ℝ := fairMass (run d t) + +def uniform (d : ℕ) (_ : State d) : ℝ := 1 / Fintype.card (State d) + +def tv {α : Type u} [Fintype α] (μ ν : α → ℝ) : ℝ := + (1 / 2 : ℝ) * ∑ a : α, |μ a - ν a| + +def distance (d t : ℕ) : ℝ := tv (law d t) (uniform d) + +def lawFrom (d t : ℕ) (g₀ : State d) : State d → ℝ := + fairMass (fun ω : History d t => run d t ω * g₀) + +abbrev LabelList (d k : ℕ) := Fin k ↪ Position d + +def coordinateRun (d t : ℕ) (ω : History d t) : State d := + (rotate d)⁻¹ ^ t * run d t ω + +def images {d k : ℕ} (t : ℕ) (start : State d) (labels : LabelList d k) + (ω : History d t) : LabelList d k := + labels.trans ((coordinateRun d t ω * start).toEmbedding) + +def listTV {d k : ℕ} (t : ℕ) (start : State d) (labels : LabelList d k) : ℝ := + tv (fairMass (images t start labels)) (fun _ => 1 / Fintype.card (LabelList d k)) + +def mixingTime (d : ℕ) : ℕ := sInf {t : ℕ | distance d t ≤ 1 / 4} + +end Thorp + +namespace ThorpNine.Harmonic + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +end Thorp + +namespace Thorp +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +open scoped BigOperators Classical +def Coins : ℕ → Type + | 0 => Unit + | d + 1 => Card d → Bool + +instance (d : ℕ) : Fintype (Coins d) := by + cases d <;> dsimp [Coins] <;> infer_instance + +instance (d : ℕ) : Nonempty (Coins d) := by + cases d <;> dsimp [Coins] <;> infer_instance + +def rotate (d : ℕ) : Equiv.Perm (Card d) where + toFun x i := x (finRotate d i) + invFun x i := x ((finRotate d).symm i) + left_inv x := by funext i; simp only [Equiv.apply_symm_apply] + right_inv x := by funext i; simp only [Equiv.symm_apply_apply] + +def step : (d : ℕ) → Coins d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, ξ => rotate (d + 1) * pairSwitch ξ + +def run (d : ℕ) : (t : ℕ) → (Fin t → Coins d) → Equiv.Perm (Card d) + | 0, _ => 1 + | t + 1, ω => step d (ω (Fin.last t)) * run d t (fun i => ω i.castSucc) + +noncomputable def law (d t : ℕ) (g : Equiv.Perm (Card d)) : ℝ := + (Fintype.card {ω : Fin t → Coins d // run d t ω = g} : ℝ) / + (Fintype.card (Fin t → Coins d) : ℝ) + +lemma card_positions (d : ℕ) : Fintype.card (Card d) = 2 ^ d := by + simp [Card] + +end Thorp +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.Specht +open scoped BigOperators Classical +@[simp] lemma card_cell (μ : YoungDiagram) : Fintype.card (Cell μ) = μ.card := by + simp [Cell, YoungDiagram.card] + +noncomputable def cellRowsEquiv (μ : YoungDiagram) : + Cell μ ≃ (i : Fin (μ.colLen 0)) × Fin (μ.rowLen i) where + toFun x := ⟨rowIndex x,⟨col x,YoungDiagram.mem_iff_lt_rowLen.mp x.2⟩⟩ + invFun p := ⟨(p.1,p.2),YoungDiagram.mem_iff_lt_rowLen.mpr p.2.2⟩ + left_inv x := by apply Subtype.ext; rfl + right_inv p := by rcases p with ⟨⟨i,hi⟩,⟨j,hj⟩⟩; rfl + +lemma card_eq_sum_rowLen (μ : YoungDiagram) : μ.card = ∑ i : Fin (μ.colLen 0), μ.rowLen i := by + rw [←card_cell,Fintype.card_congr (cellRowsEquiv μ),Fintype.card_sigma] + simp only [Fintype.card_fin] + +lemma sum_rowLens (μ : YoungDiagram) : μ.rowLens.sum = μ.card := by + rw [card_eq_sum_rowLen,YoungDiagram.rowLens] + rw [Fin.sum_univ_eq_sum_range] + have hh (n : ℕ) : (List.map μ.rowLen (List.range n)).sum = ∑ i ∈ Finset.range n, μ.rowLen i := by + induction n with + | zero => simp + | succ n ih => simp [List.range_succ,List.map_append,Finset.sum_range_succ,ih] + exact hh _ + +noncomputable def diagramPartition (μ : YoungDiagram) : Nat.Partition μ.card where + parts := μ.rowLens + parts_pos := fun {i} hi => μ.pos_of_mem_rowLens i (by simpa using hi) + parts_sum := by simp + +noncomputable def partitionDiagram {N : ℕ} (p : Nat.Partition N) : YoungDiagram := + YoungDiagram.ofRowLens (p.parts.sort (· ≥ ·)) (Multiset.pairwise_sort _ _).sortedGE + +lemma partitionDiagram_rowLens {N : ℕ} (p : Nat.Partition N) : + (partitionDiagram p).rowLens = p.parts.sort (· ≥ ·) := by + apply YoungDiagram.rowLens_ofRowLens_eq_self + intro x hx + exact p.parts_pos ((Multiset.mem_sort _).mp hx) + +lemma partitionDiagram_card {N : ℕ} (p : Nat.Partition N) : (partitionDiagram p).card = N := by + rw [←sum_rowLens,partitionDiagram_rowLens] + change (↑(p.parts.sort (· ≥ ·)) : Multiset ℕ).sum = N + rw [Multiset.sort_eq,p.parts_sum] + +lemma partitionDiagram_diagramPartition (μ : YoungDiagram) : + partitionDiagram (diagramPartition μ) = μ := by + apply YoungDiagram.equivListRowLens.injective + apply Subtype.ext + change (partitionDiagram (diagramPartition μ)).rowLens = μ.rowLens + rw [partitionDiagram_rowLens] + change (↑μ.rowLens : Multiset ℕ).sort (· ≥ ·) = μ.rowLens + rw [Multiset.coe_sort,List.mergeSort_eq_self _ μ.rowLens_sorted.pairwise] + +abbrev Shapes (N : ℕ) := {μ : YoungDiagram // μ.card = N} + +noncomputable def shapePartitionEquiv (N : ℕ) : Shapes N ≃ Nat.Partition N where + toFun μ := { parts := μ.1.rowLens + parts_pos := fun {i} hi => μ.1.pos_of_mem_rowLens i (by simpa using hi) + parts_sum := by simpa using (sum_rowLens μ.1).trans μ.2 } + invFun p := ⟨partitionDiagram p,partitionDiagram_card p⟩ + left_inv μ := by + apply Subtype.ext + obtain ⟨μ,rfl⟩ := μ + exact partitionDiagram_diagramPartition μ + right_inv p := by + apply Nat.Partition.ext + change ((partitionDiagram p).rowLens : Multiset ℕ) = p.parts + rw [partitionDiagram_rowLens,Multiset.sort_eq] + +noncomputable instance (N : ℕ) : Fintype (Shapes N) := Fintype.ofEquiv _ (shapePartitionEquiv N).symm + +noncomputable def labels {N : ℕ} (μ : Shapes N) : Cell μ.1 ≃ Fin N := + (Fintype.equivFin (Cell μ.1)).trans (finCongr ((card_cell μ.1).trans μ.2)) + +noncomputable def cardLabels (d : ℕ) (μ : Shapes (2^d)) : Card d ≃ Cell μ.1 := + ((Fintype.equivFin (Card d)).trans (finCongr (card_positions d))).trans (labels μ).symm + +noncomputable def cardRepresentation (d : ℕ) (μ : Shapes (2^d)) : + Representation ℂ (Equiv.Perm (Card d)) (hilbertSpace μ.1) := + relabelledUnitary μ.1 (cardLabels d μ) + +end Thorp.Specht +namespace Thorp.LowPlanes +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +open scoped BigOperators Classical +open Specht UnitaryFinite + +noncomputable local instance hsNorm (μ : YoungDiagram) : NormedAddCommGroup (hilbertSpace μ) := inferInstance +noncomputable local instance hsInner (μ : YoungDiagram) : InnerProductSpace ℂ (hilbertSpace μ) := inferInstance +noncomputable local instance hsFinite (μ : YoungDiagram) : FiniteDimensional ℂ (hilbertSpace μ) := inferInstance + +noncomputable def Q (d : ℕ) (μ : Shapes (2^d)) : + hilbertSpace μ.1 →L[ℂ] hilbertSpace μ.1 := + sampleOperator (V := hilbertSpace μ.1) (cardRepresentation d μ) (run d d) + +noncomputable def absoluteTrace {V : Type*} [NormedAddCommGroup V] + [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (A : V →L[ℂ] V) (P : ℝ) : ℝ := + (LinearMap.trace ℂ V (CFC.rpow (CFC.sqrt (star A * A)) P).toLinearMap).re + +noncomputable def regularTrace (d : ℕ) (P : ℝ) : ℝ := + ∑ μ : Shapes (2^d), (Module.finrank ℂ (hilbertSpace μ.1) : ℝ) * + absoluteTrace (V := hilbertSpace μ.1) (Q d μ) P + +noncomputable def sweepDistance (d v : ℕ) (σ : Equiv.Perm (Card d)) : ℝ := + (1/2:ℝ) * ∑ g : Equiv.Perm (Card d), + |law d (v*d) (g*σ⁻¹) - 1/(Nat.factorial (2^d):ℝ)| + +end Thorp.LowPlanes +end ThorpNine.Harmonic + +namespace ThorpNine.Harmonic.Thorp.LowPlanes +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +open scoped BigOperators +open Specht UnitaryFinite +attribute [local instance] hsNorm hsInner hsFinite +def weightedMoment (d r : ℕ) (μ : Shapes (2 ^ d)) : ℝ := + (Module.finrank ℂ (hilbertSpace μ.1) : ℝ) * + (LinearMap.trace ℂ (hilbertSpace μ.1) + ((star (Q d μ) * Q d μ) ^ r).toLinearMap).re + +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +def signedEntropy (α β : YoungDiagram) : ℝ := + (∑ x : Cell α, Real.log ((α.card + β.card : ℕ) / (α.rowLen (row x) : ℝ))) + + (∑ x : Cell β, Real.log ((α.card + β.card : ℕ) / (β.rowLen (row x) : ℝ))) + +def budgetCoefficient (a : ℝ) (d : ℕ) : ℝ := + a * (1 - 1 / (2 * Real.sqrt d)) + +def remainderBudget (κ : ℝ) (d l : ℕ) : ℝ := + if l = 0 then 0 else + max 0 (budgetCoefficient κ d * l * Real.log (2 ^ d : ℝ) - + l * Real.log ((2 ^ d : ℝ) / l)) + +def logWeightedMoment (d r : ℕ) (μ : Shapes (2 ^ d)) : EReal := + (ENNReal.ofReal (weightedMoment d r μ)).log + +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +def densityL2Squared (d t : ℕ) : ℝ := + (Nat.factorial (2 ^ d) : ℝ) * ∑ g : Equiv.Perm (Card d), + (law d t g - 1 / (Nat.factorial (2 ^ d) : ℝ)) ^ 2 + +def densityL2SquaredFrom (d t : ℕ) (σ : Equiv.Perm (Card d)) : ℝ := + (Nat.factorial (2 ^ d) : ℝ) * ∑ g : Equiv.Perm (Card d), + (law d t (g * σ⁻¹) - 1 / (Nat.factorial (2 ^ d) : ℝ)) ^ 2 + +end ThorpNine.Harmonic.Thorp.LowPlanes + +run_cmd Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + +namespace ThorpResults +open ThorpNine.Harmonic.Thorp +open ThorpNine.Harmonic.Thorp.Specht +open ThorpNine.Harmonic.Thorp.LowPlanes + +attribute [local instance] hsNorm hsInner hsFinite + +def FrameMain : Prop := + ∀ ε : ℝ, 0 < ε → ∀ᶠ d : ℕ in atTop, ∀ start : _root_.OAI.Thorp.State d, + _root_.OAI.Thorp.tv (_root_.OAI.Thorp.lawFrom d (32800 * d) start) (_root_.OAI.Thorp.uniform d) < ε + +def InformationMain : Prop := + (∀ ε : ℝ, 0 < ε → ∀ᶠ d : ℕ in atTop, + ∀ k : ℕ, 8 * k ≤ 7 * 2 ^ d → + ∀ (start : _root_.OAI.Thorp.State d) (labels : _root_.OAI.Thorp.LabelList d k), + _root_.OAI.Thorp.listTV (256 * d) start labels < ε) ∧ + (∀ᶠ d : ℕ in atTop, + ∀ k : ℕ, 16 * k ≤ 15 * 2 ^ d → + ∀ (start : _root_.OAI.Thorp.State d) (labels : _root_.OAI.Thorp.LabelList d k), + _root_.OAI.Thorp.listTV (1024 * d) start labels ≤ + Real.rpow ((2 : ℝ) ^ d) (-(3 : ℝ) / 2)) ∧ + (Tendsto (fun d : ℕ => _root_.OAI.Thorp.distance d (2048 * d)) atTop (nhds 0) ∧ + ∀ (d : ℕ) (start : _root_.OAI.Thorp.State d), + _root_.OAI.Thorp.tv (_root_.OAI.Thorp.lawFrom d (2048 * d) start) (_root_.OAI.Thorp.uniform d) = + _root_.OAI.Thorp.distance d (2048 * d)) + +def SpectrumMain : Prop := + ∃ p : ℝ, 0 < p ∧ ∀ d : ℕ, 1 ≤ d → + regularTrace d (2 * p) ≤ 1 + 1 / 16 ∧ + ∀ M : ℕ, p ≤ M → ∀ σ : Equiv.Perm (Card d), sweepDistance d M σ ≤ 1 / 8 + +def SignedMain : Prop := + ∀ η κ : ℝ, 0 < η → ∃ r : ℕ, 1 ≤ r ∧ ∀ d : ℕ, 1 ≤ d → + ∀ (μ : Shapes (2 ^ d)) (α β γ : YoungDiagram), + α.card + β.card + γ.card = 2 ^ d → + logWeightedMoment d r μ ≤ + ((budgetCoefficient η d * signedEntropy α β + + remainderBudget κ d γ.card : ℝ) : EReal) + +def DegreeSavingMain : Prop := + ∃ r : ℕ, Even r ∧ 2 ≤ r ∧ ∃ η : ℝ, 0 < η ∧ + ∀ d (μ : Shapes (2 ^ d)), + (Module.finrank ℂ (hilbertSpace μ.1) : ℝ) * + (LinearMap.trace ℂ (hilbertSpace μ.1) + ((Q d μ * star (Q d μ)) ^ r).toLinearMap).re ≤ + (Module.finrank ℂ (hilbertSpace μ.1) : ℝ) ^ (1 - η) + +def FullDensityMain : Prop := + ∃ v : ℕ, 1 ≤ v ∧ ∀ ε : ℝ, 0 < ε → ∀ᶠ d : ℕ in atTop, + ∀ σ : Equiv.Perm (Card d), densityL2SquaredFrom d (v * d) σ < ε + +def ForwardMixingMain : Prop := + ∃ v : ℕ, 1 ≤ v ∧ ∀ ε : ℝ, 0 < ε → ∀ᶠ d : ℕ in atTop, + ∀ σ : Equiv.Perm (Card d), sweepDistance d v σ < ε + +def OptimalOrderMain : Prop := + Asymptotics.IsTheta atTop (fun d : ℕ => (_root_.OAI.Thorp.mixingTime d : ℝ)) + (fun d : ℕ => Real.log (2 ^ d : ℝ)) + +end ThorpResults + +namespace ThorpResults +theorem remaining_main : + FrameMain ∧ InformationMain ∧ SpectrumMain ∧ SignedMain ∧ + DegreeSavingMain ∧ FullDensityMain ∧ ForwardMixingMain ∧ OptimalOrderMain := by + sorry +end ThorpResults +end + +end OAI diff --git a/lean/ComparatorChallenges/ThorpRouting.json b/lean/ComparatorChallenges/ThorpRouting.json new file mode 100644 index 0000000000000000000000000000000000000000..837ecb1a32bdf890e7464ace955ad8f41c70ae8b --- /dev/null +++ b/lean/ComparatorChallenges/ThorpRouting.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThorpRouting", + "solution_module": "OAI.Probability.ThorpRouting.Main", + "theorem_names": [ + "OAI.ThorpNine.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThorpRouting.lean b/lean/ComparatorChallenges/ThorpRouting.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2f66a0bb06de84438833f901acef28d156f23c5 --- /dev/null +++ b/lean/ComparatorChallenges/ThorpRouting.lean @@ -0,0 +1,2579 @@ +import Mathlib + +namespace OAI + +namespace ThorpNine.Adaptive + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.SparseContact +open scoped BigOperators + +noncomputable def sweepOperator (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (reverse : Bool) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) (Specht.relabelledUnitary μ e) + (fun ω : SwitchIndex d → Bool => if reverse then + (butterflyPerm d (decodeButterfly d ω))⁻¹ else butterflyPerm d (decodeButterfly d ω)) + +end Thorp.SparseContact + +namespace Thorp.Casimir +open scoped BigOperators Classical +open Filter + +noncomputable def levelScale (n k : ℕ) : ℝ := + (k:ℝ) * (1 + Real.log ((n:ℝ)/(k:ℝ))) + +end Thorp.Casimir + +namespace Thorp.AdaptiveBounds +open scoped BigOperators Classical +open Casimir + +noncomputable def positiveSquare {V : Type*} [NormedAddCommGroup V] + [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] (T : V →L[ℂ] V) : V →L[ℂ] V := + T * T.adjoint + +noncomputable def F (d : ℕ) (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ) + (rev : Bool) : Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + positiveSquare (V := Specht.hilbertSpace μ) (SparseContact.sweepOperator d μ e rev) + +noncomputable def fourthTrace (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (rev : Bool) : ℝ := + (LinearMap.trace ℂ (Specht.hilbertSpace μ) ((F d μ e rev)^4).toLinearMap).re + +def MainStatement : Prop := + ∃ c c' C c₀ : ℝ, 0 Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.Casimir + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def Coins : ℕ → Type + | 0 => Unit + | d + 1 => Card d → Bool + +instance (d : ℕ) : Fintype (Coins d) := by + cases d <;> dsimp [Coins] <;> infer_instance + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def rotate (d : ℕ) : Equiv.Perm (Card d) where + toFun x i := x (finRotate d i) + invFun x i := x ((finRotate d).symm i) + left_inv x := by funext i; simp only [Equiv.apply_symm_apply] + right_inv x := by funext i; simp only [Equiv.symm_apply_apply] + +def step : (d : ℕ) → Coins d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, ξ => rotate (d + 1) * pairSwitch ξ + +def run (d : ℕ) : (t : ℕ) → (Fin t → Coins d) → Equiv.Perm (Card d) + | 0, _ => 1 + | t + 1, ω => step d (ω (Fin.last t)) * run d t (fun i => ω i.castSucc) + +noncomputable def law (d t : ℕ) (g : Equiv.Perm (Card d)) : ℝ := + (Fintype.card {ω : Fin t → Coins d // run d t ω = g} : ℝ) / + (Fintype.card (Fin t → Coins d) : ℝ) + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +noncomputable def finiteMean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (∑ ω, f ω) / Fintype.card Ω + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.PairRouting +open scoped BigOperators +open Filter +variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq α] + +noncomputable def tupleProbability {Ω β : Type*} [Fintype Ω] [DecidableEq β] + (P : Ω → Equiv.Perm β) (x y : ι → β) : ℝ := by + classical + exact finiteMean (fun ω => if ∀ i, P ω (x i) = y i then 1 else 0) + +end Thorp.PairRouting + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev BenesCoins (d : ℕ) := (SwitchIndex d → Bool) × (SwitchIndex d → Bool) + +def palindromePerm (d : ℕ) (ω : BenesCoins d) : Equiv.Perm (Card d) := + butterflyPerm d (decodeButterfly d ω.1) * (butterflyPerm d (decodeButterfly d ω.2)).symm + +noncomputable def palindromeRowMoment (d : ℕ) {ι : Type*} [Fintype ι] + (e : ι ↪ Card d) (a : ℝ) : ℝ := + finiteMean (fun f : ι ↪ Card d => + ((Fintype.card (ι ↪ Card d):ℝ)*PairRouting.tupleProbability (palindromePerm d) e f)^(1+a)) + +end Thorp + +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.CasimirBounds +open scoped BigOperators Classical +open Filter + +noncomputable def levelScale (n k : ℕ) : ℝ := + (k:ℝ) * (1 + Real.log ((n:ℝ)/(k:ℝ))) + +noncomputable def K (d : ℕ) (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) + (Specht.relabelledUnitary μ e) (palindromePerm d) + +noncomputable def traceMoment (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (r : ℕ) : ℝ := + (LinearMap.trace ℂ (Specht.hilbertSpace μ) ((K d μ e)^r).toLinearMap).re + +noncomputable def fromDistance (d t : ℕ) (σ : Equiv.Perm (Card d)) : ℝ := + (1/2:ℝ) * ∑ g : Equiv.Perm (Card d), + |law d t (g*σ⁻¹) - 1/(Nat.factorial (2^d):ℝ)| + +def MainStatement : Prop := + ∃ a C : ℝ, 0 < a ∧ 0 < C ∧ + (∀ d k : ℕ, 1 ≤ k → k ≤ 2^d → ∀ x : Fin k ↪ Card d, + (palindromeRowMoment d x (1/64))^(64/65:ℝ) ≤ + Real.exp (C*levelScale (2^d) k)) ∧ + (∀ (d : ℕ) (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ), + 0 < μ.card-μ.rowLen 0 → + ‖K d μ e‖ ≤ Real.exp (-a*levelScale (2^d) (μ.card-μ.rowLen 0)) ∧ + (Module.finrank ℂ (Specht.space μ):ℝ) * traceMoment d μ e 65 ≤ + Real.exp (C*levelScale (2^d) (μ.card-μ.rowLen 0))) ∧ + (∃ l : ℕ, 0 < l ∧ ∀ starts : (d : ℕ) → Equiv.Perm (Card d), + Tendsto (fun d => fromDistance d (l*d) (starts d)) atTop (nhds 0)) + +end Thorp.CasimirBounds + +end ThorpNine.Casimir + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.Dense + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +noncomputable def finiteMean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (∑ ω, f ω) / Fintype.card Ω + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable def orbitSet (p : Equiv.Perm α) (x : α) : Finset α := + Finset.univ.filter (p.SameCycle x) + +end Thorp + +namespace Thorp.RoutingNetwork +open scoped BigOperators +open Filter +variable {α ι : Type*} [Fintype α] [DecidableEq α] [Fintype ι] [DecidableEq ι] +variable {A : ℕ} + +abbrev SelectedCycle (p : Equiv.Perm (α)) (S : Finset (α)) := + {C : Finset (α) // (∃ x, C = orbitSet p x) ∧ C ⊆ S} + +noncomputable instance (p : Equiv.Perm (α)) (S : Finset (α)) : + Fintype (SelectedCycle p S) := Fintype.ofFinite _ + +end Thorp.RoutingNetwork + +namespace Thorp +open scoped BigOperators +open Filter + +section +variable {β : Type*} [Fintype β] [DecidableEq β] + +def pairLayer (ξ : β → Bool) : Equiv.Perm (Bool × β) where + toFun x := (Bool.xor x.1 (ξ x.2),x.2) + invFun x := (Bool.xor x.1 (ξ x.2),x.2) + left_inv x := by + rcases x with ⟨b,x⟩ + change (Bool.xor (Bool.xor b (ξ x)) (ξ x),x) = (b,x) + cases b <;> cases ξ x <;> rfl + right_inv x := by + rcases x with ⟨b,x⟩ + change (Bool.xor (Bool.xor b (ξ x)) (ξ x),x) = (b,x) + cases b <;> cases ξ x <;> rfl + +end + +def coinStepEquiv (d : ℕ) : (SwitchIndex (d+1) → Bool) ≃ + ((SwitchIndex d → Bool) × (SwitchIndex d → Bool)) × (Card d → Bool) where + toFun ω := ((fun i => ω (Sum.inr (false,i)),fun i => ω (Sum.inr (true,i))), + fun x => ω (Sum.inl x)) + invFun ω := Sum.elim ω.2 (fun bi => if bi.1 then ω.1.2 bi.2 else ω.1.1 bi.2) + left_inv ω := by + funext i + cases i with + | inl x => rfl + | inr bi => cases bi with | mk b i => cases b <;> rfl + right_inv ω := by + rcases ω with ⟨⟨ω₀,ω₁⟩,ξ⟩ + rfl + +def headTailEquiv (d : ℕ) : Card (d+1) ≃ Bool × Card d := + (Fin.consEquiv (fun _ : Fin (d+1) => Bool)).symm + +end Thorp + +namespace Thorp.CycleColoring +open scoped BigOperators +open Filter +variable {α : Type*} [Fintype α] [DecidableEq α] + +def alternatingPerm (p : Equiv.Perm α) : Equiv.Perm (Bool × α) where + toFun x := if x.1 then (false,p x.2) else (true,x.2) + invFun x := if x.1 then (false,x.2) else (true,p.symm x.2) + left_inv x := by rcases x with ⟨b,x⟩; cases b <;> simp + right_inv x := by rcases x with ⟨b,x⟩; cases b <;> simp + +end Thorp.CycleColoring + +namespace Thorp.PairRouting +open scoped BigOperators +open Filter +variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq α] + +def required (x : ι → Bool × α) (c : ι → Bool) (i : ι) : Bool := Bool.xor (x i).1 (c i) + +def Compatible (x : ι → Bool × α) (c : ι → Bool) : Prop := + ∀ i j, (x i).2 = (x j).2 → required x c i = required x c j + +def colors (x : ι → Bool × α) (ξ : α → Bool) (i : ι) : Bool := + Bool.xor (x i).1 (ξ (x i).2) + +omit [Fintype ι] [Fintype α] [DecidableEq α] in +lemma required_colors (x : ι → Bool × α) (ξ : α → Bool) (i : ι) : + required x (colors x ξ) i = ξ (x i).2 := by + simp only [required,colors] + cases (x i).1 <;> cases ξ (x i).2 <;> rfl + +omit [Fintype ι] [Fintype α] [DecidableEq α] in +lemma colors_compatible (x : ι → Bool × α) (ξ : α → Bool) : Compatible x (colors x ξ) := by + intro i j he + simp only [required_colors,he] + +omit [Fintype ι] [Fintype α] [DecidableEq α] in +lemma Compatible.tail_injective {x : ι ↪ Bool × α} {c : ι → Bool} (hc : Compatible x c) (b : Bool) : + Function.Injective (fun i : {i : ι // c i = b} => (x i.val).2) := by + intro i j he + apply Subtype.ext + apply x.injective + apply Prod.ext + · have hh := hc i j he + simp only [required,i.property,j.property] at hh + cases h₀ : (x i.val).1 <;> cases h₁ : (x j.val).1 <;> cases b <;> simp_all + · exact he + +def childEmbedding (x : ι ↪ Bool × α) (c : ι → Bool) (hc : Compatible x c) (b : Bool) : + {i : ι // c i = b} ↪ α := ⟨fun i => (x i.val).2,hc.tail_injective b⟩ + +noncomputable def labelSet (e : ι ↪ Bool × α) : Finset (Bool × α) := Finset.univ.image e + +def alternatingProjection (p : Bool → Equiv.Perm α) : Equiv.Perm α := (p false).symm * p true + +noncomputable def alternatingCycles (e : ι ↪ Bool × α) (p : Bool → Equiv.Perm α) : ℕ := + Fintype.card (RoutingNetwork.SelectedCycle + (CycleColoring.alternatingPerm (alternatingProjection p)) (labelSet e)) + +def switchedEmbedding (e : ι ↪ Bool × α) (ξ : α → Bool) : ι ↪ Bool × α := + e.trans (pairLayer ξ).toEmbedding + +end Thorp.PairRouting + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev BenesCoins (d : ℕ) := (SwitchIndex d → Bool) × (SwitchIndex d → Bool) + +def palindromePerm (d : ℕ) (ω : BenesCoins d) : Equiv.Perm (Card d) := + butterflyPerm d (decodeButterfly d ω.1) * (butterflyPerm d (decodeButterfly d ω.2)).symm + +def sandwichShuffle {A B C D E F : Type*} : + ((A × B) × C) × ((D × E) × F) ≃ ((A × D) × (B × E)) × (F × C) where + toFun x := (((x.1.1.1,x.2.1.1),(x.1.1.2,x.2.1.2)),(x.2.2,x.1.2)) + invFun x := (((x.1.1.1,x.1.2.1),x.2.2),((x.1.1.2,x.1.2.2),x.2.1)) + left_inv _ := rfl + right_inv _ := rfl + +def benesStepEquiv (d : ℕ) : BenesCoins (d+1) ≃ + (BenesCoins d × BenesCoins d) × ((Card d → Bool) × (Card d → Bool)) := + (Equiv.prodCongr (coinStepEquiv d) (coinStepEquiv d)).trans sandwichShuffle + +noncomputable def palindromeCost : (d : ℕ) → {ι : Type*} → [Fintype ι] → + (ι ↪ Card d) → BenesCoins d → ℕ + | 0, _, _, _, _ => 0 + | d+1, _, _, e, ω => + let σ := benesStepEquiv d ω + let x := e.trans (headTailEquiv d).toEmbedding + let c := PairRouting.colors x σ.2.1 + let hc := PairRouting.colors_compatible x σ.2.1 + PairRouting.alternatingCycles (PairRouting.switchedEmbedding x σ.2.1) + (fun b => palindromePerm d (if b then σ.1.2 else σ.1.1)) + + palindromeCost d (PairRouting.childEmbedding x c hc false) σ.1.1 + + palindromeCost d (PairRouting.childEmbedding x c hc true) σ.1.2 + +end Thorp + +namespace Thorp.DenseTruncation +open scoped BigOperators + +def AdmissibleCycleLaw (j : ℕ) (p : ℕ → ℝ) : Prop := + (∀ l, 0 ≤ p l) ∧ HasSum p 1 ∧ + ∀ l, p l ≤ ((l + 1 : ℕ) : ℝ) / (2 : ℝ) ^ (j - 1) + +noncomputable def h (j : ℕ) : ℝ := + sSup {z : ℝ | ∃ p : ℕ → ℝ, AdmissibleCycleLaw j p ∧ + z = ∑' l : ℕ, p l / ((l + 1 : ℕ) : ℝ)} + +def AdmissibleAllocation (ρ : ℝ) (x : ℕ → ℝ) : Prop := + (∀ j, 0 ≤ x j ∧ x j ≤ 1) ∧ + (∑' j : ℕ, x j / (2 : ℝ) ^ (j + 1)) ≤ ρ + +noncomputable def H (ρ : ℝ) : ℝ := + sSup {z : ℝ | ∃ x : ℕ → ℝ, AdmissibleAllocation ρ x ∧ + z = (1 / 2 : ℝ) * ∑' j : ℕ, h (j + 1) * x j} + +noncomputable def entropyCorrection (ρ : ℝ) : ℝ := + (-ρ - (1 - ρ) * Real.log (1 - ρ)) / (ρ * Real.log 2) + +noncomputable def densityExponent (d r : ℕ) (x : Fin r ↪ Card d) + (ω : BenesCoins d) : ℝ := + palindromeCost d x ω + + Real.log (((2 ^ d).descFactorial r : ℝ) / ((2 : ℝ) ^ d) ^ r) / Real.log 2 + +def MainStatement : Prop := + ∀ ρ : ℝ, 0 < ρ → ∀ ε : ℝ, 0 < ε → + ∃ c : ℝ, 0 < c ∧ ∀ d r : ℕ, 1 ≤ d → 1 ≤ r → + (r : ℝ) / (2 : ℝ) ^ d = ρ → ∀ x : Fin r ↪ Card d, + finiteMean (fun ω : BenesCoins d => + if (r : ℝ) * (H ρ + entropyCorrection ρ + ε) < densityExponent d r x ω + then (1 : ℝ) else 0) ≤ Real.exp (-c * r) + +end Thorp.DenseTruncation + +end ThorpNine.Dense + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.Contact + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.SparseContact +open scoped BigOperators + +noncomputable def sweepOperator (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (reverse : Bool) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) (Specht.relabelledUnitary μ e) + (fun ω : SwitchIndex d → Bool => if reverse then + (butterflyPerm d (decodeButterfly d ω))⁻¹ else butterflyPerm d (decodeButterfly d ω)) + +def MainStatement : Prop := + ∃ Cstar C : ℝ, 0 < Cstar ∧ 0 < C ∧ + ∀ (d : ℕ), 1 ≤ d → ∀ (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ), + let k := μ.card - μ.rowLen 0 + 1 ≤ k → k < 2^d → ∀ reverse : Bool, + ‖sweepOperator d μ e reverse‖^2 ≤ + min 1 ((Cstar * d * k / (2:ℝ)^d) ^ ((k:ℝ)/2)) ∧ + (k = 1 → sweepOperator d μ e reverse = 0) ∧ + ‖sweepOperator d μ e reverse‖^2 ≤ + C^k * (1+(d:ℝ))^(C*k) * ((k:ℝ)/(2:ℝ)^d)^((k:ℝ)/2) + +end Thorp.SparseContact + +end ThorpNine.Contact + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.Harmonic + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +noncomputable def finiteMean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (∑ ω, f ω) / Fintype.card Ω + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.PairRouting +open scoped BigOperators +open Filter +variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq α] + +noncomputable def tupleProbability {Ω β : Type*} [Fintype Ω] [DecidableEq β] + (P : Ω → Equiv.Perm β) (x y : ι → β) : ℝ := by + classical + exact finiteMean (fun ω => if ∀ i, P ω (x i) = y i then 1 else 0) + +end Thorp.PairRouting + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev BenesCoins (d : ℕ) := (SwitchIndex d → Bool) × (SwitchIndex d → Bool) + +def palindromePerm (d : ℕ) (ω : BenesCoins d) : Equiv.Perm (Card d) := + butterflyPerm d (decodeButterfly d ω.1) * (butterflyPerm d (decodeButterfly d ω.2)).symm + +end Thorp + +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.SparseContact +open scoped BigOperators + +noncomputable def sweepOperator (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (reverse : Bool) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) (Specht.relabelledUnitary μ e) + (fun ω : SwitchIndex d → Bool => if reverse then + (butterflyPerm d (decodeButterfly d ω))⁻¹ else butterflyPerm d (decodeButterfly d ω)) + +end Thorp.SparseContact + +namespace Thorp.StrongSmoothing + +def coordinateRelabel (d : ℕ) (order : Equiv.Perm (Fin d)) : Equiv.Perm (Card d) where + toFun x := fun i => x (order.symm i) + invFun x := fun i => x (order i) + left_inv x := by funext i; simp + right_inv x := by funext i; simp + +def sweep (d : ℕ) (order : Equiv.Perm (Fin d)) (ω : SwitchIndex d → Bool) : + Equiv.Perm (Card d) := + coordinateRelabel d order * butterflyPerm d (decodeButterfly d ω) * + (coordinateRelabel d order)⁻¹ + +abbrev Tuples (d l : ℕ) := Fin l ↪ Card d + +noncomputable def sweepKernel (d l : ℕ) (order : Equiv.Perm (Fin d)) : + Matrix (Tuples d l) (Tuples d l) ℝ := + fun x y => PairRouting.tupleProbability (sweep d order) x y + +noncomputable def reflectedKernel (d l : ℕ) (order : Equiv.Perm (Fin d)) (orientation : Bool) : + Matrix (Tuples d l) (Tuples d l) ℝ := + let A := sweepKernel d l order + if orientation then A * A.transpose else A.transpose * A + +end Thorp.StrongSmoothing + +namespace Thorp.StrongTail +open scoped BigOperators Classical +open Specht + +def tailDiagram (μ : YoungDiagram) : YoungDiagram := + YoungDiagram.ofRowLens μ.rowLens.tail μ.rowLens_sorted.pairwise.tail.sortedGE + +end Thorp.StrongTail + +namespace Thorp.Casimir +open scoped BigOperators Classical +open Filter + +noncomputable def levelScale (n k : ℕ) : ℝ := + (k:ℝ) * (1 + Real.log ((n:ℝ)/(k:ℝ))) + +noncomputable def K (d : ℕ) (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) + (Specht.relabelledUnitary μ e) (palindromePerm d) + +end Thorp.Casimir + +namespace Thorp.HarmonicBounds +open scoped BigOperators Classical +open _root_.OAI.ThorpNine.Harmonic.Thorp.Casimir StrongSmoothing + +abbrev tail (μ : YoungDiagram) := StrongTail.tailDiagram μ + +noncomputable def W (d : ℕ) (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ) : ℝ := ‖K d μ e‖ + +noncomputable def tupleTrace (d k : ℕ) (order : Equiv.Perm (Fin d)) (rev : Bool) (p : ℕ) : ℝ := + Matrix.trace ((reflectedKernel d k order rev)^p) + +def MainStatement : Prop := + ∃ c C ζ δ cTail c₁ c₂ : ℝ, ∃ p₀ : ℕ, + 0 ((Fintype.card (Tuples d k):ℝ)* + reflectedKernel d k order rev x y)^(1+δ)) ≤ + Real.exp (C*levelScale (2^d) k)) ∧ + tupleTrace d k order rev p₀ ≤ Real.exp (C*levelScale (2^d) k)) + +end Thorp.HarmonicBounds + +end ThorpNine.Harmonic + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.Smoothing + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +noncomputable def finiteMean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (∑ ω, f ω) / Fintype.card Ω + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.PairRouting +open scoped BigOperators +open Filter +variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq α] + +noncomputable def tupleProbability {Ω β : Type*} [Fintype Ω] [DecidableEq β] + (P : Ω → Equiv.Perm β) (x y : ι → β) : ℝ := by + classical + exact finiteMean (fun ω => if ∀ i, P ω (x i) = y i then 1 else 0) + +end Thorp.PairRouting + +namespace Thorp.StrongSmoothing + +def coordinateRelabel (d : ℕ) (order : Equiv.Perm (Fin d)) : Equiv.Perm (Card d) where + toFun x := fun i => x (order.symm i) + invFun x := fun i => x (order i) + left_inv x := by funext i; simp + right_inv x := by funext i; simp + +def sweep (d : ℕ) (order : Equiv.Perm (Fin d)) (ω : SwitchIndex d → Bool) : + Equiv.Perm (Card d) := + coordinateRelabel d order * butterflyPerm d (decodeButterfly d ω) * + (coordinateRelabel d order)⁻¹ + +abbrev Tuples (d l : ℕ) := Fin l ↪ Card d + +noncomputable def sweepKernel (d l : ℕ) (order : Equiv.Perm (Fin d)) : + Matrix (Tuples d l) (Tuples d l) ℝ := + fun x y => PairRouting.tupleProbability (sweep d order) x y + +noncomputable def reflectedKernel (d l : ℕ) (order : Equiv.Perm (Fin d)) (orientation : Bool) : + Matrix (Tuples d l) (Tuples d l) ℝ := + let A := sweepKernel d l order + if orientation then A * A.transpose else A.transpose * A + +noncomputable def regularAbsoluteEvenTrace (d : ℕ) (order : Equiv.Perm (Fin d)) (u : ℕ) : ℝ := + Matrix.trace ((reflectedKernel d (2^d) order false)^u) + +def MainStatement : Prop := + ∃ u : ℕ, 1 ≤ u ∧ ∃ C : ℝ, + (∀ d l : ℕ, l ≤ 2^d → ∀ order : Equiv.Perm (Fin d), ∀ orientation : Bool, + ∀ x y : Tuples d l, + ((reflectedKernel d l order orientation)^u) x y ≤ + Real.exp (C*l)/((2^d).descFactorial l:ℝ)) ∧ + (∀ d : ℕ, ∀ order : Equiv.Perm (Fin d), + regularAbsoluteEvenTrace d order u ≤ Real.exp (C*(2:ℝ)^d)) + +end Thorp.StrongSmoothing + +end ThorpNine.Smoothing + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.Tail + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +noncomputable def finiteMean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (∑ ω, f ω) / Fintype.card Ω + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.PairRouting +open scoped BigOperators +open Filter +variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq α] + +noncomputable def tupleProbability {Ω β : Type*} [Fintype Ω] [DecidableEq β] + (P : Ω → Equiv.Perm β) (x y : ι → β) : ℝ := by + classical + exact finiteMean (fun ω => if ∀ i, P ω (x i) = y i then 1 else 0) + +end Thorp.PairRouting + +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.SparseContact +open scoped BigOperators + +noncomputable def sweepOperator (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (reverse : Bool) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) (Specht.relabelledUnitary μ e) + (fun ω : SwitchIndex d → Bool => if reverse then + (butterflyPerm d (decodeButterfly d ω))⁻¹ else butterflyPerm d (decodeButterfly d ω)) + +end Thorp.SparseContact + +namespace Thorp.StrongSmoothing + +def coordinateRelabel (d : ℕ) (order : Equiv.Perm (Fin d)) : Equiv.Perm (Card d) where + toFun x := fun i => x (order.symm i) + invFun x := fun i => x (order i) + left_inv x := by funext i; simp + right_inv x := by funext i; simp + +def sweep (d : ℕ) (order : Equiv.Perm (Fin d)) (ω : SwitchIndex d → Bool) : + Equiv.Perm (Card d) := + coordinateRelabel d order * butterflyPerm d (decodeButterfly d ω) * + (coordinateRelabel d order)⁻¹ + +abbrev Tuples (d l : ℕ) := Fin l ↪ Card d + +noncomputable def sweepKernel (d l : ℕ) (order : Equiv.Perm (Fin d)) : + Matrix (Tuples d l) (Tuples d l) ℝ := + fun x y => PairRouting.tupleProbability (sweep d order) x y + +noncomputable def reflectedKernel (d l : ℕ) (order : Equiv.Perm (Fin d)) (orientation : Bool) : + Matrix (Tuples d l) (Tuples d l) ℝ := + let A := sweepKernel d l order + if orientation then A * A.transpose else A.transpose * A + +end Thorp.StrongSmoothing + +namespace Thorp.StrongTail +open scoped BigOperators Classical +open Specht + +def tailDiagram (μ : YoungDiagram) : YoungDiagram := + YoungDiagram.ofRowLens μ.rowLens.tail μ.rowLens_sorted.pairwise.tail.sortedGE + +end Thorp.StrongTail + +namespace Thorp.StrongTail +open scoped BigOperators Classical +open StrongSmoothing + +def DensityAt (p C : ℝ) : Prop := + ∀ (d l : ℕ), l ≤ 2^d → ∀ (order : Equiv.Perm (Fin d)) (rev : Bool) + (x : StrongSmoothing.Tuples d l), + let H := StrongSmoothing.reflectedKernel d l order rev + (Thorp.finiteMean (fun y => ((Fintype.card (StrongSmoothing.Tuples d l):ℝ)*H x y)^p) + ≤ Real.exp (C*l)) ∧ + (Thorp.finiteMean (fun y => ((Fintype.card (StrongSmoothing.Tuples d l):ℝ)*H y x)^p) + ≤ Real.exp (C*l)) ∧ + (((2:ℝ)^d)^l)⁻¹ * (∑ y, ((((2:ℝ)^d)^l)*H x y)^p) ≤ Real.exp (C*l) ∧ + (((2:ℝ)^d)^l)⁻¹ * (∑ y, ((((2:ℝ)^d)^l)*H y x)^p) ≤ Real.exp (C*l) + +end Thorp.StrongTail + +namespace Thorp.StrongTail +open scoped BigOperators Classical +open Specht UnitaryFinite + +def MainStatement : Prop := + ∃ p Cdensity C : ℝ, 1 < p ∧ p ≤ 2 ∧ DensityAt p Cdensity ∧ + ∀ (d : ℕ) (μ : YoungDiagram) (e : Card d ≃ Specht.Cell μ) (rev : Bool), + ‖SparseContact.sweepOperator d μ e rev‖^2 ≤ + Real.exp (C*(μ.card-μ.rowLen 0 : ℕ)) * + (Module.finrank ℂ (Specht.space (tailDiagram μ)):ℝ)^(-((p-1)/p)) + +end Thorp.StrongTail + +end ThorpNine.Tail + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.HighTail + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +noncomputable def finiteMean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (∑ ω, f ω) / Fintype.card Ω + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable def orbitSet (p : Equiv.Perm α) (x : α) : Finset α := + Finset.univ.filter (p.SameCycle x) + +end Thorp + +namespace Thorp.RoutingNetwork +open scoped BigOperators +open Filter +variable {α ι : Type*} [Fintype α] [DecidableEq α] [Fintype ι] [DecidableEq ι] +variable {A : ℕ} + +abbrev SelectedCycle (p : Equiv.Perm (α)) (S : Finset (α)) := + {C : Finset (α) // (∃ x, C = orbitSet p x) ∧ C ⊆ S} + +noncomputable instance (p : Equiv.Perm (α)) (S : Finset (α)) : + Fintype (SelectedCycle p S) := Fintype.ofFinite _ + +end Thorp.RoutingNetwork + +namespace Thorp +open scoped BigOperators +open Filter + +def cardSplit : (r s : ℕ) → Card (s+r) ≃ Card r × Card s + | 0, s => + { toFun := fun x => ((fun i => Fin.elim0 i), x) + invFun := fun x => x.2 + left_inv := fun _ => rfl + right_inv := fun x => by + apply Prod.ext + · exact Subsingleton.elim _ _ + · rfl } + | r+1, s => + { toFun := fun x => (Fin.cons (x 0) ((cardSplit r s (Fin.tail x)).1), + (cardSplit r s (Fin.tail x)).2) + invFun := fun x => Fin.cons (x.1 0) ((cardSplit r s).symm (Fin.tail x.1,x.2)) + left_inv := by + intro x + simp only [Fin.cons_zero, Fin.tail_cons, Prod.mk.eta, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv := by + intro x + simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] } + +def assembleBits : (r s : ℕ) → (Card r × SwitchIndex s → Bool) → + (Card s × SwitchIndex r → Bool) → SwitchIndex (s+r) → Bool + | 0, _, lo, _, i => lo ((fun j => Fin.elim0 j), i) + | r+1, s, _, hi, Sum.inl y => hi ((cardSplit r s y).2,Sum.inl (cardSplit r s y).1) + | r+1, s, lo, hi, Sum.inr (b,i) => assembleBits r s + (fun j => lo (Fin.cons b j.1,j.2)) (fun j => hi (j.1,Sum.inr (b,j.2))) i + + +section +variable {β : Type*} [Fintype β] [DecidableEq β] + +def pairLayer (ξ : β → Bool) : Equiv.Perm (Bool × β) where + toFun x := (Bool.xor x.1 (ξ x.2),x.2) + invFun x := (Bool.xor x.1 (ξ x.2),x.2) + left_inv x := by + rcases x with ⟨b,x⟩ + change (Bool.xor (Bool.xor b (ξ x)) (ξ x),x) = (b,x) + cases b <;> cases ξ x <;> rfl + right_inv x := by + rcases x with ⟨b,x⟩ + change (Bool.xor (Bool.xor b (ξ x)) (ξ x),x) = (b,x) + cases b <;> cases ξ x <;> rfl + +end + +def coinStepEquiv (d : ℕ) : (SwitchIndex (d+1) → Bool) ≃ + ((SwitchIndex d → Bool) × (SwitchIndex d → Bool)) × (Card d → Bool) where + toFun ω := ((fun i => ω (Sum.inr (false,i)),fun i => ω (Sum.inr (true,i))), + fun x => ω (Sum.inl x)) + invFun ω := Sum.elim ω.2 (fun bi => if bi.1 then ω.1.2 bi.2 else ω.1.1 bi.2) + left_inv ω := by + funext i + cases i with + | inl x => rfl + | inr bi => cases bi with | mk b i => cases b <;> rfl + right_inv ω := by + rcases ω with ⟨⟨ω₀,ω₁⟩,ξ⟩ + rfl + +def headTailEquiv (d : ℕ) : Card (d+1) ≃ Bool × Card d := + (Fin.consEquiv (fun _ : Fin (d+1) => Bool)).symm + +end Thorp + +namespace Thorp.CycleColoring +open scoped BigOperators +open Filter +variable {α : Type*} [Fintype α] [DecidableEq α] + +def alternatingPerm (p : Equiv.Perm α) : Equiv.Perm (Bool × α) where + toFun x := if x.1 then (false,p x.2) else (true,x.2) + invFun x := if x.1 then (false,x.2) else (true,p.symm x.2) + left_inv x := by rcases x with ⟨b,x⟩; cases b <;> simp + right_inv x := by rcases x with ⟨b,x⟩; cases b <;> simp + +end Thorp.CycleColoring + +namespace Thorp.PairRouting +open scoped BigOperators +open Filter +variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq α] + +def required (x : ι → Bool × α) (c : ι → Bool) (i : ι) : Bool := Bool.xor (x i).1 (c i) + +def Compatible (x : ι → Bool × α) (c : ι → Bool) : Prop := + ∀ i j, (x i).2 = (x j).2 → required x c i = required x c j + +def colors (x : ι → Bool × α) (ξ : α → Bool) (i : ι) : Bool := + Bool.xor (x i).1 (ξ (x i).2) + +omit [Fintype ι] [Fintype α] [DecidableEq α] in +lemma required_colors (x : ι → Bool × α) (ξ : α → Bool) (i : ι) : + required x (colors x ξ) i = ξ (x i).2 := by + simp only [required,colors] + cases (x i).1 <;> cases ξ (x i).2 <;> rfl + +omit [Fintype ι] [Fintype α] [DecidableEq α] in +lemma colors_compatible (x : ι → Bool × α) (ξ : α → Bool) : Compatible x (colors x ξ) := by + intro i j he + simp only [required_colors,he] + +omit [Fintype ι] [Fintype α] [DecidableEq α] in +lemma Compatible.tail_injective {x : ι ↪ Bool × α} {c : ι → Bool} (hc : Compatible x c) (b : Bool) : + Function.Injective (fun i : {i : ι // c i = b} => (x i.val).2) := by + intro i j he + apply Subtype.ext + apply x.injective + apply Prod.ext + · have hh := hc i j he + simp only [required,i.property,j.property] at hh + cases h₀ : (x i.val).1 <;> cases h₁ : (x j.val).1 <;> cases b <;> simp_all + · exact he + +def childEmbedding (x : ι ↪ Bool × α) (c : ι → Bool) (hc : Compatible x c) (b : Bool) : + {i : ι // c i = b} ↪ α := ⟨fun i => (x i.val).2,hc.tail_injective b⟩ + +noncomputable def labelSet (e : ι ↪ Bool × α) : Finset (Bool × α) := Finset.univ.image e + +def alternatingProjection (p : Bool → Equiv.Perm α) : Equiv.Perm α := (p false).symm * p true + +noncomputable def alternatingCycles (e : ι ↪ Bool × α) (p : Bool → Equiv.Perm α) : ℕ := + Fintype.card (RoutingNetwork.SelectedCycle + (CycleColoring.alternatingPerm (alternatingProjection p)) (labelSet e)) + +def switchedEmbedding (e : ι ↪ Bool × α) (ξ : α → Bool) : ι ↪ Bool × α := + e.trans (pairLayer ξ).toEmbedding + +end Thorp.PairRouting + +namespace Thorp + +section +open scoped BigOperators +open Filter + +abbrev BenesCoins (d : ℕ) := (SwitchIndex d → Bool) × (SwitchIndex d → Bool) + +def palindromePerm (d : ℕ) (ω : BenesCoins d) : Equiv.Perm (Card d) := + butterflyPerm d (decodeButterfly d ω.1) * (butterflyPerm d (decodeButterfly d ω.2)).symm + +def sandwichShuffle {A B C D E F : Type*} : + ((A × B) × C) × ((D × E) × F) ≃ ((A × D) × (B × E)) × (F × C) where + toFun x := (((x.1.1.1,x.2.1.1),(x.1.1.2,x.2.1.2)),(x.2.2,x.1.2)) + invFun x := (((x.1.1.1,x.1.2.1),x.2.2),((x.1.1.2,x.1.2.2),x.2.1)) + left_inv _ := rfl + right_inv _ := rfl + +def benesStepEquiv (d : ℕ) : BenesCoins (d+1) ≃ + (BenesCoins d × BenesCoins d) × ((Card d → Bool) × (Card d → Bool)) := + (Equiv.prodCongr (coinStepEquiv d) (coinStepEquiv d)).trans sandwichShuffle + +noncomputable def palindromeCost : (d : ℕ) → {ι : Type*} → [Fintype ι] → + (ι ↪ Card d) → BenesCoins d → ℕ + | 0, _, _, _, _ => 0 + | d+1, _, _, e, ω => + let σ := benesStepEquiv d ω + let x := e.trans (headTailEquiv d).toEmbedding + let c := PairRouting.colors x σ.2.1 + let hc := PairRouting.colors_compatible x σ.2.1 + PairRouting.alternatingCycles (PairRouting.switchedEmbedding x σ.2.1) + (fun b => palindromePerm d (if b then σ.1.2 else σ.1.1)) + + palindromeCost d (PairRouting.childEmbedding x c hc false) σ.1.1 + + palindromeCost d (PairRouting.childEmbedding x c hc true) σ.1.2 + +end + +noncomputable def palindromeLowCost (H : ℕ) : (d : ℕ) → {ι : Type*} → [Fintype ι] → + (ι ↪ Card d) → BenesCoins d → ℕ + | 0, _, _, _, _ => 0 + | d+1, _, _, e, ω => + let σ := benesStepEquiv d ω + let x := e.trans (headTailEquiv d).toEmbedding + let c := PairRouting.colors x σ.2.1 + let hc := PairRouting.colors_compatible x σ.2.1 + (if d+1 ≤ H then PairRouting.alternatingCycles (PairRouting.switchedEmbedding x σ.2.1) + (fun b => palindromePerm d (if b then σ.1.2 else σ.1.1)) else 0) + + palindromeLowCost H d (PairRouting.childEmbedding x c hc false) σ.1.1 + + palindromeLowCost H d (PairRouting.childEmbedding x c hc true) σ.1.2 + +end Thorp + +namespace Thorp.HighHeight +open scoped BigOperators Classical + +noncomputable def highCost (J d : ℕ) {ι : Type*} [Fintype ι] + (x : ι ↪ Card d) (ω : BenesCoins d) : ℕ := + palindromeCost d x ω-palindromeLowCost (J-1) d x ω + +def MainStatement : Prop := + ∃ b δ C : ℝ, 0 ((2:ℝ)^b)^(highCost J d x ω)))/Real.log 2 ≤ + C*k*(2:ℝ)^(-b*J)) ∧ + (∀ d k : ℕ, ∀ x : Fin k ↪ Card d, + Real.log (finiteMean (fun ω : BenesCoins d => ((2:ℝ)^b)^(palindromeCost d x ω)))/Real.log 2 ≤ + C*k*((k:ℝ)/(2:ℝ)^d)^δ) ∧ + (∀ r s k : ℕ, ∀ x : Fin k ↪ Card (s+r), ∀ J : ℕ, J₀≤J → 2*s + ((2:ℝ)^b)^(highCost J (s+r) x (assembleBits r s lo hi,X))))/Real.log 2 ≤ + C*k*(2:ℝ)^(-b*J)) + +end Thorp.HighHeight + +end ThorpNine.HighTail + +run_cmd do + Lean.modifyEnv fun env => Lean.Meta.auxLemmasExt.setState env {} + let matcherCache := Lean.mkIdent + (Lean.mkPrivateNameCore `Lean.Meta.Match.Match `Lean.Meta.Match.matcherExt) + Lean.Elab.Command.elabCommand (← `(command| + run_cmd Lean.modifyEnv fun env => Lean.EnvExtension.setState $matcherCache env {})) + +namespace ThorpNine.SparseSaving + +namespace Thorp +open scoped BigOperators +open Filter + +abbrev Card (d : ℕ) := Fin d → Bool + +def switchFun {d : ℕ} (ξ : Card d → Bool) (x : Card (d + 1)) : Card (d + 1) := + Fin.cons (Bool.xor (x 0) (ξ (Fin.tail x))) (Fin.tail x) + +theorem switchFun_involutive {d : ℕ} (ξ : Card d → Bool) : + Function.Involutive (switchFun ξ) := by + intro x + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [switchFun, Fin.cons_zero, Fin.tail_cons] + cases x 0 <;> cases ξ (Fin.tail x) <;> rfl + · simp [switchFun, Fin.tail] + +def pairSwitch {d : ℕ} (ξ : Card d → Bool) : Equiv.Perm (Card (d + 1)) := + { toFun := switchFun ξ + invFun := switchFun ξ + left_inv := switchFun_involutive ξ + right_inv := switchFun_involutive ξ } + +def Butterfly : ℕ → Type + | 0 => Unit + | d + 1 => (Card d → Bool) × (Bool → Butterfly d) + +def childLift {d : ℕ} (p : Bool → Equiv.Perm (Card d)) : Equiv.Perm (Card (d + 1)) where + toFun x := Fin.cons (x 0) (p (x 0) (Fin.tail x)) + invFun x := Fin.cons (x 0) ((p (x 0)).symm (Fin.tail x)) + left_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.symm_apply_apply, Fin.cons_self_tail] + right_inv x := by simp only [Fin.cons_zero, Fin.tail_cons, Equiv.apply_symm_apply, Fin.cons_self_tail] + +def butterflyPerm : (d : ℕ) → Butterfly d → Equiv.Perm (Card d) + | 0, _ => 1 + | d + 1, b => pairSwitch b.1 * childLift (fun ε => butterflyPerm d (b.2 ε)) + +def SwitchIndex : ℕ → Type + | 0 => Empty + | d + 1 => Sum (Card d) (Bool × SwitchIndex d) + +instance (d : ℕ) : Fintype (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (Fintype Empty) + | succ d ih => exact inferInstanceAs (Fintype (Sum (Card d) (Bool × SwitchIndex d))) + +instance (d : ℕ) : DecidableEq (SwitchIndex d) := by + induction d with + | zero => exact inferInstanceAs (DecidableEq Empty) + | succ d ih => exact inferInstanceAs (DecidableEq (Sum (Card d) (Bool × SwitchIndex d))) + +def decodeButterfly : (d : ℕ) → (SwitchIndex d → Bool) → Butterfly d + | 0, _ => () + | d + 1, ω => (fun y => ω (Sum.inl y), fun ε => + decodeButterfly d (fun i => ω (Sum.inr (ε,i)))) + +end Thorp + +namespace Thorp.Specht +open scoped BigOperators Classical + +abbrev Cell (μ : YoungDiagram) := {x : ℕ × ℕ // x ∈ μ.cells} + +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.1 + +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.1.2 + +lemma row_lt_colLen {μ : YoungDiagram} (x : Cell μ) : row x < μ.colLen (col x) := + YoungDiagram.mem_iff_lt_colLen.mp x.2 + +noncomputable def rowIndex {μ : YoungDiagram} (x : Cell μ) : Fin (μ.colLen 0) := + ⟨row x, (row_lt_colLen x).trans_le (μ.colLen_anti 0 (col x) (Nat.zero_le _))⟩ + +abbrev Tabloid (μ : YoungDiagram) := + {f : Cell μ → Fin (μ.colLen 0) // ∃ p : Equiv.Perm (Cell μ), f = rowIndex ∘ p} + +noncomputable instance (μ : YoungDiagram) : Fintype (Tabloid μ) := Fintype.ofFinite _ + +noncomputable def baseTabloid (μ : YoungDiagram) : Tabloid μ := ⟨rowIndex, 1, rfl⟩ + +noncomputable def tabloidAct {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) : + Equiv.Perm (Tabloid μ) where + toFun f := ⟨fun x => f.1 (p⁻¹ x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p⁻¹, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + invFun f := ⟨fun x => f.1 (p x), by + obtain ⟨q,hq⟩ := f.2 + refine ⟨q*p, ?_⟩ + funext x + simp only [hq,Function.comp_apply,Equiv.Perm.mul_apply]⟩ + left_inv f := by apply Subtype.ext; funext x; simp + right_inv f := by apply Subtype.ext; funext x; simp + +@[simp] lemma tabloidAct_apply {μ : YoungDiagram} (p : Equiv.Perm (Cell μ)) + (f : Tabloid μ) (x : Cell μ) : (tabloidAct p f).1 x = f.1 (p⁻¹ x) := rfl + +@[simp] lemma tabloidAct_one (μ : YoungDiagram) : tabloidAct (1 : Equiv.Perm (Cell μ)) = 1 := by + ext f x + rfl + +@[simp] lemma tabloidAct_mul {μ : YoungDiagram} (p q : Equiv.Perm (Cell μ)) : + tabloidAct (p*q) = tabloidAct p * tabloidAct q := by + ext f x + simp only [tabloidAct_apply, mul_inv_rev,Equiv.Perm.mul_apply] + +noncomputable def tabloidRep (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (Tabloid μ → ℂ) where + toFun p := + { toFun := fun v f => v (tabloidAct p⁻¹ f) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v f; simp + map_mul' p q := by + ext v f + simp only [mul_inv_rev,tabloidAct_mul,Equiv.Perm.mul_apply] + rfl + +noncomputable def delta {μ : YoungDiagram} (f : Tabloid μ) : Tabloid μ → ℂ := + fun g => if g=f then 1 else 0 + +noncomputable def colGroup (μ : YoungDiagram) : Subgroup (Equiv.Perm (Cell μ)) where + carrier := {p | ∀ x, col (p x) = col x} + one_mem' := by intro x; rfl + mul_mem' := by intro p q hp hq x; exact (hp (q x)).trans (hq x) + inv_mem' := by intro p hp x; simpa using (hp (p⁻¹ x)).symm + +noncomputable def permSign {α : Type*} [Fintype α] [DecidableEq α] (p : Equiv.Perm α) : ℂ := + ((Equiv.Perm.sign p : ℤ) : ℂ) + + +section +variable {α V : Type*} [Fintype α] [DecidableEq α] [AddCommGroup V] [Module ℂ V] + +noncomputable def alternator (C : Subgroup (Equiv.Perm α)) + (ρ : Representation ℂ (Equiv.Perm α) V) : Module.End ℂ V := by + classical + exact ∑ c : C, permSign (c : Equiv.Perm α) • ρ c + +end + +noncomputable def polytabloid (μ : YoungDiagram) : Tabloid μ → ℂ := + alternator (colGroup μ) (tabloidRep μ) (delta (baseTabloid μ)) + +noncomputable def space (μ : YoungDiagram) : Submodule ℂ (Tabloid μ → ℂ) := + Submodule.span ℂ (Set.range (fun p : Equiv.Perm (Cell μ) => tabloidRep μ p (polytabloid μ))) + +lemma orbit_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) : + tabloidRep μ p (polytabloid μ) ∈ space μ := Submodule.subset_span ⟨p,rfl⟩ + +lemma action_mem_space (μ : YoungDiagram) (p : Equiv.Perm (Cell μ)) + (v : Tabloid μ → ℂ) (hv : v ∈ space μ) : tabloidRep μ p v ∈ space μ := by + induction hv using Submodule.span_induction with + | mem v hv => + obtain ⟨q,rfl⟩ := hv + change ((tabloidRep μ p)*(tabloidRep μ q)) (polytabloid μ) ∈ space μ + rw [←map_mul] + exact orbit_mem_space μ (p*q) + | zero => simp + | add v w hv hw ihv ihw => simpa using (space μ).add_mem ihv ihw + | smul a v hv ih => simpa using (space μ).smul_mem a ih + +noncomputable def subrepresentation (μ : YoungDiagram) : Subrepresentation (tabloidRep μ) := + ⟨space μ, fun p v hv => action_mem_space μ p v hv⟩ + +noncomputable def representation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (space μ) := + (subrepresentation μ).toRepresentation + +end Thorp.Specht + +namespace Thorp.PermutationHilbert +open scoped BigOperators ComplexConjugate Classical +open Complex +variable {X : Type*} [Fintype X] + +abbrev H (X : Type*) [Fintype X] := EuclideanSpace ℂ X + +end Thorp.PermutationHilbert + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def hilbertEquiv (μ : YoungDiagram) : + (Tabloid μ → ℂ) ≃ₗ[ℂ] PermutationHilbert.H (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm + +noncomputable def hilbertSpace (μ : YoungDiagram) : + Submodule ℂ (PermutationHilbert.H (Tabloid μ)) := (space μ).map (hilbertEquiv μ).toLinearMap + +end Thorp.Specht + +namespace Thorp.UnitaryFinite + +section +open scoped BigOperators ComplexConjugate Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +noncomputable def continuousRepresentation (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +end +open scoped BigOperators Classical +variable {G : Type*} [Group G] [Fintype G] +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +noncomputable def sampleOperator (ρ : Representation ℂ G V) (P : Ω → G) : V →L[ℂ] V := + (Fintype.card Ω:ℂ)⁻¹ • ∑ ω,continuousRepresentation ρ (P ω) + +end Thorp.UnitaryFinite + +namespace Thorp.Specht +open scoped BigOperators Classical + +noncomputable def spaceHilbertEquiv (μ : YoungDiagram) : space μ ≃ₗ[ℂ] hilbertSpace μ := + (hilbertEquiv μ).submoduleMap (space μ) + +noncomputable def unitaryRepresentation (μ : YoungDiagram) : + Representation ℂ (Equiv.Perm (Cell μ)) (hilbertSpace μ) := + ((spaceHilbertEquiv μ).conjAlgEquiv ℂ).toMonoidHom.comp (representation μ) + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +noncomputable def relabelledUnitary (μ : YoungDiagram) (e : α ≃ Cell μ) : + Representation ℂ (Equiv.Perm α) (hilbertSpace μ) := + (unitaryRepresentation μ).comp e.permCongrHom.toMonoidHom + +end Thorp.Specht + +namespace Thorp.SparseContact +open scoped BigOperators + +noncomputable def sweepOperator (d : ℕ) (μ : YoungDiagram) + (e : Card d ≃ Specht.Cell μ) (reverse : Bool) : + Specht.hilbertSpace μ →L[ℂ] Specht.hilbertSpace μ := + UnitaryFinite.sampleOperator (V := Specht.hilbertSpace μ) (Specht.relabelledUnitary μ e) + (fun ω : SwitchIndex d → Bool => if reverse then + (butterflyPerm d (decodeButterfly d ω))⁻¹ else butterflyPerm d (decodeButterfly d ω)) + +end Thorp.SparseContact + +namespace Thorp.SparseRegime + +def MainStatement : Prop := + ∃ (C : ℝ) (d₀ : ℕ), 0 < C ∧ 0 < d₀ ∧ + ∀ (d : ℕ) (μ : YoungDiagram) (e : Thorp.Card d ≃ Thorp.Specht.Cell μ), + let k := μ.card - μ.rowLen 0 + 1 ≤ k → k < 2^d → (d:ℝ)^((3:ℝ)/4) ≤ Real.log ((2:ℝ)^d/k) → + ∀ rev : Bool, + ‖Thorp.SparseContact.sweepOperator d μ e rev‖^2 ≤ + Real.exp (C*k)*((k:ℝ)/(2:ℝ)^d)^((k:ℝ)/4) ∧ + (d₀ ≤ d → ‖Thorp.SparseContact.sweepOperator d μ e rev‖^2 ≤ + ((k:ℝ)/(2:ℝ)^d)^((k:ℝ)/4)) + +end Thorp.SparseRegime + +end ThorpNine.SparseSaving + +theorem ThorpNine.main : + ThorpNine.Adaptive.Thorp.AdaptiveBounds.MainStatement ∧ + ThorpNine.Casimir.Thorp.CasimirBounds.MainStatement ∧ + ThorpNine.Dense.Thorp.DenseTruncation.MainStatement ∧ + ThorpNine.Contact.Thorp.SparseContact.MainStatement ∧ + ThorpNine.Harmonic.Thorp.HarmonicBounds.MainStatement ∧ + ThorpNine.Smoothing.Thorp.StrongSmoothing.MainStatement ∧ + ThorpNine.Tail.Thorp.StrongTail.MainStatement ∧ + ThorpNine.HighTail.Thorp.HighHeight.MainStatement ∧ + ThorpNine.SparseSaving.Thorp.SparseRegime.MainStatement := by + sorry + +end OAI diff --git a/lean/ComparatorChallenges/ThorpWeightedCompatibility.json b/lean/ComparatorChallenges/ThorpWeightedCompatibility.json new file mode 100644 index 0000000000000000000000000000000000000000..fcf2f01aa08275391d69a2cec7017fc80d9b96b6 --- /dev/null +++ b/lean/ComparatorChallenges/ThorpWeightedCompatibility.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThorpWeightedCompatibility", + "solution_module": "OAI.Probability.ThorpCompatibility.Main", + "theorem_names": [ + "OAI.ThorpCompatibility.weightedCompatibility_main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThorpWeightedCompatibility.lean b/lean/ComparatorChallenges/ThorpWeightedCompatibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ffa8457a98f50f5786f80b70e2dd2733902d5c5 --- /dev/null +++ b/lean/ComparatorChallenges/ThorpWeightedCompatibility.lean @@ -0,0 +1,52 @@ +import Mathlib + +namespace OAI + +open scoped Classical +namespace ThorpCompatibility +open Finset + +abbrev Rows (A D : ℕ) := Fin A → Equiv.Perm (Fin D) +abbrev Cols (A D : ℕ) := Fin D → Equiv.Perm (Fin A) + +def Compatible {A D : ℕ} (r : Rows A D) (c : Cols A D) : Prop := + ∀ j : Fin D, Function.Injective (fun i : Fin A => c (r i j) i) + +noncomputable def uniformMean {α : Type*} [Fintype α] (f : α → ℝ) : ℝ := + (∑ x, f x) / Fintype.card α + +noncomputable def marginalFactor {α : Type*} [Fintype α] + (θ : ℝ) (w : α → ℝ) : ℝ := + (uniformMean (fun x => Real.rpow (w x) (1 / θ))) ^ θ + +noncomputable def weightedCompatibility (A D : ℕ) + (w : Fin A → Equiv.Perm (Fin D) → ℝ) + (v : Fin D → Equiv.Perm (Fin A) → ℝ) : ℝ := by + classical + exact (Nat.factorial (A * D) : ℝ) / + ((Nat.factorial D : ℝ) ^ A * (Nat.factorial A : ℝ) ^ D) * + uniformMean (fun rc : Rows A D × Cols A D => + if Compatible rc.1 rc.2 then (∏ i, w i (rc.1 i)) * (∏ k, v k (rc.2 k)) else 0) + +def WeightedCompatibilityTheorem : Prop := + ∃ L C₀ m₀ : ℝ, 0 < L ∧ 0 < C₀ ∧ 0 < m₀ ∧ + ∀ A D : ℕ, + let n : ℝ := A * D + let m := Real.sqrt n + let θ := 1 - L / Real.log m + m₀ ≤ m → 0 < θ → m / ((2 : ℕ) : ℝ) ≤ A → (A : ℝ) ≤ ((2 : ℕ) : ℝ) * m → + m / ((2 : ℕ) : ℝ) ≤ D → (D : ℝ) ≤ ((2 : ℕ) : ℝ) * m → + ∀ (w : Fin A → Equiv.Perm (Fin D) → ℝ) + (v : Fin D → Equiv.Perm (Fin A) → ℝ), + (∀ i σ, 0 ≤ w i σ) → (∀ k σ, 0 ≤ v k σ) → + weightedCompatibility A D w v ≤ + Real.exp (C₀ * n ^ (((54 : ℕ) : ℝ) / ((100 : ℕ) : ℝ))) * + (∏ i, marginalFactor θ (w i)) * (∏ k, marginalFactor θ (v k)) + + +theorem weightedCompatibility_main : WeightedCompatibilityTheorem := by + sorry + +end ThorpCompatibility + +end OAI diff --git a/lean/ComparatorChallenges/ThreeMachine.json b/lean/ComparatorChallenges/ThreeMachine.json new file mode 100644 index 0000000000000000000000000000000000000000..f43edce328e71ef23b19fedfbf92a0a17755f1c7 --- /dev/null +++ b/lean/ComparatorChallenges/ThreeMachine.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThreeMachine", + "solution_module": "OAI.Computability.Scheduling.Main", + "theorem_names": [ + "OAI.ThreeMachine.main_theorem" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThreeMachine.lean b/lean/ComparatorChallenges/ThreeMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..82e56b4d0dd587adb74a804e2a11249e9e680f0e --- /dev/null +++ b/lean/ComparatorChallenges/ThreeMachine.lean @@ -0,0 +1,100 @@ +import Mathlib + +namespace OAI + +namespace ThreeMachine + +structure Instance (n : ℕ) where + edges : List (Fin n × Fin n) + +def Instance.edge {n : ℕ} (G : Instance n) (u v : Fin n) : Prop := + (u, v) ∈ G.edges + +def Instance.acyclic {n : ℕ} (G : Instance n) : Prop := + ∀ v, ¬Relation.TransGen G.edge v v + +def Feasible {n : ℕ} (G : Instance n) (T : ℕ) (τ : Fin n → ℕ) : Prop := + (∀ v, 1 ≤ τ v ∧ τ v ≤ T) ∧ + (∀ t, ((Finset.univ : Finset (Fin n)).filter (fun v => τ v = t)).card ≤ 3) ∧ + ∀ u v, G.edge u v → τ u < τ v + +def encodeNat (n : ℕ) : List Bool := + let b := Computability.encodeNat n + List.replicate b.length true ++ false :: b + +def encodeList {α : Type} (f : α → List Bool) (xs : List α) : List Bool := + encodeNat xs.length ++ xs.flatMap f + +def encodeInput {n : ℕ} (G : Instance n) (deadline : Option ℕ) : List Bool := + (match deadline with + | none => [false] + | some T => true :: encodeNat T) ++ + encodeList encodeNat ((List.range n).map (· + 1)) ++ + encodeList (fun (e : Fin n × Fin n) => encodeNat (e.1.val + 1) ++ + encodeNat (e.2.val + 1)) G.edges + +def encodeAnswer : Option (List ℕ) → List Bool + | none => [false] + | some slots => true :: encodeList encodeNat slots + +def slots {n : ℕ} (τ : Fin n → ℕ) : List ℕ := List.ofFn τ + +def CorrectOutput {n : ℕ} (G : Instance n) (deadline : Option ℕ) + (out : List Bool) : Prop := + match deadline with + | none => ∃ T τ, Feasible G T τ ∧ + (∀ T' τ', Feasible G T' τ' → T ≤ T') ∧ + out = encodeAnswer (some (slots τ)) + | some T => + (out = encodeAnswer none ∧ ¬∃ τ, Feasible G T τ) ∨ + ∃ τ, Feasible G T τ ∧ out = encodeAnswer (some (slots τ)) + +structure Machine (k q g : ℕ) where + transition : Fin (q + 1) → (Fin (k + 1) → Fin (g + 3)) → + Option (Fin (q + 1) × (Fin (k + 1) → Fin (g + 3) × Option Turing.Dir)) + +structure Configuration (k q g : ℕ) where + state : Fin (q + 1) + tapes : Fin (k + 1) → Turing.Tape (Fin (g + 3)) + +def bitSymbol {g : ℕ} (b : Bool) : Fin (g + 3) := + if b then ⟨2, by omega⟩ else ⟨1, by omega⟩ + +def Machine.step {k q g : ℕ} (M : Machine k q g) + (c : Configuration k q g) : Option (Configuration k q g) := do + let (state, action) ← M.transition c.state (fun i => (c.tapes i).head) + return { state := state, tapes := fun i => + let tape := (c.tapes i).write (action i).1 + match (action i).2 with + | none => tape + | some d => tape.move d } + +def Machine.initial {k q g : ℕ} (_M : Machine k q g) + (input : List Bool) : Configuration k q g := + { state := 0, tapes := fun i => + Turing.Tape.mk₁ (if i = 0 then input.map bitSymbol else []) } + +def Machine.run {k q g : ℕ} (M : Machine k q g) (input : List Bool) + (t : ℕ) : Configuration k q g := + (fun c => (M.step c).getD c)^[t] (M.initial input) + +def Machine.Produces {k q g : ℕ} (M : Machine k q g) + (input out : List Bool) (timeBound : ℕ) : Prop := + ∃ t ≤ timeBound, M.step (M.run input t) = none ∧ + ((M.run input t).tapes 0).right₀ = Turing.ListBlank.mk (out.map bitSymbol) + +def ReleaseTheorem : Prop := + ∃ (k q g : ℕ) (M : Machine k q g) (C : ℕ), 0 < C ∧ + ∀ n (G : Instance n), 1 ≤ n → G.acyclic → + ∀ deadline : Option ℕ, + (∀ T ∈ deadline, 1 ≤ T ∧ T ≤ n) → + ∃ out, CorrectOutput G deadline out ∧ + M.Produces (encodeInput G deadline) out + (C * ((encodeInput G deadline).length + 2) ^ 150020) + +theorem main_theorem : ReleaseTheorem := by + sorry + +end ThreeMachine + +end OAI diff --git a/lean/ComparatorChallenges/ThreeStateSupercritical.json b/lean/ComparatorChallenges/ThreeStateSupercritical.json new file mode 100644 index 0000000000000000000000000000000000000000..e4789b1a164596dd7154844ad98da386b100d043 --- /dev/null +++ b/lean/ComparatorChallenges/ThreeStateSupercritical.json @@ -0,0 +1,15 @@ +{ + "challenge_module": "ComparatorChallenges.ThreeStateSupercritical", + "solution_module": "OAI.Probability.ThreeState.Main", + "theorem_names": [ + "OAI.ThreeState.regular_supercritical", + "OAI.ThreeState.poisson_supercritical" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThreeStateSupercritical.lean b/lean/ComparatorChallenges/ThreeStateSupercritical.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe5745277c847260e359c23e1cacc8b1e66983ec --- /dev/null +++ b/lean/ComparatorChallenges/ThreeStateSupercritical.lean @@ -0,0 +1,108 @@ +import Mathlib + +namespace OAI + +namespace ThreeState + +abbrev Spin := Fin 3 + + +def Admissible (lam : ℝ) : Prop := -(1 / 2 : ℝ) ≤ lam ∧ lam ≤ 1 + + +noncomputable def channel (lam : ℝ) (i j : Spin) : ℝ := + if i = j then (1 + 2 * lam) / 3 else (1 - lam) / 3 + + + +def Observation : ℕ → Type + | 0 => Spin + | n + 1 => Multiset (Observation n) + +theorem channel_nonneg {lam : ℝ} (h : Admissible lam) (i j : Spin) : + 0 ≤ channel lam i j := by + unfold channel + split_ifs + · dsimp [Admissible] at h + linarith [h.1] + · dsimp [Admissible] at h + linarith [h.2] + +theorem channel_sum (lam : ℝ) (i : Spin) : ∑ j, channel lam i j = 1 := by + fin_cases i <;> simp [channel, Fin.sum_univ_succ] <;> ring + +noncomputable def channelPMF (lam : ℝ) (h : Admissible lam) (i : Spin) : PMF Spin := + PMF.ofFintype (fun j => ENNReal.ofReal (channel lam i j)) (by + rw [← ENNReal.ofReal_sum_of_nonneg (fun j _ => channel_nonneg h i j)] + simp [channel_sum]) + + +noncomputable def iidList {α : Type*} (p : PMF α) : ℕ → PMF (List α) + | 0 => PMF.pure [] + | n + 1 => p.bind fun a => (iidList p n).map (List.cons a) + + + +noncomputable def observedLaw (offspring : PMF ℕ) (lam : ℝ) (h : Admissible lam) : + (n : ℕ) → Spin → PMF (Observation n) + | 0, i => PMF.pure i + | n + 1, i => offspring.bind fun k => + (iidList ((channelPMF lam h i).bind (observedLaw offspring lam h n)) k).map + (fun xs : List (Observation n) => (xs : Multiset (Observation n))) + +noncomputable def uniformSpin : PMF Spin := PMF.ofFintype (fun _ => 1 / 3) (by + simp + exact ENNReal.mul_inv_cancel (by norm_num) (by finiteness)) + + +noncomputable def marginal {α : Type*} (law : Spin → PMF α) : PMF α := + uniformSpin.bind law + + +noncomputable def posterior {α : Type*} (law : Spin → PMF α) (y : α) (i : Spin) : ℝ := + if marginal law y = 0 then 1 / 3 + else (law i y).toReal / (3 * (marginal law y).toReal) + + + +noncomputable def advantage {α : Type*} (law : Spin → PMF α) : ℝ := + ∑' y, (marginal law y).toReal * + ((∑ i : Spin, |posterior law y i - 1 / 3|) / 2) + +noncomputable def regularLaw (b : ℕ) (lam : ℝ) (h : Admissible lam) (n : ℕ) := + observedLaw (PMF.pure b) lam h n + + +noncomputable def poissonOffspring (d : ℝ) (hd : 0 ≤ d) : PMF ℕ := by + refine ⟨fun k => ENNReal.ofReal (Real.exp (-d) * d ^ k / (k.factorial : ℝ)), ?_⟩ + apply ENNReal.hasSum_coe.2 + have hsum : HasSum (fun k : ℕ => Real.exp (-d) * d ^ k / (k.factorial : ℝ)) 1 := + ProbabilityTheory.hasSum_one_poissonMeasure ⟨d, hd⟩ + simpa using hsum.toNNReal (fun k => by positivity) + +noncomputable def poissonLaw (d : ℝ) (hd : 0 ≤ d) (lam : ℝ) + (h : Admissible lam) (n : ℕ) := + observedLaw (poissonOffspring d hd) lam h n + +noncomputable def regularAdvantage (b : ℕ) (lam : ℝ) (h : Admissible lam) (n : ℕ) : ℝ := + advantage (regularLaw b lam h n) + +noncomputable def poissonAdvantage (d : ℝ) (hd : 1 < d) (lam : ℝ) + (h : Admissible lam) (n : ℕ) : ℝ := + advantage (poissonLaw d (le_trans (by norm_num) hd.le) lam h n) + + +def Reconstructs (a : ℕ → ℝ) : Prop := + ∃ L : ℝ, 0 < L ∧ Filter.Tendsto a Filter.atTop (nhds L) + +theorem regular_supercritical (b : ℕ) (hb : 2 ≤ b) (lam : ℝ) (h : Admissible lam) + (hcrit : 1 < (b : ℝ) * lam ^ 2) : Reconstructs (regularAdvantage b lam h) := by + sorry + +theorem poisson_supercritical (d : ℝ) (hd : 1 < d) (lam : ℝ) (h : Admissible lam) + (hcrit : 1 < d * lam ^ 2) : Reconstructs (poissonAdvantage d hd lam h) := by + sorry + +end ThreeState + +end OAI diff --git a/lean/ComparatorChallenges/ThreeStateTreeClauses.json b/lean/ComparatorChallenges/ThreeStateTreeClauses.json new file mode 100644 index 0000000000000000000000000000000000000000..dd792c400944ee1c7238f7b14773505724f8965c --- /dev/null +++ b/lean/ComparatorChallenges/ThreeStateTreeClauses.json @@ -0,0 +1,15 @@ +{ + "challenge_module": "ComparatorChallenges.ThreeStateTreeClauses", + "definition_names": [], + "enable_nanoda": false, + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "solution_module": "OAI.Probability.ThreeStateClauses.Main", + "theorem_names": [ + "OAI.ThreeState.TreeClauses.Tree.regular_reconstructs_above_KS", + "OAI.ThreeState.TreeClauses.Tree.poisson_reconstructs_above_KS" + ] +} diff --git a/lean/ComparatorChallenges/ThreeStateTreeClauses.lean b/lean/ComparatorChallenges/ThreeStateTreeClauses.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0bdc7f256166c8fa888fe43e21c94427f0e3fd6 --- /dev/null +++ b/lean/ComparatorChallenges/ThreeStateTreeClauses.lean @@ -0,0 +1,104 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators ENNReal NNReal +open Filter + +namespace ThreeState.TreeClauses + +abbrev Spin := Fin 3 + +def Admissible (lam : ℝ) : Prop := -(1 / 2 : ℝ) ≤ lam ∧ lam ≤ 1 + +def channelWeight (lam : ℝ) (i j : Spin) : ℝ := + if i = j then (1 + 2 * lam) / 3 else (1 - lam) / 3 + +lemma channelWeight_nonneg {lam : ℝ} (hlam : Admissible lam) (i j : Spin) : + 0 ≤ channelWeight lam i j := by + unfold channelWeight + split_ifs <;> dsimp [Admissible] at hlam <;> linarith [hlam.1, hlam.2] + +lemma channelWeight_sum (lam : ℝ) (i : Spin) : ∑ j, channelWeight lam i j = 1 := by + fin_cases i <;> simp [channelWeight, Fin.sum_univ_three] <;> ring + +def channel (lam : ℝ) (hlam : Admissible lam) (i : Spin) : PMF Spin := + PMF.ofFintype (fun j ↦ ENNReal.ofReal (channelWeight lam i j)) (by + rw [← ENNReal.ofReal_sum_of_nonneg (fun j _ ↦ channelWeight_nonneg hlam i j), + channelWeight_sum] + norm_num) + +def Observation : ℕ → Type + | 0 => Spin + | n + 1 => Multiset (Observation n) + +def iidList {α : Type} (p : PMF α) : ℕ → PMF (List α) + | 0 => PMF.pure [] + | n + 1 => p.bind fun x ↦ (iidList p n).map (List.cons x) + +def observationLaw (lam : ℝ) (hlam : Admissible lam) (offspring : PMF ℕ) : + (ℓ : ℕ) → Spin → PMF (Observation ℓ) + | 0, i => PMF.pure i + | ℓ + 1, i => offspring.bind fun n ↦ + (iidList ((channel lam hlam i).bind (observationLaw lam hlam offspring ℓ)) n).map + (fun xs ↦ (xs : Multiset (Observation ℓ))) + +def jointWeight (lam : ℝ) (hlam : Admissible lam) (offspring : PMF ℕ) + (ℓ : ℕ) (i : Spin) (o : Observation ℓ) : ℝ≥0∞ := + (1 / 3 : ℝ≥0∞) * observationLaw lam hlam offspring ℓ i o + +def marginalWeight (lam : ℝ) (hlam : Admissible lam) (offspring : PMF ℕ) + (ℓ : ℕ) (o : Observation ℓ) : ℝ≥0∞ := + ∑ i, jointWeight lam hlam offspring ℓ i o + +def posterior (lam : ℝ) (hlam : Admissible lam) (offspring : PMF ℕ) + (ℓ : ℕ) (o : Observation ℓ) (i : Spin) : ℝ := + (jointWeight lam hlam offspring ℓ i o / marginalWeight lam hlam offspring ℓ o).toReal + +def advantage (lam : ℝ) (hlam : Admissible lam) (offspring : PMF ℕ) (ℓ : ℕ) : ℝ := + ∑' o : Observation ℓ, (marginalWeight lam hlam offspring ℓ o).toReal * + ((∑ i : Spin, |posterior lam hlam offspring ℓ o i - (1 / 3 : ℝ)|) / 2) + +def Reconstructs (lam : ℝ) (hlam : Admissible lam) (offspring : PMF ℕ) : Prop := + ∃ a : ℝ, 0 < a ∧ Tendsto (advantage lam hlam offspring) atTop (nhds a) + +namespace Probability + +def poissonWeight (rate : ℝ) (count : ℕ) : ℝ := + Real.exp (-rate) * rate ^ count / (count.factorial : ℝ) + +lemma poissonWeight_nonneg {rate : ℝ} (hrate : 0 ≤ rate) (count : ℕ) : + 0 ≤ poissonWeight rate count := by + unfold poissonWeight + positivity + +lemma poissonWeight_mass (rate : ℝ≥0) : HasSum (poissonWeight rate) 1 := + ProbabilityTheory.hasSum_one_poissonMeasure rate + +def _root_.OAI.ThreeState.TreeClauses.poissonPMF (rate : ℝ≥0) : PMF ℕ := by + refine ⟨fun count ↦ ENNReal.ofReal (poissonWeight rate count), ?_⟩ + apply ENNReal.hasSum_coe.mpr + rw [← Real.toNNReal_one] + exact (poissonWeight_mass rate).toNNReal (poissonWeight_nonneg rate.coe_nonneg) + +end Probability + +end ThreeState.TreeClauses + +open scoped Topology +namespace ThreeState.TreeClauses.Tree + +theorem regular_reconstructs_above_KS (b : ℕ) (lam : ℝ) (hlam : Admissible lam) + (hKS : 1 < (b:ℝ)*lam^2) : Reconstructs lam hlam (PMF.pure b) := by + sorry + +theorem poisson_reconstructs_above_KS (d : ℝ≥0) (lam : ℝ) (hlam : Admissible lam) + (hKS : 1 < (d:ℝ)*lam^2) : Reconstructs lam hlam (poissonPMF d) := by + sorry + +end ThreeState.TreeClauses.Tree + +end + +end OAI diff --git a/lean/ComparatorChallenges/ThreeTorus.json b/lean/ComparatorChallenges/ThreeTorus.json new file mode 100644 index 0000000000000000000000000000000000000000..4c6f960d349be47cf9078167ef6770dbc6449eb8 --- /dev/null +++ b/lean/ComparatorChallenges/ThreeTorus.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.ThreeTorus", + "solution_module": "OAI.Dynamics.ThreeTorus.Main", + "theorem_names": [ + "OAI.ThreeTorus.simple_lebesgue_spectrum" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/ThreeTorus.lean b/lean/ComparatorChallenges/ThreeTorus.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d7043b2fbc13f291681d8b5e0d924fe70fbe314 --- /dev/null +++ b/lean/ComparatorChallenges/ThreeTorus.lean @@ -0,0 +1,89 @@ +import Mathlib + +namespace OAI + +/-! +The torus is (ℝ/ℤ)³ with normalized product Haar measure. Smoothness means +local smooth lifts on the universal cover, for both the map and its inverse. + +The almost-everywhere graph conditions are independent of representatives of +L² classes. The real generator's bilateral Koopman orbit spans the entire +complex mean-zero L² space. The spectral model is the full circle L² space +with multiplication by the first Fourier character. +-/ + +noncomputable section +open MeasureTheory Set +open scoped ENNReal Topology + +namespace ThreeTorus + +abbrev Torus := Fin 3 → UnitAddCircle +abbrev Cover := Fin 3 → ℝ + +def project (x : Cover) : Torus := fun i => (x i : UnitAddCircle) + +def Smooth (T : Torus → Torus) : Prop := + ∀ x : Cover, ∃ U : Set Cover, IsOpen U ∧ x ∈ U ∧ + ∃ F : Cover → Cover, ContDiffOn ℝ ((⊤ : ℕ∞) : WithTop ℕ∞) F U ∧ + ∀ y ∈ U, T (project y) = project (F y) + +def μ : Measure Torus := Measure.pi (fun _ : Fin 3 => AddCircle.haarAddCircle) + +instance : IsProbabilityMeasure μ := by unfold μ; infer_instance + +abbrev H : Type := Lp ℂ 2 μ + +/-- The full complex subspace defined by zero Lebesgue integral. -/ +def meanZero : Submodule ℂ H where + carrier := {f | ∫ x, f x ∂μ = 0} + zero_mem' := by + change ∫ x, (0 : H) x ∂μ = 0 + rw [integral_congr_ae (Lp.coeFn_zero ℂ 2 μ)] + simp + add_mem' := by + intro f g hf hg + change ∫ x, (f + g) x ∂μ = 0 + rw [integral_congr_ae (Lp.coeFn_add f g)] + change ∫ x, f x + g x ∂μ = 0 + rw [integral_add (MemLp.integrable (by norm_num) (Lp.memLp f)) + (MemLp.integrable (by norm_num) (Lp.memLp g))] + change (∫ x, f x ∂μ) + (∫ x, g x ∂μ) = 0 + rw [show ∫ x, f x ∂μ = 0 from hf, show ∫ x, g x ∂μ = 0 from hg, add_zero] + smul_mem' := by + intro c f hf + change ∫ x, (c • f) x ∂μ = 0 + rw [integral_congr_ae (Lp.coeFn_smul c f)] + change ∫ x, c • f x ∂μ = 0 + rw [integral_smul] + rw [show ∫ x, f x ∂μ = 0 from hf, smul_zero] + +abbrev H₀ := ↥meanZero +abbrev CircleH : Type := Lp ℂ 2 (AddCircle.haarAddCircle (T := (1 : ℝ))) + +def IsReal (f : H₀) : Prop := ∀ᵐ x ∂μ, (f.1 x).im = 0 + +/-- Complete simple Lebesgue spectrum, including the stated consequences. -/ +def MainConclusion : Prop := + ∃ T : Equiv.Perm Torus, + Smooth T ∧ Smooth T.symm ∧ MeasurePreserving T μ μ ∧ + ∃ f : H₀, IsReal f ∧ + ∃ v : ℤ → H₀, + (∀ n : ℤ, ∀ᵐ x ∂μ, (v n).1 x = f.1 ((T ^ n) x)) ∧ + Orthonormal ℂ v ∧ + Dense (Submodule.span ℂ (Set.range v) : Set H₀) ∧ + Ergodic T μ ∧ + ∃ W : H₀ ≃ₗᵢ[ℂ] CircleH, + ∀ g : H₀, ∃ h : H₀, + (∀ᵐ x ∂μ, h.1 x = g.1 (T x)) ∧ + (∀ᵐ z ∂(AddCircle.haarAddCircle (T := (1 : ℝ))), + W h z = fourier 1 z * W g z) + +theorem simple_lebesgue_spectrum : MainConclusion := by + sorry + +end ThreeTorus + +end + +end OAI diff --git a/lean/ComparatorChallenges/TingleySphereIsometry.json b/lean/ComparatorChallenges/TingleySphereIsometry.json new file mode 100644 index 0000000000000000000000000000000000000000..32459dd80428ef43ab96d561995fbe7ae7659e4f --- /dev/null +++ b/lean/ComparatorChallenges/TingleySphereIsometry.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TingleySphereIsometry", + "solution_module": "OAI.Analysis.SphereIsometry.Main", + "theorem_names": [ + "OAI.Tingley.tingley_sphere_isometry_full" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TingleySphereIsometry.lean b/lean/ComparatorChallenges/TingleySphereIsometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8d14b099f558d62cffb37f1e6908d8661873ac2 --- /dev/null +++ b/lean/ComparatorChallenges/TingleySphereIsometry.lean @@ -0,0 +1,41 @@ +import Mathlib.Analysis.Normed.Module.RCLike.Basic +import Mathlib.Topology.MetricSpace.Isometry + +namespace OAI + +noncomputable section + +namespace Tingley + +universe u v + +abbrev UnitSphere (X : Type u) [NormedAddCommGroup X] := {x : X // ‖x‖ = 1} + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +def normalize (x : X) (hx : x ≠ 0) : UnitSphere X := + ⟨‖x‖⁻¹ • x, norm_smul_inv_norm hx⟩ + +/-- Radial formula, surjectivity, and uniqueness among all real-linear extensions. -/ +theorem tingley_sphere_isometry_full + {X : Type u} {Y : Type v} + [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] [CompleteSpace Y] + [Nontrivial X] [Nontrivial Y] + (f : UnitSphere X → UnitSphere Y) (hf : Isometry f) (hs : Function.Surjective f) : + ∃ T : X ≃ₗᵢ[ℝ] Y, + (∀ u : UnitSphere X, T (u : X) = (f u : Y)) ∧ + T 0 = 0 ∧ + (∀ x : X, ∀ hx : x ≠ 0, T x = ‖x‖ • (f (normalize x hx) : Y)) ∧ + Function.Surjective T ∧ + (∀ L : X →ₗ[ℝ] Y, (∀ u : UnitSphere X, L (u : X) = (f u : Y)) → + L = T.toLinearEquiv.toLinearMap) := by + sorry + +end Tingley + +end + +end OAI diff --git a/lean/ComparatorChallenges/TorsionFreeHyperbolic.json b/lean/ComparatorChallenges/TorsionFreeHyperbolic.json new file mode 100644 index 0000000000000000000000000000000000000000..486a8c4e75596e2bfb095576b454fc32c64f5d4d --- /dev/null +++ b/lean/ComparatorChallenges/TorsionFreeHyperbolic.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TorsionFreeHyperbolic", + "solution_module": "OAI.GroupTheory.Hyperbolic.Main", + "theorem_names": [ + "OAI.Release075.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TorsionFreeHyperbolic.lean b/lean/ComparatorChallenges/TorsionFreeHyperbolic.lean new file mode 100644 index 0000000000000000000000000000000000000000..83f9be6b2243d87bdc338c6e4e021a913704af90 --- /dev/null +++ b/lean/ComparatorChallenges/TorsionFreeHyperbolic.lean @@ -0,0 +1,43 @@ +import Mathlib + +namespace OAI + +namespace Release075 + +universe u v + +/-- No nonidentity element has finite order. This does not assert unique roots. -/ +def TorsionFree (G : Type u) [Group G] : Prop := + ∀ (g : G) (n : ℕ), 0 < n → g ^ n = 1 → g = 1 + +/-- A shortest edge path in the unit-edge graph. -/ +def Geodesic {V : Type u} (X : SimpleGraph V) {x y : V} (p : X.Walk x y) : Prop := + p.length = X.dist x y + +/-- Each vertex of `p` is within `δ` of a vertex of `q` or `r`. -/ +def SideThin {V : Type u} (X : SimpleGraph V) (δ : ℕ) {x y z : V} + (p : X.Walk x y) (q : X.Walk y z) (r : X.Walk z x) : Prop := + ∀ a ∈ p.support, ∃ b, (b ∈ q.support ∨ b ∈ r.support) ∧ X.dist a b ≤ δ + +/-- A finitely generated group with a unit-edge Cayley graph whose geodesic triangles +are uniformly thin. Connectedness of this Cayley graph asserts that `S` generates. -/ +def WordHyperbolic (G : Type u) [Group G] : Prop := + ∃ S : Set G, S.Finite ∧ (SimpleGraph.mulCayley S).Connected ∧ + ∃ δ : ℕ, ∀ (x y z : G) + (p : (SimpleGraph.mulCayley S).Walk x y) + (q : (SimpleGraph.mulCayley S).Walk y z) + (r : (SimpleGraph.mulCayley S).Walk z x), + Geodesic (SimpleGraph.mulCayley S) p → + Geodesic (SimpleGraph.mulCayley S) q → + Geodesic (SimpleGraph.mulCayley S) r → + SideThin (SimpleGraph.mulCayley S) δ p q r ∧ + SideThin (SimpleGraph.mulCayley S) δ q r p ∧ + SideThin (SimpleGraph.mulCayley S) δ r p q + +theorem main : ∃ (G : Type) (_ : Group G), + TorsionFree G ∧ WordHyperbolic G ∧ ¬ Group.ResiduallyFinite G := by + sorry + +end Release075 + +end OAI diff --git a/lean/ComparatorChallenges/TorsionFreeZeroDivisors.json b/lean/ComparatorChallenges/TorsionFreeZeroDivisors.json new file mode 100644 index 0000000000000000000000000000000000000000..2c51b21215bd7b38258dc2118811785e6feccf76 --- /dev/null +++ b/lean/ComparatorChallenges/TorsionFreeZeroDivisors.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TorsionFreeZeroDivisors", + "solution_module": "OAI.Algebra.GroupRing.Main", + "theorem_names": [ + "OAI.TorsionFreeZeroDivisors.main" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TorsionFreeZeroDivisors.lean b/lean/ComparatorChallenges/TorsionFreeZeroDivisors.lean new file mode 100644 index 0000000000000000000000000000000000000000..2dbb208512c5080fa9129b4aff5a2e5050755fc4 --- /dev/null +++ b/lean/ComparatorChallenges/TorsionFreeZeroDivisors.lean @@ -0,0 +1,40 @@ +import Mathlib + +namespace OAI + +namespace TorsionFreeZeroDivisors + +/-- Ordinary group torsion-freeness, without requiring uniqueness of all roots. -/ +def TorsionFree (G : Type) [Group G] : Prop := + ∀ (g : G) (n : ℕ), 0 < n → g ^ n = 1 → g = 1 + +/-- A connected finite Hausdorff 2-dimensional CW K(G,1). -/ +def HasFiniteTwoDimensionalClassifyingSpace (G : Type) [Group G] : Prop := + ∃ (X : Type) (topX : TopologicalSpace X), + letI : TopologicalSpace X := topX + ∃ (_hausdorff : T2Space X) (_connected : PathConnectedSpace X) + (cw : Topology.CWComplex (Set.univ : Set X)), + letI : Topology.CWComplex (Set.univ : Set X) := cw + Topology.CWComplex.Finite (Set.univ : Set X) ∧ + (∀ n : ℕ, 2 < n → IsEmpty (Topology.CWComplex.cell (Set.univ : Set X) n)) ∧ + Nonempty (Topology.CWComplex.cell (Set.univ : Set X) 2) ∧ + ∃ (x : X), Nonempty (G ≃* FundamentalGroup X x) ∧ + ∃ (E : Type) (topE : TopologicalSpace E), + letI : TopologicalSpace E := topE + ContractibleSpace E ∧ + ∃ p : E → X, IsCoveringMap p ∧ Function.Surjective p + +/-- The entire main theorem, including its "Moreover" clause. -/ +def MainTheorem : Prop := + ∃ (G : Type) (inst : Group G), + letI : Group G := inst + Group.IsFinitelyPresented G ∧ TorsionFree G ∧ + HasFiniteTwoDimensionalClassifyingSpace G ∧ + ∃ α β : MonoidAlgebra (ZMod 2) G, α ≠ 0 ∧ β ≠ 0 ∧ α * β = 0 + +theorem main : MainTheorem := by + sorry + +end TorsionFreeZeroDivisors + +end OAI diff --git a/lean/ComparatorChallenges/TotientAsymptotic.json b/lean/ComparatorChallenges/TotientAsymptotic.json new file mode 100644 index 0000000000000000000000000000000000000000..2322df92270f0bfa55eda8a1544bd765759681b6 --- /dev/null +++ b/lean/ComparatorChallenges/TotientAsymptotic.json @@ -0,0 +1,17 @@ +{ + "challenge_module": "ComparatorChallenges.TotientAsymptotic", + "solution_module": "OAI.NumberTheory.TotientAsymptotic.UnconditionalMain", + "theorem_names": [ + "OAI.TotientAsymptotic.totient_asymptotic_formula", + "OAI.TotientAsymptotic.weighted_totient_asymptotic", + "OAI.TotientAsymptotic.weighted_totient_one_two", + "OAI.TotientAsymptotic.coefficient_nonnegative" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TotientAsymptotic.lean b/lean/ComparatorChallenges/TotientAsymptotic.lean new file mode 100644 index 0000000000000000000000000000000000000000..37ec86e3512c5b838ffa9d7c3e94991ac11fb1bb --- /dev/null +++ b/lean/ComparatorChallenges/TotientAsymptotic.lean @@ -0,0 +1,155 @@ +import Mathlib + +namespace OAI + +/-! Totient counting and least-preimage asymptotics. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +def IsTotient (v : ℕ) : Prop := ∃ n : ℕ, 0 < n ∧ n.totient = v + +def V (x : ℝ) : ℝ := by + classical + exact (((Finset.Icc 1 ⌊x⌋₊).filter IsTotient).card : ℝ) + +def ell (v : ℕ) : ℕ := by + classical + exact if h : IsTotient v then Nat.find h else 0 + +def a (j : ℕ) : ℝ := (j + 1 : ℝ) * Real.log (j + 1) - j * Real.log j - 1 + +def RenewalRootSet : Set ℝ := + {z | 0 < z ∧ z < 1 ∧ (∑' j : ℕ, a (j+1) * z^(j+1)) = 1} + +def rho : ℝ := sInf RenewalRootSet + +def lam : ℝ := Real.log (1 / rho) + +def gamma : ℝ := (∑' j : ℕ, (j+1 : ℝ) * a (j+1) * rho^(j+1))⁻¹ + +def g : ℕ → ℝ + | 0 => 1 + | n+1 => ∑ d ∈ Finset.range (n+1), a (d+1) * g (n-d) +termination_by n => n + +def B (x : ℝ) : ℝ := Real.log (Real.log x) +def psi (b : ℝ) : ℝ := (Real.log b - Real.log (Real.log b)) / lam + +def m (x : ℝ) : ℕ := ⌊psi (B x)⌋₊ +def theta (x : ℝ) : ℝ := psi (B x) - m x + +def G (x : ℝ) (j : ℕ) : ℝ := + (B x)^j / ((Nat.factorial j : ℝ) * ∏ i ∈ Finset.Icc 1 j, g i) + +def P (H : ℕ) : ℕ := ⌊Real.log (Real.log (H : ℝ))⌋₊ +def alpha (s : ℝ) : ℝ := lam * Real.exp (lam * s) + +def largestPrimeFactor (n : ℕ) : ℕ := max 1 (n.primeFactors.sup id) + +structure TailDatum (H : ℕ) where + Q : Fin H → ℕ + cofactor : ℕ + +def tailPrime {H : ℕ} (η : TailDatum H) (h : ℕ) : ℕ := + if hH : h < H then η.Q ⟨h, hH⟩ else 1 + +def tailLog {H : ℕ} (η : TailDatum H) (h : ℕ) : ℝ := + Real.log (Real.log (tailPrime η h : ℝ)) + +def IsWitness (H : ℕ) (s : ℝ) (η : TailDatum H) : Prop := + (∀ h : Fin H, h.val < P H → η.Q h = 1) ∧ + 0 < η.cofactor ∧ + (∀ h ∈ Finset.Ico (P H) H, (tailPrime η h).Prime ∧ + (9 / 10 : ℝ) * alpha s * h * (rho^h)⁻¹ ≤ tailLog η h ∧ + tailLog η h ≤ (11 / 10 : ℝ) * alpha s * h * (rho^h)⁻¹ ∧ + (∑ l ∈ Finset.Ico (P H) h, a (h-l) * tailLog η l) ≤ + (1 + (1 / 10000 : ℝ) * Real.exp (-(h : ℝ) / 40)) * tailLog η h) ∧ + largestPrimeFactor η.cofactor ≤ tailPrime η (P H) ∧ + Real.log (η.cofactor : ℝ) ≤ + Real.exp (2 * alpha s * (P H : ℝ) * (rho^(P H))⁻¹) + +def w {H : ℕ} (η : TailDatum H) : ℕ := + η.cofactor * ∏ h ∈ Finset.Ico (P H) H, tailPrime η h + +def witnesses (H : ℕ) (s : ℝ) (d : ℕ) : Set (TailDatum H) := + {η | IsWitness H s η ∧ (w η).totient = d} + +def D {H : ℕ} (h : ℕ) (η : TailDatum H) : ℝ := + ∑ l ∈ Finset.Ico (P H) H, a (h-l) * tailLog η l + +def maxD {H : ℕ} (h : ℕ) (T : Finset (TailDatum H)) : ℝ := by + classical + exact if ht : T.Nonempty then T.sup' ht (D h) else 0 + +def AH (H : ℕ) (f : ℝ → ℝ) (s : ℝ) : ℝ := by + classical + exact rho^(H*(H-1)/2) * (gamma / alpha s)^H * + ∑ᶠ d : ℕ, + if IsTotient d then + f ((ell d : ℝ) / d) / d * + ∑ᶠ T : Finset (TailDatum H), + if T.Nonempty ∧ (↑T : Set (TailDatum H)) ⊆ witnesses H s d then + (-1 : ℝ)^(T.card-1) * + Real.exp (-(gamma / alpha s) * + ∑' n : ℕ, rho^(H+n) * maxD (H+n) T) + else 0 + else 0 + +def A (f : ℝ → ℝ) (s : ℝ) : ℝ := limUnder atTop (fun H : ℕ => AH H f s) + +def mainTerm (x : ℝ) : ℝ := x / Real.log x * G x (m x) * A (fun _ => 1) (theta x) + +def N (k : ℕ) (x : ℝ) : ℝ := by + classical + exact (((Finset.Icc 1 ⌊x⌋₊).filter fun v => + IsTotient v ∧ (k : ℝ) * x < ell v ∧ (ell v : ℝ) ≤ (k+1 : ℝ) * x).card : ℝ) + +def fk (k : ℕ) (r : ℝ) : ℝ := min 1 ((k+1 : ℝ) / r) - min 1 ((k : ℝ) / r) + +def normalizedCount (F : ℝ → ℝ) (x : ℝ) : ℝ := + F x / (x / Real.log x * G x (m x)) + +def tupleNormalization (x : ℝ) : ℝ := x / Real.log x * G x (m x) + +theorem totient_asymptotic_formula + : + TendstoUniformlyOn (fun H => AH H (fun _ => 1)) (A (fun _ => 1)) + atTop (Set.Ico (0 : ℝ) 1) ∧ + (∃ cMinus cPlus : ℝ, 0 < cMinus ∧ ∀ s ∈ Set.Ico (0 : ℝ) 1, + cMinus ≤ A (fun _ => 1) s ∧ A (fun _ => 1) s ≤ cPlus) ∧ + Tendsto (fun x => V x/mainTerm x) atTop (nhds 1) ∧ + ∀ c : ℝ, 0 < c → Tendsto (fun x => V (c*x)/V x) atTop (nhds c) := by + sorry + +theorem weighted_totient_asymptotic + (k : ℕ) (hk : 1≤k) : + TendstoUniformlyOn (fun H => AH H (fk k)) (A (fk k)) atTop (Set.Ico (0 : ℝ) 1) ∧ + Tendsto (fun x => normalizedCount (N k) x-A (fk k) (theta x)) atTop (nhds 0) ∧ + ((∃ d : ℕ, IsTotient d ∧ k*d N k x/(tupleNormalization x*A (fk k) (theta x))) atTop (nhds 1) ∧ + ∀ᶠ x : ℝ in atTop, (cMinus/cPlus)*V x≤N k x ∧ N k x≤V x) ∧ + ((¬∃ d : ℕ, IsTotient d ∧ k*d 1) s := by + sorry + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/ComparatorChallenges/TotientCompanionZero.json b/lean/ComparatorChallenges/TotientCompanionZero.json new file mode 100644 index 0000000000000000000000000000000000000000..704bb1bb7f8f6b8ddc698670f6a8d522cf1c617b --- /dev/null +++ b/lean/ComparatorChallenges/TotientCompanionZero.json @@ -0,0 +1,14 @@ +{ + "challenge_module": "ComparatorChallenges.TotientCompanionZero", + "solution_module": "OAI.NumberTheory.TotientAsymptotic.Main", + "theorem_names": [ + "OAI.TotientAsymptotic.companion_zero_case" + ], + "definition_names": [], + "permitted_axioms": [ + "propext", + "Quot.sound", + "Classical.choice" + ], + "enable_nanoda": false +} diff --git a/lean/ComparatorChallenges/TotientCompanionZero.lean b/lean/ComparatorChallenges/TotientCompanionZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..65f3674353abf748b8b42e6f221083b05684037b --- /dev/null +++ b/lean/ComparatorChallenges/TotientCompanionZero.lean @@ -0,0 +1,104 @@ +import Mathlib + +namespace OAI + +/-! The no-seed alternative of the weighted totient companion theorem. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +def IsTotient (v : ℕ) : Prop := ∃ n : ℕ, 0 < n ∧ n.totient = v + +def ell (v : ℕ) : ℕ := by + classical + exact if h : IsTotient v then Nat.find h else 0 + +def a (j : ℕ) : ℝ := (j + 1 : ℝ) * Real.log (j + 1) - j * Real.log j - 1 + +def RenewalRootSet : Set ℝ := + {z | 0 < z ∧ z < 1 ∧ (∑' j : ℕ, a (j+1) * z^(j+1)) = 1} + +def rho : ℝ := sInf RenewalRootSet + +def lam : ℝ := Real.log (1 / rho) + +def gamma : ℝ := (∑' j : ℕ, (j+1 : ℝ) * a (j+1) * rho^(j+1))⁻¹ + +def P (H : ℕ) : ℕ := ⌊Real.log (Real.log (H : ℝ))⌋₊ +def alpha (s : ℝ) : ℝ := lam * Real.exp (lam * s) + +def largestPrimeFactor (n : ℕ) : ℕ := max 1 (n.primeFactors.sup id) + +structure TailDatum (H : ℕ) where + Q : Fin H → ℕ + cofactor : ℕ + +def tailPrime {H : ℕ} (η : TailDatum H) (h : ℕ) : ℕ := + if hH : h < H then η.Q ⟨h, hH⟩ else 1 + +def tailLog {H : ℕ} (η : TailDatum H) (h : ℕ) : ℝ := + Real.log (Real.log (tailPrime η h : ℝ)) + +def IsWitness (H : ℕ) (s : ℝ) (η : TailDatum H) : Prop := + (∀ h : Fin H, h.val < P H → η.Q h = 1) ∧ + 0 < η.cofactor ∧ + (∀ h ∈ Finset.Ico (P H) H, (tailPrime η h).Prime ∧ + (9 / 10 : ℝ) * alpha s * h * (rho^h)⁻¹ ≤ tailLog η h ∧ + tailLog η h ≤ (11 / 10 : ℝ) * alpha s * h * (rho^h)⁻¹ ∧ + (∑ l ∈ Finset.Ico (P H) h, a (h-l) * tailLog η l) ≤ + (1 + (1 / 10000 : ℝ) * Real.exp (-(h : ℝ) / 40)) * tailLog η h) ∧ + largestPrimeFactor η.cofactor ≤ tailPrime η (P H) ∧ + Real.log (η.cofactor : ℝ) ≤ + Real.exp (2 * alpha s * (P H : ℝ) * (rho^(P H))⁻¹) + +def w {H : ℕ} (η : TailDatum H) : ℕ := + η.cofactor * ∏ h ∈ Finset.Ico (P H) H, tailPrime η h + +def witnesses (H : ℕ) (s : ℝ) (d : ℕ) : Set (TailDatum H) := + {η | IsWitness H s η ∧ (w η).totient = d} + +def D {H : ℕ} (h : ℕ) (η : TailDatum H) : ℝ := + ∑ l ∈ Finset.Ico (P H) H, a (h-l) * tailLog η l + +def maxD {H : ℕ} (h : ℕ) (T : Finset (TailDatum H)) : ℝ := by + classical + exact if ht : T.Nonempty then T.sup' ht (D h) else 0 + +def AH (H : ℕ) (f : ℝ → ℝ) (s : ℝ) : ℝ := by + classical + exact rho^(H*(H-1)/2) * (gamma / alpha s)^H * + ∑ᶠ d : ℕ, + if IsTotient d then + f ((ell d : ℝ) / d) / d * + ∑ᶠ T : Finset (TailDatum H), + if T.Nonempty ∧ (↑T : Set (TailDatum H)) ⊆ witnesses H s d then + (-1 : ℝ)^(T.card-1) * + Real.exp (-(gamma / alpha s) * + ∑' n : ℕ, rho^(H+n) * maxD (H+n) T) + else 0 + else 0 + +def A (f : ℝ → ℝ) (s : ℝ) : ℝ := limUnder atTop (fun H : ℕ => AH H f s) + +def N (k : ℕ) (x : ℝ) : ℝ := by + classical + exact (((Finset.Icc 1 ⌊x⌋₊).filter fun v => + IsTotient v ∧ (k : ℝ) * x < ell v ∧ (ell v : ℝ) ≤ (k+1 : ℝ) * x).card : ℝ) + +def fk (k : ℕ) (r : ℝ) : ℝ := min 1 ((k+1 : ℝ) / r) - min 1 ((k : ℝ) / r) + +/-- Without a totient value whose least preimage exceeds its prescribed multiple, +both the weighted count and its limiting coefficient vanish. -/ +theorem companion_zero_case (k : ℕ) (_hk : 0 < k) + (hno : ¬ ∃ d : ℕ, IsTotient d ∧ k*d < ell d) : + (∀ x : ℝ, 0 < x → N k x = 0) ∧ + (∀ s ∈ Set.Ico (0 : ℝ) 1, A (fk k) s = 0) := by + sorry + +end TotientAsymptotic +end + +end OAI