Skip to content

fix(proofs): repair WokeLang.lean to verify under Lean 4.30.0 + add CI gate#79

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/sleepy-carson-bREoV
Jun 14, 2026
Merged

fix(proofs): repair WokeLang.lean to verify under Lean 4.30.0 + add CI gate#79
hyperpolymath merged 1 commit into
mainfrom
claude/sleepy-carson-bREoV

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

The Lean 4 formal-verification file docs/proofs/verification/WokeLang.lean claimed "all 12 sorry eliminated / verified" — but it had silently bit-rotted and did not compile under a current Lean toolchain (~100 errors). Root cause: no CI ever ran the prover (workflows only covered the OCaml core + e2e), so the headline correctness claim was never machine-enforced.

This PR restores sorry-free compilation under Lean 4.30.0, adds the missing CI gate, and documents a coverage/correspondence audit.

What changed

Only proof bodies + 2 deriving clauses + 1 abbrev — every theorem signature and every inductive is byte-identical (verified by diff). No statement was weakened; no sorry/admit/axiom introduced.

Root causes fixed:

  • DecidableEq no longer derives for Value/WokeType (Float has none — NaN; and nested List Self blocks the deriving handler) → reduced to deriving Repr; equality decisions use Lean's classical by_cases (no instance needed).
  • induction/cases on concrete indices (emptyTypeEnv, emptyEnv) + binder-arity drift across Lean versions. preservation made type-polymorphic via induction hs generalizing t (its congruence cases need the IH at the operand type, not the result type). cases … with | inr ⟨..⟩ anonymous-constructor patterns → obtain (no longer supported in cases). Type-mismatched reduction siblings discharged with nomatch.
  • BEq Permission: made Permission a reducible abbrev so the String instance transfers.

Verification

$ lean docs/proofs/verification/WokeLang.lean   # exit 0, no output

Machine-checked: progress, preservation, type_safety (multi-step), consent_monotonicity, consent_preservation — for the expression core (incl. the Result/unwrap/error panic-propagation fragment).

Added

  • docs/proofs/verification/lean-toolchain — pins Lean v4.30.0.
  • docs/proofs/verification/AUDIT.md — answers PROOF-NEEDS.md WokeLang EBNF grammar specification #1 & Implement WokeLang interpreter in Rust #2: the proofs cover a clean expression core (a strict, honestly-scoped subset), the Lean type system corresponds to the Rust typechecker (not the OCaml core/eval.ml, which models a different language), and the consent theorems correspond to the spec's Hoare logic.
  • .github/workflows/lean-proofs.yml — installs the pinned toolchain and runs the check on every push to the proof dir, so this can't bit-rot again. SHA-pinned action, pure-bash install (matches estate governance).

Note on scope

This repairs and re-verifies the existing proofs and makes them durable. It does not yet extend coverage (more binops/comparisons, statements, arrays, compiler/VM correctness) — those remain per PROOF-NEEDS.md and are tabulated in AUDIT.md.

https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7


Generated by Claude Code

…I gate

The Lean4 verification file claimed "sorry-free, verified" but had bit-rotted:
it did not compile under current Lean, because no CI ever ran the prover.
Restore sorry-free compilation under Lean 4.30.0 with NO weakened statements
(only proof bodies + 2 deriving clauses + 1 abbrev changed; every theorem
signature and inductive is byte-identical), and add the missing CI gate.

Root causes fixed:
- DecidableEq no longer derives for Value/WokeType (Float has none; nested
  List blocks the handler) -> drop to `deriving Repr`; equality decisions use
  classical `by_cases` (no instance needed).
- induction/cases on the concrete emptyTypeEnv/emptyEnv indices + Lean binder
  arity drift; preservation made type-polymorphic via `induction hs
  generalizing t`; `cases ... with | inr ⟨..⟩` -> `obtain`; type-mismatched
  reduction siblings discharged with `nomatch`.
- BEq Permission: make Permission a reducible `abbrev`.

Verified: `lean docs/proofs/verification/WokeLang.lean` exits 0, zero
sorry/admit/axiom. progress, preservation, type_safety,
consent_{monotonicity,preservation} all machine-checked.

Adds:
- docs/proofs/verification/lean-toolchain  (pin Lean v4.30.0)
- docs/proofs/verification/AUDIT.md         (coverage/correspondence audit)
- .github/workflows/lean-proofs.yml         (CI gate so it cannot rot again)

https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7
@hyperpolymath
hyperpolymath marked this pull request as ready for review June 14, 2026 04:02
@hyperpolymath
hyperpolymath merged commit 343867d into main Jun 14, 2026
15 of 18 checks passed
@hyperpolymath
hyperpolymath deleted the claude/sleepy-carson-bREoV branch June 14, 2026 04:03
hyperpolymath added a commit that referenced this pull request Jun 14, 2026
…preorder (#80)

## Summary
Builds on the now-verified `WokeLang.lean` (#79) by **extending the
type-safety proofs** — Tier 1 (base operators) + Tier 3 (capability
lattice) from `AUDIT.md`. Every addition is machine-checked under Lean
4.30.0 by the `lean-proofs` CI gate, **still sorry-free, no axioms**.

## Tier 1 — base operators
Each adds a `HasType` rule + `Step` rule and full `progress` /
`preservation` coverage (including the congruence and error-propagation
cases):
- **`or`** (logical) — mirrors the proven `and`.
- **`sub`, `mul`** (integer) — mirror the proven `add`.

## Tier 3 — capability lattice
- **`capSubsumes_refl`**, **`capSubsumes_trans`** — capability
subsumption is a **preorder**.

This is deliberately the order shape echo-types' `DecorationStructure`
requires (`≤-refl`/`≤-trans`), keeping WokeLang's capability lattice
on-path for a future echo/loss layer.

## Echo-types design compatibility
Per your request, I checked echo-types `main` before extending, and
documented it in `AUDIT.md`. The precedent is `EchoEphapaxBridge`:
**Ephapax** (a linear-typed language) ports `EchoLinear` + `EchoResidue`
into its prover as a separate **L3 layer**. So the echo/loss layer is a
`Mode`-indexed decoration *on top of* the base type system — these
base-operator extensions are **orthogonal and compatible**, and the
capability preorder is a stepping stone toward it.

## Verification
```
$ lean docs/proofs/verification/WokeLang.lean   # exit 0, sorry-free
```

## Still open in Tier 1 (next increment)
Ordering comparisons (`lt`/`gt`/`le`/`ge`), `div`/`mod` (divide-by-zero
→ `error` panic, reusing the proven panic fragment), float variants, and
`array` typing.

https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7

---
_Generated by [Claude
Code](https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7)_

Co-authored-by: Claude <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Jun 15, 2026
…ation state (#83)

## Why

The Lean + Coq proof repair/extension landed in **#79#82 (all merged)**
but was **invisible to the estate's bot-coordination layer**. The
machine-readable state still described a pre-proof-work world:

- `STATE.a2ml [frontier]` named only an aspirational Isabelle narrative
and **omitted the existing, now-verified Lean+Coq type-safety track**
entirely; `last-shepherd` stopped at #77.
- `debt.a2ml` carried **zero** real items — so the documented proof
follow-ups would not reach the next session's Phase 0.
- `coverage.a2ml` had no record that `docs/proofs/verification/` was
visited.
- `methodology.a2ml`'s divergent-mode invariants were generic template
stubs — one example literally read *"Idris2 only … no Lean4, Coq"*, the
**opposite** of reality, a real footgun for a divergent-mode bot.

## What (all additive; no curated content overwritten)

Surfaced through the channels whose own contracts say *"updated by
agents at session end"*:

| File | Change |
|---|---|
| `bot_directives/debt.a2ml` | Carry-forward follow-ups as Phase-0
input: **should** — Coq binop parity, Lean array typing (Coq's is a
ready template), `cap_subsumes_trans`; **could** — Coq `preservation`
clean rewrite, Lean float binops, echo-types L3 integration blueprint. |
| `bot_directives/coverage.a2ml` | `docs/proofs/verification/` recorded
as a visited component (PRs #79#82). |
| `bot_directives/methodology.a2ml` | `divergent-invariants`: provers
are **Lean 4 + Coq** (not Idris2/Isabelle); admit/sorry stay **zero**;
the `Coq.Reals` axioms are **permitted, not escape hatches** (don't let
an Axiom-scanner flag them). `known-constraints`: CI-gated +
toolchain-pinned (Coq is version-sensitive); Lean/Coq cover
**complementary** subsets; PROOF-NEEDS #2 is **ill-posed** pending a
maintainer (a)/(b) decision. |
| `6a2/STATE.a2ml` | Added `type-safety-proofs` to `[frontier]`; added
`proof-gates` + `last-proof-shepherd` to `[ci]`. Existing lines
preserved. |

Source of truth for every claim:
[`docs/proofs/verification/AUDIT.md`](../blob/main/docs/proofs/verification/AUDIT.md).

## Notes for review

- **Draft on purpose** — `.machine_readable/` is maintainer-curated
(`gitbot-fleet`/`hypatia` are both barred from it), so this goes through
human review rather than direct-to-`main`.
- The only deletions are replaced **generic template-example comments**
in `methodology.a2ml` (incl. the misleading "Idris2 only" stub). No real
data removed.
- `coverage.a2ml`'s `total/visited` summary counters were left untouched
— I won't fabricate a component denominator.
- Stacked on the merged #82; the net diff is the four files above.

https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7

---
_Generated by [Claude
Code](https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants