Create a multiple set bind with a varargs list of pattern variables, like a,b,c in set S. This is used by several
obligations.
325726
protected PMultipleBind getMultipleSetBind(PExp setExp,
			ILexNameToken... patternNames)
	{
		ASetMultipleBind setBind = new ASetMultipleBind();
		List<PPattern> patternList = new Vector<PPattern>();

		for (ILexNameToken patternName : patternNames)
		{
			AIdentifierPattern pattern = new AIdentifierPattern();
			pattern.setName(patternName.clone());
			patternList.add(pattern);
		}

		setBind.setPlist(patternList);
		setBind.setSet(setExp.clone());

		return setBind;
	}
634073
def context_binding(variables)
      context = TemplateEvaluationContext.new

      helpers.each { |helper| context.extend(helper) }

      variables.each do |k, v|
        context.instance_variable_set("@#{k}", v)
      end

      context.__get_binding
    end
1349922
def _set_variables(self, cacheable):
        """"""
        # pull the parameters and inputs out of the symbolic pdf
        def extract_vars(expr):
            return [e for e in expr.atoms() if e.is_Symbol and e not in vars]
        self.cacheable = cacheable
        self.variables = {}
        vars = []
        for expression in self.expressions.values():
            vars += extract_vars(expression['function'])
        # inputs are assumed to be those things that are
        # cacheable. I.e. those things that aren't stored within the
        # object except as cached. For covariance functions this is X
        # and Z, for likelihoods F and for mapping functions X.
        self.cacheable_vars = [] # list of everything that's cacheable
        for var in cacheable:            
            self.variables[var] = [e for e in vars if e.name.split('_')[0]==var.lower()]
            self.cacheable_vars += self.variables[var]
        for var in cacheable:
            if not self.variables[var]:
                raise ValueError('Variable ' + var + ' was specified as cacheable but is not in expression. Expected to find symbols of the form ' + var.lower() + '_0 to represent ' + var)

        # things that aren't cacheable are assumed to be parameters.
        self.variables['theta'] = sorted([e for e in vars if not e in self.cacheable_vars],key=lambda e:e.name)
1029210
public TupleRefBuilder bindings( Stream<VarBinding> bindings)
    {
    bindings.forEach( binding -> tupleRef_.addVarBinding( binding));
    return this;
    }
743260
def bind!(args = {})
      path_var_values   = args[:path]    || {}
      query_var_values  = args[:query]   || {}
      header_var_values = args[:headers] || {}

      @auth.each { |header, value| header_var_values[header] = value }.clear

      # Bind variables found in the path fragments.
      path_params_to_delete = []

      path_fragments.each { |fragment|
        if fragment.respond_to?(:to_str)
          # This fragment is a string which might contain {} substitutions.
          # Make any substitutions available to the provided path variables.
          self.class.embedded_param_names(fragment).each { |name|
            value = path_var_values[name] || path_var_values[name.to_sym]

            value = if param = path_params[name]
              path_params_to_delete << param
              param % value
            else
              Param.default.format(value, name)
            end

            fragment.gsub!("{#{name}}", value)
          }
        else
          # This fragment is an array of Param objects (style 'matrix'
          # or 'plain') which may be bound to strings. As substitutions
          # happen, the array will become a mixed array of Param objects
          # and strings.
          fragment.each_with_index { |param, i|
            next unless param.respond_to?(:name)

            name = param.name

            value = path_var_values[name] || path_var_values[name.to_sym]
            value = param % value
            fragment[i] = value if value

            path_params_to_delete << param
          }
        end
      }

      # Delete any embedded path parameters that are now bound from
      # our list of unbound parameters.
      path_params_to_delete.each { |p| path_params.delete(p.name) }

      # Bind query variable values to query parameters
      query_var_values.each { |name, value|
        param = query_params.delete(name.to_s)
        query_vars << param % value if param
      }

      # Bind header variables to header parameters
      header_var_values.each { |name, value|
        if param = header_params.delete(name.to_s)
          headers[name] = param % value
        else
          warn %Q{Ignoring unknown header parameter "#{name}"!}
        end
      }

      self
    end
1227112
def _rebind_variables(self, new_inputs):
        
        expr = self._expr

        # If we have 11+ variables, some of our variable names may be
        # substrings of other variable names. For example, we might have x_1,
        # x_10, and x_100. By enumerating in reverse order, we ensure that
        # every variable name which is a substring of another variable name is
        # processed after the variable of which it is a substring. This
        # guarantees that the substitution of any given variable index only
        # ever affects exactly its own index. For example, if we have variables
        # with indices going up to 100, we will process all of the x_1xx names
        # before x_1x, which will be before x_1, so the substitution of x_1
        # will not affect x_1x, which will not affect x_1xx.
        for idx, input_ in reversed(list(enumerate(self.inputs))):
            old_varname = "x_%d" % idx
            # Temporarily rebind to x_temp_N so that we don't overwrite the
            # same value multiple times.
            temp_new_varname = "x_temp_%d" % new_inputs.index(input_)
            expr = expr.replace(old_varname, temp_new_varname)
        # Clear out the temp variables now that we've finished iteration.
        return expr.replace("_temp_", "_")
27674
private Collection<Tuple> getCombinedTuples( List<VarDef> combinedVars, Collection<Tuple> tuples)
    {
    // Apply any once-only constraints.
    Set<Tuple> onceTuples = getOnceTupleDefs( combinedVars);
    if( !onceTuples.isEmpty())
      {
      for( Tuple tuple : tuples)
        {
        tuple.setOnce( onceTuples.contains( tuple));
        }
      }
    
    return tuples;
    }
50646
public TupleCombinerBuilder include( Stream<String> varNamePatterns)
    {
    varNamePatterns.forEach( varNamePattern -> tupleCombiner_.addIncludedVar( varNamePattern));
    return this;
    }
1090790
public Bindings bind(FunctionMapper fnMapper, VariableMapper varMapper) {
		return bind(fnMapper, varMapper, null);
	}
1153796
def _apply_to_sets(self, func, operation, keys, *args):
        """"""
        keys = self._list_or_args(keys, args)
        if not keys:
            raise TypeError("{} takes at least two arguments".format(operation.lower()))
        left = self._get_set(keys[0], operation) or set()
        for key in keys[1:]:
            right = self._get_set(key, operation) or set()
            left = func(left, right)
        return left
155010
public VarSetBuilder varSetAtPath( String[] path)
    {
    VarSet varSet = null;
    if( path != null && path.length > 0)
      {
      varSet = new VarSet( path[0]);
      functionInputDef_.addVarDef( varSet);

      for( int i = 1; i < path.length; i++)
        {
        VarSet child = new VarSet( path[i]);
        varSet.addMember( child);
        varSet = child;
        }
      }

    return
      varSet == null
      ? null
      : new VarSetBuilder( varSet);
    }
1270862
public void setComponent(String component, Variable ... vars) {
		for (Variable var : vars) {
			if (var.getComponent() != null && !var.getComponent().equals(component)) {
				components.get(var.getComponent()).remove(var);
			}
		}
		if (!components.containsKey(component)) components.put(component, new ArrayList<Variable>());
		for (Variable var : vars) components.get(component).add(var);
	}

	/**
	 * Create a batch of new {@link Variable}s for this {@link ConstraintSolver}.
	 * @param num The number of variables to create.
	 * @return A batch of new {@link Variable}s.
	 */
	public final Variable[] createVariables(int num) {
		return this.createVariables(num, null);
	}

	/**
	 * Create a batch of new {@link Variable}s for this {@link ConstraintSolver}.
	 * @param num The number of variables to create.
	 * @param component The component tag to associate to these new variables.
	 * @return A batch of new {@link Variable}s.
	 */
	public final Variable[] createVariables(int num, String component) {
		Variable[] ret = createVariablesSub(num, component);
		if (ret == null) return null;
		//need to add all to network so if sth goes wrong I can delete all of them concurrently
		for (Variable v : ret) this.theNetwork.addVariable(v);
		if (!skipPropagation && autoprop && checkDomainsInstantiated() && !noPropOnVarCreation) this.propagate();
		logger.finest("Created variables " + Arrays.toString(ret));
		return ret;
	}
90585
public static Variable lookup(String varName, BindingSet bindingSet) {
        if (bindingSet == null) {
            return null;
        }
        Binding binding = bindingSet.lookup(varName);
        return (binding != null) ? binding.getVariable() : null;
    }
9064
public TupleRefBuilder bindings( VarBinding... bindings)
    {
    for( VarBinding binding : bindings)
      {
      tupleRef_.addVarBinding( binding);
      }
    return this;
    }
427654
public VarSetBuilder varSetAtPath( String[] path)
    {
    VarSet varSet = null;
    if( path != null && path.length > 0)
      {
      varSet = new VarSet( path[0]);
      varSet_.addMember( varSet);

      for( int i = 1; i < path.length; i++)
        {
        VarSet child = new VarSet( path[i]);
        varSet.addMember( child);
        varSet = child;
        }
      }

    return
      varSet == null
      ? null
      : new VarSetBuilder( varSet);
    }
65030
public static Collection<Tuple> getTuples( List<VarDef> varDefs, int tupleSize)
    {
    if( tupleSize < 1)
      {
      tupleSize = varDefs.size();
      }
    int varEnd = varDefs.size() - tupleSize + 1;
    if( varEnd <= 0)
      {
      throw new IllegalArgumentException( "Can't create " + tupleSize + "-tuples for " + varDefs.size() + " combined variables");
      }
    return getTuples( varDefs, 0, varEnd, tupleSize);
    }
572324
@Override
	public Map<RuleSet, List<Rule>> matching(Rules rules,
	                                         Map<String, Object> vars,
	                                         boolean ignoreMethodErrors) throws OgnlException
	{
		Map<RuleSet, List<Rule>> ret = new HashMap<>();

		for (RuleSet ruleSet : rules.ruleSets)
		{
			try
			{
				OgnlContext context = createContext(vars);

				List<Rule> matching = match(ruleSet, context);

				if (!matching.isEmpty())
				{
					ret.put(ruleSet, matching);
				}
			}
			catch (MethodFailedException mfe)
			{

				if (!ignoreMethodErrors)
				{
					throw mfe;
				}

				log.warn("Method failed for ruleset " + ruleSet.id, mfe);
			}
		}

		return ret;
	}