Skip to content

Commit

Permalink
fix bug in constraint instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
vale1410 committed Jul 6, 2020
1 parent 84463f5 commit ff1bac6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/bule.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,20 @@ func (p *Program) CleanRulesFromGroundBoolExpression() (bool, error) {
return false
}

transform := func(rule Rule) (result []Rule, err error) {
newRule := rule
transform := func(rule Rule) ([]Rule, error) {
newRule := rule.Copy()
newRule.Constraints = []Constraint{}
for _, cons := range rule.Constraints {
isGround, boolResult := cons.GroundBoolExpression()
if isGround {
if boolResult {
result = []Rule{newRule}
} else {
result = []Rule{}
break
if !boolResult {
return []Rule{}, nil
}
} else {
newRule.Constraints = append(rule.Constraints, cons)
newRule.Constraints = append(newRule.Constraints, cons)
}
}
return
return []Rule{newRule}, nil
}
return p.RuleExpansion(check, transform)
}
Expand Down
9 changes: 9 additions & 0 deletions test-expected/t06.bul
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a[0].
a[1].
a[2].
b[0].
b[1].
b[2].
x[1].
x[2].
x[4].
4 changes: 4 additions & 0 deletions test-input/t06.bul
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a[0..2].
b[0..2].

a[X], b[Y], X > 0, Y > 0, P == X*Y => x[P].

0 comments on commit ff1bac6

Please sign in to comment.