No project description provided
Project description
PROP-LOGIC-KERNEL
This project is a small proposition-logic tactic kernel in Lean, exposed through a line-based REPL.
LEAN MODULE
PropLogicKernel/Basic.lean: proposition syntax, tactics, goals, and statePropLogicKernel/Parser.lean: parser for propositions and tactic commands (written by cursor)PropLogicKernel/Resolver.lean: operational semantics for tacticsPropLogicKernel/Printer.lean: rendering of propositions, tactics, and goalsPropLogicKernel/REPL.lean: REPL-level state, status lines, and exit-code policyREPL/REPL.lean: generic line-based REPL loopMain.lean: executable entrypoint
PROPOSITION SPECIFICATION
A proposition P is one of:
⊥- atom
A ∧ BA ∨ BA → B
Associativity follows the parser/printer implementation:
∧,∨, and→are parsed right-associatively- parentheses may be used explicitly
PARSER SPECIFICATION
PropLogicKernel/Parser.lean uppercases proposition input before parsing.
After uppercasing, proposition input is rejected unless every character is one of:
- whitespace
(,)∧,∨,→,⊥- uppercase letters
A-Z - digits
0-9 - underscore
_
Atom names are maximal nonempty strings over:
- uppercase letters
A-Z - digits
0-9 - underscore
_
Examples of valid atom names:
AP1HELLO_WORLDX_2
GOAL/STATE MODEL
A goal consists of:
- a set of hypotheses
- a target proposition
The state tracks:
- a list of goals
varCountnewCountsorrCount
TACTIC
These are the kernel rules implemented by PropLogicKernel/Resolver.lean.
intro- If goal is
A → B, add a fresh hypothesisAand replace the goal withB.
- If goal is
apply n- If hypothesis
nisA → Band current goal isB, replace the goal withA.
- If hypothesis
exact n- If hypothesis
nexactly matches the current goal, solve the goal.
- If hypothesis
constructor- If goal is
A ∧ B, split it into two goals.
- If goal is
left- If goal is
A ∨ B, replace the goal withA.
- If goal is
right- If goal is
A ∨ B, replace the goal withB.
- If goal is
cases n- If hypothesis
nisA ∨ B, branch into two goals. - If hypothesis
nisA ∧ B, add both parts as fresh hypotheses. - If hypothesis
nis⊥, solve the goal immediately.
- If hypothesis
CLASSICAL LOGIC
lem P- Classical only.
- Adds hypothesis
(P → ⊥) ∨ P.
refine n- Classical only.
- If hypothesis
nisA1 → B1and goal isB, replace the current goal with goalsB1 → BandA1.
APPLICATION LEVEL COMMANDS
sorry- Solves the current goal unconditionally and increments
sorrCount.
- Solves the current goal unconditionally and increments
new P- Pushes a fresh goal
Pand incrementsnewCount.
- Pushes a fresh goal
FAILURE BEHAVIOR
- Parse failures return
parse error. - Resolution failures return an error message and keep the previous state.
lemandrefinefail if classical logic is disabled.- Any tactic other than
newfails on an empty goal stack.
REPL protocol
The executable built by lake build runs REPL.run from REPL/REPL.lean.
For each step:
- write zero or more status/error lines to
stderr - write zero or more output lines to
stdout - write the prompt
>tostderrwith no trailing newline - read exactly one newline-terminated line from
stdin - transition to the next state
Status lines are prefixed by -- .
Typical status line:
-- new_count 1 sorry_count 0 goals_remaining 2
Success marker:
-- all goals accomplished!
That success marker is emitted iff:
- at least one goal was successfully introduced via
new - no
sorrywas used - all goals are solved
EXIT CODE POLICY
At EOF, REPL.run returns the previous step's code.
PropLogicKernel/REPL.lean sets exit code 0 iff (same with all goals accomplished!):
- at least one goal was successfully introduced via
new - no
sorrywas used - all goals are solved
Otherwise exit code is 1.
Parse/resolution errors do not automatically force exit code 1; they preserve the previous state. So if the kernel is already in a success state, a later failing command can still leave final exit code 0.
DISCLAIMER: AI GENERATED CODE
The following files were written by Cursor:
README.md- All Python code in this repo (for example:
py_prop_logic_kernel/) PropLogicKernel/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.6.tar.gz.
File metadata
- Download URL: py_prop_logic_kernel-0.0.6.tar.gz
- Upload date:
- Size: 16.6 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 |
2f65786980962621bd7d84dd77b94a8f25824901b760ff3d2833e9934e55d053
|
|
| MD5 |
0dfe9539cc7971fe1ce7a9aa57d6f5fc
|
|
| BLAKE2b-256 |
518973f76e24d0b2adb39dbf979bcf61943e87eedc7ea32eac8dca0e8fe6aa7a
|
File details
Details for the file py_prop_logic_kernel-0.0.6-py3-none-any.whl.
File metadata
- Download URL: py_prop_logic_kernel-0.0.6-py3-none-any.whl
- Upload date:
- Size: 10.7 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 |
c4f68f6f73eebc5edd7a34e668d2162dada303e42fa05ddbfdce75ada5f974b6
|
|
| MD5 |
3ccd38fd52107945438d63d8cddb7987
|
|
| BLAKE2b-256 |
414a6946dea4f5dd2a59c058d3d0e51173ebc5036291520fddac96ca2710f87e
|