Abstract
The GACKS (a.k.a Blazingly Fast Skolem Synthesis) algorithm first appeared in Akshay et al. (2018). It presents a 2 phase algorithm that in the best case can produce polynomial-sized Skolem functions efficiently. This note outlines how the algorithm works, presents an example execution of the algorithm and finally presents a proof sketch for why this algorithm efficiently produces Skolem functions for formulae in wDNNF form.
Core Concepts
Negation Normal Form (NNF)
This is a standard form where a Boolean formula is represented as a Directed Acyclic Graph (DAG) using only (AND), (OR), and (NOT) operators, with negations applied only to variables [i.e., leaves of the graph are literals]. The following is an graph representation of NNF formula :
graph TD n1("∨") --> n2("∧") n1 --> n3("D") n2 --> n4("∧") n2 --> n5("¬") n4 --> n6("A") n4 --> n7("∨") n5 --> n8("C") n7 --> n9("¬") n7 --> n10("C") n9 --> n11("B")
wDNNF (weak Decomposable NNF)
An NNF is in wDNNF if for every -node in the graph, its children sub-formulas don’t share literals of opposing polarity. More formally, if a node represents , there is no literal such that appears in the leaves of and appears in the leaves of for any .
This is a weaker (and thus more general) requirement than DNNF where no variables can be shared by the children of an -node.
GACKS Algorithm
The GACKS Algorithm (or Algorithm 1 in the paper) has the following features:
- It takes as input the specification .
- is the boolean relation.
- is the output vector.
- is the input vector.
- It produces as output the vector such that
- is the Skolem function vector that takes as input .
It has 4 main steps:
- Finding unate Skolem functions.
- Computing approximate Skolem functions for binate output variables.
- Verification of approximate Skolem functions.
- Incase of verification failure start a CEGAR refinement loop.
Finding Skolem functions for unate variables
For each (output variables):
- If is UNSAT, then is positive unate in , and we set and substitute it into .
- essentially checks “if there exist any assignment to all other variables ( and ) where the function is SAT when AND UNSAT when ?”, i.e changing from causes the function to become UNSAT.
- If is UNSAT, then is negative unate in , and we set and substitute it into .
- essentially checks “if there exist any assignment to all other variables where the function is UNSAT when AND SAT when ?”, i.e changing from causes the function to become SAT.
A SAT solver is used to check this.
Finding (approximate) Skolem functions for binate variables
Skolem Function Boundaries
The Skolem function for lies between two boundary formulas, and . Where,
- is the “Must-Be-1” Condition: This formula identifies all input conditions for which must be set to 1.
- Definition: .
- Explanation: This formula is true when it is impossible to find a valid solution by setting . If a solution must exist, the only remaining choice is to set .
- the “Must-Be-0” Condition: This formula identifies all input conditions for which must be set to 0.
- Definition: .
- Explanation: This formula is true when it is impossible to find a valid solution by setting .
Therefore,
This means:
- : If is true (you must set ), then must output 1.
- : If outputs 1, it must only be in cases where is false (i.e., it was not impossible to set ).
and are, by themselves, valid Skolem functions. However, computing them is often computationally hard.
This step is executed for all output variables that were not found to be unate (i.e., they are “binate”).
While finding the exact Skolem functions is computationally hard (super-polynomial to the input size), GACKS attempts to compute efficient, polynomial-sized approximations instead. This is done using a three-part strategy:
- Choose a variable order using a heuristic.
- Transform the formula into the “simpler” representation.
- Compute the approximate formulas ( and ) based on this order and transformation.
Choosing the Variable Order
Before approximation, the algorithm must fix a single processing order for all binate output variables.
- Heuristic: This choice is determined by an “experimentally sound heuristic”. The algorithm inspects the AIG (And-Inverter Graph) representation of the specification. The variable that “occurs in the transitive fan-in of the least number of nodes” is ordered first.
The Transformation
To enable the efficient computation of the approximations, the algorithm transforms the original specification .
- Convert to NNF: The formula is converted to Negation Normal Form (NNF), where negations () only appear directly on variables.
- Create Fresh Variables: It then replaces every occurrence of a negated output variable with a new, fresh variable .
- Result (): The result is a new formula .
This new formula is positive unate in all the and variables. This simplicity is what allows the approximations to be computed efficiently.
The Candidate Formulas ( and )
The algorithm computes two (approximate) candidate function, and , which are efficient under-approximations of the exact (but hard-to-compute) and boundaries. To do so it uses the chosen order and the formula to compute the candidate functions.
For each variable (processed in order) it computes the following:
- (approximates the “must-be-1” boundary ). Here,
- : We replace with 1, with 0 and stays as is.
- We replace with 1 and with .
- stays as is.
- (approximates the “can-be-1” boundary )
- : We replace with 1 and stays as is.
- We replace with 1, with 0 and with .
- stays as is.
These are very efficient to compute, as they just involve substituting constants into . The algorithm then makes a practical choice: it picks whichever of the two candidates ( or ) has a smaller AIG (circuit representation).
Final Substitution Pass
After the intermediate function is chosen for every binate variable, the algorithm must eliminate the dependencies to make each a function of only the inputs .
It does this by performing a reverse substitution pass, as described in the paper.
-
Start at the end: The algorithm starts with the last variable in the order, . Its formula (e.g., or ) already depends only on .
-
Substitute and move up: It then moves to , which is a function of . It substitutes the already-computed circuit for in place of the symbolic variable. The result is a new that only depends on .
-
Repeat: It continues this process “backwards” up the order (e.g., substituting and into ) until all functions, including , depend only on .
After this pass, the algorithm has the complete candidate Skolem function vector . This is the final vector that is passed to the verification step
Verification
After generating a complete candidate Skolem function vector (containing constants for unate variables and approximations for binate ones), the algorithm must check if this vector is actually correct.
This check is performed by creating a single “error formula” and using a SAT solver to determine if it is satisfiable.
The Error Formula ()
The algorithm constructs a specific formula, , designed to find a counterexample.
Definition: . Here:
- represents the candidate solution, enforces this.
- represents the ‘witness’ solution, it is a fresh set of variables that the solver tries to find a satisfying assignment to.
Logic: A satisfying assignment for this formula represents a complete failure case:
- is TRUE: This part finds an input and a “witness” output that does satisfy the original specification . This proves that a valid solution should exist for this input .
- is TRUE: This part forces the variables to be exactly equal to the candidate functions that the algorithm just computed.
- is TRUE: This part checks if, for the same input , our candidate solution is FALSE.
The SAT Solver Check
The algorithm feeds this single formula to a SAT solver. The solver’s result determines the next step:
-
If the solver returns UNSATISFIABLE (UNSAT):
- Meaning: No counterexample exists.
- Result: The candidate functions are proven to be correct. The correctness of this check is guaranteed by Theorem 3.
- Action: The algorithm terminates and outputs as the final solution. Phase 1 was a success.
-
If the solver returns SATISFIABLE (SAT):
- Meaning: The solver found a counterexample.
- Result: The candidate functions are incorrect.
- Action: Upon failure. The algorithm must proceeds to begin a CEGAR-based refinement process using the generated counter-example.
CEGAR refinement loop
If the produced Skolem vector using Skolem functions for unate variables and approximate Skolem functions for the binate variables is incorrect the algorithm uses the counter example from the error formula to repair it.
Example
- Specification:
- Our Goal: Find Skolem functions and .
We will use the variable order as required by the algorithm.
Finding Unate Skolem Functions
The algorithm first checks each variable for unateness.
Check
We check if is positive or negative unate. Let’s check for positive unate first by checking if is UNSAT.
-
- :
- :
- Build :
- Result: This formula is of the form , which simplifies to , which is 0 (False).
- Conclusion: is UNSATISFIABLE. This proves is positive unate. The algorithm assigns its Skolem function .
The algorithm now simplifies the problem by substituting into the formula, leaving as the remaining specification.
Check (on )
Now we check the remaining variable using the new formula .
-
Check Positive Unate ():
- Result: This is SATISFIABLE (when ). is not positive unate.
-
Check Negative Unate ():
- Result: This is SATISFIABLE (when ). is not negative unate.
-
Conclusion: is binate. The algorithm must proceed to the approximation step.
Computing Approximate Skolem Functions (for )
We need to compute using the and approximations. We’ll use the original for this, as the formulas are defined on the full specification.
Transformation
- NNF:
- Replace : (Note: We only need as doesn’t appear)
Compute (Approximates “must-be-1” )
- Formula ():
- assignment:
- assignment:
- Evaluate :
- Result: .
Compute (Approximates “can-be-1” )
- Formula ():
- assignment:
- assignment:
- Evaluate :
- Result: . The candidate is .
Candidate Selection
Both candidates are identical: and . The algorithm chooses .
Verification of Approximate Skolem Functions
The algorithm has produced the final candidate vector . Now it must verify this.
Build the Error Formula
The formula is .
Let’s substitute our candidates and :
Check for Satisfiability
A SAT solver will try to find an assignment for that makes this true.
Let’s analyze the last two parts:
- This forces and . We can substitute these into :
- Let’s evaluate :
- (Note: is “is different from ?”, which is always true).
- So, (False).
Final Analysis: The error formula simplifies to:
Because the entire formula is AND-ed with 0 (False), it is impossible to satisfy.
The SAT solver will return UNSATISFIABLE (UNSAT).
🏁 Algorithm Result
- The verification check returns UNSAT.
- The algorithm terminates, and outputs the candidate vector .
- Final Answer: .
GACKS’s Approximation is Exact for wDNNF
The most important theoretical guarantee for approximation and verification process is Theorem 2(b). It states that if the transformed formula is in wDNNF, then the polynomial-time approximations ( and ) are guaranteed to be exact.
This means and for all variables . The paper proves this by showing that if the approximations were incorrect, it would directly violate the wDNNF rule.
- Assume a Failure: Let’s assume is in wDNNF, but our approximation is incorrect (i.e., ).
- The Implication: The paper shows that if this failure occurs, it logically implies that there must be some variable (and its corresponding ) that creates a specific conflict inside the formula.
- The Conflict: This failure scenario requires the existence of an AND-gate in the formula’s graph that has a path from the leaf and another path from the leaf [which represents ].
- The Contradiction: This is a direct violation of the wDNNF rule.
- Conclusion: Therefore, our initial assumption must be wrong. If the formula is in wDNNF, such a conflict cannot exist, and the approximations must be correct (exact).
This theorem is the main theoretical justification for Phase 1’s success. It provides a formal, checkable condition under which the “approximate and check” strategy is guaranteed to work.
Theorem 4(2) states this as a key property of the BFSS algorithm: If F is in wDNNF, Phase 1 computes all Skolem functions correctly. This means the verification step is guaranteed to return UNSAT, and the algorithm terminates on the “fast path.”