simplified addRule

This commit is contained in:
Felix Dilke 2026-01-30 14:28:51 +00:00
parent 2f911a9f39
commit b816bb4cae

View File

@ -53,7 +53,8 @@ instance DatalogDB NaiveDatabase where
addRule :: (Literal, [Literal]) -> NaiveDatabase -> NaiveDatabase
addRule (ruleHead, body) db =
NaiveDatabase relationMap' constants' where
insertRelation db' newRelation
where
relationName = predName ruleHead
terms = arguments ruleHead
newArity = length terms
@ -61,13 +62,10 @@ instance DatalogDB NaiveDatabase where
context = digestHead db relation ruleHead
context' = foldr digestBody context body
db' = _db context'
relationMap = relations db'
relation' = appendRule relation RelationRule {
newRelation = appendRule relation RelationRule {
headVariables = _variableNames context'
, bodyElements = toRuleBodyElement <$> _bodyConstraints context'
}
relationMap' = Map.insert relationName relation' relationMap
constants' = constants db'
addConstants :: NaiveDatabase -> Set Constant -> NaiveDatabase
addConstants db newConstants =