Interface API¶
This page documents the interface classes used to communicate with the Lean REPL.
Commands¶
Command¶
lean_interact.interface.Command
¶
Bases: BaseREPLQuery
, CommandOptions
Command to be executed in the REPL.
Attributes:
cmd: The command to be executed.
env: The environment to be used (optional). If env = None
, starts a new session (in which you can use import
).
If env
is set, the command is executed in the given environment.
all_tactics: If true, return all tactics used in the command with their associated information.
root_goals: If true, return root goals, i.e. initial goals of all declarations in the command, even if they already have a proof.
infotree: Return syntax information. Should be "full", "tactics", "original", or "substantive". Anything else is ignored.
Source code in lean_interact/interface.py
FileCommand¶
lean_interact.interface.FileCommand
¶
Bases: BaseREPLQuery
, CommandOptions
Command for file operations in the REPL. Attributes: path: The path of the file to be operated on. all_tactics: If true, return all tactics used in the command with their associated information. root_goals: If true, return root goals, i.e. initial goals of all declarations in the command, even if they already have a proof. infotree: Return syntax information. Should be "full", "tactics", "original", or "substantive". Anything else is ignored.
Source code in lean_interact/interface.py
ProofStep¶
lean_interact.interface.ProofStep
¶
Bases: BaseREPLQuery
Proof step in the REPL. Attributes: proof_state: The proof state to start from. tactic: The tactic to be applied.
Source code in lean_interact/interface.py
PickleEnvironment¶
lean_interact.interface.PickleEnvironment
¶
Bases: BaseREPLQuery
Environment for pickling in the REPL. Attributes: env: The environment to be used. pickle_to: The path to save the pickle file.
Source code in lean_interact/interface.py
UnpickleEnvironment¶
lean_interact.interface.UnpickleEnvironment
¶
Bases: BaseREPLQuery
Environment for unpickling in the REPL. Attributes: unpickle_env_from: The path to the pickle file.
Source code in lean_interact/interface.py
PickleProofState¶
lean_interact.interface.PickleProofState
¶
Bases: BaseREPLQuery
Proof state for pickling in the REPL. Attributes: proof_state: The proof state to be pickled. pickle_to: The path to save the pickle file.
Source code in lean_interact/interface.py
UnpickleProofState¶
lean_interact.interface.UnpickleProofState
¶
Bases: BaseREPLQuery
Environment for unpickling in the REPL. Attributes: unpickle_proof_state_from: The path to the pickle file.
Source code in lean_interact/interface.py
Responses¶
BaseREPLResponse¶
lean_interact.interface.BaseREPLResponse
¶
Bases: REPLBaseModel
Base class for all Lean responses. Attributes: messages: List of messages in the response. sorries: List of sorries found in the submitted code.
Source code in lean_interact/interface.py
get_errors()
¶
get_warnings()
¶
has_errors()
¶
lean_code_is_valid(start_pos=None, end_pos=None, allow_sorry=True)
¶
Check if the submitted code is valid Lean code.
Source code in lean_interact/interface.py
CommandResponse¶
lean_interact.interface.CommandResponse
¶
Bases: BaseREPLResponse
Response to a command in the REPL.
Attributes:
env: The environment state after running the code in the command
tactics: List of tactics in the code. Returned only if all_tactics
is true.
infotree: The infotree of the code. Returned only if infotree
is true.
messages: List of messages in the response.
sorries: List of sorries found in the submitted code.
Source code in lean_interact/interface.py
ProofStepResponse¶
lean_interact.interface.ProofStepResponse
¶
Bases: BaseREPLResponse
Response to a proof step in the REPL.
Attributes:
proof_status: The proof status of the whole proof. Possible values: Completed
, Incomplete
, Error
.
proof_state: The proof state after the proof step.
goals: List of goals after the proof step.
traces: List of traces in the proof step.
messages: List of messages in the response.
sorries: List of sorries found in the submitted code.
Source code in lean_interact/interface.py
Helper Classes¶
Message¶
lean_interact.interface.Message
¶
Bases: REPLBaseModel
Message in the REPL. Attributes: start_pos: The starting position of the message. end_pos: The ending position of the message. severity: The severity of the message. data: The data associated with the message.
Source code in lean_interact/interface.py
Sorry¶
lean_interact.interface.Sorry
¶
Bases: REPLBaseModel
Sorry message in the REPL. Attributes: start_pos: The starting position of the sorry message. end_pos: The ending position of the sorry message. goal: The proof goal at the sorry location. proof_state: The proof state associated to the sorry.
Source code in lean_interact/interface.py
Pos¶
lean_interact.interface.Pos
¶
Bases: REPLBaseModel
Source code in lean_interact/interface.py
Tactic¶
lean_interact.interface.Tactic
¶
Bases: REPLBaseModel
Tactic in the REPL. Attributes: start_pos: The starting position of the tactic. end_pos: The ending position of the tactic. goals: The goals associated with the tactic. tactic: The applied tactic. proof_state: The proof state associated with the tactic. used_constants: The constants used in the tactic.