Skip to content

Non user-unfriendly code in CNF parser #14

@msoos

Description

@msoos

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:

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:

skip_clause = true;

and the clauses_added count will not be increased:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions