Skip to main content

Module interface

Module interface 

Source
Expand description

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

Re-exports§

pub use match_compile::compile_clauses;
pub use match_compile::compile_clauses_reporting;
pub use match_compile::Clause;
pub use match_compile::CompileReport;
pub use match_compile::Pattern;
pub use printer::print_command;
pub use printer::print_term;
pub use printer::print_term_in;
pub use printer::PrintError;
pub use surface::Assoc;
pub use surface::OperatorForm;
pub use surface::Surface;
pub use surface::SurfaceDecl;

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.
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.
TermParser
Recursive descent parser for Term syntax.

Enums§

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.
ParseError
Parse errors for the Vernacular.

Functions§

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.
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.