Skip to content

Commit db1d37e

Browse files
author
Julien Moutinho
committed
fix resolve
1 parent 16e9acb commit db1d37e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Data/CDCL.hs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ implies (Group group) candidate = any (`subsumes` candidate) group
116116
-- __subset__ of the switches in @y@. In other words, the @x@ 'Rule' will match
117117
-- /everything/ that @y@ will.
118118
subsumes :: Rule -> Rule -> Bool
119-
subsumes (Rule these) (Rule those) = HashMap.foldrWithKey check True these
120-
where check key value acc = HashMap.lookup key those == Just value && acc
119+
subsumes (Rule x) (Rule y) = HashMap.foldrWithKey check True x
120+
where check key v acc = HashMap.lookup key y == Just v && acc
121121

122122
-- | Add a new 'Rule' to a 'Group'. Attempt to calculate any 'refinements' of
123123
-- the rule, and generalise the 'Group' as far as possible.
@@ -126,11 +126,17 @@ resolve rule group | group `implies` rule = group
126126
resolve rule@(Rule config) group@(Group rules)
127127
= case refinements rule group of
128128
[] -> Group case HashMap.toList config of
129-
[ (key, value) ] -> do -- Unit propagation
129+
[ (key, x) ] -> do -- Unit propagation
130130
HashSet.insert rule $ rules & HashSet.map \(Rule current) -> do
131-
if HashMap.lookup key current /= Just value
132-
then Rule (HashMap.delete key current)
133-
else rule
131+
Rule $ case HashMap.lookup key current of
132+
-- The unit does not appear in the current rule : keep the current rule.
133+
Nothing -> current
134+
-- The unit subsumes the current rule : delete the current rule.
135+
Just y | y == x -> config
136+
-- If the unit matches, the current rule is useless for that group to match.
137+
-- Otherwise the unit does not match, but then the current rule
138+
-- does not need to recheck that : delete the unit from the current rule.
139+
| otherwise {- y == not x -} -> HashMap.delete key current
134140

135141
_ -> rules & HashSet.filter (not . (rule `subsumes`))
136142
& HashSet.insert rule

0 commit comments

Comments
 (0)