Research-Stack/0-Core-Formalism/lean/Semantics/Semantics/RRCLogogramProjection.lean
Brandon Schneider 835299fd9a fix(lean+shim): enforce lean-coding rules across audit surface
## Lean fixes

- RRCLogogramProjection.lean: replace `native_decide` → `decide` in 5
  compiler-surface theorem witnesses (semantic_tear_projects_after_repair,
  semantic_tear_does_not_merge, semantic_tear_uses_quarantine_lane,
  unrepaired_tear_does_not_project, ordinary_logogram_projects_and_merges).
  All 5 pass under `decide`; no logic change.

- PistSimulation.lean: add `-- expect: <value>` to every `#eval`/`#eval!`
  block across §6–§11 (~104 annotation lines). Document 8 undocumented
  `ofRawInt` magic integers in fixtureSpectralWindow (10.0, 20.0, 100.0,
  40.0, 20.0, 10.0, 5.0, 5.0 × 65536).

- DynamicCanal.lean: add `-- expect:` to all 15 #eval witness blocks in
  §17 (fixed-point constructors, DIAT encoding, coarse-graining tests).

- MISignal.lean: add `-- expect: 131072` to both #eval witnesses.

- Functions/BracketedCalculus.lean: add `-- expect: 327680` to #eval.

- AVMIsa/Emit.lean, RRC/Emit.lean, RRC/ReceiptDensity.lean, ReceiptCore.lean:
  previously-staged `-- expect:` additions (from prior session) carried
  forward in this commit.

## Python shim fixes

- Add `# PARTIAL BOUNDARY: contains domain logic; not a provable surface.
  Port to Lean/RRC before treating as authoritative.` to 9 shim files:
  pist_trace_classify_mcp.py, genus0_sphere_shell_demo.py,
  routing_benchmark.py, route_repair_v14a.py, pist_prove_and_classify.py,
  label_canary_theorems.py, validate_rrc_predictions.py,
  pist_receipt_density_injector.py, rrc_pist_shape_alignment.py.

## Build baseline

  lake build Compiler  →  3311 jobs, 0 errors
  lake build           →  3567 jobs, 0 errors

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 23:17:40 -05:00

177 lines
6.3 KiB
Text

/-!
# Rainbow Raccoon Compiler Logogram Projection
This module formalizes the small claim proven by the current Python receipt:
* a logogram can be type-admissible as a `LogogramProjection`;
* a torn logogram can be projection-admissible after repair/quarantine;
* the same torn logogram is not merge-admissible.
This is intentionally not a proof that the source mathematics is true. It is a
proof that the routing discipline separates type admission, projection
admission, and merge admission.
-/
namespace Semantics.RRCLogogramProjection
/-- Lawful RRC type-shapes currently used by the shim. -/
inductive RRCShape where
| signalShapedRouteCompiler
| projectableGeometryTopology
| cognitiveLoadField
| cadForceProbeReceipt
| logogramProjection
| holdForUnlawfulOrUnderspecifiedShape
deriving DecidableEq, Repr
/-- RRC witness status. `candidate` is not a proof; it only admits next-stage checks. -/
inductive WitnessStatus where
| candidate
| hold
deriving DecidableEq, Repr
/-- Semantic topology regime for a compiled logogram. -/
inductive SemanticRegime where
| beautifulTopologicalFolding
| uglyAsymmetricPruning
| horribleManifoldTearing
deriving DecidableEq, Repr
/-- Projection lane chosen after semantic-regime gating. -/
inductive ProjectionLane where
| normalProjection
| quarantineProjection
deriving DecidableEq, Repr
/-- Receipt core for one compiled logogram projection. -/
structure LogogramReceipt where
shape : RRCShape
status : WitnessStatus
regime : SemanticRegime
payloadBound : Bool
contradictionWitness : Bool
tearBoundary : Bool
detachedMass : Bool
residualLane : Bool
deriving Repr
/-- A tear is repaired only when it has all quarantine evidence. -/
def hasTearRepair (r : LogogramReceipt) : Bool :=
r.contradictionWitness && r.tearBoundary && r.detachedMass && r.residualLane
/-- Type admission: the object has the RRC logogram shape and bounded payload. -/
def typeAdmissible (r : LogogramReceipt) : Bool :=
r.shape == RRCShape.logogramProjection &&
r.status == WitnessStatus.candidate &&
r.payloadBound
/-- Merge admission: only non-tearing logogram projections may enter ordinary merge space. -/
def mergeAdmissible (r : LogogramReceipt) : Bool :=
typeAdmissible r &&
r.regime != SemanticRegime.horribleManifoldTearing
/-- Projection admission: non-tears project normally; repaired tears project into quarantine. -/
def projectionAdmissible (r : LogogramReceipt) : Bool :=
typeAdmissible r &&
(r.regime != SemanticRegime.horribleManifoldTearing || hasTearRepair r)
/-- Lane choice is a pure function of the semantic regime. -/
def projectionLane (r : LogogramReceipt) : ProjectionLane :=
if r.regime == SemanticRegime.horribleManifoldTearing then
ProjectionLane.quarantineProjection
else
ProjectionLane.normalProjection
/-- The repaired `semantic_tear` receipt from the Python bridge, abstracted to booleans. -/
def semanticTearReceipt : LogogramReceipt :=
{ shape := RRCShape.logogramProjection
status := WitnessStatus.candidate
regime := SemanticRegime.horribleManifoldTearing
payloadBound := true
contradictionWitness := true
tearBoundary := true
detachedMass := true
residualLane := true }
/-- An ordinary logogram projection with no tear. -/
def ordinaryLogogramReceipt : LogogramReceipt :=
{ shape := RRCShape.logogramProjection
status := WitnessStatus.candidate
regime := SemanticRegime.uglyAsymmetricPruning
payloadBound := true
contradictionWitness := false
tearBoundary := false
detachedMass := false
residualLane := false }
/-- A torn logogram with no repair evidence remains projection-inadmissible. -/
def unrepairedTearReceipt : LogogramReceipt :=
{ shape := RRCShape.logogramProjection
status := WitnessStatus.candidate
regime := SemanticRegime.horribleManifoldTearing
payloadBound := true
contradictionWitness := false
tearBoundary := false
detachedMass := false
residualLane := false }
/-! ## Executable theorem witnesses -/
theorem semantic_tear_projects_after_repair :
projectionAdmissible semanticTearReceipt = true := by
decide
theorem semantic_tear_does_not_merge :
mergeAdmissible semanticTearReceipt = false := by
decide
theorem semantic_tear_uses_quarantine_lane :
projectionLane semanticTearReceipt = ProjectionLane.quarantineProjection := by
decide
theorem unrepaired_tear_does_not_project :
projectionAdmissible unrepairedTearReceipt = false := by
decide
theorem ordinary_logogram_projects_and_merges :
projectionAdmissible ordinaryLogogramReceipt = true ∧
mergeAdmissible ordinaryLogogramReceipt = true ∧
projectionLane ordinaryLogogramReceipt = ProjectionLane.normalProjection := by
decide
/-- Any merge-admissible logogram is also projection-admissible. -/
theorem merge_implies_projection (r : LogogramReceipt) :
mergeAdmissible r = true -> projectionAdmissible r = true := by
unfold mergeAdmissible projectionAdmissible
intro h
cases hType : typeAdmissible r
· simp [hType] at h
· cases hRegime : (r.regime != SemanticRegime.horribleManifoldTearing)
· simp [hType, hRegime] at h
· exact rfl
/-- A repaired tear is projection-admissible but not merge-admissible. -/
theorem repaired_tear_separates_projection_from_merge
(r : LogogramReceipt)
(hType : typeAdmissible r = true)
(hTear : r.regime = SemanticRegime.horribleManifoldTearing)
(hRepair : hasTearRepair r = true) :
projectionAdmissible r = true ∧ mergeAdmissible r = false := by
constructor
· unfold projectionAdmissible
simp [hType, hTear, hRepair]
· unfold mergeAdmissible
simp [hType, hTear]
/-! ## Eval witnesses for script/readback use. -/
-- semanticTearReceipt: repaired tear, logogram type → admissible for projection, not merge, normal lane
#eval projectionAdmissible semanticTearReceipt -- expect: true
#eval mergeAdmissible semanticTearReceipt -- expect: false
#eval projectionLane semanticTearReceipt -- expect: Semantics.RRCLogogramProjection.ProjectionLane.quarantineProjection
-- unrepairedTearReceipt: unrepaired tear → not admissible for projection
#eval projectionAdmissible unrepairedTearReceipt -- expect: false
-- ordinaryLogogramReceipt: no tear → merge admissible
#eval mergeAdmissible ordinaryLogogramReceipt -- expect: true
end Semantics.RRCLogogramProjection