Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to count the number of solutions to an ANF input? #31

Closed
msoos opened this issue Mar 9, 2022 · 0 comments
Closed

How to count the number of solutions to an ANF input? #31

msoos opened this issue Mar 9, 2022 · 0 comments

Comments

@msoos
Copy link
Collaborator

msoos commented Mar 9, 2022

Basically, you can translate your ANF to CNF, and that CNF will have a "c ind X Y Z 0" line. You can now read this CNF with CryptoMiniSat and get all the solutions:

soos@tiresias:build$ cat a.anf
x1 + x2 + x3 + x0
x1 + x2 + 1
soos@tiresias:build$ ./bosphorus --anfread a.anf --cnfwrite a.cnf
c Bosphorus SHA revision 47edb6b2cd98c6fbc3bffcc35dbf2569bc29f58e
c Executed with command line: ./bosphorus --anfread a.anf --cnfwrite a.cnf
[...]
soos@tiresias:build$ cat a.cnf
p cnf 4 4
2 3 0
-2 -3 0
1 4 0
-1 -4 0
c ind 1 2 3 4 0
soos@tiresias:build$ ./cryptominisat5 --maxsol 1000 a.cnf
[...]
c Number of solutions found until now:      4
s UNSATISFIABLE

So this means, the original ANF had 4 solutions. If the original ANF has many solutions, you can use ApproxMC to count the number of solutions:

soos@tiresias:build$ ./approxmc a.cnf
[...]
c [appmc] Number of solutions is: 4*2**0
s mc 4

Note that ApproxMC is much more suitable if you have many more solutions.

@msoos msoos closed this as completed Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant