BoundsCheck checks whether the rules respect the bounds.
()
| 1023 | |
| 1024 | // BoundsCheck checks whether the rules respect the bounds. |
| 1025 | func (bc *BoundsAnalyzer) BoundsCheck() error { |
| 1026 | predMap := make(map[string]ast.PredicateSym) |
| 1027 | for pred := range bc.programInfo.IdbPredicates { |
| 1028 | predMap[pred.Symbol] = pred |
| 1029 | } |
| 1030 | for pred := range bc.initialFactMap { |
| 1031 | predMap[pred.Symbol] = pred // overwrite ok |
| 1032 | } |
| 1033 | preds := make([]ast.PredicateSym, 0, len(predMap)) |
| 1034 | for _, v := range predMap { |
| 1035 | preds = append(preds, v) |
| 1036 | } |
| 1037 | // Fix the order in which we do our checks. |
| 1038 | sort.Slice(preds, func(i, j int) bool { return preds[i].Symbol < preds[j].Symbol }) |
| 1039 | for _, pred := range preds { |
| 1040 | if err := bc.inferAndCheckBounds(pred); err != nil { |
| 1041 | return err |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | return nil |
| 1046 | } |
| 1047 | |
| 1048 | // Entry point for bounds checking. |
| 1049 | func (bc *BoundsAnalyzer) inferAndCheckBounds(pred ast.PredicateSym) error { |