In the context of my research, I am having a hard time in solving this problem. It resembles the topological ordering problem, but since that the graph can contain cycles, I cannot apply the existing algorithm.
I have a set of initial nodes. Through an iterative process, I can use a pair of distinct nodes (initial or not) to imply a third node (initial or not). Every node, initial or not, can imply 0 or more nodes.
Suppose I have generated a graph with those rules.
Starting from a non-initial node, I want to enumerate all possible implication chains which start from a subset of initial nodes and reach a target node. Each non-initial node in the chain must be implied by exactly one pair of nodes. Each initial node must not be implied by other nodes, as initial nodes are base cases.
In other words, starting from a non-initial node, I must select exactly one pair of nodes which imply the target node, and do this recursively for the nodes of the pair, unless they are initial nodes, as initial nodes are base cases.
Let me give some examples. Initial nodes have an asterisk; non-initial nodes do not.
Example 1:
Suppose the goal is X. The only solution is:
- A*, B*, A*+B*=X.
In fact, I cannot use Y+Z=X as Z is only obtainable by first having X.
Example 2:
Suppose the goal is X. There are two solutions:
- A*, B*, A*+B*=X
- B*, Y*, B*+Y*=Z
Suppose the goal is Z. There are two solutions:
- A*, B*, A*+B*=X, Y*, X+Y*=Z
- B*, Y*, B*+Y*=Z
Edit, answering to user D.W.:
I am using your suggestion of encoding your problem into a SAT problem, but I don't understand how it can possibly avoid circular dependencies. Let me spell the SAT rules which encode the problem in question and instantiate them for Example 1:
- Each non-initial node must be implied by one pair of nodes.
X ⟺ ABX ∨ YZX
Z ⟺ XYZ
- For each non-initial node, we can choose at most one implication.
(¬ABX ∨ ¬YZX)
- Each implication requires the implicants:
ABX ⟺ (A ∧ B)
XYZ ⟺ (X ∧ Y)
YZX ⟺ (Y ∧ Z)
- Each node (with the exception of the target node) can be selected only if it appears in (at least one) implication.
A ⟺ ABX
B ⟺ ABX
Y ⟺ XYZ ∨ YZX
Z ⟺ YZX
(There are probably more rules, but these are okay to start and see what happens).
Using a SAT solver, the solutions to this problem are:
- A, B, X, ABX
- X, Y, Z, YZX, XYZ
Solution 2 is contains a circular dependency.

