Computes the complete backbone for a given formula.
@param formula the given formula
@return the backbone or {@code null} if the formula is UNSAT
359797
public static Backbone compute(final Formula formula) {
        return compute(formula, formula.variables(), BackboneType.POSITIVE_AND_NEGATIVE);
    }
1286827
public static int getElementCount(IMolecularFormula formula, String symbol) {
        return getElementCount(formula, formula.getBuilder().newInstance(IElement.class, symbol));
    }
265273
public static Backbone computePositive(final Collection<Formula> formulas) {
        return compute(formulas, allVariablesInFormulas(formulas), BackboneType.ONLY_POSITIVE);
    }
1041566
def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'r'
          @formula_run << MathRun.new(parent: self).parse(node_child)
        when 'box', 'borderBox'
          @formula_run << Box.new(parent: self).parse(node_child)
        when 'func'
          @formula_run << Function.new(parent: self).parse(node_child)
        when 'rad'
          @formula_run << Radical.new(parent: self).parse(node_child)
        when 'e', 'eqArr'
          @formula_run << DocxFormula.new(parent: self).parse(node_child)
        when 'nary'
          @formula_run << Nary.new(parent: self).parse(node_child)
        when 'd'
          @formula_run << Delimiter.new(parent: self).parse(node_child)
        when 'sSubSup', 'sSup', 'sSub'
          @formula_run << Index.new(parent: self).parse(node_child)
        when 'f'
          @formula_run << Fraction.new(parent: self).parse(node_child)
        when 'm'
          @formula_run << Matrix.new(parent: self).parse(node_child)
        when 'bar'
          @formula_run << Bar.new(parent: self).parse(node_child)
        when 'acc'
          @formula_run << Accent.new(parent: self).parse(node_child)
        when 'groupChr'
          @formula_run << GroupChar.new(parent: self).parse(node_child)
        when 'argPr'
          @argument_properties = ArgumentProperties.new(parent: self).parse(node_child)
        when 'sPre'
          @formula_run << PreSubSuperscript.new(parent: self).parse(node_child)
        when 'limUpp', 'limLow'
          @formula_run << Limit.new(parent: self).parse(node_child)
        end
      end
      return nil if @formula_run.empty?

      self
    end
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;
  }
1135250
public function calculateFormula($formula)
    {
        //check whether worksheet name is set or not
        if ($this->worksheetName == '')
            throw new Exception('Worksheet name not specified');
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
            '/worksheets/' . $this->worksheetName . '/formulaResult?formula=' . $formula;
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        return $json->Value->Value;

    }
1315865
private IMolecularFormula putInOrder(IMolecularFormula formula) {
        IMolecularFormula new_formula = formula.getBuilder().newInstance(IMolecularFormula.class);
        for (int i = 0; i < orderElements.length; i++) {
            IElement element = builder.newInstance(IElement.class, orderElements[i]);
            if (MolecularFormulaManipulator.containsElement(formula, element)) {
                Iterator<IIsotope> isotopes = MolecularFormulaManipulator.getIsotopes(formula, element).iterator();
                while (isotopes.hasNext()) {
                    IIsotope isotope = isotopes.next();
                    new_formula.addIsotope(isotope, formula.getIsotopeCount(isotope));
                }
            }
        }
        //		new_mf.setCharge(charge);
        return new_formula;
    }
940975
public static String getCellValue(Cell c) {
        String o;
        switch (c.getCellTypeEnum()) {
            case BLANK:
                o = "";
                break;
            case BOOLEAN:
                o = String.valueOf(c.getBooleanCellValue());
                break;
            case FORMULA:
                o = calculationFormula(c);
                break;
            case NUMERIC:
                if (DateUtil.isCellDateFormatted(c)) {
                    o = DateUtils.date2Str(c.getDateCellValue());
                } else {
                    o = String.valueOf(c.getNumericCellValue());
                    o = matchDoneBigDecimal(o);
                    o = RegularUtils.converNumByReg(o);
                }
                break;
            case STRING:
                o = c.getStringCellValue();
                break;
            default:
                o = null;
                break;
        }
        return o;
    }
756518
def append_formula(self, formula, no_return=True):
        

        if self.maplesat:
            res = None
            for clause in formula:
                res = self.add_clause(clause, no_return)

            if not no_return:
                return res
475464
public Formula encode(final Formula formula) {
    switch (this.config().algorithm) {
      case FACTORIZATION:
        if (this.factorization == null)
          this.factorization = new CNFFactorization();
        return formula.transform(this.factorization);
      case TSEITIN:
        if (this.tseitin == null || this.currentAtomBoundary != this.config().atomBoundary) {
          this.currentAtomBoundary = this.config().atomBoundary;
          this.tseitin = new TseitinTransformation(this.config().atomBoundary);
        }
        return formula.transform(this.tseitin);
      case PLAISTED_GREENBAUM:
        if (this.plaistedGreenbaum == null || this.currentAtomBoundary != this.config().atomBoundary) {
          this.currentAtomBoundary = this.config().atomBoundary;
          this.plaistedGreenbaum = new PlaistedGreenbaumTransformation(this.config().atomBoundary);
        }
        return formula.transform(this.plaistedGreenbaum);
      case BDD:
        if (this.bddCnfTransformation == null)
          this.bddCnfTransformation = new BDDCNFTransformation();
        return formula.transform(this.bddCnfTransformation);
      case ADVANCED:
        if (this.factorizationHandler == null) {
          this.factorizationHandler = new AdvancedFactorizationHandler();
          this.advancedFactorization = new CNFFactorization(this.factorizationHandler);
        }
        this.factorizationHandler.reset(this.config().distributionBoundary, this.config().createdClauseBoundary);
        return this.advancedEncoding(formula);
      default:
        throw new IllegalStateException("Unknown CNF encoding algorithm: " + this.config().algorithm);
    }
  }
446152
private static String multipleExtractor(String formula) {
        String recentCompoundCount = "0";
        String recentCompound = "";

        boolean found = false;
        for (int f = 0; f < formula.length(); f++) {
            char thisChar = formula.charAt(f);
            if (thisChar >= '0' && thisChar <= '9') {
                if (!found)
                    recentCompoundCount += thisChar;
                else
                    recentCompound += thisChar;

            } else {
                found = true;
                recentCompound += thisChar;
            }
        }
        return muliplier(recentCompound, Integer.valueOf(recentCompoundCount));
    }
739721
public Formula get(final int i) {
    if (i < 0 || i >= this.formulas.length)
      throw new IllegalArgumentException("Illegal formula index: " + i);
    return this.formulas[i];
  }
415782
private void addCNF(final Formula formula, int weight) {
    switch (formula.type()) {
      case TRUE:
        break;
      case FALSE:
      case LITERAL:
      case OR:
        this.addClause(formula, weight);
        break;
      case AND:
        for (Formula op : formula)
          this.addClause(op, weight);
        break;
      default:
        throw new IllegalArgumentException("Input formula ist not a valid CNF: " + formula);
    }
  }
1153966
public Formula and(final Collection<? extends Formula> operands) {
    final LinkedHashSet<Formula> ops = new LinkedHashSet<>(operands);
    return this.constructAnd(ops);
  }
1362004
public static List<IElement> elements(IMolecularFormula formula) {

        List<IElement> elementList = new ArrayList<IElement>();
        List<String> stringList = new ArrayList<String>();
        for (IIsotope isotope : formula.isotopes()) {
            if (!stringList.contains(isotope.getSymbol())) {
                elementList.add(isotope);
                stringList.add(isotope.getSymbol());
            }

        }
        return elementList;
    }
970784
function parse(formula) {
    formula = formula.trim().toLowerCase();

    if (formula === "even") {
        return [2, 0];
    } else if (formula === "odd") {
        return [2, 1];
    } else {
        var parsed = formula.match(re_nthElement);

        if (!parsed) {
            throw new SyntaxError(
                "n-th rule couldn't be parsed ('" + formula + "')"
            );
        }

        var a;

        if (parsed[1]) {
            a = parseInt(parsed[1], 10);
            if (isNaN(a)) {
                if (parsed[1].charAt(0) === "-") a = -1;
                else a = 1;
            }
        } else a = 0;

        return [a, parsed[3] ? parseInt((parsed[2] || "") + parsed[3], 10) : 0];
    }
}
1260323
@Override
    public IMolecularFormula add(IMolecularFormula formula) {
        for (IIsotope newIsotope : formula.isotopes()) {
            addIsotope(newIsotope, formula.getIsotopeCount(newIsotope));
        }
        if (formula.getCharge() != null) {
            if (charge != null)
                charge += formula.getCharge();
            else
                charge = formula.getCharge();
        }
        return this;
    }