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")