yet more herbrand code

This commit is contained in:
Felix Dilke 2026-02-10 17:36:41 +00:00
parent 591a24d755
commit d5beb57492

View File

@ -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