Abstract Base Classes
Quantifier Elimination#
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.qe provides generic classes for effective
quantifier elimination, which can used by various theories via subclassing.
Generic Types#
We use type variables qe.α, qe.τ,
qe.χ, qe.σ in anology to their counterparts in
the module logic1.firstorder.formula.
- logic1.abc.qe.α = TypeVar('α', bound='AtomicFormula')#
- logic1.abc.qe.τ = TypeVar('τ', bound='Term')#
- logic1.abc.qe.χ = TypeVar('χ', bound='Variable')#
- logic1.abc.qe.σ = TypeVar('σ')#
We introduce the following additional type variables.
- logic1.abc.qe.ν = TypeVar('ν', bound='Node')#
A type variable denoting a node with upper bound
Node.
- logic1.abc.qe.ι = TypeVar('ι')#
A type variable denoting the type of the principal argument of the abstract method
QuantifierElimination.init_env().
- logic1.abc.qe.λ = TypeVar('λ', bound='Assumptions')#
A type variable denoting a assumptions with upper bound
Assumptions.
- logic1.abc.qe.μ = TypeVar('μ', bound='Hashable')#
A type variable denoting the information stored in the Memory attribute of
NodeListand its subclasses.
- logic1.abc.qe.ω = TypeVar('ω', bound='Options')#
A type variable denoting a options for
QuantifierElimination.__call__()with upper boundOptions.
Assumptions#
- class logic1.abc.qe.Assumptions[source]#
Bases:
Generic[α,τ,χ,σ],ABCHolds the currently valid assumptions. This starts with user assumptions explicitly provided by the user. Certain variants of quantified elimination may add further assumptions in the course of the elimination.
See also
The argument
assumeofQuantifierElimination.__call__().Generic quantifier elimination in
RCF.qe.
This is an upper bound for the type variable
λ.
Nodes#
- class logic1.abc.qe.Node[source]#
Bases:
Generic[α,τ,χ,σ,λ,μ],ABCHolds a subproblem for existential quantifier elimination. Theories implementing the interface can put restrictions on the existing fields and add further fields.
- abstractmethod memorize() μ[source]#
Return a hashable object that identifies this node. This is used to avoid processing the same node twice.
- abstractmethod process(assumptions: λ) Sequence[Self][source]#
This
nodedescribes a formulaEx(node.variables, node.formula). Select a variable fromnode.variablesand compute a listSof successor nodes such that:variableis not insuccessor.variablesforsuccessorinS;variabledoes not occur insuccessor.formulaforsuccessorinS;Or(*(Ex(successor.variables, successor.formula) for s in S))is logically equivalent toEx(node.variables, node.formula).
Options#
- class logic1.abc.qe.Options[source]#
Bases:
objectThis class holds options that can be provided to
QuantifierElimination.__call__(). Theories subclassingQuantifierEliminationcan add further options by subclassingOptions.This is an upper bound for the type variable
ω.- workers: int#
Controls the number of CPUs used for processing subproblems:
With the default value
workers=0, the implementation runs sequentially. For all other values, additional processes are started.A positive value
workers=nusesn + 2CPUs:nfor worker processes that process subproblems, one for the master process, and another one for a proxy process that manages shared data.A negative value
workers=-nusesos.cpu_count() - nCPUs for workers, plus two additional CPUs for the master and proxy processes. It follows thatworkers=-2uses all available CPUs, whileworkers=-3leaves one CPU free.
Attention
workers=1uses the parallel implementation with only one worker. Algorithmically, this is similar to the sequential implementation withworkers=0, but introduces overhead.workers=-1usesos.cpu_count() + 1CPUs, which is not a natural choice.
See also
logic1.abc.qe.NodeThe subproblems referred to above correspond to instances of this class.
Quantifier Elimination#
- class logic1.abc.qe.QuantifierElimination[source]#
Bases:
Generic[ν,μ,λ,ι,ω,α,τ,χ,σ],ABCA generic callable class that implements quantifier elimination.
A first group of attributes holds the state of the computation:
- property assumptions: list[α]#
A list of atoms, which serve as external assumptions. This includes the assumptions passed via the assume parameter of
__call__(). Some theories have an option for generic quantifier elimination, which adds additional assumptions on parameters in the course of the elimination.
- blocks: Prefix[χ] | None = None#
Remaining quantifier blocks, to be processed after the current block.
- matrix: Formula[α, τ, χ, σ] | None = None#
The quantifier-free formula associated with
blocks. This isNonewhile there is a block being processed.
- negated: bool | None = None#
Indicates whether or not the block currently processed has been logically negated in order to equivalently transform universal quantifiers into existential quanitifers.
- root_nodes: list[ν] | None = None#
The root nodes of the next block to be processed. Logically, the list describes a disjunction, and each node in root_nodes describes a quantifier elimination subproblem
Ex(node.variables, node.formula). This is an intermediate object for moving the innermost block with and the matrix into theworking_nodes.
- working_nodes: WorkingNodeList[ν, μ] | None = None#
Subproblems left for the current block. Element nodes of
working_nodeshave the same shape as element nodes ofroot_nodes
- success_nodes: NodeList[ν, μ] | None = None#
Finished subproblems of the current block. For each node in success_nodes we have
node.variables == [].
- failure_nodes: NodeList[ν, μ] | None = None#
Failed subproblems of the current block, which can occur with incomplete quantifier elimination procedures. An element nodes of
failure_nodeshave the same shape as an element node ofworking_nodes, but quantifier elimination procedure could not eliminate any variable from the node.
Note that the parameter f of
__call__()inizializesblocksandmatrix, and the parameter assume inizializesassumptions. The next group of attributes corresponds to read-only input parameters of__call__():- options: ω | None = None#
The options that have been passed to
__call__().
The third and last group of attributes holds comprehensive timing information on the last computation. All times are wall times in seconds:
- time_syncmanager_enter: float | None = None#
The time spent for starting the
SyncManager, which is a proxy process that manages shared data inmultiprocessing.
- time_start_first_worker: float | None = None#
The time spent for starting the first worker process in
multiprocessing.
- time_start_all_workers: float | None = None#
The time spent for starting all worker processes in
multiprocessing.
- time_multiprocessing: float | None = None#
The time spent in
multiprocessingafter the first worker process has been started and until the last worker process has terminated.
- time_import_failure_nodes: float | None = None#
The time spent for importing all
failure_nodesfrom theSyncManagerinto the master process after all workers have terminated.
- time_import_success_nodes: float | None = None#
The time spent for importing all
success_nodesfrom theSyncManagerinto the master process after all workers have terminated.
- time_import_working_nodes: float | None = None#
The time spent for importing all
working_nodesfrom theSyncManagerinto the master process after all workers have terminated.
- time_syncmanager_exit: float | None = None#
The time spent for exiting the
SyncManager.
- time_final_simplification: float | None = None#
The time spent for finally simplifying the disjunction over all
success_nodesimported from the workers. This yields the finalresult, which is also the return value of__call__().
- time_total: float | None = None#
The total time spent in
__call__().
- __call__(f: Formula[α, τ, χ, σ], assume: Iterable[α] = [], **options) Formula[α, τ, χ, σ] | None[source]#
The entry point of the callable class
QuantifierElimination.- Parameters:
f – The input formula to which quantifier elimination will be applied.
assume – A list of atomic formulas that are assumed to hold. The return value is equivalent modulo those assumptions.
**options – Keyword arguments with keywords corresponding to attributes of the generic type
ω, which extendsOptions.
- Returns:
A quantifier-free equivalent of
fmodulo certain assumptions. A simplified equivalent of all relevant assumptions are available asassumptions.Regularly, the assumptions are exactly those passed as the assume parameter.
Some theories have an option for generic quantifier elimination, which adds additional assumptions in the course of the elimination.
- abstractmethod create_options(**kwargs) ω[source]#
Create an instance of
ωthat holds **kwargs. The **kwargs arriving here are the **options that have been passed to__call__().
- abstractmethod create_root_nodes(variables: Iterable[χ], matrix: Formula[α, τ, χ, σ]) list[ν][source]#
If matrix is not a disjunction, create a list containing one instance node of
νwithnode.variables == variablesandnode.formula == matrix. If matrix is a disjunctionOr(*args), create a list containing one such node for each arg in args.
- abstractmethod create_assumptions(assume: Iterable[α]) λ[source]#
Create in instance of
λthat holds assume. Those assumptions assume are the corresponding parameter of__call__().
- abstractmethod create_true_node() ν[source]#
Create an instance node of
νwithnode.variables == []andnode.formula == _T().
- abstractmethod final_simplify(formula: Formula[α, τ, χ, σ], assume: Iterable[α] = []) Formula[α, τ, χ, σ][source]#
Used for simplifying the disjunction of all
success_nodes. The return value yieldsresult, which is then used as the return value of__call__().
- abstractmethod classmethod init_env(arg: ι) None[source]#
A hook for initialization of worker process. This is used, e.g., in Real Closed Fields for reconstructing within the worker the Sage polynomial ring of the master.
- abstractmethod init_env_arg() ι[source]#
Create an instance of
ιto be used as an argument for a subsequent call ofinit_env().