Assert(n.getKind() == MK_BAG);
Assert(e.getType() == n.getType().getBagElementType());
+ /*
+ * (ite (and (= e x) (>= c 1))
+ * (= (bag.count e skolem) c)
+ * (= (bag.count e skolem) 0))
+ */
Node x = n[0];
Node c = n[1];
+ InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG);
+ Node same = d_nm->mkNode(EQUAL, e, x);
Node geq = d_nm->mkNode(GEQ, c, d_one);
- if (d_state->areEqual(e, x))
- {
- // (= (bag.count e skolem) (ite (>= c 1) c 0)))
- InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG_SAME_ELEMENT);
- Node skolem = getSkolem(n, inferInfo);
- Node count = getMultiplicityTerm(e, skolem);
- Node ite = d_nm->mkNode(ITE, geq, c, d_zero);
- inferInfo.d_conclusion = count.eqNode(ite);
- return inferInfo;
- }
- if (d_state->areDisequal(e, x))
- {
- //(= (bag.count e skolem) 0))
- InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG_SAME_ELEMENT);
- Node skolem = getSkolem(n, inferInfo);
- Node count = getMultiplicityTerm(e, skolem);
- inferInfo.d_conclusion = count.eqNode(d_zero);
- return inferInfo;
- }
- else
- {
- // (= (bag.count e skolem) (ite (and (= e x) (>= c 1)) c 0)))
- InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG);
- Node skolem = getSkolem(n, inferInfo);
- Node count = getMultiplicityTerm(e, skolem);
- Node same = d_nm->mkNode(EQUAL, e, x);
- Node andNode = same.andNode(geq);
- Node ite = d_nm->mkNode(ITE, andNode, c, d_zero);
- Node equal = count.eqNode(ite);
- inferInfo.d_conclusion = equal;
- return inferInfo;
- }
+ Node andNode = same.andNode(geq);
+ Node skolem = getSkolem(n, inferInfo);
+ Node count = getMultiplicityTerm(e, skolem);
+ Node equalC = d_nm->mkNode(EQUAL, count, c);
+ Node equalZero = d_nm->mkNode(EQUAL, count, d_zero);
+ Node ite = d_nm->mkNode(ITE, andNode, equalC, equalZero);
+ inferInfo.d_conclusion = ite;
+ return inferInfo;
}
/**
/**
* @param n is (bag x c) of type (Bag E)
* @param e is a node of type E
- * @return an inference that represents the following cases:
- * 1- e, x are in the same equivalent class, then we infer:
- * (= (bag.count e skolem) (ite (>= c 1) c 0)))
- * 2- e, x are known to be disequal, then we infer:
- * (= (bag.count e skolem) 0))
- * 3- if neither holds, we infer:
- * (= (bag.count e skolem) (ite (and (= e x) (>= c 1)) c 0)))
+ * @return an inference that represents the following lemma:
+ * (ite (and (= e x) (>= c 1))
+ * (= (bag.count e skolem) c)
+ * (= (bag.count e skolem) 0))
* where skolem = (bag x c) is a fresh variable
*/
InferInfo mkBag(Node n, Node e);