def joinWithParent(arg): instances = arg.getInstances(nonsupered=True) newInstances = {} for (sort, index) in instances.keys(): (expr, pol) = instances[(sort, index)] if pol == Common.DEFINITELY_OFF: continue (lower, upper, _) = sort.instanceRanges[index] for i in range(lower, min(sort.parentInstances, upper + 1)): (old_expr, old_pol) = newInstances.get( (sort.parent, i), (SMTLib.SMT_BoolConst(False), Common.DEFINITELY_OFF)) if pol == Common.DEFINITELY_ON and lower == upper: new_pol = Common.DEFINITELY_ON new_expr = SMTLib.SMT_BoolConst(True) else: new_pol = Common.aggregate_polarity(old_pol, Common.UNKNOWN) new_expr = mOr( old_expr, mAnd( expr, SMTLib.SMT_EQ(sort.instances[index], SMTLib.SMT_IntConst(i)))) newInstances[(sort.parent, i)] = (new_expr, new_pol) return ExprArg(newInstances, nonsupered=True)
def op_intersection(left, right): ''' :param left: :type left: :class:`~ExprArg` :param right: :type right: :class:`~ExprArg` :returns: :class:`~ExprArg` Computes the set intersection (left & right) ''' assert isinstance(left, ExprArg) assert isinstance(right, ExprArg) if left.getInts() or right.getInts(): sys.exit("FIXME ints intersection") matches = getSetInstancePairs(left, right) newInstances = {} for (sort, index) in matches.keys(): key = (sort, index) ((lexpr, lpol), (rexpr, rpol)) = matches[(sort, index)] if rpol == Common.DEFINITELY_OFF or lpol == Common.DEFINITELY_OFF: continue else: new_expr = mAnd(lexpr, rexpr) newInstances[key] = (new_expr, Common.aggregate_polarity(lpol, rpol)) return ExprArg(newInstances)
def op_intersection(left,right): ''' :param left: :type left: :class:`~ExprArg` :param right: :type right: :class:`~ExprArg` :returns: :class:`~ExprArg` Computes the set intersection (left & right) ''' assert isinstance(left, ExprArg) assert isinstance(right, ExprArg) if left.getInts() or right.getInts(): sys.exit("FIXME ints intersection") matches = getSetInstancePairs(left,right) newInstances = {} for (sort,index) in matches.keys(): key = (sort,index) ((lexpr,lpol),(rexpr,rpol)) = matches[(sort,index)] if rpol == Common.DEFINITELY_OFF or lpol == Common.DEFINITELY_OFF: continue else: new_expr = mAnd(lexpr,rexpr) newInstances[key] = (new_expr, Common.aggregate_polarity(lpol, rpol)) return ExprArg(newInstances)
def addMatchValues(matches, instances, left=True): ''' Ignores PrimitiveSorts ''' for (sort, index) in instances.keys(): (expr,polarity) = instances[(sort,index)] #!!! default = (SMTLib.SMT_BoolConst(False), Common.DEFINITELY_OFF) (prev_left, prev_right) = matches.get((sort,index), (default,default)) if left: (prev_expr, prev_pol) = prev_left new_left = (mOr(expr, prev_expr), Common.aggregate_polarity(polarity, prev_pol)) new_right = prev_right else: (prev_expr, prev_pol) = prev_right new_left = prev_left new_right = (mOr(expr, prev_expr), Common.aggregate_polarity(polarity, prev_pol)) matches[(sort,index)] = (new_left,new_right) return matches
def addMatchValues(matches, instances, left=True): ''' Ignores PrimitiveSorts ''' for (sort, index) in instances.keys(): (expr, polarity) = instances[(sort, index)] #!!! default = (SMTLib.SMT_BoolConst(False), Common.DEFINITELY_OFF) (prev_left, prev_right) = matches.get((sort, index), (default, default)) if left: (prev_expr, prev_pol) = prev_left new_left = (mOr(expr, prev_expr), Common.aggregate_polarity(polarity, prev_pol)) new_right = prev_right else: (prev_expr, prev_pol) = prev_right new_left = prev_left new_right = (mOr(expr, prev_expr), Common.aggregate_polarity(polarity, prev_pol)) matches[(sort, index)] = (new_left, new_right) return matches
def getInstances(self, nonsupered=False): if nonsupered or self.hasBeenSupered: return self.clafers else: newClafers = {} for (sort, index) in self.clafers.keys(): (expr, polarity) = self.clafers[(sort,index)] if polarity == Common.DEFINITELY_OFF: continue key = (sort.highestSuperSort, sort.indexInHighestSuper + index) if polarity == Common.DEFINITELY_ON: newClafers[key] = (SMTLib.SMT_BoolConst(True), Common.DEFINITELY_ON) continue (currEntry, currPolarity) = newClafers.get(key, (SMTLib.SMT_BoolConst(False), Common.DEFINITELY_OFF)) currEntry = mOr(currEntry, expr) newClafers[key] = (currEntry, Common.aggregate_polarity(currPolarity, polarity)) self.clafers = newClafers self.hasBeenSupered = True return self.clafers
def getInstances(self, nonsupered=False): if nonsupered or self.hasBeenSupered: return self.clafers else: newClafers = {} for (sort, index) in self.clafers.keys(): (expr, polarity) = self.clafers[(sort, index)] if polarity == Common.DEFINITELY_OFF: continue key = (sort.highestSuperSort, sort.indexInHighestSuper + index) if polarity == Common.DEFINITELY_ON: newClafers[key] = (SMTLib.SMT_BoolConst(True), Common.DEFINITELY_ON) continue (currEntry, currPolarity) = newClafers.get( key, (SMTLib.SMT_BoolConst(False), Common.DEFINITELY_OFF)) currEntry = mOr(currEntry, expr) newClafers[key] = (currEntry, Common.aggregate_polarity( currPolarity, polarity)) self.clafers = newClafers self.hasBeenSupered = True return self.clafers