当前位置: 首页>>代码示例>>Java>>正文


Java IFormula类代码示例

本文整理汇总了Java中ap.parser.IFormula的典型用法代码示例。如果您正苦于以下问题:Java IFormula类的具体用法?Java IFormula怎么用?Java IFormula使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IFormula类属于ap.parser包,在下文中一共展示了IFormula类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interpolate

import ap.parser.IFormula; //导入依赖的package包/类
public ProverExpr[] interpolate(int[][] partitionSeq) {
	final ArrayBuffer<Set<Object>> args = new ArrayBuffer<Set<Object>>();
	for (int i = 0; i < partitionSeq.length; ++i) {
		final ArrayBuffer<Object> indexes = new ArrayBuffer<Object>();
		for (int j = 0; j < partitionSeq[i].length; ++j)
			indexes.$plus$eq(Integer.valueOf(partitionSeq[i][j]));
		args.$plus$eq(indexes.toSet());
	}

	final Seq<IFormula> ints = api.getInterpolants(args.toSeq(),1000000);

	final ProverExpr[] res = new ProverExpr[partitionSeq.length - 1];
	for (int i = 0; i < partitionSeq.length - 1; ++i)
		res[i] = new FormulaExpr(ints.apply(i));

	return res;
}
 
开发者ID:SRI-CSL,项目名称:bixie,代码行数:18,代码来源:PrincessProver.java

示例2: and

import ap.parser.IFormula; //导入依赖的package包/类
@Override
public IFormula and(IExpression t1, IExpression t2) {
  if (t1 == t2) {
    return (IFormula) t1;
  }
  if (isTrue(t1)) {
    return (IFormula) t2;
  }
  if (isTrue(t2)) {
    return (IFormula) t1;
  }
  if (isFalse(t1)) {
    return pFalse;
  }
  if (isFalse(t2)) {
    return pFalse;
  }
  return simplify(new IBinFormula(IBinJunctor.And(), (IFormula) t1, (IFormula) t2));
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:20,代码来源:PrincessBooleanFormulaManager.java

示例3: or

import ap.parser.IFormula; //导入依赖的package包/类
@Override
public IFormula or(IExpression t1, IExpression t2) {
  if (t1 == t2) {
    return (IFormula) t1;
  }
  if (isTrue(t1)) {
    return pTrue;
  }
  if (isTrue(t2)) {
    return pTrue;
  }
  if (isFalse(t1)) {
    return (IFormula) t2;
  }
  if (isFalse(t2)) {
    return (IFormula) t1;
  }
  return simplify(new IBinFormula(IBinJunctor.Or(), (IFormula) t1, (IFormula) t2));
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:20,代码来源:PrincessBooleanFormulaManager.java

示例4: addConstraint

import ap.parser.IFormula; //导入依赖的package包/类
@Override
public Integer addConstraint(BooleanFormula f) {
  Preconditions.checkState(!closed);
  int termIndex = counter.getFreshId();
  IFormula t = (IFormula) mgr.extractInfo(f);

  // set partition number and add formula
  api.setPartitionNumber(termIndex);
  addConstraint0(t);

  // reset partition number to magic number -1,
  // which represents formulae belonging to all partitions.
  api.setPartitionNumber(-1);

  assertedFormulas.peek().add(termIndex);
  annotatedTerms.put(termIndex, t);
  return termIndex;
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:19,代码来源:PrincessInterpolatingProver.java

示例5: substitute

import ap.parser.IFormula; //导入依赖的package包/类
/**
 * Simultaneously substitute <code>from</code> with <code>to</code>
 * in <code>target</code>. <code>from</code> has to be an array of
 * free or bound variables.
 */
public ProverExpr substitute(ProverExpr target,
                              ProverExpr[] from, ProverExpr[] to) {
  assert(from.length == to.length);
  
     final scala.collection.mutable.HashMap<ConstantTerm, ITerm> constantSubst =
         new scala.collection.mutable.HashMap<ConstantTerm, ITerm>();
     final scala.collection.mutable.HashMap<Predicate, IFormula> predicateSubst =
         new scala.collection.mutable.HashMap<Predicate, IFormula>();

     for (int i = 0; i < from.length; ++i) {
       if (from[i] instanceof TermExpr) {
         final ConstantTerm c = ((IConstant)((TermExpr)from[i]).term).c();
         final ITerm t = ((TermExpr)to[i]).term;
         constantSubst.put(c, t);
       } else {
         final Predicate p = ((IAtom)((FormulaExpr)from[i]).formula).pred();
         assert(p.arity() == 0);
         final IFormula f = ((FormulaExpr)to[i]).formula;
         predicateSubst.put(p, f);
       }
     }
     
     // We currently just assume that there are no clashes between substituted
     // terms and predicates/formulae, and that the substitutions can be
     // carried out in sequence
     
     if (target instanceof TermExpr) {
       final ITerm t1 = ((TermExpr)target).term;
       final ITerm t2 = ConstantSubstVisitor$.MODULE$.apply(t1, constantSubst);
       final ITerm t3 = PredicateSubstVisitor$.MODULE$.apply(t2, predicateSubst);
       return new TermExpr(t3, target.getType());
     } else {
       final IFormula f1 = ((FormulaExpr)target).formula;
       final IFormula f2 = ConstantSubstVisitor$.MODULE$.apply(f1, constantSubst);
       final IFormula f3 = PredicateSubstVisitor$.MODULE$.apply(f2, predicateSubst);
       return new FormulaExpr(f3);
     }
}
 
开发者ID:SRI-CSL,项目名称:bixie,代码行数:44,代码来源:PrincessProver.java

示例6: simplify

import ap.parser.IFormula; //导入依赖的package包/类
@Override
protected IExpression simplify(IExpression f) {
  // TODO this method is not tested, check it!
  if (f instanceof IFormula) {
    f = BooleanCompactifier.apply((IFormula) f);
  }
  return PartialEvaluator.apply(f);
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:9,代码来源:PrincessFormulaManager.java

示例7: ifThenElse

import ap.parser.IFormula; //导入依赖的package包/类
@Override
public IExpression ifThenElse(IExpression condition, IExpression t1, IExpression t2) {
  if (t1 instanceof IFormula) {
    return new IFormulaITE((IFormula) condition, (IFormula) t1, (IFormula) t2);
  } else {
    return new ITermITE((IFormula) condition, (ITerm) t1, (ITerm) t2);
  }
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:9,代码来源:PrincessBooleanFormulaManager.java

示例8: not

import ap.parser.IFormula; //导入依赖的package包/类
@Override
public IFormula not(IExpression pBits) {
  if (pBits instanceof INot) {
    return ((INot) pBits).subformula(); // "not not a" == "a"
  } else {
    return new INot((IFormula) pBits);
  }
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:9,代码来源:PrincessBooleanFormulaManager.java

示例9: simplify

import ap.parser.IFormula; //导入依赖的package包/类
/** simplification to avoid identical subgraphs: (a&b)&(a&c) --> a&(b&c), etc */
private IFormula simplify(IFormula f) {
  if (f instanceof IBinFormula) {
    final IBinFormula bin = (IBinFormula) f;
    if (bin.f1() instanceof IBinFormula
        && bin.f2() instanceof IBinFormula
        && ((IBinFormula) bin.f1()).j().equals(((IBinFormula) bin.f2()).j())) {
      Enumeration.Value operator = ((IBinFormula) f).j();
      Enumeration.Value innerOperator = ((IBinFormula) bin.f1()).j();

      IFormula s11 = ((IBinFormula) bin.f1()).f1();
      IFormula s12 = ((IBinFormula) bin.f1()).f2();
      IFormula s21 = ((IBinFormula) bin.f2()).f1();
      IFormula s22 = ((IBinFormula) bin.f2()).f2();

      // only check for object equality, for performance
      if (s11 == s21) { // (ab)(ac) -> a(bc)
        return new IBinFormula(innerOperator, s11, new IBinFormula(operator, s12, s22));
      } else if (s11 == s22) { // (ab)(ca) -> a(bc)
        return new IBinFormula(innerOperator, s11, new IBinFormula(operator, s12, s21));
      } else if (s12 == s21) { // (ba)(ac) -> a(bc)
        return new IBinFormula(innerOperator, s12, new IBinFormula(operator, s11, s22));
      } else if (s12 == s22) { // (ba)(ca) -> a(bc)
        return new IBinFormula(innerOperator, s12, new IBinFormula(operator, s11, s21));
      }
    }
  }

  // if we cannot simplify the formula, we create an abbreviation
  // return getFormulaCreator().getEnv().abbrev(f);
  return f;
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:33,代码来源:PrincessBooleanFormulaManager.java

示例10: addSymbol

import ap.parser.IFormula; //导入依赖的package包/类
/** add external definition: boolean variable. */
void addSymbol(IFormula f) {
  Preconditions.checkState(!closed);
  api.addBooleanVariable(f);
  if (!trackingStack.isEmpty()) {
    trackingStack.getLast().booleanSymbols.add(f);
  }
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:9,代码来源:PrincessAbstractProver.java

示例11: parseStringToTerms

import ap.parser.IFormula; //导入依赖的package包/类
public List<? extends IExpression> parseStringToTerms(String s, PrincessFormulaCreator creator) {

    Tuple3<
            Seq<IFormula>, scala.collection.immutable.Map<IFunction, SMTFunctionType>,
            scala.collection.immutable.Map<ConstantTerm, SMTType>>
        triple = api.extractSMTLIBAssertionsSymbols(new StringReader(s));

    List<? extends IExpression> formula = seqAsJavaList(triple._1());
    Map<IFunction, SMTFunctionType> functionTypes = mapAsJavaMap(triple._2());
    Map<ConstantTerm, SMTType> constantTypes = mapAsJavaMap(triple._3());

    ImmutableSet.Builder<IExpression> declaredFunctions = ImmutableSet.builder();
    for (IExpression f : formula) {
      declaredFunctions.addAll(creator.extractVariablesAndUFs(f, true).values());
    }
    for (IExpression var : declaredFunctions.build()) {
      if (var instanceof IConstant) {
        SMTType type = constantTypes.get(((IConstant) var).c());
        if (type instanceof SMTParser2InputAbsy.SMTArray) {
          arrayVariablesCache.put(var.toString(), (ITerm) var);
        } else {
          intVariablesCache.put(var.toString(), (ITerm) var);
        }
        addSymbol((IConstant) var);
      } else if (var instanceof IAtom) {
        boolVariablesCache.put(((IAtom) var).pred().name(), (IFormula) var);
        addSymbol((IAtom) var);
      } else if (var instanceof IFunApp) {
        IFunction fun = ((IFunApp) var).fun();
        functionsCache.put(fun.name(), fun);
        functionsReturnTypes.put(fun, convertToTermType(functionTypes.get(fun)));
        addFunction(fun);
      }
    }
    return formula;
  }
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:37,代码来源:PrincessEnvironment.java

示例12: getType

import ap.parser.IFormula; //导入依赖的package包/类
private static String getType(IExpression var) {
  if (var instanceof IFormula) {
    return "Bool";

    // functions are included here, they cannot be handled separate for princess
  } else if (var instanceof ITerm) {
    return "Int";
  }

  throw new IllegalArgumentException("The given parameter is no variable or function");
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:12,代码来源:PrincessEnvironment.java

示例13: tree2List

import ap.parser.IFormula; //导入依赖的package包/类
/** returns a post-order iteration of the tree. */
private List<BooleanFormula> tree2List(Tree<IFormula> tree) {
  return from(Traverser.<Tree<IFormula>>forTree(node -> asJavaIterable(node.children()))
          .depthFirstPostOrder(tree))
      .transform(node -> mgr.encapsulateBooleanFormula(node.d()))
      .toList();
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:8,代码来源:PrincessInterpolatingProver.java

示例14: mkQuantifier

import ap.parser.IFormula; //导入依赖的package包/类
@Override
public IExpression mkQuantifier(Quantifier q, List<IExpression> vars, IExpression body) {
  checkArgument(body instanceof IFormula);
  ap.terfor.conjunctions.Quantifier pq = (q == Quantifier.FORALL) ? ALL$.MODULE$ : EX$.MODULE$;
  if (vars.size() == 0) {

    // Body already contains bound variables.
    return new IQuantified(pq, (IFormula) body);
  } else {
    return IExpression.quanConsts(
        pq, iterableAsScalaIterable(toConstantTerm(vars)), (IFormula) body);
  }
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:14,代码来源:PrincessQuantifiedFormulaManager.java

示例15: addConstraint

import ap.parser.IFormula; //导入依赖的package包/类
@Override
@Nullable
public Void addConstraint(BooleanFormula constraint) {
  Preconditions.checkState(!closed);
  final IFormula t = (IFormula) mgr.extractInfo(constraint);
  final int formulaId = addAssertedFormula(t);
  if (computeUnsatCores) {
    api.setPartitionNumber(formulaId);
  }
  addConstraint0(t);
  return null;
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:13,代码来源:PrincessTheoremProver.java


注:本文中的ap.parser.IFormula类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。