agent_logic.core.functions
Classes
|
Represents a function f(x) in predicate logic. |
|
Represents a predicate relation R(x, y, ...). |
- class agent_logic.core.functions.Function(**data)[source]
Bases:
BaseModelRepresents a function f(x) in predicate logic.
- Parameters:
name (str)
parameters (List[str])
function (Callable[[...], Any])
- evaluate(context)[source]
Evaluate the function using context for parameter values.
- Return type:
Any- Parameters:
context (Dict[str, Any])
- function: Callable[..., Any]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str
- parameters: List[str]
- class agent_logic.core.functions.Relation(**data)[source]
Bases:
LogicalExpressionRepresents a predicate relation R(x, y, …).
- Parameters:
name (str)
parameters (List[str])
- depth()[source]
Computes the depth of the logical expression tree.
- Return type:
int- Returns:
Integer representing the depth of the expression tree.
- Raises:
NotImplementedError – This is an abstract method that must be implemented by subclasses.
- evaluate(context)[source]
Evaluates a predicate relation based on the truth values in context.
- Return type:
bool- Parameters:
context (Dict[str, bool])
- classmethod from_dict(data)[source]
Recursively reconstructs an expression from a dictionary.
- Parameters:
data (
Dict) – Dictionary representation of a logical expression. Must include a ‘type’ field.- Return type:
- Returns:
Reconstructed logical expression.
- Raises:
ValueError – If the data is not a dictionary, doesn’t have a type field, or has an unknown expression type.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str
- parameters: List[str]