• No se han encontrado resultados

The elimination of a block of quantifiers is done by block-loop given below. It manipulates with containers of QE tree nodes, expands work nodes, and calls elimination set computation and virtual substitution subroutines. In the following we denote the three containers of work, success, and failure nodes by

W , S, and F , respectively.

Algorithm block-loop(X, ϕ).

Input: a set of variables X = {x1, . . . , xn} and an ∧-∨-combination of Tarski

atomic formulas ϕ.

Output: containers S and F containing QE nodes representing an equivalent of ∃X(ϕ) = ∃xn. . . ∃x1(ϕ). If F = ∅, then the elimination of ∃X from ∃X(ϕ) was

successful, and S contains a quantifier-free equivalent of ∃X(ϕ). 1. W := ∅; S := ∅; F := ∅; H := ∅

2. Insert node (X, ϕ, ∅) into W . 3. While W 6= ∅ do

3.1. Take a node (Y, φ, s) from W . 3.2. If s 6= ∅, then

3.2.1. Apply the structural virtual substitution s to φ and simplify. 3.2.2. For each disjunction member ψ of the resulting formula do

3.2.2.1. Insert (Y, ψ, ∅) into W . 3.2.3. Continue with step 3.

3.3. If φ is in the hash table H and s is not of the form y = arbitrary, then continue with step 3.

3.4. If φ is not in the hash table H, then insert φ into H. 3.5. If φ is “true,” then

3.5.1. W := ∅; S := ∅; F := ∅ 3.6. If Y = ∅, then

3.6.1. Insert (Y, φ, ∅) into S. 3.6.2. Continue with step 3.

3.7. expand-node(Y, φ, ∅) 4. Return S and F .

Algorithm block-loop begins by inserting the root node of the to-be con- structed QE tree into the container of working nodes W . Each iteration of the block loop in step 3 first checks whether we need to apply s to the taken working node. If this is the case, we carry out the structural virtual substitu- tion s accordingly using the approach described in Subsection 6.1.2. Putting in step 3.2.2 all the resulting disjuncts into the working container W , we ensure that they will be taken later with s = ∅.

In step 3.3 we have s = ∅, i.e., no structural virtual substitution needs to be applied to φ, and we can continue with the next variable. First we check whether

φ was already considered as a QE subproblem. If this is not the case, we add it

to the hash table H. If there is a variable to eliminate, then we expand the node (Y, φ, ∅) in step 3.7. Otherwise, we are done with the node and insert it into the success container. If we found “true,” then we empty all three containers. This means that we will eventually add “true” to the success container after fixing substitutions y = arbitrary for every remaining y in Y . This becomes clear from expand-node that constructs the children of an internal node in the QE tree: Algorithm expand-node(Y, φ, s).

Input: a node (Y, φ, s) of a QE tree with s = ∅.

Output: no meaningful return value; We directly modify W , S, and F . 1. For each variable y ∈ Y , considered in some prescribed ordering, do

1.1. If y does not occur in φ, then

1.1.1. Insert (Y \ {y}, φ, y = arbitrary) into W . 1.1.2. Return.

2. For each variable y ∈ Y , considered in some prescribed ordering, do 2.1. Ey:= s-shift(φ, y)

2.2. If Ey6= ∅, then

2.2.1. For each (√dy, π, F ) ∈ Eˆ

y do

2.2.1.1. Insert (Y \ {y}) ∪ {ˆy}, φ, y = (dy, π, F )ˆ  into W .

2.2.2. Denote by P the positions of all structural degree shift test points in Ey.

2.2.3. Insert Y, φP, ∅ into W . 2.2.4. Return.

3. If variable selection strategy 1, then

3.1. Let y be the minimum variable in Y w.r.t. some prescribed ordering. 3.2. Compute a structural elimination set Ey for φ and y.

3.3. If this failed, then

3.3.1. Insert (Y, φ, ∅) into F . 3.3.2. Return.

3.4.1. Insert Y \ {y}, φ, y = (e, π, F ) into W . 3.5. Return.

4. If variable selection strategy 2, then

4.1. For each variable y ∈ Y , considered in some prescribed ordering, do 4.1.1. Compute a structural elimination set Ey for φ and y.

4.1.2. If this was successful, then 4.1.2.1. For each (e, π, F ) ∈ Ey do

Insert Y \ {y}, φ, y = (e, π, F ) into W . 4.1.2.2. Return.

4.2. Insert (Y, φ, ∅) into F . 4.3. Return.

5. M := ∅

6. For each variable y ∈ Y do

6.1. Compute a structural elimination set Ey for φ and y.

6.2. If this was successful, then add the pair (y, Ey) to M .

7. If M = ∅, then

7.1. Insert (Y, φ, ∅) into F . 7.2. Return.

8. If variable selection strategy 3, then

8.1. Pick a pair (y, Ey) from M with “the best” elimination set Ey.

8.2. For each (e, π, F ) ∈ Ey do

8.2.1. Insert Y \ {y}, φ, y = (e, π, F ) into W . 8.3. Return.

9. If variable selection strategy 4, then 9.1. For each pair (y, Ey) ∈ M do

9.1.1. Substitute the set Ey for y into φ by means of structural VS.

9.2. Pick the pair (y, Ey) that yielded “the best” resulting formula.

9.3. For each (e, π, F ) ∈ Ey do

9.3.1. Let ψ be the formula obtained by substituting e for y into φFπ. 9.3.2. Insert (X \ {y}, ψ0, ∅) into W for every disjunct ψ0 of the formula

ψ after simplification.

9.4. Return.

The procedure expand-node constructs the children of an internal node in a QE tree. In step 1 we first check whether there exists a variable in Y , which does not occur in φ.

Then the procedure s-shift of Subsection 4.2.2 tries a structural degree shift w.r.t. each π ∈ Pos(φ). Since the resulting nodes are put into W and

eventually considered in some later iteration of block-loop, this implicitly simulates the recursive algorithm s-preproc discussed below Theorem 77 in Subsection 4.2.2. If (Y, φ, s) was created from its parent by applying a struc- tural degree shift y =dy, π, Fˆ , then the recursive depth could be bounded by

setting an upper bound on the number of consecutive structural degree shifts w.r.t. shadow variables.

Our implementation does not call s-shift in step 2.1 though. It simply tries whether a global degree shift for y and φ is applicable. Observe that this cannot lead to a consecutive recursive calls as when using s-preproc, because a global degree shift is applicable at most once w.r.t. any particular variable. Furthermore, when a global degree shift is applicable, then φP is obviously equivalent to “false” in step 2.2.3.

It is noteworthy that for a “successful” structural degree shift elimination set we obtain in step 2.2.3 a formula φP that does not contain y. First, this means that the maximum degree of ˆy after shift will be lower than the degree

of y in φ. Second, if φP is “false,” e.g., when using a global shift, then it can be dropped directly instead of inserting it into W . This is what was implicitly done in our example QE tree in Figure 6.1 in node ({y, z}, ϕ2).

In step 3 we know that each variable from Y in fact occurs in φ, and no struc- tural degree shifts are applicable. Therefore, we enter the core of expand-node, i.e., a variable selection strategy. We apply one of the following four variable selection strategies:

1. Use the minimum variable y ∈ Y w.r.t. some prescribed total ordering. 2. Use the first feasible, i.e., “non-failing” variable in Y w.r.t. some prescribed

total ordering.

3. Decide which variable from Y to use by looking at the obtained structural elimination sets.

4. Decide which variable from Y to use by eliminating each variable and by looking at the resulting equivalents.

Each computation of a structural elimination set in any of the four strategies is done as we have described in Subsection 6.1.1.

A natural total ordering of the variables used in strategies 1 and 2 satisfies

x1 ≺ · · · ≺ xn, whereas all the shadow variables ˆxi,j introduced for xi satisfy

xi ≺ ˆxi,j ≺ xi+1. Combined with strategy 1, this means that we eliminate

the quantifiers from the inside to the outside in ∃xn. . . ∃x1(ϕ), using as many

shadow quantifiers for xi as needed, eliminating them right after xi.

The default variable selection strategy of the Redlog’s original implementa- tion, and also of our implementation, is strategy 3. However, our implementa- tion selects “the best” structural elimination set just by counting the number of test points. Note that this choice can be significantly improved by taking the degrees and the number of other quantified variables and parameters in the computed elimination sets into account.

The greedy strategy 4 might seem to be the best choice among the four strategies. Note that it is the most costly one, and it does not guarantee to obtain the best results after eliminating the whole quantifier block.

An implementation of block-loop needs to keep only the actual working nodes and leaves of the tree in memory. Rest of the tree can be deleted by

simply dropping the expanded nodes as we do it tacitly in block-loop. If one is interested in obtaining the whole tree, it is straightforward to adjust block-loop so that each node contains a reference to its parent. This can be then used to investigate the whole quantifier elimination tree, or as a basis for extended quantifier elimination of Section 5.1 and our EQR post-processing method of Section 5.3.

Documento similar