No project description provided
Project description
prop-logic-kernel
This repo contains:
Main.lean: a tiny proposition-logic tactic kernel wrapped in aREPL.runlooppy_repl/: a small Python package that can drive anyREPL.run-based binary via stdin/stdout/stderrpy_prop_logic_kernel/: the Python package you publish; it parses the kernel output into structured steps such asgoals_remaining
Lean code spec
The Lean kernel is defined primarily by:
PropLogicKernel/Basic.lean: proposition syntax, tactics, goals, and statePropLogicKernel/Parser.lean: string parser for propositions and tacticsPropLogicKernel/Resolver.lean: operational semantics for each tacticPropLogicKernel/REPL.lean: REPL transition function built on top of the resolverMain.lean: executable entrypoint
Core data model
- A proposition
Pis one of:⊥, atom, conjunctionA ∧ B, disjunctionA ∨ B, implicationA → B. - A goal is a pair of:
- a hypothesis map from natural-number names to propositions
- a target proposition
- A state is a stack of goals plus a counter used to assign fresh hypothesis names.
Tactic resolution rules
These are the actual rules implemented in PropLogicKernel/Resolver.lean.
intro:- If the goal is
A → B, add a fresh hypothesisAand replace the goal withB.
- If the goal is
apply n:- If hypothesis
nisA → Band the current goal isB, replace the goal withA.
- If hypothesis
exact n:- If hypothesis
nis exactly the current goalA, solve the goal.
- If hypothesis
constructor:- If the goal is
A ∧ B, split it into two goals:AandB.
- If the goal is
left:- If the goal is
A ∨ B, replace it withA.
- If the goal is
right:- If the goal is
A ∨ B, replace it withB.
- If the goal is
cases n:- If hypothesis
nisA ∨ B, branch into two goals: one with fresh hypothesisA, one with fresh hypothesisB. - If hypothesis
nisA ∧ B, add fresh hypothesesAandBto the current goal. - If hypothesis
nis⊥, solve the goal immediately.
- If hypothesis
lem P:- Available only in classical mode.
- Adds a fresh hypothesis
(P → ⊥) ∨ P.
refine n:- Available only in classical mode.
- If hypothesis
nisA1 → B1and the current goal isB, replace the current goal with two goals:B1 → BA1
sorry:- Solves the current goal unconditionally.
new P:- Pushes a fresh goal
Ponto the state, with an empty hypothesis map.
- Pushes a fresh goal
Failure behavior
- If a tactic does not match the current goal or referenced hypothesis shape, resolution fails with an error message.
lemandrefinefail if classical logic is disabled.- Any tactic other than
newfails on an empty goal stack.
REPL protocol spec (REPL.run)
The executable produced by lake build (see .lake/build/bin/Main-lean) implements a simple line-based protocol driven by REPL.run in REPL/REPL.lean.
Each step:
- stderr (error/status stream): write zero or more lines of status/errors.
- In this repo, status lines are typically prefixed with
--(e.g.-- goals remaining 2).
- In this repo, status lines are typically prefixed with
- stdout (output stream): write zero or more lines of “main output” (e.g. the rendered goal state).
- stderr (prompt): write the prompt string (default
>) without a trailing newline. - stdin (input): read exactly one line (newline-terminated). That line is passed to the transition function.
Then the next step repeats forever.
Notes for clients
- Do not assume stdout and stderr are synchronized; a robust client should read both streams until it observes the prompt on stderr.
- Flush matters:
REPL/REPL.leanflushes stdout/stderr after writes so subprocess-driven clients do not hang on buffered output.
Python package spec
py_prop_logic_kernel is a Python-only wrapper around the built Lean binary.
py_prop_logic_kernel.Client:- starts
.lake/build/bin/Main-lean - sends lines to the REPL
- parses stderr for
-- goals remaining N - returns structured
Step(out, err, goals_remaining)
- starts
Client.send(line):- sends any supported REPL command, including
newandsorry
- sends any supported REPL command, including
Client.send_honest(line):- like
send, but ifneworsorryappears in the input line, it does not send the command and returns aStepwith the policy message inerr
- like
Client.init_prompt():- returns a human/AI-oriented summary of usage and tactic semantics
AI-generated code disclaimer
The following files were written by Cursor AI:
README.mdpy_prop_logic_kernel/__init__.pypy_prop_logic_kernel/client.pypy_prop_logic_kernel/repl.pypy_repl/__init__.pypy_repl/repl.pyPropLogicKernel/Parser.lean
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_prop_logic_kernel-0.0.3.tar.gz.
File metadata
- Download URL: py_prop_logic_kernel-0.0.3.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c73d062125ef217a3f23adc2103e005589ec41a9ad09abcfbfe29470fe75283a
|
|
| MD5 |
5368230daea9be01453edc23e3335d24
|
|
| BLAKE2b-256 |
59d13a9d1e81f3bb179def27bea7c890b8ad3e7f8c7e577387f048907b9e6493
|
File details
Details for the file py_prop_logic_kernel-0.0.3-py3-none-any.whl.
File metadata
- Download URL: py_prop_logic_kernel-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e1a2307262f5cb3f782404742db4a1052c937d3c95ad64003941336ee71f4c9
|
|
| MD5 |
51c6a1637d447209610c3bec111f0009
|
|
| BLAKE2b-256 |
d5663e8b8bfc8598b510be4aa7119bb32a11dc85f71ab584763c9a4bc6ff889c
|