Manthan (Golia et al., 2020) is a novel framework for Boolean functional synthesis that views the task as a classification problem: it learns candidate functions from data generated via constrained sampling and iteratively repairs them using formal reasoning (MaxSAT and Unsat Cores) to guarantee correctness. It solves 356/609 benchmark instances.
Overview of Manthan
Manthan is a data-driven framework for Boolean Functional Synthesis. The goal is to take a relational specification F(X,Y) (where X are inputs and Y are outputs) and synthesize a vector of deterministic functions Ψ(X) such that replacing Y with Ψ(X) satisfies the specification.
It uses a hybrid architecture:
Machine Learning: To “guess” candidate functions quickly using data.
Automated Reasoning: To “verify and fix” those guesses using formal proofs.
The workflow is divided into three phases: Preprocess, LearnSkF, and Refine.
Phase 1: Preprocess
Before applying complex algorithms, Manthan simplifies the formula by solving for “easy” variables using logical properties called unate.
Concept: A variable is a “positive unate” if changing it from 0 to 1 can turn the formula from False to True, but never from True to False.
Mechanism: Manthan performs SAT checks to detect these properties.
Positive Unate: If yi is positive unate, its function is ψi(X)=1.
Negative Unate: If yi is negative unate, its function is ψi(X)=0.
Outcome: These variables are effectively “solved” and removed from the learning pile, reducing the dimensionality of the problem for the next phase.
Phase 2: LearnSkF (Learn Skolem Function)
This is the data-driven core where Manthan approximates the remaining functions. It treats synthesis as a classification task.
Step 2.1: Data Generation (GetSamples)
Manthan needs input-output examples (X, Y) to train its models.
The Challenge:F(X,Y) is a relation, not a function. Uniform random sampling often misses “corner cases” where the output Y is strictly determined by X.
The Solution:Weighted Constrained Sampling.
AdaBiasGen Strategy:
Generate pilot samples with a strong bias (e.g., P(yi=1) = 0.9) to explore boundaries.
Analyze the distribution of these pilot samples.
Generate the full training set using biases tuned to “push” the sampler into interesting regions of the Boolean space.
Manthan learns a separate Decision Tree for each variable yj.
Feature Selection: To predict yj, it uses X and any other output variables Y∖{yj} that do not depend on yj. This implicitly builds a dependency graph.
Model: ID3 algorithm using Gini Index for impurity.
Symbolic Conversion: The trained tree is converted into a Boolean formula.
For every leaf node labeled 1, the path from the root is extracted as a conjunction of literals.
The function ψj is the disjunction (OR) of all such paths.
Step 2.3: Ordering (FindOrder)
Because functions can depend on each other (e.g., ψ2 uses y1), Manthan computes a TotalOrder (linear execution order) by topologically sorting the dependency graph. This ensures no cyclic dependencies exist.
Pseudocode: CandidateSkF
def CandidateSkF(Sigma, F, y_j, D): """ Sigma: Training samples F: Specification formula y_j: The output variable to learn D: Current dependency graph """ # 1. Select Features: Inputs X + non-dependent Y variables featset = X for y_k in Y: if y_k != y_j and (y_j not in dependencies_of(y_k)): featset.add(y_k) # 2. Extract training data for y_j from Sigma using featset features, labels = AdaBiasGen(Sigma, featset, y_j) # 3. Train ID3 Decision Tree tree = CreateDecisionTree(features, labels) # 4. Convert Tree to Formula psi_j = False # Initialize as empty disjunction for leaf in tree.LeafNodes(): if Label(leaf) == 1: # Convert path (e.g., x1=0, x2=1) to formula (NOT x1 AND x2) path_formula = Path(tree, root, leaf) psi_j = psi_j OR path_formula # 5. Update dependency graph D # If psi_j uses y_k, then y_j depends on y_k for variable in psi_j: if variable in Y: update_dependencies(D, y_j, variable) return psi_j, D
Phase 3: Refine (Verification and Refinement)
The learned candidates are just approximations. This phase uses formal logic to find bugs and patch them.
Step 3.1: Verification
Manthan constructs an Error FormulaE to check if the candidate functions Ψ are valid:
E=F(X,Y)∧¬F(X,Y′)∧(Y′↔Ψ(X))
UNSAT: The functions are valid. The process finishes.
SAT: The solver returns a counterexampleσ. This is a specific input X where the current functions produce an invalid output, even though a valid output exists.
Step 3.2: Fault Localization (MaxSAT)
Identifying which function is wrong is crucial to avoid breaking correct parts of the system.
Tool:MaxSAT Solver.
Query: “Find an assignment that satisfies the specification (Hard Constraint) while changing as few function outputs as possible (Soft Constraints)”.
Result: Variables that violate the soft constraints are flagged as erring functions.
Step 3.3: Proof-Guided Repair
Manthan repairs each erring function ψk using Unsat Cores.
Construct Gk: A temporary formula that asserts the function’s current (incorrect) value alongside the specification and counterexample. This formula is naturally UNSAT (contradictory).
Extract Core: The Unsat Core of Gk is extracted. This subset of clauses explains why the contradiction exists.
Patch (β): A repair formula β is created from the core.
If the function output 1 but should be 0: ψk←ψk∧¬β.
If the function output 0 but should be 1: ψk←ψk∨β.
Step 3.4: Self-Substitution (The Safety Net)
Some functions (like parity) are hard for decision trees to learn.
Heuristic: If a function is repaired more than 10 times, it is marked “hard-to-learn”.
Action: Manthan switches to Self-Substitution. It solves for ψk analytically by setting ψk=F(X,Y)∣yk=1. This is precise but computationally expensive, so it is used sparingly.
Pseudocode: RefineSkF
def RefineSkF(F, Psi, sigma, TotalOrder): """ sigma: The counterexample found by the SAT solver Psi: The current candidate functions """ # 1. Fault Localization via MaxSAT # H: Hard constraints (The spec F must be true) H = F(X,Y) AND (X == sigma[X]) # S: Soft constraints (Keep current outputs if possible) S = (Y == sigma[Y_prime]) # Identify which variables MUST change to satisfy H erring_indices = MaxSATList(H, S) for y_k in erring_indices: # 2. Check for "Hard to Learn" variables # If repaired > 10 times, switch to symbolic substitution if CheckSubstitute(y_k): DoSelfSubstitution(F, y_k) continue # 3. Proof-Guided Repair # Create formula G_k forcing the error context G_k = (y_k == sigma[y_k_prime]) AND F ... ret, rho = CheckSat(G_k) if ret == UNSAT: # Extract the reason for failure (Core) C = FindCore(G_k) beta = Conjunction(C) # The patch # Apply patch to psi_k if sigma[y_k_prime] == 1: Psi[y_k] = Psi[y_k] AND NOT beta else: Psi[y_k] = Psi[y_k] OR beta
Final Step: Substitute
Once the Refine loop ensures the functions are correct (UNSAT error formula), the functions in Ψ might still depend on each other (e.g., y2 depends on y1).
The Substitute routine uses the TotalOrder to recursively replace these dependencies.
Result: A clean vector Ψ(X) where every function depends only on the inputs X.
Overview of Manthan2
Abstract
In Golia et al. (2021) the authors introduce Manthan2, a significantly improved data-driven Boolean functional synthesis engine that achieves state-of-the-art scalability by integrating the following into Manthan:
interpolation-based function extraction,
clustering-based multi-classification, and
dependency-aware repair mechanisms
Manthan2 solves 509 instances, a 153-instance improvement over Manthan, which had only improved on the prior state-of-the-art by 76 instances. It introduces key innovations like retaining determined features and clustering-based multi-classification to enhance scalability and efficiency.
The Solution/Methodology
The authors propose Manthan2, which enhances the original Manthan pipeline through four distinct algorithmic improvements.
Unique Function Extraction (UniDef): Before learning, the system checks if any output variables (Y) are uniquely defined by the remaining variables using Padoa’s Theorem and interpolation. If a definition is found, it is extracted immediately and removed from the learning queue.
Variable Retention (Determined Features): Contrary to standard practice where defined variables are eliminated/removed from the formula (e.g., using substitution (y3=¬y2) or elimination(Φ∣y3=1)), Manthan2 retains these variables. They act as “determined features” (extra inputs) that help the machine learning model learn simpler functions for the remaining difficult variables.
Clustering-based Multi-Classification: Instead of learning one decision tree for every single output variable (which is slow), Manthan2 groups related output variables using a graph-clustering approach. It then trains a multi-output classifier to predict values for a whole cluster at once, significantly speeding up the learning phase.
Lexicographic MaxSAT Repair: When candidate functions fail verification, Manthan2 uses Lexicographic MaxSAT to select which functions to repair. It imposes a strict hierarchy: it prefers fixing variables that appear earlier in the dependency order, preventing wasted effort on downstream variables that might automatically resolve once the upstream dependency is fixed.
Key Results & Contributions
State-of-the-Art Performance: Manthan2 solved 509 out of 609 benchmarks, a massive leap over the previous best (Manthan) which solved 356. This increase of 153 instances is double the improvement Manthan originally made over its predecessor.
Efficiency: The PAR-2 score (a cumulative runtime metric) dropped from 6374.39 (Manthan) to 2858.61 (Manthan2), indicating it is more than twice as fast/effective on average.
Validation of Methods:
Clustering: Grouping variables reduced runtime by ~250 seconds.
LexMaxSAT: Prioritizing repairs saved ~100 seconds in PAR-2 score.
Unique Extraction: Proved vital; for ~40% of benchmarks, Manthan2 could extract exact functions for >95% of the variables without needing learning at all.
Manthan2 Architecture Introduction
These notes follow the execution flow of the Manthan2 algorithm, using the paper’s running example to illustrate each step.
The algorithm begins by reducing the problem space. Instead of learning everything, it checks for variables that are mathematically fixed by the specification.
Concept: Uses Padoa’s Theorem and Interpolation. If F(X,Y) implies yi↔H(X,Y∖yi), then H is the Skolem function.
Example: The system analyzes (y3∨y4)∧(¬y3∨¬y4). It identifies that y4 is uniquely defined by y3.
Result: It extracts ψ4=¬y3.
Determined Set (Z):y4 is added to the “determined set”.
Unlike previous tools, Manthan2 keepsy4 in the formula. It treats ψ4 as a known feature for future steps rather than deleting y4 via substitution. This keeps the remaining functions simpler.
Phase 2: Clustering & Sampling
Now the system generates data to learn the remaining undefined variables {y1,y2,y3}.
Sampling: It generates random satisfying assignments (samples) of F(X,Y).
Clustering (ClusterY): It builds a primal graph where edges connect variables appearing in the same clause.
y1 and y2 share a clause (x2∨¬y1∨y2).
y3 is isolated from them.
Result: The algorithm clusters Y into groups: {{y1,y2},{y3}}.
Benefit: This allows using a multi-classifier. Instead of two separate trees for y1 and y2, one tree predicts the vector ⟨y1,y2⟩.
Phase 3: Learning Candidates (CandidateSkF)
Manthan2 learns decision trees (DT) for the clusters.
Cluster {y1,y2}:
Features:X={x1,x2} (and potentially determined variables if valid).
Labels: The combination pairs observed in samples (e.g., 01, 10, 11).
Tree Logic: The tree splits on x1 and x2.
Extraction:
For ψ1 (corresponding to y1): It takes the disjunction of paths where the label for y1 is 1.
Learned ψ1=x1∨(¬x1∧¬x2).
Learned ψ2=¬x1.
Cluster {y3}:
Learned ψ3=x2.
Current Candidate Vector:Ψ=⟨ψ1,ψ2,ψ3,ψ4⟩.
Phase 4: Verification
The system checks if the candidates are actually valid Skolem functions.
Error Formula:E(X,Y,Y′)=F(X,Y)∧¬F(X,Ψ(X)).
Check: Is there an input X where the candidates Ψ(X) fail to satisfy F?
Result: The formula is SAT (Satisfiable), meaning the candidates are imperfect. A counterexample σ is found (e.g., x1=1,x2=0,…).
Phase 5: Dependency-Aware Repair (LexMaxSAT)
The candidates need fixing. The key is deciding which one to fix.
Dependency Order: The system determines a topological order: y4 depends on y3, y3 might depend on others, etc. Let’s assume order TotalOrder=y4>y3>y2>y1.
The Issue: A standard MaxSAT might suggest fixing y4. But if y4 depends on y3, and y3 is wrong, fixing y4 is useless.
LexMaxSAT Solution: Manthan2 sets up “soft constraints” (preferences) to keep the current candidate functions, but weights them by their dependency order. It prioritizes fixing the independent variables first. If y1 is independent and wrong, it must be fixed before looking at y2.
In Example: The solver identifies that ψ2 needs repair (specifically for the counterexample assignment).
Repair Execution: It constructs a repair formula G2 which forces ψ2 to flip its output for the problematic input.
Manthan2 updates ψ2←ψ2∨(repair condition).
New ψ2=¬x1∨y1.
Final Outcome
With the repaired ψ2, the error formula becomes UNSAT. The system outputs the valid Skolem function vector.
References
Golia, P., Roy, S., & Meel, K. S. (2020). Manthan: A Data-Driven Approach for Boolean Function Synthesis. In S. K. Lahiri & C. Wang (Eds.), Computer Aided Verification (Vol. 12225, pp. 611–633). Springer International Publishing. https://doi.org/10.1007/978-3-030-53291-8_31
Golia, P., Slivovsky, F., Roy, S., & Meel, K. S. (2021). Engineering an Efficient Boolean Functional Synthesis Engine. 2021 IEEE/ACM International Conference On Computer Aided Design (ICCAD), 1–9. https://doi.org/10.1109/ICCAD51958.2021.9643583