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
4 changes: 4 additions & 0 deletions src/estimates/propositional_tactics.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ def __init__(self, statement: Boolean, name: str = "this") -> None:
def activate(self, state: ProofState) -> list[ProofState]:
if not isinstance(self.statement, Boolean):
raise ValueError(f"{self.statement!s} is not a proposition.")
if not is_defined(self.statement, state.get_all_vars()):
raise ValueError(
f"{self.statement!s} is not defined in the current proof state."
)
name = state.new(self.name)
new_states = []
new_state = state.copy()
Expand Down
13 changes: 13 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,16 @@ def test_subst_all_solution_reversed(self, capsys):
def test_sympy_simplify_solution(self, capsys):
sympy_simplify_solution()
self.proof_complete(capsys)

def test_bycases_requires_defined(self):
"""ByCases must reject free symbols not declared in the proof state."""
from sympy import Symbol
p = ProofAssistant()
x = p.var("pos_real", "x")
p.begin_proof(x > 0)
w = Symbol("w", real=True)
try:
p.use(ByCases(w > 1, "h"))
assert False, "expected ValueError"
except ValueError as e:
assert "not defined" in str(e)
Loading