from enum import Enum
from typing import Iterable
from gavel.logic.logic import LogicElement
class ProblemElement:
pass
class Sentence(ProblemElement):
def is_conjecture(self):
raise NotImplementedError
class AnnotatedFormula(Sentence):
__visit_name__ = "annotated_formula"
def __init__(
self,
logic,
name: str = None,
role: FormulaRole = None,
formula: LogicElement = None,
annotation=None,
):
self.logic = logic
self.name = name
self.role = role
self.formula = formula
self.annotation = annotation
def symbols(self):
return self.formula.symbols()
def is_conjecture(self):
return self.role in (FormulaRole.CONJECTURE, FormulaRole.NEGATED_CONJECTURE)
def __str__(self):
return (
"{logic}({name},{role},{formula})".format(
logic=self.logic, name=self.name, role=self.role, formula=self.formula
)
+ ("# " + str(self.annotation))
if self.annotation
else ""
)
def __eq__(self, other):
return type(self) == type(other) and all(
getattr(self, n) == getattr(other, n) for n in self.__dict__
)
class Import(ProblemElement):
__visit_name__ = "import"
def __init__(self, path):
self.path = path.replace("'", "")
[docs]class Problem:
"""
This class stores the important information that are needed for a proof
Attributes
----------
premises: :class:`gavel.logic.logic.Sentence`
The premises available for this problem
conjecture: :class:`gavel.logic.logic.Sentence`
The conjecture that should be proven`
"""
def __init__(
self, premises: Iterable[Sentence], conjecture: Iterable[Sentence], imports=None
):
self.premises = premises
self.conjecture = conjecture
self.imports = imports or []