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§
- Engine
- In-process execution tier. All choices consume the same optimized program.
- 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.
- failure_
sites_ of - Every
Stmt::Sitemarkerinputparsed to, as the(span, component, action)FailureSitethe marker’s id indexes — in the author’s own file coordinates, the implicit-## Mainwrap and the stdlib-prelude splice already undone (matchinglgx_findings_of/parse_error_of’s own treatment). The tree-walker’scurrent_site()and a compiled program’ssite_atpc-lookup both answer an id into THIS SAME table; whoever renders a runtime failure looks it up here and callsFailureSite::renderwith the message. - 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 - IMPLICIT MAIN: a source with no
##headers whose first non-blank line reads as an imperative statement runs as its own## Mainbody, so a bare script runs rather than parsing as logic prose. Natural-language documents (no statement-keyword opening) are untouched. Returns the wrapped source, orNonewhen the input is not a bare script. - 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_ sync_ with_ args_ scoped - Project-aware form of
interpret_for_ui_sync_with_args. The scope gate consumes the AST this execution already parsed, so explicit VM/JIT runs do not pay for a separate front-end parse on every invocation. - 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 alogicaffeine_runtime::SchedSnapshottoobserverafter 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. - interpret_
unsatisfiable_ require - The tree-walk interpreter (
largo run --interpret) is the raw differential tier — it applies NO optimizations, so it cannot satisfy any## Require <opt>. Returns the honest error for the first requirement (mirroring the compiled tiers’ message), orNonewhen there is none. - lgx_
findings_ of - The accessibility and structure warnings
lgx/check.rscomputes forinput. - logic_
compile_ note - Why Logic’s Compile has no Rust to give for
input, orNonewhen it has one: a finite-domain puzzle is solved by Execute, and extracting it would run the whole solver — the same testextract_logic_rustmakes before it bails. - parse_
error_ of - The parse error for
input, in the AUTHOR’s own file coordinates — the implicit-## Mainwrap and the stdlib-prelude splice both undone, exactly aswith_parsed_program_checkedundoes them for its callers — orNonewheninputparses. A pure parse check with no## Requiregate: a caller that wants to render its OWN caret block (largo run --interpret, matching whatlargo checkalready shows) takes the located error from here instead of formatting whateverResult::Errvariant happened to reach it. - parse_
math_ statements - Split a Math-mode program into complete vernacular statements.
- partition_
mixed - Partition a possibly-MIXED document into its imperative and math streams.
- program_
required_ opts - The
## Require <opt>demands declared ininput(a lightweight parse viaparse_seam). Empty for a program with no## Requiredecorators. - 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 ofrun_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_ concurrent_ traced run_vm_concurrent_seeded, also returning the recorded scheduling trace — the seam the.replayfailure artifact captures its schedule through.- run_
vm_ concurrent_ traced_ with_ config run_vm_concurrent_tracedunder an explicitSchedulerConfig(the config-parameterized core both the default-config and knobbed entry points delegate to).- run_
vm_ concurrent_ with_ config - Run a concurrent program on the VM under an EXPLICIT
SchedulerConfig— the same knob surface the AOT bytecode-walker’s stepped scheduler exposes (crate::codegen_c::concurrency::SchedulerKnobs). This is the oracle side of the cross-tier knob equivalence:AOT-at-knobs-K == VM-at-knobs-K. The default-config wrapper isrun_vm_concurrent. - run_
vm_ io_ async - Run an IO program (peer networking and/or tcp.lg sockets) on the BYTECODE VM (single task, no
channels): drive the resumable VM and service each
VmBlock::Net*/VmBlock::Tcpthrough the sharedNetInbox/TcpRegistry— the SAME seams the tree-walker uses — so networking and sockets run byte-identically on both tiers. The cross-tier locks prove they agree. - run_
vm_ net_ async - Run a peer-networking program on the BYTECODE VM — the historical name for
run_vm_io_async, kept so existing locks keep reading naturally. - 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_
engine - Select the tier used by subsequent in-process runs on this thread.
- 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_
certificate - Build an INDEPENDENTLY RE-CHECKABLE certificate for a proved English
## 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.
- value_
copy_ findings_ of - The value-semantics copy lint’s warnings for
input— seelogicaffeine_language::lint. Same shape aslgx_findings_of: computed on every parse, worth nothing until something reads it. - verify_
theorem - Phase 78: Verify a theorem with full kernel certification.
- vm_
listing - The bytecode the VM runs for
input, aslargo run --interpretcompiles it: the run path’s optimizer, the oracle and the VM compiler. One section per function,## Mainfirst, then## To <name>in code order, each instruction at its pc. A source that does not parse, or that only the tree-walker runs, answers why. - with_
monomorphic_ program with_parsed_programover the program’s monomorphic form (crate::monomorphize) — every generic function and applied generic type made concrete — for a backend that lowers only concrete code.- with_
monomorphic_ program_ checked with_parsed_program_checkedover the program’s monomorphic form (crate::monomorphize) — every generic function and applied generic type made concrete — for a backend that lowers only concrete code.- 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_ scoped with_optimized_program, with the assembled project’s file scope checked on the same parsed AST before it is optimized. Project runners use this to avoid assembling and parsing the entire project a second time merely to enforce import visibility.- 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 (see
parse_seam): lex → MWE → discovery → parse, with the file’s## Nodecorators installed as the active config.## Requireis NOT enforced here — this generic variant serves the differential-test seams and callers whose return type can’t carry a compile error; usewith_parsed_program_checkedfor the emit paths that must fail an unfired## Require. - with_
parsed_ program_ checked with_parsed_programfor a Result-returning compile (theemit c/isa/wasmbackends): installs## No, opens a## Requirefiring-trace aroundf, and afterfsucceeds fails the compile on any demanded optimization that did not fire — the honest answer when a backend (e.g. the VM tiers, which don’t memoize) cannot provide a required optimization.f’s own error propagates unchanged.- with_
parsed_ tensor_ program with_parsed_programthat also hands over every tensor’s(rows, cols)— the shape table the parser keeps and the desugared statements do not (a declaration desugars to a flatSeqofrows · colselements). The spatial walk reads it to declare each tensor in the shape the program gives it.- 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.