Skip to content

Commit

Permalink
add three error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Dec 20, 2024
1 parent 2b3f4bf commit 6d3c88d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
MINIF2F_TEST_FILE = PROJECT_ROOT / 'experiments/minif2f/test.jsonl'
MINIF2F_ROOT = PROJECT_ROOT / 'experiments/minif2f/MiniF2F'

@pytest.fixture
def minif2f_root():
return MINIF2F_ROOT

@pytest.fixture
def minif2f_valid():
return pd.read_json(MINIF2F_VALID_FILE, lines=True)
Expand Down
39 changes: 38 additions & 1 deletion tests/test_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@
from pantograph.expr import *
from pantograph.server import TacticFailure

special_cases = [
"""theorem mathd_numbertheory_552
(f g h : ℕ+ → ℕ)
(h₀ : ∀ x, f x = 12 * x + 7)
(h₁ : ∀ x, g x = 5 * x + 2)
(h₂ : ∀ x, h x = Nat.gcd (f x) (g x))
(h₃ : Fintype (Set.range h)) :
(∑ k in (Set.range h).toFinset, k) = 12 := sorry
""",
"""theorem amc12_2000_p15
(f : ℂ → ℂ)
(h₀ : ∀ x, f (x / 3) = x ^ 2 + x + 1)
(h₁ : Fintype (f ⁻¹' {7})) :
(∑ y in (f ⁻¹' {7}).toFinset, y / 3) = -1 / 9 := sorry
""",
"""theorem sample (p q r x : ℂ)
(h₀ : (x - p) _(x - q) = (r - p)_ (r - q)) :
(x - r) _x = (x - r)_ (p + q - r) := sorry
"""
]

@pytest.mark.basic
def test_goal_start_with_ambiguous_type():
Expand All @@ -18,4 +38,21 @@ def test_goal_start_with_ambiguous_type():
state = server.goal_start("1 + 1 = 2")
with pytest.raises(TacticFailure):
server.goal_tactic(state, 0, "simp")


@pytest.mark.error
def test_jsondecode(minif2f_root):
server = Server(imports=['Mathlib', 'Init'], project_path=minif2f_root)
unit = server.load_sorry(special_cases[0])
goal_state, message = unit.goal_state, '\n'.join(unit.messages)
assert unit is not None and 'error' not in message.lower() and len(goal_state.goals) == 1

unit = server.load_sorry(special_cases[1])
goal_state, message = unit.goal_state, '\n'.join(unit.messages)
assert unit is not None and 'error' not in message.lower() and len(goal_state.goals) == 1

@pytest.mark.error
def test_proof_with_warn_type(minif2f_root):
server = Server(imports=['Mathlib', 'Init'], project_path=minif2f_root)
unit = server.load_sorry(special_cases[2])
goal_state, message = unit.goal_state, '\n'.join(unit.messages)
assert unit is not None and 'error' not in message.lower() and len(goal_state.goals) == 1

0 comments on commit 6d3c88d

Please sign in to comment.