[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"Ck5gFHnn4l":3},"# lean-canny\n\nA Lean formalization of the theorem that the\nExistential Theory of the Reals (ETR) is in PSPACE,\nor stated in terms of complexity-theory classes: ∃ℝ ⊆ PSPACE,\nand native PSPACE bounds for semialgebraic point and whole-space connectivity.\nThis theorem is from John Canny's 1988 technical report\n[*Some Algebraic and Geometric Computations in PSPACE*](https://www2.eecs.berkeley.edu/Pubs/TechRpts/1988/6041.html)\n(stored in this repo as [`canny-tr.pdf`](canny-tr.pdf)), published as a\n[STOC ’88 paper](https://doi.org/10.1145/62212.62257) (pp. 460–467).\n\nThe main results in\n[`ETR/CoercivePSPACE.lean`](LeanCanny/ETR/CoercivePSPACE.lean) are:\n\n```lean\nLeanCanny.ETR.etr_mem_PSPACE : LeanCanny.ETR.language ∈ LeanCanny.PSPACE\nLeanCanny.ETR.existsReal_subset_PSPACE : LeanCanny.ExistsReal ⊆ LeanCanny.PSPACE\n```\n\nThese are unconditional theorems for the project's encoded ETR language and\n[Complexitylib](https://github.com/cslib-community/complexitylib)'s\nmachine-based PSPACE class. The coefficient algorithms,\nmetadata preparation, recursive evaluation, and final sign decisions are\nconstructed internally. The development uses Lean 4.36.0-rc1 with pinned\nMathlib, CSLib, and Complexitylib dependencies.\n\nThis establishes the report's ETR and connectivity PSPACE upper bounds for the\nencoded problems below. Explicit roadmap output and motion-planning interfaces\nare separate from these language-membership results.\nThe proof uses a coercive one-parameter sampling construction; it does not\nformalize every intermediate construction in the report verbatim.\n\nThe formalization also identifies a [gap in Canny's coordinate-recovery\nargument](RESEARCH.md#gap-in-cannys-symmetric-coordinate-recovery): three\ncollinear solutions can produce a cubic GCD where the construction requires a\nlinear one, regardless of the projection coefficients. The completed PSPACE\nproof avoids this failed step.\n\nFor independently readable, checked statements of all three PSPACE bounds, see\n[`Abstract.lean`](LeanCanny/Abstract.lean). A reader can inspect its definitions\nand theorem statements to assess the claimed result; Lean verifies the proofs\nthrough [`AbstractBridge.lean`](LeanCanny/AbstractBridge.lean) and the development.\nAll public definitions are local to the abstract or use background libraries.\nA declaration-driven command generates the local flat token encoding using\nComplexitylib encoders; its PSPACE transfer is checked\nin [`AbstractEncodingBridge.lean`](LeanCanny/AbstractEncodingBridge.lean).\n\n## ETR proof outline\n\n1. **Compile ETR to one integer equation.** The binary grammar, normalization,\n   and equation compiler have native polynomial-time certificates. Correctness\n   covers every bitstring; malformed formulas are rejected. Degree, arity,\n   encoded length, and coefficient-mass bounds are derived from the input.\n2. **Construct bounded critical samples.** For the compiled polynomial q,\n   minimize `q² + s * Σ Xᵢ^(2D+2)` as positive s tends to zero. Its gradient has\n   finite fibers for every nonzero s. Bounded integer coordinate annihilants\n   give a source-size root radius, so satisfiability is equivalent to eventual\n   bounded critical samples with the required residual and penalty bounds.\n3. **Compute annihilants and primitive coordinates.** A fixed full Macaulay\n   block determinant supplies nonzero coordinate annihilants. Native modular\n   readers feed actual integer degree/GCD/direction preparation. A uniform\n   recursive symbolic evaluator computes the prepared primitive parameter;\n   indexed pair readers and ordered matrix products compute its rational\n   coordinates. All child computation costs and malformed metadata cases are\n   included in the space certificates.\n4. **Decide eventual signs.** Even denominator clearing preserves the sample\n   equations and inequalities. Native readers compute the resulting integer\n   bivariate queries without storing their expanded coefficients. The\n   infinitesimal root/sign decision procedure decides four sign patterns in\n   PSPACE. Their union is exactly ETR; closure under polynomial-time reductions\n   gives `ExistsReal ⊆ PSPACE`.\n\nSelected entry points:\n\n| Stage | Modules |\n| --- | --- |\n| Encoding and compilation | [`Grammar`](LeanCanny/ETR/Grammar.lean), [`EquationCompilerFP`](LeanCanny/ETR/EquationCompilerFP.lean), [`Complexity`](LeanCanny/ETR/Complexity.lean) |\n| Bounded sample semantics | [`CoerciveSourceSampling`](LeanCanny/ETR/CoerciveSourceSampling.lean), [`CoerciveRootRadius`](LeanCanny/Geometry/CoerciveRootRadius.lean) |\n| Actual annihilator and query coefficients | [`CoerciveNativeOriginalResidue`](LeanCanny/ETR/CoerciveNativeOriginalResidue.lean), [`CoerciveQueryCoefficient`](LeanCanny/ETR/CoerciveQueryCoefficient.lean) |\n| Native preparation and symbolic parameter | [`CoerciveIntegerPreparation`](LeanCanny/ETR/CoerciveIntegerPreparation.lean), [`CoerciveTableCorrectness`](LeanCanny/ETR/CoerciveTableCorrectness.lean), [`CoerciveParameterCoefficient`](LeanCanny/ETR/CoerciveParameterCoefficient.lean) |\n| Coordinates and cleared queries | [`CoerciveCoordinatePairReaders`](LeanCanny/ETR/CoerciveCoordinatePairReaders.lean), [`CoerciveClearedQueryCoefficient`](LeanCanny/ETR/CoerciveClearedQueryCoefficient.lean) |\n| Final decision | [`CoerciveInfinitesimalSemantics`](LeanCanny/ETR/CoerciveInfinitesimalSemantics.lean), [`CoercivePSPACE`](LeanCanny/ETR/CoercivePSPACE.lean) |\n\n[`SpaceFunction`](LeanCanny/Computation/SpaceFunction.lean) wraps\nComplexitylib's `ComputableInPolySpace`.\n[`SpaceDecider`](LeanCanny/Computation/SpaceDecider.lean) carries membership in\nits native PSPACE class. Polynomial-time reductions and all FP controls also\nuse Complexitylib directly. Space composition charges the original readers;\nno free coefficient oracle or execution-time bound on a space-bounded child\nis assumed.\n\n## Alternative constructions\n\nThe default `LeanCanny` library and `import LeanCanny` contain the completed\nETR and connectivity proofs through the formal abstract. The optional\n`LeanCannyAlternatives` library is available through\n`import LeanCanny.Alternatives`; it also imports\nthe completed result. All source modules retain their existing paths.\n\nThe repository also develops Canny's compact tube and generic projection\nconstructions, projective elimination, finite-root sign feasibility, and\nnonsingular tube sampling. These are independently proved ingredients and\nalternative samplers. The tube route's effective epsilon/delta/direction and\nretained-level choices are unresolved; the completed ETR theorem uses the\ncoercive route and does not depend on those choices.\n\nFurther work includes relating this encoding to other ETR presentations,\nproving the NP lower inclusion, and constructing explicit roadmaps and\nmotion-planning interfaces. The alternative library remains checked by the full\nverification commands below.\nSee [`RESEARCH.md`](RESEARCH.md) for prior work,\nproof details, and the unused tube route's precise gaps.\n\n## Connectivity\n\nThe separate `LeanCannyConnectivity` target (`import LeanCanny.Connectivity`)\nproves both original connectivity languages are in native PSPACE:\n\n```lean\nLeanCanny.Connectivity.pointLanguage_mem_PSPACE :\n  LeanCanny.Connectivity.pointLanguage ∈ LeanCanny.PSPACE\nLeanCanny.Connectivity.connectedLanguage_mem_PSPACE :\n  LeanCanny.Connectivity.connectedLanguage ∈ LeanCanny.PSPACE\n```\n\nThe closed statements are in\n[`NativeConnectivityPSPACE.lean`](LeanCanny/Connectivity/NativeConnectivityPSPACE.lean).\nInputs contain a unary dimension and arbitrary Boolean combinations of integer\npolynomial sign conditions. Point inputs describe singleton endpoints by formulas,\nallowing irrational algebraic points. Whole-space connectivity means\n`IsPreconnected`, accepting the empty set. Malformed, ill-scoped, inconsistent\nand nonunique endpoint inputs are rejected. Neither theorem takes a geometric\nmodel, component oracle, edge evaluator or radius bound as a premise.\n\nThe construction checks both original component labels, the actual radial grid\nand every interval cut on one complete sampler tuple. The original frontier\nedge is exactly projected-sample equality or oriented guarded joint feasibility.\nEndpoint formulas select existing samples after adding tautologies that preserve\nthe space. Native finite graph scans finish both decision procedures.\nSee the [connectivity proof outline](RESEARCH.md#connectivity-proof-outline)\nand [correctness pitfalls](RESEARCH.md#connectivity-correctness-pitfalls)\nfor the construction and the failed shortcuts it must avoid. Detailed\n[construction notes](CONNECTIVITY-PROTOTYPE.txt) and the\n[historical checkpoint ledger](CONNECTIVITY-HISTORY.md) are separate.\n\n## Attribution and report integrity\n\nThe Sturm–Tarski proof adaptation and its changes are documented in\n[`STURM_SOURCES.md`](STURM_SOURCES.md).\n\nThe report PDF [`canny-tr.pdf`](canny-tr.pdf) is from the\n[Berkeley Technical Reports archive](https://www2.eecs.berkeley.edu/Pubs/TechRpts/1988/Archive/CSD-88-439.pdf).\nThe downloaded file has 936,246 bytes and SHA-256\n`7606d41dea23ac1160562a759c196267906d8aec0f754cd4998fdd14fcd185f8`.\nThe report retains its original rights; the source-code license does not apply\nto it.\n\n## Build and verification\n\nInstall [elan](https://github.com/leanprover/elan), then run:\n\n```sh\nlake update\nlake exe cache get\nlake build\n```\n\n[`lean-toolchain`](lean-toolchain) and [`lake-manifest.json`](lake-manifest.json)\nrecord the versions used. The default entry point is [`LeanCanny.lean`](LeanCanny.lean).\n`lake build` checks the formal abstract and its completed proofs. To build the\nretained alternative constructions, run `lake build LeanCannyAlternatives`;\ntheir entry point is [`Alternatives.lean`](LeanCanny/Alternatives.lean).\nBuild the connectivity extension with `lake build LeanCannyConnectivity`.\n\nImport the formal abstract with `import LeanCanny.Abstract`, or build it with\n`lake build --wfail LeanCanny.Abstract`. It is also included in the default build.\n\nDependencies are pinned to Complexitylib revision `393e2b13` and Lean\n`v4.36.0-rc2`, with matching CSLib and Mathlib revisions. The Lake package is\n`complexitylib`, from its canonical `cslib-community/complexitylib` repository.\nThe build targets above require only their transitive dependency imports;\nthey do not build Complexitylib's full library or result collection.\n\nFor stricter verification:\n\n```sh\nlake build LeanCanny LeanCannyAlternatives LeanCannyConnectivity --wfail --iofail\nlake env lean scripts/CheckCoreImports.lean\nlake env lean scripts/CheckAxioms.lean\nlake env lean scripts/CheckAbstract.lean\nlake env lean scripts/CheckAbstractEncoding.lean\nlake env lean scripts/CheckGrammar.lean\nlake env lean scripts/CheckSpaceFoundation.lean\nlake env lean scripts/CheckPolyTimeFoundation.lean\nlake env lean scripts/CheckConnectivity.lean\nlake env lean scripts/CheckJointFrontier.lean\nlake env lean scripts/CheckConnectivityPSPACE.lean\nlake env lean scripts/CheckImplicitStratumSampler.lean\nlake env lean scripts/CheckEffectiveBallConnections.lean\nlake env lean scripts/CheckProviderAtomic.lean\nlake env lean scripts/CheckProviderSemantics.lean\nlake env lean scripts/CheckProviderRecursive.lean\nlake env lean scripts/CheckAlgebraicArcs.lean\nlake env lean scripts/CheckAffineShiftArcs.lean\nlake env lean scripts/CheckIntegerGridValues.lean\nlake env lean scripts/CheckIntegerGridArcs.lean\nlake env lean scripts/CheckFiniteFiberSlabs.lean\nlake env lean scripts/CheckBinaryValueReaders.lean\nlake env lean scripts/CheckGridValueReaders.lean\nlake env lean scripts/CheckEndpointMidpoints.lean\nlake env lean scripts/CheckAffineShiftReaders.lean\nlake env lean scripts/CheckActualHeightReaders.lean\nlake env lean scripts/CheckRoadmapBridges.lean\nlake env lean scripts/CheckRoadmapChains.lean\nlake env lean scripts/CheckRoadmapEncoding.lean\nlake env lean scripts/CheckRoadmapInternal.lean\nlake env lean scripts/CheckRoadmapLevels.lean\nlake env lean scripts/CheckRoadmapNativeGraph.lean\nlake env lean scripts/CheckRoadmapOccurrences.lean\nlake env lean scripts/CheckRoadmapOrigins.lean\n```\n\nThe core import check keeps the ETR endpoint independent of the optional tube\nroute. The formal abstract also imports connectivity and its shared algebra.\nThe axiom and space audits include all three library targets. The axiom audit checks\ndeclarations in the `LeanCanny` namespace, local Nat\ncodec extensions, and their transitive dependencies, allowing only Lean's\nstandard `propext`, `Classical.choice`, and `Quot.sound` axioms. The foundation\nchecks enforce the native Complexitylib time and space interfaces and reject\nlegacy machine dependencies. `CheckAbstract` also follows public definitions\nand statement dependencies to reject hidden implementation references.\n",1794686186816]