yet more herbrand code
This commit is contained in:
parent
591a24d755
commit
d5beb57492
@ -67,13 +67,21 @@ computeHerbrand db =
|
|||||||
amalgamateRelationSub newFacts relation =
|
amalgamateRelationSub newFacts relation =
|
||||||
foldr amalgamateRule newFacts (_rules relation) where
|
foldr amalgamateRule newFacts (_rules relation) where
|
||||||
amalgamateRule :: RelationRule -> NewFacts -> NewFacts
|
amalgamateRule :: RelationRule -> NewFacts -> NewFacts
|
||||||
amalgamateRule (RelationRule headVars body) newFacts =
|
amalgamateRule (RelationRule headVars bodyElements) newFacts =
|
||||||
newFacts where
|
newFacts where
|
||||||
(facts, changed) = newFacts
|
(facts, changed) = newFacts
|
||||||
knownTuples :: Set [Constant] = _tuples $ facts Map.! (_name relation)
|
knownTuples :: Set [Constant] =
|
||||||
|
_tuples $ facts Map.! (_name relation)
|
||||||
extraTuples = do
|
extraTuples = do
|
||||||
varmap <- allMaps headVars (Set.toList $ allConstants db)
|
varmap <- allMaps headVars (Set.toList $ allConstants db)
|
||||||
let tuple = (\name -> varmap Map.! name) <$> headVars
|
let tuple = (\name -> varmap Map.! name) <$> headVars
|
||||||
guard $ not $ Set.member tuple knownTuples
|
guard $ not $ Set.member tuple knownTuples
|
||||||
|
let twig :: Int -> Int -> Int
|
||||||
|
twig x y = x + y
|
||||||
|
satisfied :: RuleBodyElement -> Bool
|
||||||
|
satisfied (RuleBodyElement subRelationId ruleElements) = all (satisfiedSub (facts Map.! subRelationId)) ruleElements
|
||||||
|
satisfiedSub :: Relation -> RuleElement -> Bool
|
||||||
|
satisfiedSub subRelation ruleElement = True
|
||||||
|
guard $ all satisfied bodyElements
|
||||||
return varmap
|
return varmap
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user