Skip to content
Open
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
25 changes: 19 additions & 6 deletions packages/proveit/logic/booleans/quantification/existence/exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def eliminate(skolem_constants, judgment, **defaults_config):
Exists.choose() method to produce the Skolem constant-based
subset of assumptions you wish to eliminate from S.
'''
from proveit import Lambda
from proveit import free_vars, Lambda
from proveit import n, P, Q, alpha
from proveit.logic import And
from proveit.core_expr_types import (x_1_to_n, y_1_to_n)
Expand All @@ -157,6 +157,18 @@ def eliminate(skolem_constants, judgment, **defaults_config):
"Skolem constants to be eliminated must appear "
"exactly as specified in the original "
"Exists.choose() method.".format(skolem_constants))
# Since the Skolem constants appear to be correct, we check
# if any of the Skolem constants appear as free variables in
# the judgment, raising an error if so:
skolem_constants_remaining = (
set(skolem_constants).intersection(free_vars(judgment)) )
if skolem_constants_remaining != set():
raise ValueError(
"In calling the Exists.eliminate() static method, which "
"might have arisen from a judgment.eliminate() call, "
f"the Skolem constant(s) {skolem_constants_remaining} "
"still appear as free variable(s) in the target judgment "
f"{judgment}, which is not allowed. ")
existential = Exists.skolem_consts_to_existential[skolem_constants]
skolem_assumptions = set(existential.choose(
*skolem_constants, print_message=False))
Expand Down Expand Up @@ -184,11 +196,12 @@ def eliminate(skolem_constants, judgment, **defaults_config):
# the skolem_elim theorem being instantiated further below
P_implies_alpha = _alpha.as_implication(
hypothesis=_P.apply(*skolem_constants))
# the generalization to further match theorem details
# can be handled through automation
# P_implies_alpha.generalize(
# skolem_constants,
# conditions=[_Q.apply(*skolem_constants)])
# Although the generalization to further match theorem
# details can be handled through automation, it can reduce
# computations to explicitly handle it here right now:
P_implies_alpha.generalize(
skolem_constants,
conditions=[_Q.apply(*skolem_constants)])

return skolem_elim.instantiate(
{n: _n, P: _P, Q: _Q, alpha: _alpha,
Expand Down