Skip to content

optifab v0.3.0: plant model and loop proved in Lean; a model proposes through it and hands its notes on - #13

Open
abu-aska wants to merge 7 commits into
mainfrom
claude/intelligence-network-convergence-q5ti6q
Open

abu-aska wants to merge 7 commits into
mainfrom
claude/intelligence-network-convergence-q5ti6q

Conversation

@abu-aska

@abu-aska abu-aska commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What this is

The next step after #2, towards the vision in #3: a formally verified system that improves its own hardware and software. v0.2.0 proved a gate and ran a seeded search through it. This version moves the proof outwards and puts something that learns on the proposing side.

Nothing here is measured. The word "verified" is still not claimed: no reviewer has approved the specification. An independent read found five defects in the plant model. They are disclosed and not fixed here (#14).

What moved

Part of the vision Before (v0.2.0) Now
Formally verified 8 theorems about the gate. Margins were handed to it from Python. 15 theorems. The plant model, the bounds, the objective and the step are inside the proved code, so the three margins that move are computed there.
End to end 50 decisions replayed in Lean from recorded margins. 3,071 decisions from four ledgers, each worked out again in Lean from the two designs. Each ledger also agrees when run in one piece through the proved loop.
Recursively improving The objective was observed not to fall. loop_never_worse proves it cannot fall, for any proposer. One proposer's notes were handed to the next, which needed 4 proposals where the first needed 11.
Intelligence A seeded search. A language model proposed through the interface, seeing only the printed state, and reached the best objective a direct search finds.
Network One campus. A first look, which shows the placement problem of #11 is degenerate in the current plant model.

Still missing, unchanged: sensors, load control, machines, a reviewer for the specification, and any proof that the model describes a real plant.

The seven new theorems

All in formal/PlantGate/Spec.lean, accepted by lake comparator --paranoid under six kernels with the standard axioms only.

  • step_complete: with budget left and the design held within the limit, a design within the bounds and the headroom that does not lower the objective is taken up. This rules out a loop that takes nothing up.
  • step_refusal_changes_nothing: a design that is not taken up leaves the design held and the budget as they were.
  • loop_safe, loop_in_bounds, loop_bounded: from a start within the limit and the bounds, after any list of proposed designs, the margins of the design held are within the limit, its genes are within their bounds, and the changes are within the budget.
  • loop_never_worse: after any list of proposed designs, the objective is at least what it was. It may be equal.
  • loop_keeps_physics: with the limit at 1,000,000 ppm and a start within it, the design held satisfies three exact inequalities, free of rounding. The cooling needed at full load is at most what the captured heat can drive. The fixed heat load is at most the cooling gained at the scheduler's floor. The IT heat of one outage is at most what the store holds. The first follows from the second for any floor up to the IT load.

A Python copy of the gate, the model and the step (formal/tests/oracle.py, which loop.py now calls) agrees with the Lean executable on 405,000 inputs: 300,000 gate decisions, 100,000 proposed designs and 5,000 whole runs. The seeded run's figures are unchanged from v0.2.0.

What the runs showed

  • A model as the proposer (results/model_run.json). Given only the output of tools/propose.py, a language model made 11 proposals. 10 were taken up, 4 of them changing hardware and software in one step, and the objective reached 0.919548. A direct search finds that to be the best any design within the limits can score. The seeded search reached 0.919009 in 50 proposals. Every proposal carries the model's reason.
  • Notes handed on (results/model_lessons.md, results/model_run_2.json). The first run's closing notes, word for word, were given to a second instance with no memory of the run. It reached the same objective in 4 proposals with none refused, and left its own notes.
  • A good proposer ends where it cannot move. Both runs finish with the load-floor margin at 999,215 ppm, 785 from its limit. The objective may not fall, so the design cannot back away. A loop proved safe and proved never to get worse comes to rest at the edge of its envelope. The objective has to give headroom a value before this loop can keep evolving.
  • An adversary (3,006 proposals: genes out of bounds, margins past limits, lower-scoring designs, then random ones) spent the budget of 64 and no more, and never held a design outside a limit or a bound.
  • A network, first look (network_first_look, section 13 of the model note). If the chiller keeps its design share of the reversible COP, the load floor is 0.564 MW at 30 °C recooling, 2.804 MW at 38 °C, and at 41 °C the campus cannot cool itself at any load. In the plant model utility power has the same slope at every site, so moving load between campuses changes no energy.

Two runs of one model are anecdotes. They show the interface and the hand-over work. They measure nothing.

In the diff

  • formal/: the model and the loop over designs in PlantGate.lean, seven statements and their proofs, a design mode and a whole-run mode in Main.lean, the Python copy with 100,000 design cases and 5,000 whole runs in tests/, and the specification, page, bar.toml and bar report brought up to date.
  • loop.py: margins and objective from the exact model; run_proposals replays any recorded list of proposals; the ledger records both designs of every decision; check_continuity checks that each entry starts from the outcome of the one before.
  • tools/propose.py: the proposer's command line.
  • verify.py (v0.3.0): replay of recorded runs, the adversarial proposer, the network first look, must-fail controls 25 to 28, and a formal record with one hash per ledger.
  • results/: two run files, their ledgers, two sets of notes, the certificate and the formal record.
  • Documents: README findings 13, 14 and 16 to 19; docs/VISION.md; docs/MODEL.md sections 11 to 13; status notes under proposals 3 and 8; HANDOFF.md; CHANGELOG.md.

Check it

pip install sympy
python3 verify.py
# [PASS] optifab v0.3.0: 28/28 controls, ... recorded proposer 10 of 11,
#        adversary held to the envelope over 3006 proposals, Lean replay 3071 decisions 0 mismatches, ...

python3 verify.py --formal        # needs Linux, elan and bubblewrap
# [FORMAL] comparator accepts 15 theorems under 6 kernels; 405000 differential tests, 0 failures;
#          ledger replay 3071 decisions, 0 mismatches

For the reviewer

  • An independent read has been done and answered. A separate agent, given the code and not my conclusions, read the new statements against the prose and the earlier floating-point model. Its ten findings and what I did with each are in a comment below. The prose that claimed more than the statements say is corrected.
  • Five defects in the model are disclosed and not fixed (formal/SPEC.md, "Known defects in the model"; Five known defects in the plant model, found by an independent read #14). The two that change numbers: the objective is about 18 ppm too high for every design, and the outage margin leaves out the fixed heat load. Fixing them changes every objective figure and the ledgers of the recorded runs, so I propose a separate pull request. Say so if you want it done here.
  • The specification grew, so its hash changed. formal/SPEC.md and the last seven statements of formal/PlantGate/Spec.lean are the part that needs a person.
  • The model is exact, not true. Its constants come from certificates that are claimed. Eleven of its fourteen margins are carried as constants. The bounds on each gene and the scenario are declared in loop.py.
  • The sub-agents were told not to read the repository. That instruction was not enforced. The run files say so.
  • The rules that tools/propose.py prints were reworded after both runs, from what the proposers found unclear. The two recorded runs saw the earlier wording.
  • Assumption A-4 (a constant share of the reversible COP) carries the whole of finding 19. A chiller datasheet would replace it.
  • Three commits in the middle are marked work in progress and skip CI. They are snapshots taken while the recorded runs were still being appended to. The head commit is a verifying state.

Decisions this needs

  • The model defects (Five known defects in the plant model, found by an independent read #14). Fix and re-run the recorded runs, or fix and keep them with a note.
  • Bar item 7. In CI the bar check reports item 7 as open, because main does not require the bar / bar check. Only a repository admin can add that branch rule.
  • Proposal 8. The first slice as written (a linear programme for placing load) has no single optimum in this model. The status note under proposal 8 gives three ways to change it. The owners should pick.
  • The objective. It rewards a lower load floor and nothing rewards headroom, so a good proposer freezes the design at a limit. Whether headroom should have a value in the objective is a design decision.

After merging

Disclosure

Prepared by an AI agent (Claude Code) working for the owner of aska-physical. Not reviewed by a person. Under the Foundation-0 rule that a person signs, nothing here counts until a named person has reviewed it.

🤖 Generated with Claude Code

https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K

The model that turns a design into margins and an objective, the bounds,
and the step that takes a design up are now exact integer arithmetic in
formal/PlantGate.lean, with a tested Python copy in formal/tests/oracle.py
that loop.py calls. Six new theorems, accepted by lake comparator --paranoid
under six kernels together with the eight about the gate:

- step_complete: a design within the bounds and the headroom that does not
  lower the objective is taken up.
- loop_safe, loop_in_bounds, loop_bounded: whatever designs are proposed,
  the margins the model computes stay within the limit, the genes stay
  within their bounds, and the changes stay within the budget.
- loop_never_worse: the objective of the design held never falls.
- loop_keeps_physics: a margin within the limit means three exact
  inequalities (drive heat, load floor, outage), free of rounding.

The ledger now records both designs of every decision, and the replay
works the margins, the objective and the verdict out again in Lean from
them. Differential tests: 400,000 inputs (300,000 gate decisions, 100,000
proposed designs), 0 failures. The loop's figures are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K
…ers, network first look [skip ci]

Not a verifying state. The certificate, the formal record and the
documents are regenerated once the recorded run in results/model_run.json
is complete; that run is still being appended to. Committed now so that
nothing is held only in the session.

- tools/propose.py: the proposer's command line.
- verify.py: replay of recorded runs, an adversarial proposer, a first
  look at site-dependent load floors, must-fail controls 25 to 27.
- docs/MODEL.md: section 11 and 12 describe the model in Lean.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K
…arted [skip ci]

Not a verifying state. results/model_run.json is complete (11 proposals).
results/model_lessons.md holds the first proposer's closing notes, word
for word. results/model_run_2.json is the second run, given those notes,
and is still being appended to.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K
Not a verifying state. results/model_run_2.json is still being appended to.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K
… network, documents

- tools/propose.py: the proposer's side of the loop as a command line.
  loop.run_proposals replays any recorded list of proposals.
- results/model_run.json: a language model, shown only the loop's printed
  state, made 11 proposals; 10 were taken up and the objective reached
  0.919548, the best a direct search finds. The seeded search reached
  0.919009 in 50 proposals. Its closing notes are in model_lessons.md.
- results/model_run_2.json: a second instance with no memory of the first
  run, given those notes, reached the same objective in 4 proposals.
- An adversarial proposer (3,006 proposals) cannot move the design out of
  its limits, its bounds or its budget, and cannot lower the objective.
- network_first_look: under a stated assumption the load floor rises
  steeply with recooling temperature, and placement between campuses is
  degenerate in the current plant model.
- Must-fail controls 25 to 27. --formal replays 3,071 decisions from four
  ledgers in Lean with no mismatch.
- README findings 13, 14 and 16 to 19; VISION, MODEL (sections 11 to 13),
  PROPOSALS, HANDOFF, CHANGELOG, the bar report and the unit notes brought
  to v0.3.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K
A separate agent, given the code and not my conclusions, read the plant
model and the six new statements against the prose and the earlier
floating-point model. It confirmed the units and the integer model, and
found defects. This commit fixes those that belong here and discloses
the rest.

Fixed:
- Prose that dropped hypotheses. loop_safe, loop_in_bounds and
  loop_keeps_physics hold from a start within the limit and the bounds;
  step_complete needs budget left. README, MODEL, VISION, formal/README
  and SPEC now say so. 'The loop only improves' is now 'never worse'.
- A new theorem, step_refusal_changes_nothing: a design that is not taken
  up leaves the design held and the budget as they were. Fifteen in all.
- Nothing executed the proved loop and changes. The Lean executable has
  a whole-run mode that does; --formal runs each ledger through it in one
  piece, and loop.check_continuity checks that each entry starts from the
  outcome of the one before. Must-fail control 28. 5,000 whole runs added
  to the differential tests (405,000 inputs).
- Wording: ten margins are certified upstream and one is derived here;
  the eleven constants, the plant, the bounds, the scenario and the limit
  are inputs; the model is defined in the proved code, not proved.

Disclosed, not fixed (formal/SPEC.md, known defects):
- The objective is about 18 ppm too high for every design.
- The outage margin leaves out the fixed heat load.
- A design that scores the same is taken up and charged.
- Nothing requires the inputs to make sense.
- A large move towards safety is refused; an unsafe start cannot be repaired.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tWK9W6CVMEDEnj5eQTe6K

Copy link
Copy Markdown
Member Author

The independent read I mentioned in the description has reported. I gave a separate agent the code and the prose, not my conclusions, and asked whether the statements and definitions say what the prose claims. I checked each of its numbers before acting on it. Two commits answer it: 79eebf5 and ebf298d.

What it confirmed. The units and scaling of every quantity in the model. That the integer model matches the earlier floating-point one (0 ppm difference over 200,000 designs on the reference plant). That Main.lean prints nothing that does not come from the proved functions, apart from the label of a refusal.

What it found, and what I did.

# Finding Action
1 The prose dropped the start hypothesis of loop_safe, loop_in_bounds and loop_keeps_physics. A start with the scheduler floor at 500 kW is past a limit and the loop holds it forever. Fixed. README findings 13 and 16, MODEL, VISION, formal/README.md and SPEC.md now state the hypotheses.
2 "The loop only improves" is stronger than loop_never_worse. A design that ties is taken up and charged, even one identical to the design held. Wording fixed to "never worse". The behaviour is disclosed and left for #14.
3 The objective's outage term subtracts fixed overhead, so every objective is about 18 ppm too high. Disclosed, not fixed. #14.
4 The outage margin leaves out the fixed heat load, about 71 kWh per outage. Disclosed, not fixed. #14.
5 Nothing executed loop or changes, which five of the theorems are about. The chaining was in Python. Fixed. The Lean executable has a whole-run mode that goes through the proved loop and changes. --formal runs each of the four ledgers through it in one piece, and loop.check_continuity checks that each entry starts from the outcome of the one before. Must-fail control 28. 5,000 whole runs are added to the differential tests.
6 No statement requires the plant, the bounds or the start to make sense. Disclosed. #14 proposes a WellFormed hypothesis.
7 DriveHeatSuffices follows from SelfCoolsAtFloor for any floor up to the IT load, so the "three inequalities" are two independent facts. Stated in SPEC.md, in the Lean doc comment and in README finding 16.
8 No theorem said a refused design changes nothing. A step that zeroed the budget on refusal would have passed all six. step_complete's hypotheses were missing from the prose. Fixed. New theorem step_refusal_changes_nothing, fifteen in all. Prose corrected.
9 Stale or loose wording: "eleven certified margins" (ten are certified, one is derived here); "nothing is passed across by hand" (the constants, plant, bounds, scenario and limit are inputs); a title saying the model is proved. Fixed.
10 A large move towards safety is refused as too far, and an unsafe start cannot be repaired. Disclosed. #14.

State after these commits. lake comparator --paranoid accepts 15 theorems under 6 kernels. 405,000 differential tests, 0 failures. 28 of 28 must-fail controls. 3,071 decisions replayed in Lean with no mismatch, and each of the four ledgers also agrees when run through the Lean loop in one piece. The bar check passes items 2 to 6. The specification hash is now 6531b84894f8c75cd679358ae933812648e928c2e2855114165d3b7654c5a54a.

What I chose not to do here. Findings 3 and 4 are real mistakes in the model. Fixing them changes every objective and margin figure, the seeded ledger and the ledgers of both recorded runs, whose notes quote the present figures. I think that belongs in its own pull request, where the correction can be reviewed apart from everything else. #14 has the numbers and two ways to do it. If you would rather it were fixed before this merges, say so and I will do it here.


Generated by Claude Code

This branch has not been deployed

No deployments
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