Circular Logic
A 6-input binary truth table tau(a,b,c,d,e,f) must satisfy: tau(a,b,c,d,e,f) wedge tau(b,c,d,e,f, a + (b wedge c)) = 0 for all inputs (a,b,c,d,e,f) in {0,1}^6. How many such truth tables exist?
Problem Statement
This archive keeps the full statement, math, and original media on the page.
\(k\)-input binary truth table is a map from \(k\) input bits (binary digits, \(0\) [false] or \(1\) [true]) to \(1\) output bit. For example, the \(2\)-input binary truth tables for the logical \(\mathbin {\text {AND}}\) and \(\mathbin {\text {XOR}}\) functions are:
| \(x\) | \(y\) | \(x\) \(\mathbin {\text {AND}}\) \(y\) |
| \(0\) | \(0\) | \(0\) |
| \(0\) | \(1\) | \(0\) |
| \(1\) | \(0\) | \(0\) |
| \(1\) | \(1\) | \(1\) |
auto
| \(x\) | \(y\) | \(x\) \(\mathbin {\text {XOR}}\) \(y\) |
| \(0\) | \(0\) | \(0\) |
| \(0\) | \(1\) | \(1\) |
| \(1\) | \(0\) | \(1\) |
| \(1\) | \(1\) | \(0\) |
How many \(6\)-input binary truth tables, \(\tau \), satisfy the formula \[\tau (a, b, c, d, e, f) \mathbin {\text {AND}} \tau (b, c, d, e, f, a \mathbin {\text {XOR}} (b \mathbin {\text {AND}} c)) = 0\] for all \(6\)-bit inputs \((a, b, c, d, e, f)\)?
Problem 209: Circular Logic
Analysis
Constraint as a Graph
The condition says: for each input , at most one of and can be 1, where:
This defines a permutation on the 64 inputs . The constraint is that for each input , we cannot have both and .
Cycle Decomposition
Since is a function from a finite set to itself, it decomposes into cycles and tails. In fact, is a bijection (it’s invertible: given , we can recover ), so it’s a permutation and decomposes into disjoint cycles.
Independent Set Counting on Cycles
The constraint says: on each cycle of , we cannot assign to two consecutive elements. This is the problem of counting independent sets on a cycle graph.
For a cycle of length , the number of independent sets (including the empty set) is:
where is the -th Fibonacci number (Lucas numbers).
Equivalently, .
Computing the Cycle Structure
We enumerate all 64 inputs, apply repeatedly, and find the cycle lengths. The total count is the product of Lucas numbers over all cycles.
Cycle Lengths
Computing for all 64 inputs and finding cycles:
- The permutation on has the following cycle structure (computed programmatically):
- Cycles of various lengths
The product of Lucas numbers for each cycle gives the answer.
Correctness
Theorem. The method described above computes exactly the quantity requested in the problem statement.
Proof. The preceding analysis identifies the admissible objects and derives the formula, recurrence, or exhaustive search carried out by the algorithm. The computation evaluates exactly that specification, so every valid contribution is included once and no invalid contribution is counted. Therefore the returned value is the required answer.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main() {
// sigma(a,b,c,d,e,f) = (b,c,d,e,f, a XOR (b AND c))
// Encode (a,b,c,d,e,f) as a 6-bit integer: a*32 + b*16 + c*8 + d*4 + e*2 + f
auto sigma = [](int x) -> int {
int a = (x >> 5) & 1;
int b = (x >> 4) & 1;
int c = (x >> 3) & 1;
int d = (x >> 2) & 1;
int e = (x >> 1) & 1;
int f = x & 1;
int new_f = a ^ (b & c);
return (b << 5) | (c << 4) | (d << 3) | (e << 2) | (f << 1) | new_f;
};
// Find cycle structure
vector<bool> visited(64, false);
vector<int> cycle_lengths;
for (int i = 0; i < 64; i++) {
if (visited[i]) continue;
int len = 0;
int cur = i;
while (!visited[cur]) {
visited[cur] = true;
cur = sigma(cur);
len++;
}
cycle_lengths.push_back(len);
}
// For each cycle of length n, count independent sets = Lucas(n)
// Lucas(1) = 1, Lucas(2) = 3, Lucas(n) = Lucas(n-1) + Lucas(n-2)
// But Lucas(1) should be 1 for self-loops (tau(x) AND tau(x) = 0 => tau(x) = 0)
// Standard Lucas: L(1)=1, L(2)=3, L(n)=L(n-1)+L(n-2)
auto lucas = [](int n) -> long long {
if (n == 1) return 1;
if (n == 2) return 3;
long long a = 1, b = 3;
for (int i = 3; i <= n; i++) {
long long c = a + b;
a = b;
b = c;
}
return b;
};
long long answer = 1;
for (int len : cycle_lengths) {
answer *= lucas(len);
}
cout << answer << endl;
return 0;
}
"""
Problem 209: Circular Logic
Count 6-input truth tables tau such that
tau(a,b,c,d,e,f) AND tau(b,c,d,e,f, a XOR (b AND c)) = 0
for all inputs.
This is equivalent to counting independent sets on the cycle graph
formed by the permutation sigma on {0,1}^6.
The answer is the product of Lucas numbers over all cycle lengths.
"""
def solve():
def sigma(x):
a = (x >> 5) & 1
b = (x >> 4) & 1
c = (x >> 3) & 1
d = (x >> 2) & 1
e = (x >> 1) & 1
f = x & 1
new_f = a ^ (b & c)
return (b << 5) | (c << 4) | (d << 3) | (e << 2) | (f << 1) | new_f
# Find cycles
visited = [False] * 64
cycle_lengths = []
for i in range(64):
if visited[i]:
continue
length = 0
cur = i
while not visited[cur]:
visited[cur] = True
cur = sigma(cur)
length += 1
cycle_lengths.append(length)
print(f"Cycle structure: {sorted(cycle_lengths)}")
print(f"Number of cycles: {len(cycle_lengths)}")
print(f"Sum of cycle lengths: {sum(cycle_lengths)}")
# Lucas numbers: L(1)=1, L(2)=3, L(n)=L(n-1)+L(n-2)
def lucas(n):
if n == 1:
return 1
if n == 2:
return 3
a, b = 1, 3
for _ in range(3, n + 1):
a, b = b, a + b
return b
answer = 1
for length in cycle_lengths:
answer *= lucas(length)
return answer
answer = solve()
assert answer == 15964587728784
print(answer)