Write a function of four variables that depends on all of them and is 1 on exactly three assignments.
A function of n variables has a value on each of its 2^n assignments. It depends on a variable when changing that variable alone changes its value on at least one assignment, which is when its two cofactors on that variable differ. The assignments where it is 1 can be counted: that count is what the Workbench calls its minterms.
n
2^n
Suppose a task asks for a function of p, q and r that depends on all three and is 1 on exactly 2 of its 8 assignments. Test the candidate k = p & (q ^ r).
p
q
r
k = p & (q ^ r)
Count: k is 1 only when p = 1, and then q ^ r is 1 on 2 of the 4 assignments of q and r. So k is 1 on 2 assignments.
k
p = 1
q ^ r
Dependence: at p = 1, r = 0, changing q changes k; at p = 1, q = 0, changing r does too; and at q = 1, r = 0, changing p does.
p = 1, r = 0
p = 1, q = 0
q = 1, r = 0
So k meets that smaller task: 2 assignments, and it depends on p, q and r.
Write a function h of a, b, c and d that depends on all four variables and is 1 on exactly 3 of their 16 assignments.
h
a
b
c
d
One definition, h = expression;, in the variables a, b, c and d, with any operator of the language. For example, a function of other variables might read m = s & (t | u);.
h = expression;
m = s & (t | u);
h depends on exactly a, b, c and d.
h is 1 on exactly 3 of the 16 assignments.
Read the conditions: they show the variables h depends on and how many of the 16 assignments make it 1, as you type.
In the diagram, every one of a, b, c and d must have at least one node: a variable with no node is one h does not depend on.
Kata 1.3 of Binary Decision Diagrams with CUDD on formal.org. The site checks the answer when you press Check answer; sign in to keep your progress.