Expand description
UI bridge for web interface integration.
This module provides high-level, UI-friendly wrappers around the compilation pipeline, returning structured results suitable for display in the browser.
§Key Functions
| Function | Purpose |
|---|---|
compile_for_ui | Compile LOGOS to FOL (UI format) |
compile_for_proof | Compile and search for proofs |
compile_theorem_for_ui | Compile theorems with derivation trees |
verify_theorem | Verify a theorem is provable |
interpret_for_ui | Run imperative code and return output |
generate_rust_code | Generate Rust source (requires codegen feature) |
§Result Types
All functions return serializable result types:
CompileResult- Tokens, FOL, AST, errorsProofCompileResult- FOL with proof search resultsTheoremCompileResult- Theorem verification with derivation treeInterpreterResult- Program output lines and errors
§Token Categories
The TokenCategory enum provides syntactic highlighting categories:
Quantifier, Noun, Verb, Adjective, Connective, Determiner, etc.
Re-exports§
pub use crate::interpreter::InterpreterResult;
Structs§
- AstNode
- AST node for tree visualization in the UI.
- Compile
Result - Result of compiling English input to FOL with UI metadata.
- Grid
Column - One category column of a
SolvedGrid. - Proof
Compile Result - Result of compiling English to a proof expression.
- Solved
Grid - A solved (or partially solved) logic grid: the row entities plus one column per declared category closure. Every filled cell is an entailment the no-Z3 certified prover (CDCL+RUP / kernel) closed, so the whole table is independently checkable.
- Theorem
Compile Result - Result of compiling and verifying a theorem block.
- Theorem
Trace - An English theorem proved, with its FOL and a human-readable PROOF TRACE — the “English in → proof out, see the trace” path. Parsing yields the premises and goal as FOL; the kernel-certified backward chainer yields the derivation, which renders as an indented step-by-step proof.
- Theory
Compile Result - The result of compiling a program’s formal development — its
## Axiomdeclarations (a shared premise base) plus the theorems of its## Theoryblock, each discharged in citation order and kernel-certified by the multi-theorem driver. - Theory
Theorem Result - A single theorem’s verdict within a compiled formal development.
- Token
Info - Token information for UI display with position and category.
Enums§
- Token
Category - Syntactic category of a token for UI highlighting.
Functions§
- answer_
question - ANSWER a wh-question theorem (“Given: … Prove: Who is a lawyer?”). A wh-goal
converts to ∃x.φ(x); the ANSWER is the witness. We find it the same way the
puzzle is meant to be solved — by the GENERAL kernel-certified prover, applied
per candidate: enumerate the domain individuals named in the premises and prove
each candidate goal φ(c); the c’s that prove are the answer (usually one, for a
puzzle with a unique solution). No question-specific reasoning — every step is
the same
prove_certify_checkthat proves Socrates. - compile_
for_ proof - Compile English input to ProofExpr for the proof engine.
- compile_
for_ ui - Compile English input to FOL with full UI metadata.
- compile_
theorem_ for_ ui - Compile a theorem block for UI display.
- compile_
theory_ for_ ui - Compile a program’s formal development end to end: collect every
## Axiom(a shared premise base) and every## Theoryblock’sAxiom/Theoremdeclarations, then prove the theorems in citation order, each kernel-certified by the multi-theorem driver. This is the seam that turns a Tarski-style source file into a verified development. - expr_
to_ ast_ node - Converts a logic expression to an AST node for tree visualization.
- extract_
logic_ module - Like
extract_logic_rust, but emits NO demomain— the linkable form bundled into an imperative program’smod proven(which has its ownmain). Produces theWorld+holds(+Monitor) library items only. - extract_
logic_ rust - Compile a Logic-mode input to runnable Rust.
- extract_
math_ module - Extract every user-defined inductive/definition in
ctxinto one Rust module — types, functions, andcheck_*property fns from proven theorems — WITHOUT a demomain. This is the linkable artifact bundled into an imperative program’smod proven;extract_math_rustwraps it with a self-verifyingmainfor the standalone Math compile. - extract_
math_ module_ from_ source - Like
extract_math_rust_from_source, but produces the main-less module (the linkable artifact bundled into an imperative program’smod proven). - extract_
math_ rust - Extract every user-defined inductive and definition in
ctxinto one Rust module — the “compile my math to Rust” path for the Math studio. Shared and StandardLibrary dependencies are pulled in only when a user definition transitively needs them, and are emitted exactly once. - extract_
math_ rust_ from_ source - Compile a Math-mode SOURCE program (the editor text) to a Rust module: split it into vernacular statements, run them into a fresh kernel, then extract every user-defined inductive/definition. This is the exact pipeline the Studio’s Math “🦀 Compile” button drives, exposed as one function so it is testable.
- generate_
rust_ code - Generate Rust code from LOGOS source — the Studio Code path. Mixed-document
aware: a source interleaving imperative code with Coq-style math
(
Definition/## Theorem:/…) extracts the math into a bundledmod proventhat the imperative half calls into. Pure imperative source is a no-op partition. - generate_
rust_ code_ with_ proven generate_rust_codewith an already-extracted proven module bundled in.- grounded_
grid_ problem - The GROUNDED, quantifier-free grid problem
(solver_input, goal)for anAutogrid theorem — the EXACT problemcompile_theorem_for_uisolves, exposed so the trust tiers (Untrusted CDCL / RUP / Kernel) and the benchmark all run the same input.Noneif the theorem is not anAutofinite-domain grid. - implicit_
main - Partition a possibly-MIXED document into its imperative and math streams.
- interpret_
for_ ui - interpret_
for_ ui_ baseline - Baseline-tier interpret for the interactive UI (the Studio) — the cold-start
engine. Runs on the bytecode VM with NO run-path optimizer
(
with_parsed_program, notwith_optimized_program) and NO oracle (compile_with_types, notcompile_with_oracle), so there is no optimize/analysis latency before execution.largo runand the benchmarks keepinterpret_for_ui, which optimizes ahead of execution for peak throughput. Output is identical — the VM is differentially gated against the tree-walker on the SAME parsed statements (see the debug shadow-oracle assert ininterpret_for_ui_baseline_sync_with_args); only the startup latency differs. This is the baseline half of the EXODIA tier split; promoting hot code to the optimized path is a later step. - interpret_
for_ ui_ baseline_ sync_ with_ args - The synchronous baseline core: parse (UNoptimized) → bytecode VM (no oracle)
→ run. Mirrors
interpret_for_ui_sync_with_argsexactly, minusoptimize_for_runand the oracle range analysis. - interpret_
for_ ui_ baseline_ with_ args - Like
interpret_for_ui_baseline, but supplies the program’s argument vector to theargs()system native. - interpret_
for_ ui_ sync - Interpret LOGOS imperative code synchronously (no async runtime needed).
- interpret_
for_ ui_ sync_ with_ args - Like
interpret_for_ui_sync, but supplies the program’s argument vector to theargs()system native.program_argsis the full argv (index 0 is the program name), matching the compiled binary’senv::args()— this is whatlargo run --interpret Nforwards so an args-drivenmain.lgruns the same on the VM/JIT as on the native binary. - interpret_
for_ ui_ with_ args - Like
interpret_for_ui, but supplies the program’s argument vector to theargs()system native.program_argsis the full argv (index 0 is the program name), matching the compiled binary’senv::args(). - interpret_
streaming - Interpret LOGOS imperative code with streaming output.
- interpret_
streaming_ with_ vfs - Like
interpret_streaming, but routes the interpreter’s file I/O (Write/Read/Mount) tovfs. The browser Studio passes itsWebVfshere so the standard-library I/O vocabulary works against OPFS/IndexedDB; aNonevfs leaves file I/O reporting “VFS not initialized” as before. The clone-per-task model means concurrent tasks inherit the same VFS handle. - interpret_
streaming_ with_ vfs_ observer - Like
interpret_streaming_with_vfs, but also emits a [logicaffeine_runtime::SchedSnapshot] toobserverafter each scheduler slice — the Studio’s Tasks/Channels strip subscribes here to show a concurrent program’s live task and channel state as it runs. - parse_
math_ statements - Split a Math-mode program into complete vernacular statements.
- partition_
mixed - prove_
theorem_ trace - Prove an English
## Theoremblock and return its FOL plus a rendered PROOF TRACE. Unlikeverify_theorem(which returns the raw kernel term), this surfaces the derivation tree so the proof steps are visible. - repl_
global_ bindings - Run a program on the synchronous tree-walker and return its global
bindings as sorted
(name, type, value)rows — the REPL’s:varsinspection. ReturnsNonefor programs the sync walker can’t host (async/concurrent) or that fail to parse or run. - run_
treewalker_ concurrent_ seeded - Parse
inputand run its concurrent program on the tree-walker scheduler under an explicitseed— the seeded sibling of the defaultrun_program_concurrententry, used by the cross-tier seeded differential. - run_
vm_ concurrent - Run a concurrent program on the bytecode VM under the deterministic
scheduler (T11): compile to opcodes, then drive the main
Vm(and any spawned per-task VMs) throughrun_until_blockvia aVmTask. This is the VM analog of [run_program_concurrent]; the default routing still sends concurrent programs to the tree-walker, so this is the explicit VM entry used to exercise and (Phase 5c) differentially compare the VM concurrency tier. - run_
vm_ concurrent_ seeded run_vm_concurrentunder an explicit schedulerseed— the VM sibling ofrun_treewalker_concurrent_seededfor the cross-tier seeded differential.- run_
vm_ net_ async - Run a peer-networking program on the BYTECODE VM (single task, no channels): drive the resumable
VM and service each
VmBlock::Net*through the sharedNetInbox— the SAME inbox the tree-walker uses — soConnect/Listen/Send/Stream/Awaitrun byte-identically on both tiers. The VM analog of the tree-walker’s networking path; the cross-tier lock proves they agree. - run_
vm_ workstealing_ seeded run_vm_concurrent_seededunder the work-stealing M:N driver:workersOS-thread workers poll task bodies in parallel while one coordinator owns the scheduler and applies channel ops + flushes output in deterministic pick order. The observable result is byte-identical to the cooperative driver at the same seed (diff_cooperative_eq_workstealing_seeded) — the difference is that task bodies genuinely run on multiple cores.- set_
pending_ aot_ natives - Queue compiled-native functions for the next VM run on this thread (HOTSWAP §Axis-3).
Consumed by the next
interpret_for_ui_*VM run. - solve_
grid - SOLVE the whole grid for the studio (the form-recognized easter egg): re-parse the
theorem and, if it is a finite-domain grid, fill every cell the certified prover can
force.
Nonefor a non-grid theorem. - theorem_
dependency_ graph - The
usesdependency graph (Rung 0b) for an English document: its## Defineblocks plus the theorem’s premises and goal, lowered and analyzed. Each node is a definition or the theorem; each edge is auses. This is the structure amathscrapesnode/edge compiles into. - theorem_
proof_ exprs - Parse a
## Theorem:block and convert its premises and goal toProofExprs — the shared front half ofverify_theoremandcheck_theorem_smt. Parse a## Theoremdocument and convert its premises and goal toProofExpr. Public so a puzzle solver can obtain the parsed-FOL premises (the Given clues/declarations) and feed them to the entailment oracle. - theorem_
proof_ exprs_ with_ defs - Like
theorem_proof_exprsbut also returns the document’s## Defineblocks (Rung 0a) lowered to proof-layer definitions, so the prover can δ-unfold them. This is the entry the kernel-certified theorem path uses. - tokenize_
for_ ui - Tokenizes input text and returns token information for UI display.
- verify_
theorem - Phase 78: Verify a theorem with full kernel certification.
- with_
optimized_ program with_parsed_program, but the statements pass through the RUN-PATH optimizer (EXODIA D1: the Futamura residual — PE, GVN, LICM, closed-form, deforestation, interval analysis, DCE) before reaching the closure. The livelargo runengines consume this; the differential seams stay on the raw variant so optimizer correctness is itself differentially gated (optimized-VM vs raw-tree-walker).- with_
optimized_ program_ tiered with_optimized_programgated by an explicit hotnesstier(HOTSWAP §4): the statements pass throughcrate::optimize::optimize_for_run_tieredattier.Tier::T3reproduceswith_optimized_programexactly;Tier::T0skips the optimizer (the baseline tier). The accumulator→loop TCO rewrite is a LANGUAGE SEMANTIC, not an optimization, so it runs at every tier — deep recursion stays constant-stack regardless of the optimization tier.- with_
parsed_ program - The execution front-end shared by every engine: lex → MWE → discovery → parse. The tree-walker and the bytecode VM MUST both come through here so they see the identical token stream, type registry, and policies — a differential test that parses differently per engine is comparing two different programs.
- with_
v2_ optimized_ program - Like
with_optimized_program, but the program runs through the ARCHITECT pipeline (optimize_program_v2): equality saturation with kernel-certified rewrites in place of GVN + LICM + closed-form. The differential gates inphase_exodia_architect.rshold this path to the raw tree-walker’s outcomes.
Type Aliases§
- Observer
Callback - A snapshot sink for the Studio’s Tasks/Channels strip — invoked between scheduler slices with the live task/channel state.