BioSight/harness/lean_formalism.md
allaun e0b2283972 feat(phi): full docstring + verification hardening pass
Every function in all 5 phi modules now has:
- Google-style docstring with Args/Returns/Examples
- Verified behavior via doctest examples (46 total)
- Self-verification assertion blocks on direct execution

Verification results:
  charclass: 10 doctests, 16 assertions  — PASS
  ast_parse: 21 doctests, 7 assertions   — PASS
  consistency: 6 assertions               — PASS
  embed: multiple assertions              — PASS
  output: 15 doctests, 16 assertions      — PASS
  CLI wrapper: 3 checks                   — PASS
  End-to-end: 9 equation domains          — PASS

Also added:
- .opencode/opencode.jsonc (gemma4 MCP config)
- phi/AGENTS.md (module-level contract)
- phi/test_phi.py (unittest test file)
- phi/encoding_rationale.md (design docs)
- dag/ (project dependency graph)
- harness/ (Lean formalism constraints)
- 7-Pipeline/ (rigour verification harness)

Build: python3 -W error -m py_compile — 0 warnings
2026-06-24 03:57:50 -05:00

1.3 KiB

Harness: Lean Formalism

Context

This harness defines the constraints for all Lean-based formalization within the SilverSight/BioSight project. Use these rules to minimize LLM drift during proof construction.

Core Quirks & Constraints

  1. Fixed-Point Arithmetic:

    • NEVER use Float in core compute paths.
    • Always use Q16_16 (mixed) or Q0_16 (pure fraction).
    • Exception: External boundary inputs/outputs (JSON parsing, sensor data).
  2. The Closure Constraint (Rule 7):

    • Every formal claim must be "closed" under the operation defined by its DNA Signature.
    • If a theorem is incomplete, it's not just a sorry; it must have a TODO(lean-port) describing why it's open.
  3. DNA Mapping Alignment:

    • The Lean proof structure must mirror the BioSight \tau (topology) and \delta (depth) values.
    • Example: A high \delta value implies nested definitions or recursive structures in Lean.
  4. Verification Protocol:

    • Every change requires a lake build.
    • No "bare" sorries are allowed unless they represent a specific, identified gap in the logic.
    • Use #eval to provide witnesses for every major theorem.

Reference Anchors

  • Base Type: Semantics.FixedPoint.Q16_16
  • Core Module: 0-Core-Formalism/lean/Semantics/