Computes a MUS for the given propositions with the default algorithm and the default configuration.
@param propositions the propositions
@param f            the formula factory
@param <T>          the type of the MUSes propositions
@return the MUS
171815
public <T extends Proposition> UNSATCore<T> computeMUS(final List<T> propositions, final FormulaFactory f) {
    return this.computeMUS(propositions, f, new MUSConfig.Builder().build());
  }
1213551
public static MiniSat glucose(final FormulaFactory f) {
    return new MiniSat(f, SolverStyle.GLUCOSE, new MiniSatConfig.Builder().build(), new GlucoseConfig.Builder().build());
  }
409705
public static List<Formula> readCNF(final File file, final FormulaFactory f) throws IOException {
    return readCNF(file, f, "v");
  }
1185022
public boolean sameFeature(JFeature f){
		return this.name.equals(f.name) && this.type.equals(f.type);
	}
991003
@Override
	public <NK, NV> FMap<NK, NV> map(BiFunction<? super K, ? super V, Product2<? extends NK, ? extends NV>> f) {
		HashFMap<NK, NV> ret = new HashFMap<>(new HashMap<>(this.size()));
		for (java.util.Map.Entry<K, V> entry : entrySet()) {
			Product2<? extends NK,? extends NV> t = f.apply(entry.getKey(), entry.getValue());
			ret.put(t.get1(), t.get2());
		}
		return ret;
	}
585920
public MutableFst compute(final Fst fst) {
    fst.throwIfInvalid();

    // init for this run of compute
    this.semiring = fst.getSemiring();
    this.gallicSemiring = new GallicSemiring(this.semiring, this.gallicMode);
    this.unionSemiring = makeUnionRing(semiring, gallicSemiring, mode);
    this.inputFst = fst;
    this.outputFst = MutableFst.emptyWithCopyOfSymbols(fst);

    this.outputStateIdToTuple = HashBiMap.create();
    // workQueue holds the pending work of determinizing the input fst
    Deque<DetStateTuple> workQueue = new LinkedList<>();
    // finalQueue holds the pending work of expanding out the final paths (handled by the FactorFst in the
    // open fst implementation)
    Deque<DetElement> finalQueue = new LinkedList<>();

    // start the algorithm by starting with the input start state
    MutableState initialOutState = outputFst.newStartState();
    DetElement initialElement = new DetElement(fst.getStartState().getId(),
      GallicWeight.createEmptyLabels(semiring.one()));
    DetStateTuple initialTuple = new DetStateTuple(initialElement);
    workQueue.addLast(initialTuple);
    this.outputStateIdToTuple.put(initialOutState.getId(), initialTuple);

    // process all of the input states via the work queue
    while (!workQueue.isEmpty()) {
      DetStateTuple entry = workQueue.removeFirst();
      MutableState outStateForTuple = getOutputStateForStateTuple(entry);

      Collection<DetArcWork> arcWorks = groupByInputLabel(entry);
      arcWorks.forEach(this::normalizeArcWork);

      for (DetArcWork arcWork : arcWorks) {
        DetStateTuple targetTuple = new DetStateTuple(arcWork.pendingElements);
        if (!this.outputStateIdToTuple.inverse().containsKey(targetTuple)) {
          // we've never seen this tuple before so new state + enqueue the work
          MutableState newOutState = outputFst.newState();
          this.outputStateIdToTuple.put(newOutState.getId(), targetTuple);
          newOutState.setFinalWeight(computeFinalWeight(newOutState.getId(), targetTuple, finalQueue));
          workQueue.addLast(targetTuple);
        }
        MutableState targetOutState = getOutputStateForStateTuple(targetTuple);
        // the computed divisor is a 'legal' arc meaning that it only has zero or one substring; though there
        // might be multiple entries if we're in non_functional mode
        UnionWeight<GallicWeight> unionWeight = arcWork.computedDivisor;
        for (GallicWeight gallicWeight : unionWeight.getWeights()) {
          Preconditions.checkState(gallicSemiring.isNotZero(gallicWeight), "gallic weight zero computed from group by",
            gallicWeight);
          int oLabel = this.outputEps;
          if (!gallicWeight.getLabels().isEmpty()) {
            Preconditions.checkState(gallicWeight.getLabels().size() == 1,
              "cant gave gallic arc weight with more than a single symbol", gallicWeight);
            oLabel = gallicWeight.getLabels().get(0);
          }
          outputFst.addArc(outStateForTuple, arcWork.inputLabel, oLabel, targetOutState, gallicWeight.getWeight());
        }
      }
    }

    // we might've deferred some final state work that needs to be expanded
    expandDeferredFinalStates(finalQueue);
    return outputFst;
  }
137843
private Formula distribute(final Formula f1, final Formula f2) {
    if (this.handler != null)
      this.proceed = this.handler.performedDistribution();
    if (this.proceed) {
      final FormulaFactory f = f1.factory();
      if (f1.type() == FType.OR || f2.type() == FType.OR) {
        final LinkedHashSet<Formula> nops = new LinkedHashSet<>();
        for (final Formula op : f1.type() == FType.OR ? f1 : f2) {
          final Formula distribute = this.distribute(op, f1.type() == FType.OR ? f2 : f1);
          if (!this.proceed)
            return null;
          nops.add(distribute);
        }
        return f.or(nops);
      }
      final Formula clause = f.and(f1, f2);
      if (this.handler != null)
        proceed = this.handler.createdClause(clause);
      return clause;
    }
    return null;
  }
81531
public static <T0, R> FuncN<R> fromFunc(final Func1<? super T0, ? extends R> f) {
        return new FuncN<R>() {

            @SuppressWarnings("unchecked")
            @Override
            public R call(Object... args) {
                if (args.length != 1) {
                    throw new RuntimeException("Func1 expecting 1 argument.");
                }
                return f.call((T0) args[0]);
            }

        };
    }
943403
public static void fe_mul121666(int[] h,int[] f)
{
  int f0 = f[0];
  int f1 = f[1];
  int f2 = f[2];
  int f3 = f[3];
  int f4 = f[4];
  int f5 = f[5];
  int f6 = f[6];
  int f7 = f[7];
  int f8 = f[8];
  int f9 = f[9];
  long h0 = f0 * (long) 121666;
  long h1 = f1 * (long) 121666;
  long h2 = f2 * (long) 121666;
  long h3 = f3 * (long) 121666;
  long h4 = f4 * (long) 121666;
  long h5 = f5 * (long) 121666;
  long h6 = f6 * (long) 121666;
  long h7 = f7 * (long) 121666;
  long h8 = f8 * (long) 121666;
  long h9 = f9 * (long) 121666;
  long carry0;
  long carry1;
  long carry2;
  long carry3;
  long carry4;
  long carry5;
  long carry6;
  long carry7;
  long carry8;
  long carry9;

  carry9 = (h9 + (long) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
  carry1 = (h1 + (long) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
  carry3 = (h3 + (long) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
  carry5 = (h5 + (long) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
  carry7 = (h7 + (long) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;

  carry0 = (h0 + (long) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
  carry2 = (h2 + (long) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
  carry4 = (h4 + (long) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
  carry6 = (h6 + (long) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
  carry8 = (h8 + (long) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;

  h[0] = (int)h0;
  h[1] = (int)h1;
  h[2] = (int)h2;
  h[3] = (int)h3;
  h[4] = (int)h4;
  h[5] = (int)h5;
  h[6] = (int)h6;
  h[7] = (int)h7;
  h[8] = (int)h8;
  h[9] = (int)h9;
}
52858
private List<Map.Entry<Sentence, Map.Entry<Integer, Integer>>> getRelevantSentences(List<String> inputs, String token, int maxSentences) throws IOException {
    List<Map.Entry<Sentence, Map.Entry<Integer, Integer>>> sentences = new ArrayList<>();
    for (String input : inputs) {
      if (new File(input).isDirectory()) {
        File file = new File(input, token + ".txt");
        if (!file.exists()) {
          throw new RuntimeException("File with example sentences not found: " + file);
        }
        try (FileInputStream fis = new FileInputStream(file)) {
          SentenceSource sentenceSource = new PlainTextSentenceSource(fis, language);
          sentences = getSentencesFromSource(inputs, token, maxSentences, sentenceSource);
        }
      } else {
        SentenceSource sentenceSource = MixingSentenceSource.create(inputs, language);
        sentences = getSentencesFromSource(inputs, token, maxSentences, sentenceSource);
      }
    }
    return sentences;
  }
336100
public void addClause(final Literal... literals) {
    if (this.miniSat == null && this.cleaneLing == null)
      this.result.add(this.f.clause(literals));
    else if (this.miniSat != null) {
      final LNGIntVector clauseVec = new LNGIntVector(literals.length);
      for (final Literal lit : literals) {
        int index = this.miniSat.underlyingSolver().idxForName(lit.name());
        if (index == -1) {
          index = this.miniSat.underlyingSolver().newVar(!this.miniSat.initialPhase(), true);
          this.miniSat.underlyingSolver().addName(lit.name(), index);
        }
        final int litNum;
        if (lit instanceof EncodingAuxiliaryVariable)
          litNum = !((EncodingAuxiliaryVariable) lit).negated ? index * 2 : (index * 2) ^ 1;
        else
          litNum = lit.phase() ? index * 2 : (index * 2) ^ 1;
        clauseVec.push(litNum);
      }
      this.miniSat.underlyingSolver().addClause(clauseVec, null);
      this.miniSat.setSolverToUndef();
    } else {
      for (final Literal lit : literals) {
        final int index = this.cleaneLing.getOrCreateVarIndex(lit.variable());
        if (lit instanceof EncodingAuxiliaryVariable)
          this.cleaneLing.underlyingSolver().addlit(!((EncodingAuxiliaryVariable) lit).negated ? index : -index);
        else
          this.cleaneLing.underlyingSolver().addlit(lit.phase() ? index : -index);
      }
      this.cleaneLing.underlyingSolver().addlit(CleaneLing.CLAUSE_TERMINATOR);
      this.cleaneLing.setSolverToUndef();
    }
  }
892031
protected static double calcP_i(double f, double mu, double sigma) {
    final double fmu = f - mu;
    return ONEBYSQRT2PI / sigma * FastMath.exp(fmu * fmu / (-2 * sigma * sigma));
  }
215900
public static MiniSat miniSat(final FormulaFactory f) {
    return new MiniSat(f, SolverStyle.MINISAT, new MiniSatConfig.Builder().build(), null);
  }
607561
@Override
    public ImmutableSubstitution<ImmutableTerm> composeWith(ImmutableSubstitution<? extends ImmutableTerm> f) {
        if (isEmpty()) {
            return (ImmutableSubstitution<ImmutableTerm>)f;
        }
        if (f.isEmpty()) {
            return (ImmutableSubstitution<ImmutableTerm>)this;
        }

        Map<Variable, ImmutableTerm> substitutionMap = new HashMap<>();

        /**
         * For all variables in the domain of f
         */

        for (Map.Entry<Variable, ? extends ImmutableTerm> gEntry :  f.getImmutableMap().entrySet()) {
            substitutionMap.put(gEntry.getKey(), apply(gEntry.getValue()));
        }

        /**
         * For the other variables (in the local domain but not in f)
         */
        for (Map.Entry<Variable, ? extends ImmutableTerm> localEntry :  getImmutableMap().entrySet()) {
            Variable localVariable = localEntry.getKey();

            if (substitutionMap.containsKey(localVariable))
                continue;

            substitutionMap.put(localVariable, localEntry.getValue());
        }

        return substitutionFactory.getSubstitution(
                substitutionMap.entrySet().stream()
                        // Clean out entries like t/t
                        .filter(entry -> !entry.getKey().equals(entry.getValue()))
                        .collect(ImmutableCollectors.toMap()));
    }
827292
public static List<DiscreteFactor> coerceToDiscrete(Collection<Factor> factors) {
    List<DiscreteFactor> returnFactors = Lists.newArrayList();
    for (Factor factor : factors) {
      returnFactors.add(factor.coerceToDiscrete());
    }
    return returnFactors;
  }
794775
public static MiniSat glucose(final FormulaFactory f, final MiniSatConfig miniSatConfig,
                                final GlucoseConfig glucoseConfig) {
    return new MiniSat(f, SolverStyle.GLUCOSE, miniSatConfig, glucoseConfig);
  }
558321
private Formula vec2clause(final LNGVector<Literal> literals) {
    final List<Literal> lits = new ArrayList<>(literals.size());
    for (final Literal l : literals)
      lits.add(l);
    return this.f.clause(lits);
  }