Skip to content

Commit

Permalink
some more edgecases
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Sep 8, 2024
1 parent 59b2b64 commit 11b3aae
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions R/CnfFormula.R
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,22 @@ simplify_cnf = function(entries, universe) {

if (do_sse || do_sse_reverse) {

if (length(new_entry) == 1) {
# we have a unit clause now

# It could happen that we eliminate the entry further, in which
# case units[[]] would get stale, but then we return_false anyway.
units[[names(new_entry)]] = new_entry[[1]]
can_simplify = TRUE # do unit elimination all over again
## TODO: we could probably make this more efficient by only unit-eliminating the terms that are new
}

if (!length(new_entry)) {
# we have a contradiction now
# Maybe this could happen if we SS-Eliminate multiple symbols from a clause in a row.
return(return_false)
}

# What can have happened now is that the newly created element can eliminate other elements.
# If it can eliminate the current element i, that means it is a subset of ei, which only happens if ej\s is a subset of ei\s. However, in that case, we always want to keep element i.
# We therefore only need to loop up to i - 1.
Expand All @@ -618,13 +634,6 @@ simplify_cnf = function(entries, universe) {
eliminated[[k]] = TRUE
}
}

if (length(new_entry) == 1) {
# we have a unit clause now
units[[names(new_entry)]] = new_entry[[1]]
can_simplify = TRUE # do unit elimination all over again
## TODO: we could probably make this more efficient by only unit-eliminating the terms that are new
}
next
}
}
Expand Down

0 comments on commit 11b3aae

Please sign in to comment.