pylogic.expressions package¶
Submodules¶
pylogic.expressions.abs module¶
pylogic.expressions.expr module¶
- class pylogic.expressions.expr.Add(*args, **kwargs)[source]¶
Bases:
Expr
- class pylogic.expressions.expr.BinaryExpression(*args, **kwargs)[source]¶
Bases:
CustomExpr
[U
]
- class pylogic.expressions.expr.CustomExpr(*args, **kwargs)[source]¶
Bases:
Expr
,Generic
[U
]U is the return type after evaluating the expression, unless it is not fully evaluated.
- class pylogic.expressions.expr.Expr(*args, **kwargs)[source]¶
Bases:
ABC
- abstractmethod evaluate(**kwargs) Expr [source]¶
Evaluate the expression. Keyword arguments are used for passing additional information to the evaluation function.
- is_atomic = False¶
- property is_even: bool | None¶
- property is_finite: bool | None¶
- is_in(other: Set | Variable, **kwargs) IsContainedIn [source]¶
- property is_integer: bool | None¶
- property is_list: bool | None¶
- property is_natural: bool | None¶
- property is_negative: bool | None¶
- property is_nonnegative: bool | None¶
- property is_nonpositive: bool | None¶
- property is_nonzero: bool | None¶
- property is_odd: bool | None¶
- property is_positive: bool | None¶
- property is_rational: bool | None¶
- property is_real: bool | None¶
- property is_sequence: bool | None¶
- property is_set: bool | None¶
- property is_zero: bool | None¶
- kwargs = [('knowledge_base', 'knowledge_base')]¶
- mutable_attrs_to_copy = ['independent_dependencies', '_is_real', '_is_rational', '_is_integer', '_is_natural', '_is_zero', '_is_nonpositive', '_is_nonnegative', '_is_positive', '_is_negative', '_is_even', '_is_sequence', '_is_set', '_is_list', '_is_finite', 'args', 'variables', 'independent_dependencies', 'constants', 'sets', 'class_ns', 'sets_contained_in']¶
- replace(replace_dict: dict, equal_check: Callable | None = None, positions: list[list[int]] | None = None) Self [source]¶
For replacing subexpressions in an expression. equal_check is a function that checks if two objects are equal in order to replace.
- property symbols: set[Any]¶
- unify(other: Self) Any | Literal[True] | None [source]¶
Algorithm to unify two expressions. If unification succeeds, a dictionary of values to instantiate variables to is returned. The dictionary never instantiates a variable y to variable y. It may instantiate a variable y to variable x or a variable y to a symbol or value y. If no instantiations need to be made (eg propositions are equal), return True. Otherwise (unification fails), return None.
- class pylogic.expressions.expr.Mul(*args, **kwargs)[source]¶
Bases:
Expr
- class pylogic.expressions.expr.Pow(*args, **kwargs)[source]¶
Bases:
Expr
- pylogic.expressions.expr.distance(a, b, eval_func: Callable[[U, U], Term | None] | None = None) Abs | CustomExpr [source]¶
General distance function.
Returns an expression representing the ‘distance’ between two terms.
When evaluated, it returns the absolute value of the difference for real numbers, or the result of the evaluation function for other types.
- pylogic.expressions.expr.replace(expr: Any, replace_dict: dict, equal_check: Callable | None = None, positions: list[list[int]] | None = None) Any [source]¶
For replacing subexpressions in an expression. equal_check is a function that checks if two objects are equal in order to replace.
- pylogic.expressions.expr.to_sympy(expr: int) Integer [source]¶
- pylogic.expressions.expr.to_sympy(expr: float) Float
- pylogic.expressions.expr.to_sympy(expr: Fraction) Rational
- pylogic.expressions.expr.to_sympy(expr: Expr) Basic
- pylogic.expressions.expr.to_sympy(expr: Any) Symbol
- pylogic.expressions.expr.to_sympy(expr: Set) Set
pylogic.expressions.function module¶
- class pylogic.expressions.function.CalledFunction(*args, **kwargs)[source]¶
Bases:
Expr
- class pylogic.expressions.function.Function(*args, **kwargs)[source]¶
Bases:
Expr
the function’s args include the domain and codomain.
- class pylogic.expressions.function.SelfFunc(*args: Any)[source]¶
Bases:
Expr
- pylogic.expressions.function.contains_self(expr: Expr) bool [source]¶
Check if an expression contains a SelfFunc.
pylogic.expressions.gcd module¶
pylogic.expressions.limit module¶
- class pylogic.expressions.limit.Limit(*args, **kwargs)[source]¶
Bases:
Expr
- evaluate(**kwargs) Limit | Constant [source]¶
Evaluate the expression. Keyword arguments are used for passing additional information to the evaluation function.
- classmethod make_epsilon_N_definition(limit: Term, sequence: Sequence | Variable, **kwargs) ForallInSet [source]¶
pylogic.expressions.max module¶
- class pylogic.expressions.max.Max(*args, **kwargs)[source]¶
Bases:
Expr
pylogic.expressions.min module¶
pylogic.expressions.mod module¶
- class pylogic.expressions.mod.Mod(*args, **kwargs)[source]¶
Bases:
Expr
The smallest natural number that remains when an integer is divided by another integer.
pylogic.expressions.piecewise module¶
- class pylogic.expressions.piecewise.OtherwiseBranch(then: Any)[source]¶
Bases:
Expr
- pylogic.expressions.piecewise.Piecewise¶
alias of
PiecewiseExpr
- class pylogic.expressions.piecewise.PiecewiseBranch(*args, **kwargs)[source]¶
Bases:
Expr
,Generic
[P
]Represents one branch of a piecewise function. Technicially, this should not be used in isolation, but only as part of a PiecewiseExpr.
- class pylogic.expressions.piecewise.PiecewiseExpr(*args, **kwargs)[source]¶
Bases:
Expr
,Generic
[Unpack
[Ps
]]- evaluate(knowledge_base: set[Proposition] | None = None, **kwargs) Term [source]¶
For now, we assume the knowledge base contains only proven propositions.
- pylogic.expressions.piecewise.otherwise(then: Any) OtherwiseBranch [source]¶
pylogic.expressions.prod module¶
- class pylogic.expressions.prod.Prod(*args, **kwargs)[source]¶
Bases:
_Aggregate
Represents a product of a sequence of non-set terms. For products of sets, see pylogic.structures.set_.CartesProduct
pylogic.expressions.sequence_term module¶
- class pylogic.expressions.sequence_term.SequenceTerm(*args, **kwargs)[source]¶
Bases:
Expr
,Generic
[T
]- contains(term: Term, **kwargs) IsContainedIn [source]¶
For sequences of sets.
- evaluate(**kwargs) SequenceTerm | T [source]¶
Evaluate the expression. Keyword arguments are used for passing additional information to the evaluation function.
- predicate(term: Term) IsContainedIn [source]¶
For sequences of sets.
pylogic.expressions.sum module¶
- class pylogic.expressions.sum.Sum(*args, **kwargs)[source]¶
Bases:
_Aggregate
Represents a sum of a sequence of non-set terms. For unions of sets, see pylogic.structures.set_.Union