Convert the demos to single-file Spectre.Console apps - #110
HowardvanRooijen wants to merge 4 commits into
Conversation
Replaces the Z3.Linq.Demo project - a single Program.cs that wrote its output with Console.WriteLine - with a series of standalone .NET file-based apps (`dotnet run demos/<name>.cs`) that render the same problems with Spectre.Console: figlet banners, rules, panels, tables, and a 9x9 Sudoku grid. Each demo is one file that declares its own dependencies at the top (`#:package Spectre.Console`, `#:project` the Z3.Linq and Z3.Linq.Examples projects), so it needs no solution entry and builds against local source. Z3.Linq.Examples is untouched - it is the reusable theorem library the demos consume, not a presentation concern. Demos, one file each: - river-crossing.cs - Missionaries & Cannibals; Solve (any plan) vs Optimize/orderby (the shortest), as a crossing table plus a comparison. - sudoku.cs - two puzzles on a rendered grid, clues driven through expression-tree constraints so the puzzle array is the single source of truth. - boolean-logic.cs - x XOR y over an anonymous type, a value tuple and a record. - linear-systems.cs - small integer systems incl. Bart's TechEd 2012 example. - oil-purchase.cs / warehouse.cs - least-cost linear programs. - menu.cs - a Spectre SelectionPrompt launcher that runs the others. Non-ASCII is limited to the Sudoku box-drawing; the maths and logic are ASCII, so the demos render in any terminal and degrade to plain text when redirected. - Removed solutions/Z3.Linq.Demo and its .slnx entry; README now points at demos/, and demos/README.md lists and explains each one. - Each of the six content demos verified with `dotnet run`; menu.cs builds. - `./build.ps1 -Configuration Release` - 46 tasks, 0 errors, 0 warnings, with the Demo project gone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PipoHZJsgydrV3JC3fQN6Q
Theorem<T>.Solve() returns T?, so dereferencing the result of a reference-type environment without a guard warned CS8602. Value-type environments (the tuples) were already fine, and the guarded demos (river-crossing, sudoku) already were too. Null-forgive the reference-type solves - boolean-logic's anonymous-type and record rows, and linear-systems' two Symbols<...> sections - since XOR and those small systems are always satisfiable. All six demos now build with zero warnings and run unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PipoHZJsgydrV3JC3fQN6Q
".NET Interactive" is now "Polyglot Notebooks", and Microsoft deprecated both in early 2026 and archived dotnet/interactive (read-only since April 2026). No community-maintained fork has been established - only discussed. Renames the reference, adds a sourced deprecation note, and leads the Examples section with the single-file demos as the maintained, tooling-free way to run the examples. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PipoHZJsgydrV3JC3fQN6Q
Microsoft deprecated and archived Polyglot Notebooks / .NET Interactive, so the examples/z3-problems.dib notebook and every reference to it are removed: the Examples section now points only to the maintained single-file demos, the "For Polyglot Notebooks" getting-started subsection is dropped, and the stale notebook link in the project history is removed. The examples/ folder held only the notebook, so it is gone too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PipoHZJsgydrV3JC3fQN6Q
|
Ran the full stack on an independent fresh Windows machine (win-x64, .NET SDK 10.0.400) — validation notes, in case they're useful before the Z3 release unblocks: Suite: 322/322 green.
Merge rehearsal against our fork (context:
The rehearsal branch is pushed as Also opened #111 in support: a minimal xUnit floor pinned to current |
Replaces the
Z3.Linq.Demoproject - a singleProgram.csthat dumped every scenario throughConsole.WriteLine- with a series of standalone single-file Spectre.Consoleapps under
demos/. Each is a.NET file-based app:
one
.csfile that declares its own dependencies at the top and runs withdotnet run demos/<name>.cs.slnxentry.The demos
river-crossing.csSolvevsOptimize/orderbycomparisonsudoku.csboolean-logic.csx XOR y, three wayslinear-systems.csoil-purchase.cswarehouse.csmenu.csSelectionPromptthat runs any of the aboveEach file references the library with
#:project ../solutions/Z3.Linq/...(andZ3.Linq.Exampleswhere it uses the sample theorems), so the demos build against local source andpick up the native Z3 package transitively.
Sudoku's clues are turned intoCell{r}{c} == vconstraints with expression trees, so the printed puzzle and the constraints come from one array.
Why the examples project is untouched
Z3.Linq.Examplesis the reusable theorem library (MissionariesAndCannibals,SudokuTheorem/SudokuTable,RecordTheorem) - it has no console I/O and even ships as a NuGetpackage. The Spectre work is purely presentation, so the demos consume the examples as-is rather
than changing them.
Portability
Non-ASCII is limited to the Sudoku box-drawing (near-universal, and what Spectre's own borders use);
the maths and logic are ASCII, per the guide's advice against fragile Unicode. Spectre auto-detects
terminal capability and degrades to plain text when output is redirected, so the demos are safe to
capture in scripts.
Verified
dotnet run demos/<name>.cs- all six produce correct results(both Sudoku puzzles solved, the river-crossing
Solveplan at 24 steps vs the minimal 12 fromOptimize/orderby, the LPs at their known optima).menu.cscompiles.solutions/Z3.Linq.Demodeleted, dropped fromZ3.Linq.slnx, READMEupdated, and a new
demos/README.mdadded../build.ps1 -Configuration Release- 46 tasks, 0 errors, 0 warnings with the Demo project gone.bin/objor needs ignoring.Reference
Built following the endjin Spectre.Console guide (read from the local knowledge-base clone; the URL
provided carried an access token, which was not fetched or transmitted).
Release note
No library or public-API change - developer-facing demos only. Releases remain on hold under #60.
🤖 Generated with Claude Code