makeSingleDeltaRule turns rule into a delta rule, with i-th subgoal used as "delta subgoal." The i-th subgoal must be a positive atom or temporal literal.
(rule ast.Clause, i int)
| 330 | // makeSingleDeltaRule turns rule into a delta rule, with i-th subgoal used as "delta subgoal." |
| 331 | // The i-th subgoal must be a positive atom or temporal literal. |
| 332 | func makeSingleDeltaRule(rule ast.Clause, i int) ast.Clause { |
| 333 | var newpremises []ast.Term |
| 334 | |
| 335 | for j, subgoal := range rule.Premises { |
| 336 | if i == j { |
| 337 | switch p := subgoal.(type) { |
| 338 | case ast.Atom: |
| 339 | newpremises = append(newpremises, makeDeltaAtom(p)) |
| 340 | case ast.TemporalLiteral: |
| 341 | if atom, ok := p.Literal.(ast.Atom); ok { |
| 342 | deltaAtom := makeDeltaAtom(atom) |
| 343 | tl := ast.TemporalLiteral{ |
| 344 | Literal: deltaAtom, |
| 345 | Operator: p.Operator, |
| 346 | Interval: p.Interval, |
| 347 | } |
| 348 | newpremises = append(newpremises, tl) |
| 349 | } else { |
| 350 | newpremises = append(newpremises, subgoal) // Should not happen |
| 351 | } |
| 352 | default: |
| 353 | newpremises = append(newpremises, subgoal) |
| 354 | } |
| 355 | } else { |
| 356 | newpremises = append(newpremises, subgoal) |
| 357 | } |
| 358 | } |
| 359 | clause := ast.NewClause(rule.Head, newpremises) |
| 360 | clause.Transform = rule.Transform |
| 361 | return clause |
| 362 | } |
| 363 | |
| 364 | // makeDeltaRules creates delta rules to check if newly added facts lead to new derivations. |
| 365 | func makeDeltaRules(decls map[ast.PredicateSym]*ast.Decl, predToRules map[ast.PredicateSym][]ast.Clause) map[ast.PredicateSym][]ast.Clause { |