Existential quantifier elimination for a given set of variables.
@param variables the variables to eliminate
@return the BDD with the eliminated variables
491377
public BDD exists(final Collection<Variable> variables) {
    final BDD resBDD = this.factory.build(this.factory.getF().and(variables));
    return new BDD(this.factory.underlyingKernel().exists(index(), resBDD.index()), this.factory);
  }
134261
private Expr determineVariableAliases(GlobalEnvironment environment,
			Set<WyalFile.VariableDeclaration> freeVariables) {
		Expr aliases = null;
		for (WyalFile.VariableDeclaration var : freeVariables) {
			WyalFile.VariableDeclaration parent = environment.getParent(var);
			if (parent != null) {
				// This indicates a variable alias, so construct the necessary
				// equality.
				Expr.VariableAccess lhs = new Expr.VariableAccess(var);
				Expr.VariableAccess rhs = new Expr.VariableAccess(parent);
				Expr aliasEquality = new Expr.Equal(lhs, rhs);
				//
				aliases = and(aliases, aliasEquality);
			}
		}
		return aliases;
	}
286225
@Nonnull
  public EChange removeVariables (@Nullable final Iterable <String> aNames)
  {
    EChange eChange = EChange.UNCHANGED;
    if (aNames != null)
      for (final String sName : aNames)
        eChange = eChange.or (removeVariable (sName));
    return eChange;
  }

  /**
   * @return A mutable copy of all contained variables. Never <code>null</code>
   *         but maybe empty.
   */
  @Nonnull
  @ReturnsMutableCopy
  public ICommonsMap <String, ?> getAllVariables ()
  {
    return m_aMap.getClone ();
  }

  /**
   * @return The number of contained variables. Always &ge; 0.
   */
  @Nonnegative
  public int getVariableCount ()
  {
    return m_aMap.size ();
  }

  /**
   * Remove all variables at once.
   *
   * @return {@link EChange#CHANGED} if at least one variable was removed.
   */
  @Nonnull
  public EChange clear ()
  {
    return m_aMap.removeAll ();
  }

  /**
   * Set multiple variables at once.
   *
   * @param aVars
   *        The variables to be set. May be <code>null</code>.
   */
  public void setAllVariables (@Nullable final Map <String, ?> aVars)
  {
    m_aMap.setAll (aVars);
  }

  @Nullable
  public Object resolveVariable (@Nonnull final QName aVariableName)
  {
    ValueEnforcer.notNull (aVariableName, "VariableName");

    final String sLocalName = aVariableName.getLocalPart ();
    return m_aMap.get (sLocalName);
  }

  @Nonnull
  @ReturnsMutableCopy
  public MapBasedXPathVariableResolver getClone ()
  {
    return new MapBasedXPathVariableResolver (this);
  }

  @Override
  public boolean equals (final Object o)
  {
    if (o == this)
      return true;
    if (o == null || !getClass ().equals (o.getClass ()))
      return false;
    final MapBasedXPathVariableResolver rhs = (MapBasedXPathVariableResolver) o;
    return EqualsHelper.equals (m_aMap, rhs.m_aMap);
  }

  @Override
  public int hashCode ()
  {
    return new HashCodeGenerator (this).append (m_aMap).getHashCode ();
  }

  @Override
  public String toString ()
  {
    return new ToStringGenerator (this).append ("map", m_aMap).getToString ();
  }
}
821169
public final void removeVariables(Variable[] v) throws VariableNotFound, IllegalVariableRemoval {
		
		HashSet<Constraint> incidentRevised = new HashSet<Constraint>();

		//Keep track of solvers of dependent variables
		HashMap<ConstraintSolver,ArrayList<Variable>> solversToDepVars = new HashMap<ConstraintSolver, ArrayList<Variable>>();

		for (Variable var : v) {
			if (!this.theNetwork.containsVariable(var) ) throw new VariableNotFound(var);
			Constraint[] incident = this.theNetwork.getIncidentEdges(var);
			for (Constraint con : incident) {
				if ((!con.isAutoRemovable() && !(con instanceof DummyConstraint))) {
					throw new IllegalVariableRemoval(var, this.theNetwork.getIncidentEdges(var));
				}
				else if (con instanceof DummyConstraint) {
					Constraint toRemove = this.removeDummyConstraint((DummyConstraint)con);
					if (toRemove != null) incidentRevised.add(toRemove);
				}
				else incidentRevised.add(con);
			}
			
			//Gather solvers of dependent variables
			for (Variable depVar : var.getDependentVariables()) {
				if (!solversToDepVars.containsKey(depVar.getConstraintSolver())) {
					solversToDepVars.put(depVar.getConstraintSolver(), new ArrayList<Variable>());
				}
				solversToDepVars.get(depVar.getConstraintSolver()).add(depVar);
			}
		}
		
		//Remove dependent variables
		for (ConstraintSolver cs : solversToDepVars.keySet()) {
			cs.removeVariables(solversToDepVars.get(cs).toArray(new Variable[solversToDepVars.get(cs).size()]));
			logger.finest("Removed " + solversToDepVars.get(cs).size() + " dependent variables");
		}
		
		this.removeConstraints(incidentRevised.toArray(new Constraint[incidentRevised.size()]));

		removeVariablesSub(v);
		for (Variable var : v) {
			this.theNetwork.removeVariable(var);
		}
		for (ArrayList<Variable> vec : components.values()) {
			vec.removeAll(Arrays.asList(v));
		}
		if (!skipPropagation && autoprop && checkDomainsInstantiated()) this.propagate();
		logger.finest("Removed variables " + Arrays.toString(v));
		
	}
1346481
public FunctionConfigurationEnvironment withVariables(java.util.Map<String, String> variables) {
        setVariables(variables);
        return this;
    }
374763
public SortedSet<Literal> literals() {
    final SortedSet<Literal> literals = new TreeSet<>();
    for (final Formula f : this.formulas)
      literals.addAll(f.literals());
    return literals;
  }

  /**
   * Returns the variable profile of this formula list.  For each variable the number of occurrences is counted.
   * @return the variable profile of this formula list
   */
  public SortedMap<Variable, Integer> varProfile() {
    final VariableProfileFunction variableProfileFunction = new VariableProfileFunction();
    final SortedMap<Variable, Integer> profile = new TreeMap<>();
    for (final Formula f : this.formulas)
      for (final Map.Entry<Variable, Integer> entry : f.apply(variableProfileFunction).entrySet()) {
        final Integer currentCount = profile.get(entry.getKey());
        if (currentCount == null)
          profile.put(entry.getKey(), entry.getValue());
        else
          profile.put(entry.getKey(), entry.getValue() + currentCount);
      }
    return profile;
  }

  /**
   * Returns the literal profile of this formula list.  For each literal the number of occurrences is counted.
   * @return the literal profile of this formula list
   */
  public SortedMap<Literal, Integer> litProfile() {
    final LiteralProfileFunction literalProfileFunction = new LiteralProfileFunction();
    final SortedMap<Literal, Integer> profile = new TreeMap<>();
    for (final Formula f : this.formulas)
      for (final Map.Entry<Literal, Integer> entry : f.apply(literalProfileFunction).entrySet()) {
        final Integer currentCount = profile.get(entry.getKey());
        if (currentCount == null)
          profile.put(entry.getKey(), entry.getValue());
        else
          profile.put(entry.getKey(), entry.getValue() + currentCount);
      }
    return profile;
  }

  /**
   * Performs a given substitution on this formula list.
   * @param substitution the substitution
   * @return a new substituted formula
   */
  public ImmutableFormulaList substitute(final Substitution substitution) {
    final Formula[] subst = new Formula[this.formulas.length];
    for (int i = 0; i < this.formulas.length; i++)
      subst[i] = this.formulas[i].substitute(substitution);
    return new ImmutableFormulaList(this.operator, false, subst);
  }

  /**
   * Returns a copy of this formula list as array.
   * @return a copy of this formula list as array
   */
  public Formula[] toArray() {
    return Arrays.copyOf(this.formulas, this.formulas.length);
  }

  /**
   * Returns a copy of this formula list as list.
   * @return a copy of this formula list as list
   */
  public List<Formula> toList() {
    return Arrays.asList(this.formulas);
  }

  @Override
  public int hashCode() {
    return Objects.hash(this.operator, Arrays.hashCode(this.formulas));
  }

  @Override
  public boolean equals(final Object other) {
    return this == other || (other instanceof ImmutableFormulaList) && this.operator == ((ImmutableFormulaList) other).operator
            && Arrays.equals(this.formulas, ((ImmutableFormulaList) other).formulas);
  }

  @Override
  public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append(this.operator).append("[");
    for (int i = 0; i < this.formulas.length; i++) {
      sb.append(this.formulas[i]);
      if (i != this.formulas.length - 1)
        sb.append(", ");
    }
    sb.append("]");
    return sb.toString();
  }

  @Override
  public Iterator<Formula> iterator() {
    return new Iterator<Formula>() {
      private int i;

      @Override
      public boolean hasNext() {
        return this.i < ImmutableFormulaList.this.formulas.length;
      }

      @Override
      public Formula next() {
        if (this.i == ImmutableFormulaList.this.formulas.length)
          throw new NoSuchElementException();
        return ImmutableFormulaList.this.formulas[this.i++];
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException();
      }
    };
  }
}
61380
public int getID(Variable var) {
		Variable[] vars = this.getVariables();
		for (int i = 0; i < vars.length; i++) {
			if (vars[i].equals(var)) return i;
		}
		return -1;
	}
1167861
public static void setVariableWithSingleQuotationMarks(final String variablename,
		final Object object, final Map<String, Object> variables)
	{
		if (object != null)
		{
			variables.put(variablename, "'" + object + "'");
		}
		else
		{
			variables.put(variablename, "null");
		}
	}
1362962
public DynamicVariableSet addFixedVariables(VariableNumMap variables) {
    Preconditions.checkArgument(!fixedVariables.containsAny(variables));

    return new DynamicVariableSet(fixedVariables.union(variables), plateNames, plates,
        maximumReplications);
  }
687927
private String getPartition(Set<String> variables) {
    String key = buildKey(variables);
    return partitionIds.computeIfAbsent(key, k -> Character.toString((char)(BASE_ID + idSequence++)));
  }
222740
public static Variable[] getVariables(NameSpace ns, String[] names) {
        if (null == ns || null == names)
            return new Variable[0];
        return Stream.of(names).map(name->getVariable(ns, name))
            .filter(Objects::nonNull).toArray(Variable[]::new);
    }
828713
@SuppressWarnings("unchecked")
  public <T extends TypedValue> T getVariableTyped(String variableName) {
    TypedValue variable = associationManager.getVariable(variableName);
    return variable != null ? (T) (variable) : null;
  }
157497
private boolean makeComplete( TestCaseDef testCase, VarTupleSet tuples, List<VarDef> vars)
    {
    boolean complete;

    // Test case still missing a required property?
    if( testCase.isSatisfied())
      {
      // No, complete bindings for remaining variables
      complete = completeSatisfied( testCase, tuples, vars);
      }
    else
      {
      // Yes, find tuples that contain satisfying bindings.
      int prevBindings = testCase.getBindingCount();
      Iterator<Tuple> satisfyingTuples = getSatisfyingTuples( testCase, tuples);
      for( complete = false;

           satisfyingTuples.hasNext()
             && !(
               // Does this tuple lead to satisfaction of all current test case conditions?
               makeSatisfied( testCase, tuples, satisfyingTuples.next())

               // Can we complete bindings for remaining variables?
               && (complete = completeSatisfied( testCase, tuples, vars)));

           // No, try next tuple
           testCase.revertBindings( prevBindings));
      }

    return complete;
    }
924278
private static String buildKey(Set<String> variables) {
    return variables.stream().sorted().collect(Collectors.joining(", "));
  }
965648
public Map<String, Variable> getDeclaredVariables() {
        if (declaredVariables == Collections.EMPTY_MAP) {
            return declaredVariables;
        } else {
            return Collections.unmodifiableMap(declaredVariables);
        }
    }
386406
private Stack<Integer> createInitialCandidates(final List<Integer> variables) {
        for (final Integer var : variables) {
            if (isUPZeroLit(var)) {
                final int backboneLit = mkLit(var, !this.model.get(var));
                addBackboneLiteral(backboneLit);
            } else {
                final boolean modelPhase = this.model.get(var);
                if (isBothOrNegativeType() && !modelPhase || isBothOrPositiveType() && modelPhase) {
                    final int lit = mkLit(var, !modelPhase);
                    if (!this.config.isInitialUBCheckForRotatableLiterals() || !isRotatable(lit)) {
                        this.candidates.add(lit);
                    }
                }
            }
        }
        return this.candidates;
    }
694377
public <T extends Variable> T lookupVariable(String token) {
        Variable result = variables.get(token);
        return (T)result;
    }