ca98703538
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYqwNMyPUHeTbFWg83GQq6
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from leanbench.lint import lint
|
||
from leanbench.project import project
|
||
|
||
|
||
def found(code):
|
||
return lint(project(code))
|
||
|
||
|
||
def test_clean_statement_has_no_findings():
|
||
code = "theorem t (G : Type*) [Group G] (g : G) : g * 1 = g := by sorry"
|
||
assert found(code) == []
|
||
|
||
|
||
def test_unused_binder():
|
||
assert "unused_binder:k" in found("theorem t (n k : ℕ) : n = n := by rfl")
|
||
|
||
|
||
def test_carrier_type_is_not_flagged_as_unused():
|
||
assert not any(f.startswith("unused") for f in found(
|
||
"theorem t (G : Type*) [Group G] (g : G) : g = g := by rfl"))
|
||
|
||
|
||
def test_natural_subtraction_hazard():
|
||
assert "nat_subtraction" in found("theorem t (a b : ℕ) : a - b + b = a := by sorry")
|
||
assert "nat_subtraction" not in found("theorem t (a b : ℤ) : a - b + b = a := by ring")
|
||
|
||
|
||
def test_integer_division_hazard():
|
||
assert "integer_division" in found("theorem t (a : ℕ) : a / 2 * 2 = a := by sorry")
|
||
|
||
|
||
def test_trivial_goal_and_degenerate():
|
||
assert "trivial_goal" in found("theorem t (n : ℕ) : True := by trivial")
|
||
assert "degenerate" in found("theorem t : 2 + 2 = 4 := by norm_num")
|