Commit Graph
17 Commits
Author SHA1 Message Date
alexmandClaude 33684cf7bd Pin core faa71d2; the shared zip includes core's library submodule
Build, test, deploy / site (push) Failing after 5s
scripts/package.py now lists each submodule with --recurse-submodules, so
the zip carries core and core's library/ and runs every test on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 12:24:14 +00:00
alexmandClaude bd51349967 Add the library page, and pin core with sized types and the library
core 477dffe brings pseudo's sized types (INT8..UINT64, FLOAT32), exact
numerical built-ins, USE IEEE, and USE for pplus-library, its new
submodule: 16 routines checked at every level.

- #/library (src/ui/library.ts): every routine by module with a count
  of how its checks ended; a routine's page shows its pseudo, cases and
  results, every check with its detail, each reference implementation
  with its note, tolerance and source, the Dafny proof and the sources.
- Open in the Bridge: a routine opens as the problem lib:<id>
  (src/core/library.ts), its first case as the call, so it can be
  stepped through; the problem menu names it.
- Library in the site nav; README, docs/app.md and AGENTS.md updated.
- Two Quarto examples expected "X_BAR returned 3" for a FLOAT result;
  core now prints it in its type, 3.0.

Gate: site 113 pass; core 332 pass; library-check no failing check.
Manual check: #/library lists 16 routines with chips; a routine's page
shows numbered pseudo, cases, checks; Open in the Bridge steps through
NeedlemanWunschScore; no console errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 12:19:08 +00:00
alexmandClaude 2bc297644c Pin pplus-core as the git submodule core/
core/ now lives in its own repository (pplus-core, extracted from this
one with its history), so the site takes it at one commit and moves the
pointer on purpose, in a commit that says what it brings.

- .gitmodules: core at ../pplus-core.git, beside this repository on the
  same host, tracking main.
- scripts/package.py: the shared zip includes the files core's checkout
  tracks, so it builds without a second download.

Gate: site 110 pass against core c5157fc; pplus-core from a fresh clone
306 pass (the Dafny check skips until dafny-fetch), corpus status
--strict passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 05:49:01 +00:00
alexmandClaude 82e18f7966 Move the engine core into core/, a project of its own (pplus-core)
What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.

- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
  mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
  place of the site's Session), scripts (corpus pipeline, play, the
  exercise and probe starters, engines export/diff), and its docs
  (engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
  package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
  page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
  platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
  index.html, "imports" in package.json for node, core's declarations for
  tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
  quarto-export and quarto-css read core/dist and core/mojo; quarto-css
  copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
  describe the split (checkout with submodules; core's tests and corpus
  status run against the pinned commit).

Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 05:43:58 +00:00
alexmandClaude f43bbfe0cf Point two engine tests at core's problem list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 05:17:38 +00:00
alexmandClaude 977117504f Give the catalog, the machine presets and AreaId homes on the core side
Two engine modules reached into app modules: the exercise type named the
app's AreaId, and the assembly service read the machine presets from the
Hardware area's board module. And the catalog mixed core's problems with
the app's areas and saved state.

- core/machine.ts holds the machine presets and their names (parseMachine,
  machineSpec, machineLabel); hardware.ts re-exports them for the board.
- AreaId lives in core/types.ts; areas.ts re-exports it.
- core/problems.ts builds the problems from the exercises and the corpus
  (PROBLEMS, problemById, workForProblem for a Workspace). core/catalog.ts
  adds each problem's area and stateForProblem.

No behavior changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 05:16:27 +00:00
alexmandClaude c1544e7550 Separate what the sources mean (Workspace) from how the app keeps them (Session)
The engines are moving into their own project. Session mixed the two jobs:
deciding what a program means (the hub's cascade, parsing every language,
diagnostics, the run, the proof, the fuzzer) and app concerns (the area,
saving to localStorage, versions, compile history, the best-practices
helper, change events). Tests of meaning could only reach it through the
app's state.

src/core/workspace.ts is the first job alone, with no DOM, storage or
areas: Workspace reads a WorkState (sources, sync, lang, call, input, setup,
machine), and edit() returns whether anything changed. Session now extends
it, keeps every app concern, and overrides only what the app changes: the
Bridge's Mojo is derived (derivesMojo), and the Mojo diagnostics come from
the compiler's answer and the helper when there is one.

No behavior changes; every test passes unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 05:12:49 +00:00
alexmandClaude acf0b8e620 Add docs/trust.md and a clean package task
docs/trust.md lists every badge and verdict the app shows (where code came
from, what a compiler said, what a proof, the fuzzer, a translation and the
model machine say): what earns each one, what it means, and what it does
not mean. New badges get a row there in the same commit.

pixi run package zips the files git tracks, plus new files it does not
ignore, into package/programming-plus-<commit>.zip (marked -dirty with
uncommitted changes). The zip shared before this held .DS_Store files,
__pycache__ folders and __MACOSX entries (3,661 files); the package holds
none of them (1,694 files). Python standard library only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:46:04 +00:00
alexmandClaude 5c6e7e2df5 Send Compile & run through a CompileBackend instead of straight to godbolt
Every compile went to godbolt.org from the session directly. The roadmap
moves compiles, and later Dafny and Lean checks, to a pinned service of the
app's own, and godbolt has no service guarantee, so where a compile goes is
now one replaceable piece.

- src/services/compile-backend.ts: a CompileBackend (id, host, compiler,
  compile), explorerBackend() for any service that speaks Compiler
  Explorer's API at a base URL, GODBOLT as the default, and
  compileBackend() / setCompileBackend().
- godbolt.ts: compileMojo takes a CompileTarget (base, compiler, host) and
  names that host in its messages; the request body is unchanged, so
  tests/mojo.test.mjs still holds it to what the corpus pipeline sends.
- Session.compile asks the current backend and records which host answered
  (CompileRecord.host; older records came from godbolt.org).
- The Compiler view names the host it is asking and the host that answered.
  The "Compiled on godbolt" badge keeps its wording until a second backend
  is deployed.

A test sends a compile through a fake backend and a refused local address.

Manual check list: open a Mojo exercise in the Developer area, Compile &
run, and see "Asking godbolt.org (mojo_1_1_0)…" then "Mojo 1.1.0 on
godbolt.org" in the Compiler view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:46:04 +00:00
alexmandClaude 0d313f989d Make this repository the engines' home; the course copies from here
Whether the engines' changes went back to the course or the course took
them from here was an open question (docs/engines.md). Soundness fixes to
the prover cannot wait for a round trip through a repository with no engine
tests, so this repository now owns the engines.

- pixi run engines-export <course>/static builds and writes every engine
  module into the course's static/js/: JavaScript modules as written,
  TypeScript ones (logic, solver, vcgen) as built, without source maps.
- pixi run engines-diff now shows what the course has not taken yet,
  comparing the file the course would receive with its copy. Both scripts
  share the list of modules in scripts/engines-files.mjs.
- docs/engines.md describes the ownership, the prover's three modules and
  its number model, the soundness tests and the bugs found so far, the
  changes the course receives with the next export, and how to export.
- AGENTS.md gains a hard rule: never let the prover call something proved
  that a run breaks, with how to add a soundness regression first.
- docs/app.md's Known limits no longer sends engine fixes upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:33:58 +00:00
alexmandClaude 2416d7fc8e Convert the VC generator to TypeScript
vcgen.ts types the symbolic executor under strict mode: the store (a term,
or the mark of a variable not yet set), the translation context, the raw
obligations, the loop hooks the invariant inference uses, and the report it
returns (Obligation, UnitReport, Report, VerifyOptions, exported for the
next stages). The parsed program is still built by parse.js and check.js,
which stay JavaScript, so its nodes are typed as PNode: a kind, a position
and untyped fields.

The behavior is unchanged: every obligation of every exercise, corpus
program, lesson solution and example, and the regression programs, comes
out byte for byte as it did before the conversion. Places where the code
read a store value it knew to be a term now say so (valOf), and an unset
value read as a term becomes a fresh unknown (asTerm), which is what the
name lookup already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:32:06 +00:00
alexmandClaude 765459c340 Keep "X is in the collection" inside a FOR EACH pass, not on the way out
The way out of a FOR EACH loop includes the case of no pass at all, but the
checker added "X is in the collection" to the loop's head state and then used
that same state as the way out. After a loop over an empty list the fact is
FALSE, so the checker held a contradiction and proved anything after the
loop, ASSERT 1 == 2 included (tests/prover/foreach-empty.pseudo). The fact is
now assumed only for the body of a pass.

The soundness test gains a canary: after every program that runs to its end
without input, ASSERT 1 == 2 is appended and must not be proved, since a
proof there means a contradiction on a path every run takes. A one-off scan
with the canary after every top-level statement of every program (476
points) found nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:26:43 +00:00
alexmandClaude f219384e57 Convert the prover's term language and solver to TypeScript
This repository now owns the engines, and the next stages extend the prover
(a claims model, translation to Dafny and Lean, precision claims). Doing that
under strict mode needs the terms it reasons about to have types.

logic.ts gives the term language a discriminated union (Num, Lit, Sym, Bv,
Op, And, Or, Not, Cmp, Ite, App, Quant, QuantC) and types every
constructor, rewrite and printer. solver.ts types the rationals, linear
constraints, Fourier-Motzkin, union-find with congruence, the case split
and quantifier instantiation, and exports ProveResult and ProveOptions.
Walks that looked inside any kind of term through x[k] now go through a
small fields() helper that keeps the same order.

The behavior is unchanged: every obligation of every exercise, corpus
program, lesson solution and example, and the regression programs, comes
out byte for byte the same as before the conversion (kind, line, column,
label, status, paths, goal and facts as shown, inferred invariants, notes).
The few places where the JavaScript would have thrown on a null it never
receives (an identity for a quantifier that has one) now skip instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:24:09 +00:00
alexmandClaude ee44a03c54 Give the solver and the VC generator tests of their own
The engines had no tests of their own in the course repository; this
repository now owns them, so a change to solver.js or vcgen.js needs
something to answer to besides the end-to-end tests.

tests/engine-solver.test.mjs holds:
- a table of goals the solver must prove (transitivity, integer
  tightening, case splits, congruence on positions, DIV and MOD by a
  constant, lengths at least 0) and goals it must leave unknown (a false
  step, FLOAT tightening, products of unknowns, rounded FLOAT addition,
  different positions); one known gap, 2X == 1 not seen as impossible, is
  recorded so an improvement shows up;
- 400 random linear integer formulas with DIV, MOD, if-then-else and
  boolean structure; every one the solver proves is checked against all
  729 assignments of X, Y, Z in [-4, 4];
- programs whose obligations must come out proved or not: a counting loop
  with its invariant, an index one past the end, a division that needs a
  REQUIRE, FILL and RANDINT arguments, and the int-model note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:21:18 +00:00
alexmandClaude c652b86a2a Stop a run on a FLOAT that is not finite, so proofs about FLOAT hold
The prover reasons about a FLOAT as a number: Y == Y holds, and X < Z or
X >= Z. The interpreter let 1.0E308 * 10.0 become infinity and X - X become
NaN and carried on, so a run broke claims the prover had proved
(tests/prover/float-overflow.pseudo proved ASSERT Y == Y with Y NaN).

The notation already stops on a FLOAT division by zero and on a whole number
past 2^53 - 1. It now also stops, with an 'overflow' error, when an
arithmetic result, a built-in's result or a literal is not a finite number
(finiteCheck in interp.js). Every run then stays inside what a proof covers.

Regression programs whose fix was to the language rather than to a rule now
say where the run must stop, with a RUN-STOPS header the soundness test
checks.

A unit that does FLOAT arithmetic now carries a 'float-model' note: FLOAT is
treated as a finite number, rounding is opaque, and the lab stops past about
1.8e308, while the generated Mojo goes on with inf or nan (stated for a
division by zero, the case probes/float-special has verified).

New probe mojo/probes/float-overflow.mojo asks the compiler what a Float64
product past the largest double gives; it is unverified and needs
pixi run mojo-verify-item 'probes/float-overflow' (network).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:21:18 +00:00
alexmandClaude dd1e949ea2 Make the prover sound: fix two rules, add missing obligations, add a soundness gate
The prover could mark an obligation proved that a run of the same program
breaks. Two rules did it, both found with programs now in tests/prover/:

- Invariant inference (vcgen.js infer) stopped after four rounds and assumed
  the candidates left even when the last round had still been dropping some.
  A non-inductive guess became a fact, and a false ASSERT was proved
  (houdini-cap.pseudo). Inference now runs up to eight rounds and keeps its
  guesses only when a whole round leaves them unchanged.
- RAND(X) assumed 0 <= R < X for every X. For X <= 0 that fact is false
  (RAND(0.0) is 0.0, RAND(-1.0) is in (-1, 0]), so the checker held a
  contradiction and proved anything, even ASSERT 1 == 2 (rand-zero,
  rand-negative). The fact now covers all three signs of X.

FILL and RANDINT assumed facts about their arguments that the interpreter
enforces by stopping the program, without asking whether the arguments are
allowed. A crashing call was reported as fully proved. They now raise an
obligation of a new kind, 'argument' ("Argument allowed"), mapped to the
runtime 'value' error, and their facts are guarded.

tests/prover-soundness.test.mjs is the gate: each regression program's
MUST-NOT-PROVE obligation stays unproved and is really broken by a run, and
across every exercise, corpus program, lesson solution and example, nothing
marked proved is broken by the fuzzer (kind, line, column) or by running the
program (kind, line).

In the app, a proved obligation that a generated input breaks at the same
place is now shown as broken rather than proved.

Proofs over INTEGER are about whole numbers of any size; a unit that does
integer arithmetic now carries an 'int-model' note saying so, with the lab's
2^53 - 1 limit and Mojo Int's wraparound past 2^63 - 1 (from the stored
godbolt answer for probes/int-overflow-int).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 03:10:22 +00:00
alexm 31f2fb8a5a Baseline: tree as shared 2026-10-05 03:03:38 +00:00