Fix a bug in projectTuple where it wasn't ensuring that variables that appeared multiple times were bound to the same thing in the resulting set of tuples.
This commit is contained in:
parent
c09e07042b
commit
a775f753e0
@ -145,10 +145,16 @@ evalConjunction db atoms = do
|
||||
return (foldr (><) (Set.singleton Map.empty) rs)
|
||||
|
||||
projectTuple :: Set ConId -> Map VarId ConId -> [Term] -> Set [ConId]
|
||||
projectTuple univ m = Set.fromList . mapM proj
|
||||
projectTuple univ m0 ts0 = Set.fromList $ proj m0 ts0
|
||||
where
|
||||
proj (Con c) = [c]
|
||||
proj (Var v) = Map.findWithDefault (Set.toList univ) v (fmap (:[]) m)
|
||||
proj _ [] = [[]]
|
||||
proj m (Con c : ts) = map (c:) (proj m ts)
|
||||
proj m (Var v : ts) = case Map.lookup v m of
|
||||
Just c -> map (c:) (proj m ts)
|
||||
Nothing -> do
|
||||
c <- Set.toList univ
|
||||
s <- proj (Map.insert v c m) ts
|
||||
return (c : s)
|
||||
|
||||
immediateConsequences :: Database -> Rule -> Either EvalError (Set [ConId])
|
||||
immediateConsequences db (Atom _ ts :- bodyAtoms) = do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user