idp_engine.Problem¶
Class to represent a collection of theory and structure blocks.

class
idp_engine.Problem.
Problem
(*blocks, extended=False)[source]¶ A collection of theory and structure blocks.

extended
¶ True when the truth value of inequalities and quantified formula is of interest (e.g. in the Interactive Consultant)
 Type
Bool

declarations
¶ the list of type and symbol declarations
 Type
dict[str, Type]

constraints
¶ a set of assertions.
 Type

assignments
¶ the set of assignments. The assignments are updated by the different steps of the problem resolution. Assignments include inequalities and quantified formula when the problem is extended
 Type

clark
¶ A mapping of defined symbol to the rule that defines it.
 Type
dict[(SymbolDeclaration, Definition), Rule]

def_constraints
¶ A mapping of defined symbol to the wholedomain constraint equivalent to its definition.
 Type
dict[SymbolDeclaration, Definition], Expression

interpretations
¶ A mapping of enumerated symbols to their interpretation.
 Type
dict[string, SymbolInterpretation]

goals
¶ A set of goal symbols
 Type
dict[string, SymbolDeclaration]

_formula
¶ the logic formula that represents the problem.
 Type
Expression, optional

co_constraints
¶ the set of co_constraints in the problem.
 Type

assert_
(code: str, value: Any, status: idp_engine.Assignments.Status = <Status.GIVEN: 2>)[source]¶ asserts that an expression has a value
 Parameters
code (str) – the code of the expression, e.g., “p()”
value (Any) – a Python value, e.g., “True”
status (Status, Optional) – how the value was obtained. Default: Status.GIVEN

symbolic_propagate
(tag=<Status.UNIVERSAL: 4>)[source]¶ determine the immediate consequences of the constraints

get_range
(term: str)[source]¶ Returns a copy of the problem, with its
assignments
property containing a description of the possible values of the term.

explain
(consequence)[source]¶ returns the facts and laws that justify ‘consequence in the ‘self Problem
 Parameters
self (Problem) – the problem state
consequence (string) – the code of the sentence to be explained. Must be a key in self.assignments
 Returns
list of facts and laws that explain the consequence
 Return type
(facts, laws) (List[Assignment], List[Expression])]

simplify
()[source]¶ returns a simpler copy of the Problem, using known assignments
Assignments obtained by propagation become fixed constraints.

decision_table
(goal_string='', timeout=20, max_rows=50, first_hit=True, verify=False)[source]¶ returns a decision table for goal_string, given self.
 Parameters
goal_string (str, optional) – the last column of the table.
timeout (int, optional) – maximum duration in seconds. Defaults to 20.
max_rows (int, optional) – maximum number of rows. Defaults to 50.
first_hit (bool, optional) – requested hitpolicy. Defaults to True.
verify (bool, optional) – request verification of table completeness. Defaults to False
 Returns
the nonempty cells of the decision table
 Return type
list(list(Assignment))
