yet more herbrand code
This commit is contained in:
parent
591a24d755
commit
d5beb57492
@ -67,13 +67,21 @@ computeHerbrand db =
|
||||
amalgamateRelationSub newFacts relation =
|
||||
foldr amalgamateRule newFacts (_rules relation) where
|
||||
amalgamateRule :: RelationRule -> NewFacts -> NewFacts
|
||||
amalgamateRule (RelationRule headVars body) newFacts =
|
||||
amalgamateRule (RelationRule headVars bodyElements) newFacts =
|
||||
newFacts where
|
||||
(facts, changed) = newFacts
|
||||
knownTuples :: Set [Constant] = _tuples $ facts Map.! (_name relation)
|
||||
knownTuples :: Set [Constant] =
|
||||
_tuples $ facts Map.! (_name relation)
|
||||
extraTuples = do
|
||||
varmap <- allMaps headVars (Set.toList $ allConstants db)
|
||||
let tuple = (\name -> varmap Map.! name) <$> headVars
|
||||
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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user