Skip to content

Commit 413f7e6

Browse files
Copilotphilzook58
andcommitted
Wrap qed() prove call and add test for qed errors
- Wrap prove call in qed() method for complete error coverage - Add test for qed() failures showing goal state context - All tests pass (31 passing) Co-authored-by: philzook58 <[email protected]>
1 parent c8dd177 commit 413f7e6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/kdrag/tactics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ def qed(self, **kwargs) -> kd.kernel.Proof:
15781578
kwargs["by"].extend(self.lemmas[-1].values())
15791579
else:
15801580
kwargs["by"] = list(self.lemmas[-1].values())
1581-
pf = kd.kernel.prove(thm, **kwargs)
1581+
pf = self._wrap_prove_error(kd.kernel.prove, thm, **kwargs)
15821582
kdrag.config.perf_event(
15831583
"ProofState", self.thm, time.perf_counter() - self.start_time
15841584
)

tests/test_proofstate_errors.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,21 @@ def test_simp_error_with_goal_state():
121121
# The wrapping is in place for when it does call prove
122122
l.simp()
123123
assert True # If we got here, simp didn't crash
124+
125+
126+
def test_qed_error_with_goal_state():
127+
"""Test that qed() errors include goal state context."""
128+
x = smt.Int("x")
129+
# Create a lemma but don't prove it
130+
l = kd.Lemma(x > 100)
131+
132+
with pytest.raises(ProofStateError) as exc_info:
133+
# Try to finalize without proving the goal
134+
l.qed(by=[])
135+
136+
error = exc_info.value
137+
assert isinstance(error, ProofStateError)
138+
# Check that the goal state is in the error message
139+
assert "x > 100" in str(error)
140+
# Check that the original error is also present
141+
assert "Countermodel" in str(error)

0 commit comments

Comments
 (0)