Techniqueresearch
Positive equality
Also called Bryant-German-Velev positive equality.
Bryant, German and Velev's reduction of EUF formulas that gives distinct constants to terms used only in positive equations, which makes processor verification fast.
Positive equality is a way to decide validity of formulas in the logic of equality with uninterpreted functions (EUF) much faster when most equations occur only positively. Bryant, German and Velev (2001) noticed that in the formulas of Burch-Dill flushing, the data values of a processor are compared for equality only in the final, positive check, while register identifiers and control values also appear in negated equations and in the conditions of if-then-else terms. They split the function symbols in two classes. A p-function symbol is used only in positive equations, and a g-function symbol is used in general. Their central theorem says that a formula in which the p-symbols occur only positively is valid exactly when it is true in the maximally diverse interpretations, where terms of p-symbols are equal only when functional consistency forces it. After the function applications are removed, each p-variable can therefore take a fixed constant, distinct from every other value, and it needs no Boolean variables at all. Only the g-variables are encoded, so the propositional formula that a SAT or BDD tool gets is much smaller.
In plain words
To prove an equation about a processor, you must check every way the values in it can be equal or different. With many values this is a huge number of cases.
Look at how each value is used. Some values are only ever compared at the end, in a check that says "these two must be equal". Making two such values equal by chance can only help that check succeed. So the hardest case for the check is the one where all those values are different, unless the circuit itself forces them to be equal. You can give each of them its own fixed constant and stop treating it as an unknown.
Other values are compared inside the logic, for example a register number that selects a bypass. Those stay unknown and are encoded with Boolean variables. In processor formulas most values are data, so most unknowns disappear.
When it applies
- The input is a formula of EUF: domain variables, function and predicate applications, if-then-else terms , equations, propositional variables, , and . The question is whether is universally valid: true for every nonempty domain and every interpretation of the symbols. A domain variable is a function symbol of arity 0.
- is in negation normal form, so is applied only to equations and predicate applications. Any formula can be put in this form with De Morgan's laws.
- Let and be the sets of syntactically distinct formulas and terms of . The negative formulas form the smallest set that contains for every in , contains the condition of every in , and contains and whenever it contains or . The negative terms form the smallest set that contains and for every equation in , and and for every in .
- A function symbol is in if some term is in , and in otherwise. A symbol does not become a g-symbol because its applications appear as arguments of other applications: arguments may be p-terms. Theorem 1 of Bryant, German and Velev says that can then be parsed as a p-formula of their logic PEUF, with the symbols of as g-symbols and those of as p-symbols.
- The technique pays off when is large. In Burch-Dill formulas, the data values, the ALU and the results are usually p-symbols, while register identifiers, which are compared in bypass and stall logic, are g-symbols.
Maximally diverse interpretations. For an interpretation , write when . Let be a set of function symbols of . The interpretation is diverse for with respect to if, for every function application term of with , holds for a function application term of only when has the same symbol and for all . It is maximally diverse if it is diverse with respect to the set of all p-function symbols of . So a p-application equals another term only when functional consistency forces it.
Theorem 2 (Bryant, German and Velev). A p-formula is universally valid if and only if it is true in all maximally diverse interpretations.
The template
POSITIVE-EQUALITY(F_top)- 1
F ← the negation normal form of F_top - 2
compute the negative formulas Φ⁻ and the negative terms Θ⁻ of F - 3
F_g ← symbols with an application in Θ⁻; F_p ← all other function symbols - 4
F* ← F with every function application replaced by nested ITE terms over fresh domain variables, innermost applications first - 5
P ← the fresh variables of the symbols in F_p, and the domain variables in F_p - 6
give each variable in P its own fixed constant, distinct from all other values - 7
encode equations between the other domain variables with Boolean variables - 8
return whether the propositional formula from F* is a tautology, by SAT or BDDs
Line L4 is the function elimination of Bryant, German and Velev. Let be the applications of a symbol , in an order where each argument has already been rewritten. Each application gets a fresh variable , and the -th application becomes
where means equality of all arguments. The result has only domain variables, and it is valid exactly when is (their Theorem 3). It keeps functional consistency by construction: equal arguments select the same variable. The new equations between arguments sit in ITE conditions, which are negative positions of . Even so, Theorem 4 of the paper says that is valid exactly when is true in every interpretation that is diverse with respect to the fresh variables of the p-symbols, so line L5 takes the polarity from , not from . Corollary 1 then allows the fixed constants of line L6, taken from a set disjoint from the values of the g-variables. Lines L7 and L8 are any propositional encoding of the remaining equations; Theorem 5 of the paper treats two of them.
Proof of a small case. The direction from validity to truth in the maximally diverse interpretations is immediate. For the other direction, here is a complete proof for p-formulas in which every function symbol is a domain variable. ITE terms, propositional variables and predicate symbols may occur. The general proof is Lemmas 1 and 2 of the paper. Lemma 1 splits one equivalence class of a not maximally diverse interpretation without making the formula true, and Lemma 2 repeats this, which ends because a partition of the finite term set can be properly refined only finitely often.
Let be such a p-formula, true in all maximally diverse interpretations, and let be any interpretation over a domain . Take a fresh value for each p-variable , and let . Let map to and fix . Define over : for each p-variable, for each g-variable and each propositional variable, and for each predicate symbol. We show, by induction on the PEUF syntax:
- for every term , and for every g-term.
- for every g-formula .
- implies for every p-formula .
For a variable, (1) holds by the definition of , and a g-term variable is a g-variable. For , the condition is a g-formula, so by (2) both interpretations pick the same branch, and (1) passes up from that branch. A g-formula is an equation of g-terms, a predicate application, a propositional variable, or a Boolean combination of g-formulas with , , . Equations of g-terms keep their value by (1). For a predicate, by (1). The rest is a Boolean combination of equal values, so (2) holds. A p-formula is a g-formula, an equation of p-terms, or a combination of p-formulas with and only. For an equation, gives , which is by (1). and are monotone, so (3) passes up. This proves the three claims.
is maximally diverse. The value of a term under is the value of the variable that its ITE conditions select, so only when is itself, and a p-variable is equal to no other variable term. So is true, and by (3) is true. As was arbitrary, is valid.
The proof also shows why polarity matters. Claim (3) is only an implication, so it survives and but not and not ITE conditions. That is why p-terms may appear only in positive equations.
Example. The running example of the paper is
The equation is negated, so and are g-symbols. The symbols and occur only in the positive equation and in arguments, so they are p-symbols. The formula has seven function application terms: , , , , , , . There are 877 ways to partition seven terms, the Bell number , and 384 of them are functionally consistent. Only two come from maximally diverse interpretations: D1, where all seven terms are different, and D2, with classes . In D2, forces , which forces . is true in D1 because , and true in D2 because . By Theorem 2 it is valid. (These counts were checked by enumeration of all 877 partitions while writing this page.)
The same check through lines L4 to L8: eliminate in the order and in the order :
| term | after elimination | with distinct constants |
|---|---|---|
| , as constants differ from g-values | ||
Here and are the rewritten forms of and , and is the one Boolean variable for . With the constants, is , which is . The formula becomes , which is , a tautology. Without positive equality, the five fresh variables and would all be encoded, with equations among them.
Cost. Line L4 adds, for a symbol with applications of arity , at most argument comparisons of equations each, so has size with shared subterms. A formula with domain variables only is valid exactly when it is valid over a domain of values, because a falsifying interpretation uses at most values and can be cut down to them. So without positive equality the variables need Boolean variables in a binary encoding, or variables for the equations, plus constraints for transitivity. With positive equality the p-variables need none, and only the g-variables are encoded. Validity of EUF stays coNP-complete, so the worst case does not change. The gain is measured, not proved. Bryant, German and Velev report experiments on pipelined processor models in which the reduction makes the propositional problem much smaller and faster to solve than encodings that treat every variable as general.
Classic examples
- Burch-Dill formulas. The commuting diagram of Burch-Dill flushing compares the register files of the two routes in one positive equation. The data terms and the uninterpreted ALU are p-symbols. Positive equality made these checks scale to larger pipelines than direct EUF procedures could handle.
- Ackermann's reduction. Ackermannization removes function applications with functional consistency constraints . These constraints put the fresh variables on both sides of an implication, that is in negative equations, so every variable becomes general. The nested ITE scheme of line L4 keeps the p-variables positive. This is why Bryant, German and Velev use it.
- Eager SMT encodings. Eager encodings of equality logic to propositional logic, with small domains or variables and transitivity constraints, are the back end of lines L7 and L8. Positive equality shrinks their input before they start.
- Lazy procedures. Congruence closure inside a lazy SMT solver decides the same formulas without any encoding, and does not need the polarity split.
Variations
- Only part of the polarity. A symbol with some applications in negative positions is a g-symbol for all its applications in the basic method. A finer split classifies application terms, not symbols. Theorem 2 is stated for symbols.
- Fixed constants versus diverse interpretations. Theorem 2 quantifies over all maximally diverse interpretations. Corollary 1 of the paper fixes the values of the p-variables to distinct constants outside the domain of the g-variables, which is what a propositional encoding needs.
- Memories. Memories modeled with uninterpreted read and write functions put address comparisons in ITE conditions, so addresses are g-terms while the stored data can stay p-terms.
- BDDs or SAT. The propositional formula of line L8 can be checked with BDDs or with a CDCL SAT solver on its negation.
Pitfalls
- A g-term treated as a p-term is unsound. is not valid, but with and given distinct constants it becomes true. The classification of line L3 must use every negative position, including ITE conditions and equations under after the formula is in negation normal form.
- A p-term treated as a g-term is only slow. Every interpretation with fixed p-constants is an interpretation, so encoding more variables as general never gives a wrong answer.
- Shared subterms. holds syntactically distinct terms. A term that occurs once positively and once in a negative equation is in , and its symbol is a g-symbol everywhere.
- The order of elimination. Line L4 needs the arguments of an application rewritten before the application itself, so nested applications such as refer to the fresh variable of the inner one.
- Algebraic facts. Like all EUF methods, positive equality proves only what holds for every interpretation. A design that relies on fails unless the fact is added as an axiom, and an axiom with equations in its premise changes the polarity of the terms in it.
Exercises
- Classify the symbols of , and show that the formula is valid by checking its maximally diverse interpretations.
- Give a formula in which a symbol has one application in a negative equation and one only in positive ones. What does the basic method do, and why is it sound?
- Extend the small-case proof to function symbols of arity 1 when every application has a domain variable as its argument. Which step of Lemma 1 of the paper do you need?
References
- R. E. Bryant, S. German and M. N. Velev, Processor verification using efficient reductions of the logic of uninterpreted functions to propositional logic, ACM Transactions on Computational Logic 2(1), 93 to 134, 2001, Section 3 (the PEUF syntax of Figure 2, the sets of negative formulas and terms, Theorem 1 on parsing, diverse and maximally diverse interpretations, Theorem 2 with Lemmas 1 and 2), Section 4 (function elimination by nested ITE terms, Theorems 3 and 4, Corollary 1) and Section 5 (propositional encodings, Theorem 5)
- R. E. Bryant, S. German and M. N. Velev, Processor verification using efficient reductions of the logic of uninterpreted functions to propositional logic, technical report CMU-CS-99-115, 1999, the preprint of the journal paper, with the running example F_eg, Table 2 and the counts 877 and 384 in Section 3.3
- J. R. Burch and D. L. Dill, Automatic verification of pipelined microprocessor control, Computer Aided Verification (CAV 1994), LNCS 818, 68 to 80, 1994, the EUF formulas of pipelined processors that positive equality was made to decide
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag A2BZNH Edit this page History Report an error Markdown