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: object

Evaluates 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:
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:
static evaluate_with_assignment(expression, assignment)[source]

Evaluates a logical expression under a specific truth assignment.

Parameters:
  • expression (LogicalExpression) – The logical expression to evaluate

  • assignment (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: object

Generates 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.

is_satisfiable()[source]

Checks if there exists a truth assignment that makes the expression true.

Return type:

bool

Returns:

True if at least one assignment makes the expression True, otherwise False.

is_tautology()[source]

Checks if the expression is always true.

Return type:

bool

Returns:

True if the expression evaluates to True for all assignments, otherwise False.

Modules

evaluator

Expression evaluator module.

truth_table