Abstract Base Classes
Simplification#
Attention
This documentation page addresses implementers rather than users. Concrete implemtations of the abstract classes described here are documented in the corresponding sections of the various domains:
This module logic1.abc.simplify provides a generic abstract
implementation of deep simplifcication based on generating and propagating
internal representations during recursion. This is essentially the standard
simplifier, which has been proposed for Ordered Fields in
[DolzmannSturm-1997].
Generic Types#
We use type variables simplify.α, simplify.τ,
simplify.χ, simplify.σ in anology to their counterparts in
formula.
- logic1.abc.simplify.α = TypeVar('α', bound='AtomicFormula')#
- logic1.abc.simplify.τ = TypeVar('τ', bound='Term')#
- logic1.abc.simplify.χ = TypeVar('χ', bound='Variable')#
- logic1.abc.simplify.σ = TypeVar('σ')#
Additionally, we introduce a type variable ρ for internal
representations and a type variable ω for options used by the
simplifier.
- logic1.abc.simplify.ρ = TypeVar('ρ', bound='InternalRepresentation')#
A type variable denoting a type of variables with upper bound
logic1.abc.simplify.InternalRepresentation.
- logic1.abc.simplify.ω = TypeVar('ω', bound='Options')#
A type variable denoting a options for
Simplify.simplify()with upper boundOptions.
Internal Representations#
- class logic1.abc.simplify.RESTART[source]#
Bases:
EnumUsed for the return value of
InternalRepresentation.add().- NONE = 1#
No formulas of the current level require resimplification.
- OTHERS = 2#
Non-atoms of the current level require resimplification.
- ALL = 3#
All formulas of the current level require resimplification.
- class logic1.abc.simplify.InternalRepresentation[source]#
-
This abstract class serves as an upper bound for the type variable
ρinabc.simplify.Simplify. It specifies an interface comprising methods required there.The principal idea is that a
InternalRepresentationshould holds information that corresponds to a conjunction of atomic formulas. In the course of recursive simplification inabc.simplify.Simplify, instances of this class are inherited from higher levels and are enriched with information from all atomic formulas on the toplevel of the subformula currently under consideration.- exception Inconsistent[source]#
Bases:
ExceptionIndicates that an instance of
InternalRepresentationcontains inconsistent information. This exception is typically handled inabc.simplify.Simplifyand its derived classes, where appropriate values are returned.
- abstractmethod add(gand: type[And[α, τ, χ, σ] | Or[α, τ, χ, σ]], atoms: Iterable[α]) RESTART[source]#
Add information originating from
atoms. IfgandisAnd, consideratoms. IfgandisOr, consider(Not(at) for at in atoms). Simplification among atoms is supposed to take place here.
- abstractmethod extract(gand: type[And[α, τ, χ, σ] | Or[α, τ, χ, σ]], ref: Self) Iterable[α][source]#
Comapare
selfandrefto identify and extract information that must be represented on the toplevel of the subformula currently under consideration. IfgandisAnd, the result represents a conjunction. IfgandisOr, it represents a disjunction.
- abstractmethod next_(remove: χ | None = None) Self[source]#
Create a copy of
self, optionally removing all information involving the variableremove.
- restart(ir: Self) Self[source]#
Return a new internal representation for the current level during simplifiation after
RESTART.ALLhas been returned byInternalRepresentation.add(). In this case,iris the internal representation of the current level, andselfis the internal representation of the previous level.Raise a
NotImplementedErrorby default.
Simplification and Validity#
- class logic1.abc.simplify.Options[source]#
Bases:
ABCThis class holds options that can be provided to
Simplify.simplify(). Theories subclassingSimplifycan add further options by subclassingOptions.This is an upper bound for the type variable
ω.
- class logic1.abc.simplify.Simplify[source]#
Bases:
Generic[α,τ,χ,σ,ρ,ω]Deep simplification following [DolzmannSturm-1997].
See also
Derived classes in various theories:
RCF.simplify.Simplify,Sets.simplify.Simplify,Complex.simplify.Simplify- abstractmethod create_initial_representation(assume: Iterable[α]) ρ[source]#
Create a fresh instance of
ρ.
- is_valid(f: Formula[α, τ, χ, σ], assume: Iterable[α] = []) bool | None[source]#
Simplification-based heuristic test for vailidity of a formula.
Mathematical definition
A first-order formula is valid if it holds for all values all free variables.
- Parameters:
f – The formula to be tested for validity
assume – A list of atomic formulas that are assumed to hold. The result of the validity test is correct modulo these assumptions.
- Returns:
Returns
TrueorFalseifabc.simplify.Simplify.simplify()succeeds in heuristically simplifyingftoTorF, respectively. ReturnsNonein the sense of “don’t know” otherwise.
- abstractmethod simpl_at(atom: α, context: type[And[α, τ, χ, σ]] | type[Or[α, τ, χ, σ]] | None) Formula[α, τ, χ, σ][source]#
Simplify the atomic formula
atom. Thecontexttells whetheratomoccurs within a conjunction or a disjunction. This can be taken into consideration for the inclusion of certain simplification strategies. For instance, simplification ofxy == 0toOr(x == 0, y == 0)over the reals could be desirable within a disjunction but not otherwise.
- simplify(f: Formula[α, τ, χ, σ], assume: Iterable[α] = []) Formula[α, τ, χ, σ][source]#
Simplify
fmoduloassume.- Parameters:
f – The formula to be simplified
assume – A list of atomic formulas that are assumed to hold. The simplification result is equivalent modulo those assumptions.
- Returns:
A simplified equivalent of
fmoduloassume.