Skip to main content

Module interface

Module interface 

Source
Expand description

Re-export of the LOGOS interface types from the kernel crate.

Provides access to core types like World and Entity for integration with the LOGOS runtime. Vernacular interface for the Kernel.

Provides a text-based command interface for interacting with the kernel:

  • Definition name : type := term. - Add a definition
  • Check term. - Print the type of a term
  • Eval term. - Normalize and print a term
  • Inductive Name := C1 : T1 | C2 : T2. - Define an inductive type

§Surface extensions (they declare a SPELLING, never a global)

  • Notation "a ⊕ b" := ((myOp a) b). - Mixfix notation; identifier pieces are holes
  • Infixl 65 "⋄" := f. / Infixr / Prefix "∽" := neg. / Postfix "‼" := bang.
  • Macro "twice $e" := …. / MacroRules "list![$x, $xs]" := …. - Pattern rewriting
  • Section Name. … End Name. - Scope a Local Notation to a section
  • /-- doc -/, /-! module doc -/, -- line comment - Prose, which declares nothing

§Doors

Repl::execute reads ONE command and refuses a prefix; Repl::execute_document reads a whole document and stops at the first block that does not check.

parse_command and parse_command_in read a command from TEXT ALONE. One surface cannot be read from text alone — a literate Consider’s equation set has to be compiled against the discriminant’s inductive, and the constructor list, its order and its arities live in the kernel context — so parse_command_in_ctx is the door that has one.

§Literate Syntax (English-like alternative)

  • A Bool is either Yes or No. - Define an inductive type
  • ## To add (n: Nat) and (m: Nat) -> Nat: - Define a function
  • Consider x: When Zero: Yield m. - Pattern matching

Modules§

lean
Lean 4 kernel export (NDJSON 3.1) as an input surface of the LOGOS kernel.
literate_parser
Literate Specification Parser for the Kernel.
match_compile
The equation compiler: surface patterns → the kernel’s positional Match tree.
printer
The kernel’s surface, written back: the exact inverse of term_parser and command_parser.
surface
The SURFACE environment — user-declared notation, fixity and macros.

Structs§

BinderSurface
Everything the SURFACE says about ONE parameter that the kernel’s three-field Term::Pi cannot hold: how it is supplied, and what fills it when the caller does not.
Clause
One equation: one pattern per column, and the body those patterns’ variables are free in.
CompileReport
What the compiler noticed on the way through, beyond the term itself.
DeclarationSurface
A declared type split into the pure kernel type the context is keyed at and the per-parameter surface information that has to be recorded beside it.
InductiveMember
One member of an Command::InductiveBlock.
Repl
The Vernacular REPL.
Surface
The surface environment: a stack of scopes, innermost last.
TermParser
Recursive descent parser for Term syntax.

Enums§

Assoc
Which way a chain of one operator nests.
BinderKind
How a parameter is SUPPLIED at a call site – Lean’s four binder kinds.
Command
A command in the Vernacular language.
InterfaceError
Errors that can occur in the interface layer.
OperatorForm
The shape a fixity command implies for its operator.
ParseError
Parse errors for the Vernacular.
Pattern
A surface pattern, exactly as a When clause spells it.
PrintError
A term or command the LOGOS surface cannot spell (yet).
SurfaceDecl
A declaration that extends the SURFACE rather than the context. Emitted by the command parser, applied by the REPL — so the one place a parser extension can land is the surface environment.

Functions§

compile_clauses
Compile a clause matrix against a list of scrutinees.
compile_clauses_reporting
compile_clauses, plus what the compiler noticed.
parse_command
Parse ONE command, and require it to be the WHOLE input.
parse_command_in_ctx
Parse ONE command with the kernel CONTEXT available, and require it to be the whole input.
parse_command_prefix_in
Parse ONE command off the FRONT of input, returning it with the number of bytes consumed.
parse_command_prefix_in_ctx
Parse ONE command off the FRONT of input with the kernel CONTEXT available, returning it with the number of bytes consumed.
print_command
Spell command as one vernacular command, terminated by its period.
print_term
Spell term in the kernel term surface.
print_term_in
Spell term read in a context whose locals are locals: each prints as its own name. A goal and its hypotheses are spelled this way for a reader; a closed term’s round trip is print_term’s, which refuses a free name because the surface would read it as a global.
standard_context
A context of its own for a REPL or a document to extend: a copy-on-write clone of the process’s one standard library registration, crate::prelude::StandardLibrary::context.