-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Hi,
As you know, I love sharpSAT, however, I recently bumped into this issue, and it's uinfriendly to users, so I suggest changing. Basically, the line here:
Line 331 in edfbde3
| while ((input_file >> c) && clauses_added < nCls) { |
makes sure that only nCls clauses are parsed (not precisely, see below). This is an issue, because in case the header says fewer clauses than actually in the file (i.e. incorrect header), sharpSAT will not parse more than nCls clauses, and will likely return a larger count than if it had parsed all clauses. Of course, the CNF is incorrect. The header should be correct, but the user may have made an honest mistake, and sharpSAT could warn them about it. But unfortunately, sharpSAT does not warn, and skips the rest of the CNF :( Many modern SAT solvers either ignore the number of clauses, or exit with error (the kissat and CaDiCaL way is to exit with error).
An insidious bug related to this is that sharpSAT will actually parse more clauses than claimed in the header, in case the clause is of the form a -a ... -- in these cases, skip_clause will be set:
Line 344 in edfbde3
| skip_clause = true; |
and the clauses_added count will not be increased:
Line 354 in edfbde3
| clauses_added++; |
and so sharpSAT will parse more clauses than in the header. Of course, the CNF is incorrect either way, however, this makes it less likely that the user will understand what's happening 😞
I am currently changing GANAK to exit with an error message in these cases. We have been chasing our tails regarding an issue related to a file with incorrect header with GANAK: meelgroup/ganak#21 😭
Thanks again for sharpSAT, it's amazing!
Mate