Skip to main content

Crate rml

Crate rml 

Source

Re-exports§

pub use lean_export::export_lean;
pub use lean_export::lean_ident;
pub use lean_export::LeanExportResult;

Modules§

check
cst
Universal lossless CST infrastructure for issue #138.
cst_convert
Universal CST converter dispatch (issue #138).
cst_js
JavaScript ↔ .lino CST converter (issue #138).
cst_lean
Lean 4 ↔ .lino CST converter (issue #138).
cst_rocq
Rocq ↔ .lino CST converter (issue #138).
cst_rust
Rust ↔ .lino CST converter (issue #138).
lean_export
Lean 4 exporter for the typed RML fragment (issue #60).
meta
repl
RML — Interactive REPL (issue #29)
rocq
Rocq exporter for the typed LiNo fragment (issue #61).

Structs§

ActiveImplementationDescriptor
Active implementation selected by the current foundation scope for a construct such as and or not. This is the behaviour-facing counterpart to the global root-construct descriptor: strict pure-links mode consults it before falling back to the global registry.
AllowHostPrimitiveDecl
Parsed (allow-host-primitive <name>...) directive.
AtpOptions
Configured external ATP invocation for the (by atp) tactic.
AtpStatus
Parsed SZS status line from an ATP.
AutomaticSequenceDecision
Decision record produced by the built-in automatic-sequences plugin.
CheckResult
Result of a check call: a boolean indicating whether the term checks against the expected type, plus any diagnostics emitted along the way.
CoinductiveDecl
A parsed (coinductive Name (constructor …) …) declaration. Mirrors InductiveDecl but additionally guarantees the productivity check (at least one recursive constructor) has succeeded.
ConstructorDecl
One constructor of an inductive datatype.
ConvertOptions
Options for definitional equality / convertibility checks.
CoverageDiagnostic
Structured coverage diagnostic mirroring TotalityDiagnostic.
CoverageResult
Outcome of a coverage check.
DefineClause
One (case <pattern-args> <body>) clause of a (define …) declaration.
DefineDecl
A parsed (define <name> [(measure …)] (case …) …) declaration.
Dependency
Explicit dependency record used to keep unsupported claims partial.
Diagnostic
A single diagnostic emitted by parser, evaluator, or type checker.
Env
The evaluation environment: holds terms, assignments, operators, and range/valence config.
EnvOptions
Options for creating an Env.
EvalNatResult
Result of (eval-nat <term>). normal_form is the semantic result; the numeric value is only the legacy renderer for that Peano normal form.
EvaluateOptions
Options for evaluate_with_options — bundles environment settings with runtime flags like trace and with_proofs. Keeps evaluate() backwards compatible.
EvaluateResult
Result of evaluate(src): a list of query results (numeric or type) plus any diagnostics emitted while parsing/evaluating. When tracing is enabled via evaluate_with_options, trace carries the deterministic sequence of TraceEvent values recorded during evaluation; otherwise it is empty. When proof production is enabled (via EvaluateOptions::with_proofs or any per-query (? expr with proof) keyword), proofs[i] carries a derivation tree for results[i]; bare queries that did not request a witness get None so the vec stays index-aligned with results. Mirrors the JavaScript {results, diagnostics, trace, proofs} shape.
Formalization
A dependency-aware RML formalization.
FormalizationEvaluation
Evaluation result for the meta-expression adapter.
FormalizationRequest
Request object for formalize_selected_interpretation.
FoundationDescriptor
A foundation descriptor. Bundles a coherent set of root-construct interpretations. Selecting a foundation never silently rewires behaviour; the host operators always run, but the active-foundation tag is exposed via the foundation report so users can audit which foundation they are trusting.
FoundationFrame
Stack frame pushed when entering a foundation scope. Stores the previous active foundation name plus a snapshot of any operators the foundation rebinds, so exit_foundation can restore the prior semantics exactly. snapshot maps operator name -> previous Op (None if the op did not exist before). Carrier snapshot fields (issue #97 Section 2) preserve the strict-carrier state of the enclosing scope so nested (with-foundation ...) bodies roll back cleanly when their inner scope exits.
FoundationReport
Snapshot of the foundation/root-construct state for the trust report.
InductiveDecl
A parsed (inductive Name (constructor …) …) declaration.
Interpretation
Selected interpretation supplied by a consumer such as meta-expression.
Lambda
A stored lambda definition (param name, param type, body).
ProofAssumption
An explicit proof leaf. Proof objects cite these with (premise-by name) or (uses name) so assumptions and axioms are visible in the proof graph.
ProofAssumptionSnapshot
Printed view of a proof assumption/axiom for foundation_report().
ProofGoal
A single open proof goal plus its local hypothesis context.
ProofObject
A concrete derivation that claims to be an instance of a rule. Stored alongside the rule so (check-proof <name>) can re-validate it on demand without re-parsing the source.
ProofObjectSnapshot
Printed view of a ProofObject for foundation_report(). Mirrors ProofRuleSnapshot and additionally records the referenced rule.
ProofReport
Per-proof dependency/trust report (issue #97, Phase 13). Built by Env::proof_report and surfaced as RunResult::Proof so the trust audit can be performed for an individual proof object instead of only globally via foundation-report.
ProofReportDependency
One entry of the transitive dependency walk inside a ProofReport.
ProofReportVerdict
Verdict for (proof-report <name>). Mirrors CheckProofVerdict shape without the substitution table.
ProofRule
A declared rule of inference. Premises and the conclusion are stored as AST nodes; leaves whose token starts with ? are metavariables that bind during check_proof_object. Repeated metavariables must structurally match.
ProofRuleSnapshot
Printed view of a ProofRule for foundation_report(). Patterns are stringified via key_of so consumers can pretty-print without owning the AST representation.
ProofState
A tactic proof state: open goals and the successful tactic links applied so far.
RewriteOptions
Options for a single rewrite pass.
RewriteResult
Result of a single rewrite pass.
RootConstructDescriptor
A root-construct descriptor. Stored on the Env for the foundation registry (issue #97). Every field is purely informational: declaring a descriptor never changes evaluator behaviour. The CLI’s foundation report and tests inspect these records to verify the trust contract.
SimplifyOptions
Options for repeated simplification with a rewrite set.
SimplifyResult
Result of simplification by repeated rewrite passes.
Span
A source span: 1-based line/col, optional file path, and a length of the offending region (used to render carets in the CLI).
StrictFoundationDecl
Parsed (strict-foundation <profile>) directive.
SynthResult
Result of a synth call: the synthesised type as an AST node (or None when synthesis fails) plus any diagnostics emitted along the way.
TacticOptions
Options supplied to tactic execution.
TacticRunResult
Result of running tactics over a proof state.
TemplateDecl
A pre-evaluation template declaration (issue #59). (template (<name> <param>...) <body>) records a reusable link shape; later (<name> arg...) uses are expanded before they reach eval_node.
TerminationDiagnostic
Per-clause / per-call termination diagnostic returned by is_terminating.
TerminationResult
Outcome of a termination check.
TotalityDiagnostic
Per-clause / per-call totality diagnostic returned by is_total.
TotalityResult
Outcome of a totality check.
TraceEvent
A single trace event emitted by the evaluator.
TruthTableEntry
One resolved row inside an Op::TruthTable. Inputs and output are stored as f64 after symbolic constants have been looked up.
TruthTableRow
One row of a (truth-table <op> ...) declaration: a sequence of input tokens and the output token. See FoundationDescriptor::truth_tables.

Enums§

Aggregator
Supported aggregator types for AND/OR operators.
AtpStatusKind
High-level classification of a parsed SZS ATP status.
CheckProofVerdict
Result of validating a proof-object against its declared rule. On success the substitution map records each metavariable’s witness; on failure the error string is suitable for surfacing as an E064 diagnostic.
DefineMeasure
Optional measure attached to a (define …) declaration.
EvalResult
Result of evaluating an expression: either a plain value or a query result.
ExtractTarget
Supported source-code generation targets for extract_program.
FormalizationResultValue
Result value from evaluating a formalization.
ModeFlag
Per-argument mode flag for a relation declared via (mode …).
Node
AST node: either a leaf string or a list of child nodes.
Op
Operator types supported by the environment.
RewriteDirection
Direction for applying an equality rewrite rule.
RewriteOccurrence
Which occurrence of the left-hand side to rewrite.
RunResult
A result from running a query: a numeric value, a type string, a foundation report, or a per-proof report (issue #97).

Functions§

automatic_sequences_domain_plugin
build_corecursor_type
Compose the dependent corecursor type for Name-corec, given the parsed constructor list. The state parameter binds the symbol _state_type throughout, and each constructor case parameter binds case_<ctorName>.
build_dependency_graph
Build a [(name, [dep, ...]), ...] listing covering every registered root-construct in deterministic, sorted order at every level. Constructs with no dependencies map to an empty vector so the trust audit can still see them. Complement of Env::dependency_closure(name) which gives a per-construct slice.
build_eliminator_type
Compose the dependent eliminator type for Name-rec, given the parsed constructor list. The motive parameter binds the symbol _motive throughout, and each constructor case parameter binds case_<ctorName>.
build_proof
Build a derivation tree witnessing how node reduces under env. Returns a Node::List of the form (by <rule> <subderivation>...).
check
Check term against expected_type under env.
check_proof_object
classify_equality_rule
Equality-layer classification used by both build_proof and the per-query provenance walker. Precedence (issue #97): assigned > structural > definitional > numeric. Returns the rule string verbatim so JS and Rust emit identical labels.
compute_form_spans
Compute (line, col) source positions for every top-level link in text. Mirrors compute_form_spans in the JavaScript implementation.
dec_round
decide_automatic_sequence_theorem
decode_anum
Decode an anum-encoded string into a Node. Strictly enforces the [tag payload] shape; any character outside the four-abit alphabet raises an error. Returns the decoded Node; errors if trailing content remains after the top-level frame.
desugar_hoas
Higher-order abstract syntax (issue #51, D7): rewrite the surface keyword forall to the kernel binder Pi. Both forms share identical structure (<binder> (Type x) body), so the desugarer walks the AST and rewrites the head leaf in place. Object-language binders are encoded as host-language lambda and Pi/forall, letting substitution and capture-avoidance reuse the kernel primitives without a separate object-level binder representation.
encode_anum
equality_provenance_for_query
Return the equality-layer rule for a query whose body is a direct equality, or None for any other query shape. Composite queries like ((a = true) and (b = true)) are intentionally returned as None: the per-equality rules still appear in the proof witness, but the surface provenance describes the query itself.
eval_nat_term
Normalize a closed Peano term by dispatching through active links-level computation rules. Host arithmetic is only used by the final renderer.
eval_node
Evaluate an AST node in the given environment.
evaluate
Evaluate a complete LiNo knowledge base and return both results and any diagnostics emitted by the parser, evaluator, or type checker.
evaluate_file
Read a file from disk and evaluate it, honouring (import "...") directives. Mirrors evaluate() but takes a path on disk; relative imports inside the file are resolved against the file’s directory. A missing file is reported as an E007 diagnostic instead of an OS error.
evaluate_formalization
Evaluate a formalization when it has an executable RML AST.
evaluate_with_env
Variant of evaluate that runs against a caller-owned Env instead of allocating a fresh one. Used by the REPL to preserve state across inputs.
evaluate_with_options
Like evaluate, but takes structured EvaluateOptions. When options.trace is true the returned EvaluateResult.trace carries a deterministic sequence of TraceEvent values (operator resolutions, assignment lookups, top-level reductions) — one entry per event, in source order.
extract_literate_lino
Extract LiNo code from fenced lino blocks in a literate .lino.md file.
extract_program
Extract a typed, non-probabilistic lambda program to JavaScript or Rust.
flatten_neutral_applies
Drop the explicit apply keyword on neutral applications, recursively. (apply f a) whose head is a free constructor-like symbol becomes (f a) so the printed normal form matches the LiNo surface example from issue #50: (succ (succ zero)) rather than the explicit (apply succ (apply succ zero)).
formalize_selected_interpretation
Convert an explicitly selected interpretation into an executable or partial RML formalization.
format_diagnostic
Format a diagnostic for human-readable CLI output: <file>:<line>:<col>: <CODE>: <message> <source line> ^
format_foundation_report
Render the foundation report as a human-readable text block. Mirrors the JS formatFoundationReport helper.
format_proof_report
Pretty-print a ProofReport for the REPL / CLI. Mirrors the JS formatProofReport shape so transcripts agree across runtimes.
format_trace_event
Format a trace event as [span <file>:<line>:<col>] <kind> <details>.
format_trace_value
Format a numeric value for trace output — strips trailing zeros so 1.000000 reads as 1 and 0.5 stays 0.5. Mirrors formatTraceValue in the JavaScript implementation so cross-runtime traces match exactly.
goal_to_tptp
Export a proof goal plus local context as a TPTP FOF problem.
is_convertible
Decide whether two terms are definitionally equal under the current environment using beta-normalization and explicit equality assignments.
is_convertible_with_options
Variant of is_convertible with opt-in conversion features.
is_covered
Public coverage checker. Mirrors isCovered in the JavaScript implementation and returns identical diagnostic shapes so external tooling sees consistent output across runtimes.
is_num
Check if a string is numeric (including negative).
is_structurally_same
Check structural equality of two nodes.
is_terminating
Public termination checker. Returns a TerminationResult with structured diagnostics; callers can either propagate them as-is or convert each entry into a Diagnostic for the existing pipeline. The mirrored JS helper is exported under the same name (isTerminating).
is_total
Public totality checker. Returns a TotalityResult with structured diagnostics; callers can either propagate them as-is or convert each entry into a Diagnostic for the existing pipeline. The mirrored JS helper is exported under the same name (isTotal) and produces an equivalent shape so downstream tools see consistent output.
key_of
Create a canonical key representation of a node.
match_proof_pattern
nf
Public full normal form API (issue #50, D4). Reduces every redex in term, including those nested under binders and in argument positions, until the term is in beta-(eta-)normal form. The result is post-processed by flatten_neutral_applies so it prints in the surface shape (succ (succ zero)) from the issue.
nf_with_options
Variant of nf that takes an explicit ConvertOptions.
parse_allow_host_primitive_form
parse_atp_status
Parse the first SZS status line from ATP output.
parse_binding
Parse a binding form in two supported syntaxes:
parse_bindings
Parse comma-separated bindings: (Natural x, Natural y) → vec of (name, type) pairs. Tokens arrive as [“Natural”, “x,”, “Natural”, “y”] or [“Natural”, “x”] (single binding).
parse_coinductive_form
Parse a (coinductive Name (constructor …) …) form into a CoinductiveDecl. Panics with Coinductive declaration error: on a malformed or non-productive declaration so the existing diagnostic dispatch maps it to E036.
parse_inductive_form
Parse an (inductive Name (constructor …) …) form into an InductiveDecl. Panics with Inductive declaration error: on a malformed declaration so the existing diagnostic dispatch maps it to E033.
parse_lino
Parse LiNo text into a vector of link strings (each a top-level parenthesized expression).
parse_one
Parse tokens into an AST node.
parse_proof_assumption_form
parse_proof_object_form
parse_rule_form
parse_strict_foundation_form
parse_tactic_links
Parse a LiNo snippet into tactic links.
quantize
Quantize a value to N discrete levels in range [lo, hi]. For N=2 (Boolean): levels are {lo, hi} For N=3 (ternary): levels are {lo, mid, hi} For N<2 (continuous/unary): no quantization See: https://en.wikipedia.org/wiki/Many-valued_logic
register_coinductive
Install a coinductive declaration on the environment: register the type, every constructor, and the generated corecursor together with its dependent Pi-type. Mirrors registerCoinductive in the JavaScript kernel.
register_inductive
Install an inductive declaration on the environment: register the type, every constructor, and the generated eliminator together with its dependent Pi-type. Mirrors registerInductive in the JavaScript kernel.
rewrite
Rewrite goal once using equality eq from left to right.
rewrite_with_options
Rewrite goal once using equality eq and explicit options.
run
Run a complete LiNo knowledge base and return query results.
run_tactics
Apply link tactics to a proof state, stopping at the first failing tactic.
run_tactics_with_options
Apply link tactics with configured rewrite rules, stopping at the first failing tactic.
run_typed
Run a complete LiNo knowledge base and return query results (including type queries).
scan_pure_links_offenders
Walk a queried node and return sorted, deduplicated dependency paths that end at a host-primitive or host-derived construct and are not covered by (allow-host-primitive ...).
simplify
Repeatedly apply rules until no rule changes the term.
simplify_with_options
Repeatedly apply rules until no rule changes the term or the guard fires.
subst
Substitute all free occurrences of variable name with replacement in expr.
substitute
Backwards-compatible alias for subst.
synth
Synthesise the type of term under env.
tokenize_one
Tokenize a single link string into tokens (parens and words).
whnf
Public weak-head normal form API (issue #50, D4). Reduces only the spine of term — leaves binders and arguments untouched.
whnf_term
Weak-head normal form (D4): reduce the spine of node — i.e. unfold the head as long as there are arguments to apply to it — without descending into binders or argument positions. Mirrors whnfTerm in the JS runtime and nf/is_convertible already use normalize_term for the full version. Substitution may expose a redex inside the residual body, but that is no longer on the original spine, so this routine returns it unevaluated; full normalization is the place that descends into those positions.
whnf_with_options
Variant of whnf that takes an explicit ConvertOptions.

Type Aliases§

DomainPluginFn
A domain plugin receives the body of (domain <name> ...) and mutates the evaluator environment with any decisions it can certify.