Skip to content

Commit 358f5c3

Browse files
msoosclaude
andcommitted
Make make test d-DNNF fuzzing fast
`make test` ran the compile fuzzer at 100 cases with up to 16 vars; the oracle (brute force + model-set + function-model enumeration) is 2^nv, so it took ~21s. - Add --minvars/--maxvars knobs to ddnnf_fuzz.py (default 7..16 unchanged for manual deep runs). - ctest now runs fewer, smaller cases: compile fuzz 40 @ vars 6..10, synth weak0/weak3 30 each. Total d-DNNF test time ~21s -> ~2.6s for the compile fuzz; whole `make test` ~6.5s. Deep fuzzing is still a manual `ddnnf_fuzz.py 200 [--maxvars N]` away. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6e8b2f4 commit 358f5c3

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ python3 tests/ddnnf_fuzz.py 200 # circuit count == true count, model
8181
# == true models (validates arc literals),
8282
# strictly decomposable, faithful as a fn
8383
python3 tests/ddnnf_fuzz.py 200 --seed N # reproduce a specific run
84+
python3 tests/ddnnf_fuzz.py 200 --maxvars 14 # cap var count (oracle is 2^nv, so
85+
# this is the main runtime/coverage knob;
86+
# also --minvars N)
8487
```
8588

8689
`ganak --compile out.nnf in.cnf` writes a faithful d-DNNF. `--weak 0` is that

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,15 @@ if(ENABLE_TESTING)
565565
# count/model set as an oracle, and check the emitted circuit against it.
566566
# Seeded so a regression reproduces identically; they self-check against the
567567
# oracle, so there is no golden file to break when the circuit shape changes.
568+
# Small/few by design: the oracle is 2^nv and each case spawns ganak, so we
569+
# keep these quick for `make test`. For deep fuzzing run them by hand with a
570+
# larger count / --maxvars (see CLAUDE.md).
568571
add_test(NAME ddnnf_compile_fuzz
569-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/ddnnf_fuzz.py 100 --seed 1)
572+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/ddnnf_fuzz.py 40 --seed 1 --minvars 6 --maxvars 10)
570573
add_test(NAME ddnnf_synth_weak0
571-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/ddnnf_synth.py 60 --seed 1)
574+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/ddnnf_synth.py 30 --seed 1)
572575
add_test(NAME ddnnf_synth_weak3
573-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/ddnnf_synth.py 60 --seed 1 --weak 3)
576+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/ddnnf_synth.py 30 --seed 1 --weak 3)
574577
endif()
575578

576579
# -----------------------------------------------------------------------------

tests/ddnnf_fuzz.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,25 @@ def compile_nnf(path, nnf, weak_level):
102102
def main():
103103
n = 200
104104
seed = random.randrange(1 << 30)
105+
minv, maxv = 7, 16 # var-count range; the oracle is 2^nv, so this drives runtime
105106
args = sys.argv[1:]
106107
i = 0
107108
while i < len(args):
108109
if args[i] == "--seed":
109110
seed = int(args[i + 1])
110111
i += 1
112+
elif args[i] == "--minvars":
113+
minv = int(args[i + 1])
114+
i += 1
115+
elif args[i] == "--maxvars":
116+
maxv = int(args[i + 1])
117+
i += 1
111118
else:
112119
n = int(args[i])
113120
i += 1
121+
minv = min(minv, maxv)
114122
random.seed(seed)
115-
print(f"seed={seed} tests={n} mode=STRONG")
123+
print(f"seed={seed} tests={n} vars={minv}..{maxv} mode=STRONG")
116124

117125
fails = 0
118126

@@ -129,7 +137,7 @@ def save_fail(t):
129137
shutil.copy(clean, unique_file("fail", ".clean.nnf"))
130138

131139
for t in range(n):
132-
nv = random.randint(7, 16)
140+
nv = random.randint(minv, maxv)
133141
nc = random.randint(nv, nv * 4)
134142
k = random.choice([2, 3, 3, 4])
135143
clauses = gen_cnf(nv, nc, k)

0 commit comments

Comments
 (0)