agent_logic.evaluation
Logical evaluation module.
This module provides tools for evaluating logical expressions, including truth table generation and formula validation.
- class agent_logic.evaluation.Evaluator[source]
Bases:
objectEvaluates logical expressions with different truth assignments.
This class provides methods to evaluate expressions and determine logical properties such as consistency, validity, and equivalence.
- static are_equivalent(expr1, expr2)[source]
Determines if two expressions are logically equivalent.
Expressions are equivalent if they have the same truth value for all possible truth assignments to their variables.
- Parameters:
expr1 (
LogicalExpression) – First logical expressionexpr2 (
LogicalExpression) – Second logical expression
- Return type:
bool- Returns:
True if the expressions are equivalent, False otherwise
- static evaluate(expression, context)[source]
Evaluates a logical expression under a given context of truth values.
- Return type:
bool- Parameters:
expression (LogicalExpression)
context (Dict[str, bool])
- static evaluate_with_assignment(expression, assignment)[source]
Evaluates a logical expression under a specific truth assignment.
- Parameters:
expression (
LogicalExpression) – The logical expression to evaluateassignment (
Dict[str,bool]) – Dictionary mapping variable names to boolean values
- Return type:
bool- Returns:
Boolean result of evaluating the expression
- static expression_depth(expression)[source]
Computes the depth of a logical expression.
- Return type:
int- Parameters:
expression (LogicalExpression)
- static is_satisfiable(expression)[source]
Determines if an expression is satisfiable (true for at least one assignment).
- Parameters:
expression (
LogicalExpression) – The logical expression to check- Return type:
bool- Returns:
True if the expression is satisfiable, False otherwise
- static is_valid(expression)[source]
Determines if an expression is valid (true for all assignments).
- Parameters:
expression (
LogicalExpression) – The logical expression to check- Return type:
bool- Returns:
True if the expression is valid, False otherwise
- class agent_logic.evaluation.TruthTable(expression)[source]
Bases:
objectGenerates a truth table for a given logical expression.
- Parameters:
expression (LogicalExpression)
- generate()[source]
Generates all possible truth values for the logical expression.
- Return type:
List[Dict[str,Union[bool,str]]]- Returns:
List of dictionaries, where each dictionary represents a row in the truth table.
- is_contradiction()[source]
Checks if the expression is always false.
- Return type:
bool- Returns:
True if the expression evaluates to False for all assignments, otherwise False.
Modules
Expression evaluator module. |
|