A small kernel for propositional logic, written in Lean 4. It supports goal-directed natural deduction in both intuitionistic and classical logic, with an interactive REPL and tooling for automated puzzle generation and verification.
The kernel models propositional proofs as a stack of goals. Each goal is a pair ⟨Γ, φ⟩ where Γ is a context of indexed hypotheses and φ is the target proposition. Tactics define transitions on this stack; a proof is complete when the stack is empty.
P ::= ⊥ | <var> | P ∧ P | P ∨ P | P → P
| Tactic | Effect |
|---|---|
intro |
⊢ A → B → introduce A as a hypothesis, new goal ⊢ B |
exact n |
Close goal if hypothesis n matches it |
apply n |
hyp[n] = A → B, ⊢ B → new goal ⊢ A |
constructor |
⊢ A ∧ B → two subgoals ⊢ A and ⊢ B |
left / right |
⊢ A ∨ B → choose a side |
cases n |
Split ∨/∧ hypothesis, or close goal from ⊥ |
lem P |
Introduce ¬P ∨ P (classical logic) |
PropLogicKernel/
Kernel.lean — core types and tactic semantics
Auto.lean — iterative-deepening proof search
Parser.lean — proposition and tactic parser
Printer.lean — precedence-aware pretty printer
Serialize.lean — serialization helpers
REPL/
REPL.lean — REPL protocol
Command.lean — command dispatch
Main.lean — entry point
Requires Lean 4 / elan. Toolchain version is pinned in lean-toolchain.
lake build./.lake/build/bin/Main-leanThen type propositions and tactics interactively:
> new A ∧ B → B ∧ A
> intro
> cases 0
> constructor
> exact 2
> exact 1
An interactive browser-based proof REPL lives in claude/web_repl. It lets you type propositions, apply tactics step by step, undo moves, and run an auto-solver — all without the Lean binary.
Prerequisites: Node.js
# 1. Build the TypeScript kernel library
cd claude/ts_prop_logic_kernel
npm install
npm run build
# 2. Start the dev server
cd ../web_repl
npm install
npm run devThen open http://localhost:5173 in your browser.
Python tooling for generating datasets of propositional logic puzzles and verifying them against the built kernel.
Prerequisites: uv, and lake build completed first.
cd claude
uv syncuv run python examples/generate_puzzles.py \
--min-vars 4 --max-vars 6 \
--min-depth 4 --max-depth 8 \
--examples-per-config 50Output goes to output/prop_logic_puzzle/, organized by num_vars and depth. Run with --help for all options.
uv run python examples/check_puzzles.pyRuns every puzzle in output/prop_logic_puzzle/ through the kernel binary and writes a result.csv with pass/fail per file.
HF_USER=your-username uv run python examples/upload_huggingface.pyThe Lean 4 source (PropLogicKernel/, REPL/, Main.lean) is written by the author. The Python tooling (claude/py_prop_logic_kernel/, claude/examples/, claude/main.py), TypeScript port (claude/ts_prop_logic_kernel/), web UI (claude/web_repl/), and this README were generated with AI assistance (Claude).