Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"

tasks:
deps:
desc: "Install Python packages and Lean toolchain"
cmds:
- pip install --upgrade pip
- pip install -r requirements.txt
- curl -fsSL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | bash -s -- -y
- echo "source $HOME/.elan/env" >> ~/.bashrc

test:
desc: "Run PyTest suite"
deps: [deps]
cmds:
- bash -c '. "$HOME/.elan/env" && export PYTHONPATH="$PWD" && pytest -q tests/'
37 changes: 37 additions & 0 deletions tests/test_sanity_loss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# tests/test_sanity_loss.py
import torch
import torch.nn as nn

def test_dummy_loss_decreases():
"""
Sanity-check that a mini training step actually lowers loss.
Uses a 2-layer MLP on random data so it runs in <2 s on CPU.
"""
torch.manual_seed(0)

model = nn.Sequential(
nn.Linear(4, 8),
nn.ReLU(),
nn.Linear(8, 1)
)

x = torch.randn(32, 4)
y = torch.randn(32, 1)

criterion = nn.MSELoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)

# loss before training
loss_start = criterion(model(x), y).item()

# one quick training step
optimizer.zero_grad()
criterion(model(x), y).backward()
optimizer.step()

# loss after training
loss_end = criterion(model(x), y).item()

assert loss_end < loss_start, (
f"loss did not decrease: start={loss_start:.4f}, end={loss_end:.4f}"
)
6 changes: 6 additions & 0 deletions tests/test_sanity_tactic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from tests.util_stub import suggest_tactics

def test_tactic_generator_nonempty():
"""Generator should emit at least one tactic string."""
tactics = suggest_tactics("⊢ 1 = 1")
assert tactics and any(t.strip() for t in tactics), "generator returned nothing"
3 changes: 3 additions & 0 deletions tests/util_stub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def suggest_tactics(state, top_k=3):
"""Return a dummy tactic list (acts like a stand-in for the real generator)."""
return ["rfl"] # works for the goal ⊢ 1 = 1