List of usage examples for com.google.common.collect Constraint toString
@Override String toString();
From source file:org.sosy_lab.cpachecker.cpa.chc.ConstraintManager.java
public static Constraint and(Constraint cn1, Constraint cn2) { ArrayList<Term> andCn = new ArrayList<>(cn1.getConstraint()); andCn.addAll(cn2.getConstraint());/*w w w. j a v a 2 s . c o m*/ logger.log(Level.FINEST, "\n * " + cn1.toString() + "\n * and \n * " + cn2.toString()); /* * create a list of variable to solve the constraint * Remove all non primed variables which occur in * the set of primed variables */ HashMap<String, Term> newVars = ConstraintManager.selectVariables(cn1.getVars(), cn2.getVars()); Constraint andConstraint = ConstraintManager.simplify(andCn, newVars); logger.log(Level.FINEST, "\n * " + andConstraint.toString()); return andConstraint; }
From source file:org.sosy_lab.cpachecker.cpa.chc.ConstraintManager.java
public static boolean subsumes(Constraint cn1, Constraint cn2) { // Constraint 1 Term constraint1 = Util.termArrayToList(cn1.getConstraint().toArray(new Term[0])); // Constraint 2 Term constraint2 = Util.termArrayToList(cn2.getConstraint().toArray(new Term[0])); Term args[] = { constraint1, constraint2 }; Query q = new Query("entails", args); logger.log(Level.FINEST, "\n * " + cn1.toString() + "\n * entails" + "\n * " + cn2.toString() + ")"); boolean res = q.hasSolution(); logger.log(Level.FINEST, "\n * result: " + res); return res;// w ww. ja v a 2 s. c om }
From source file:org.sosy_lab.cpachecker.cpa.chc.ConstraintManager.java
@SuppressWarnings("unchecked") public static Constraint generalize(Constraint cn1, Constraint cn2) { // Constraint 1 Term constraint1 = Util.termArrayToList(cn1.getConstraint().toArray(new Term[0])); // Constraint 2 Term constraint2 = Util.termArrayToList(cn2.getConstraint().toArray(new Term[0])); Term args[] = { constraint1, constraint2, new Variable("G") }; Query q = new Query("generalize", args); logger.log(Level.FINEST, "\n * definition: " + cn1.toString() + "\n * ancestor : " + cn1.toString()); return normalize("G", q.oneSolution()); }
From source file:org.sosy_lab.cpachecker.cpa.chc.ConstraintManager.java
private static Constraint normalize(String sol, Hashtable<String, Term> varMap) { // fetches the solution Term cn = varMap.get(sol);/*w w w .j a va 2 s . c o m*/ String newConstraint = cn.toString(); Constraint nres = new Constraint(); if (Constraint.isFalse(newConstraint)) { return nres.setFalse(); } Hashtable<String, Term> varSolMap = new Hashtable<>(varMap); varSolMap.remove(sol); /* * replace all occurrences of primed variables * by their corresponding unprimed version */ for (Map.Entry<String, Term> me : varSolMap.entrySet()) { newConstraint = newConstraint.replaceAll(me.getValue().toString(), ConstraintManager.primedVarToVar(me.getKey())); nres.addVar(var2CVar(ConstraintManager.primedVarToVar(me.getKey())), new Variable(primedVarToVar(me.getKey()))); } // TODO: to be improved nres.setConstraint(new ArrayList<>(Arrays.asList(Util.listToTermArray(Util.textToTerm(newConstraint))))); logger.log(Level.FINEST, "\n * result: " + nres.toString()); return nres; }