def assertConstraint(self, constraint, cfr): if Common.FLAG: SMTLib.toStr(constraint) if Options.PRODUCE_UNSAT_CORE: p = cfr.solver.convert(SMTLib.SMT_Bool("bool" + str(Common.getConstraintUID()) + "_" + str(self.assertID))) cfr.unsat_core_trackers.append(p) cfr.low_level_unsat_core_trackers[str(p)] = constraint cfr.unsat_map[str(p)] = self cfr.solver.add(SMTLib.SMT_Implies(p, constraint, unsat_core_implies=True)) else: cfr.solver.add(constraint)
def declpexpVisit(self, element): if Options.BREAK_QUANTIFIER_SYMMETRY: #TODO actually do this... sys.exit("BREAK_QUANTIFIER_SYMMETRY still unimplemented.") symmetryChecker = CheckFunctionSymmetry(self.cfr) visitors.Visitor.visit(symmetryChecker, element.bodyParentExp) isSymmetric = symmetryChecker.isSymmetric # print(symmetryChecker.isSymmetric) else: isSymmetric = False num_args = 0 if element.declaration: visitors.Visitor.visit(self, element.declaration.body.iExp[0]) if not self.currentConstraint.stack: return arg = self.currentConstraint.stack.pop() isDisjunct = element.declaration.isDisjunct for i in range(len(arg)): (combinations, ifconstraints) = self.createAllLocalsCombinations( element.declaration.localDeclarations, arg[i], isDisjunct, isSymmetric) if len(combinations) == 0: if element.quantifier == "Some": self.currentConstraint.stack.append( [BoolArg(SMTLib.SMT_Bool(False))]) elif element.quantifier == "All": self.currentConstraint.stack.append( [BoolArg(SMTLib.SMT_Bool(True))]) return num_args = len(combinations[0]) num_combinations = len(combinations) for i in combinations: for j in range(num_args): self.currentConstraint.addLocal( element.declaration.localDeclarations[j].element, [i[j]]) visitors.Visitor.visit(self, element.bodyParentExp) self.currentConstraint.addQuantifier(element.quantifier, num_args, num_combinations, ifconstraints) exprArgList = [] for i in range(len(arg)): exprArgList.insert(0, self.currentConstraint.stack.pop()[0]) self.currentConstraint.addArg(exprArgList) else: visitors.Visitor.visit(self, element.bodyParentExp) num_args = 1 num_combinations = 1 ifconstraints = [] exprList = self.currentConstraint.stack.pop() exprArgList = [] for i in exprList: self.currentConstraint.stack.append([i]) self.currentConstraint.addQuantifier(element.quantifier, num_args, num_combinations, ifconstraints) exprArgList.append(self.currentConstraint.stack.pop()[0]) self.currentConstraint.addArg(exprArgList)