Package expression.logical

Examples of expression.logical.LogicalExpression


  // as a list of conjunctions
  // Do not compute a complete DNF
  public static ArrayList<LogicalExpression> negate(TermSystem p,Node next){
    ArrayList<LogicalExpression> result = new ArrayList<LogicalExpression>();
      Node saveNext = next.cloneNode(true);
      LogicalExpression exp;
      try {
        exp = LogicalExprVisitor.parse(saveNext,p);
        addConjunct(exp,result);
      } catch (AnalyzeException e) {
        // TODO Auto-generated catch block
View Full Code Here


      return (LogicalExpression)((NotExpression)e).arg1();
    }
    // a=>b is (not a or b) so returns return (a and not b)
    else if (e instanceof ImpliesExpression){
      Expression a1 = ((ImpliesExpression)e).arg1();
      LogicalExpression a2 = (LogicalExpression)((ImpliesExpression)e).arg2();
      return new AndExpression(a1,negateCase(a2));
    }
    // returns the negation
    else return new NotExpression(e);
  }
View Full Code Here

  // <!ENTITY % ExprLogical "(IDSExprLogicalOr|IDSExprLogicalAnd|IDSExprLogicalNot
  // |IDSExprParenthesis|IDSExprEquality|IDSExprSup|IDSExprInf)"> 
  // if b, then save sub-expressions in boolean table of p
  public static LogicalExpression parse(Node n,TermSystem p) throws AnalyzeException,  ConstraintException {
//    System.out.println("parse logical " + n.getNodeName());
    LogicalExpression result = null;
    if (isLogicalRelation(n)){
      result = logicalRelation(n,p);
    }
    else if (isLogicalOperator(n)){
      result = logicalOperator(n,p);
View Full Code Here

  /* <!ELEMENT IDSExprLogicalNot (%ExprLogical;)> */
  static private LogicalExpression logicalNot(Node n,TermSystem p)
  throws AnalyzeException, ConstraintException {
    ChildIterator child = new ChildIterator(n);
    Node next = child.next();
    LogicalExpression first = parse(next,p);
    return new NotExpression(first);
  }
View Full Code Here

  static private LogicalExpression logicalOperator(Node n,TermSystem p)
  throws AnalyzeException, ConstraintException {
    String operator = ((Element) n).getTagName();
    ChildIterator child = new ChildIterator(n);
    Node next = child.next();
    LogicalExpression first = parse(next,p);
    if (!child.hasMoreChild()) exception(1);
    LogicalExpression second = logicalOperatorAux(child,p, operator);
    LogicalExpression result = null;
    if (isOr(operator))result = new OrExpression(first,second);
    else if (isAnd(operator)) result = new AndExpression(first,second);
    return result;
  }
View Full Code Here

  // PRECOND : child a encore un fils
  static private LogicalExpression logicalOperatorAux(ChildIterator child,TermSystem p,  String op)
  throws AnalyzeException, ConstraintException {

    Node next = child.next();
    LogicalExpression result = null;
    LogicalExpression first = parse(next,p);
    result = first;
    if (child.hasMoreChild()) {
      LogicalExpression second = logicalOperatorAux(child,p,op);
      if (isOr(op)) result = new OrExpression(first,second);
      else if (isAnd(op))result = new AndExpression(first,second);
      return result;
    }
    return first;
View Full Code Here

 
  /** this method takes a comparison operator with its parameters
   * It returns the corresponding LogicalExpression
   */
  static private LogicalExpression relation(TermSystem p,String op,Expression first,Expression second) { 
    LogicalExpression result=null;
    if (isEqual(op)) {
      result = new EqualExpression(first,second);
    }
    else if (isLess(op))
      result = new LessExpression(first,second);
View Full Code Here

  static private LogicalExpression logicalImplies(Node n,TermSystem p) throws AnalyzeException,
  ConstraintException {
    ChildIterator child = new ChildIterator(n);
    if (!child.hasMoreChild()) exception(1);
    Node next = child.next();
    LogicalExpression first = parse(next,p);
    if (!child.hasMoreChild()) exception(3);
    next = child.next();
    LogicalExpression second = parse(next,p);
    return new ImpliesExpression(first,second);
  }
View Full Code Here

   * @throws ConstraintException
   */
  public void validate(int timeout)
  throws AnalyzeException,ConstraintException,ValidationException {
    // build the LogicalExpression
    LogicalExpression e = parse();
    // get the list of terms in the DNF
    ArrayList<Expression> cases = Strategy.extractDisjunct(e);

    // validate each case
    System.out.println("\n\nSearching solutions for term in " + fileName);
View Full Code Here

   * @throws AnalyzeException
   *
   */
  public void validateAll(int timeout) throws AnalyzeException, ConstraintException, ValidationException {
    // build the LogicalExpression
    LogicalExpression e = parse();
   
    // validate all the cases
    // stop on the first case which has a solution (i.e counter-example)
    ArrayList<Expression> cases = Strategy.extractDisjunct(e);
    System.out.println("\n\nSearching solutions for term in " + fileName);
View Full Code Here

TOP

Related Classes of expression.logical.LogicalExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.