Package org.mindswap.pellet.utils.iterator

Examples of org.mindswap.pellet.utils.iterator.MultiListIterator


       * After this step, <code>conjuncts</code> is the flattened list of
       * conjuncts, each in DNF
       */
      ATermList rootConjuncts = (ATermList) term.getArgument( 0 );
      List<ATermAppl> conjuncts = new ArrayList<ATermAppl>();
      MultiListIterator i = new MultiListIterator( rootConjuncts );
      while( i.hasNext() ) {
        ATermAppl a = i.next();
        if( isAnd( a ) )
          i.append( (ATermList) a.getArgument( 0 ) );
        else {
          ATermAppl dnfA = dnfFromNnf( a );
          conjuncts.add( dnfA );
        }
      }

      /*
       * Step 2: element-wise distribute any disjunction among the
       * conjuncts.
       */
      List<ATermAppl> disjuncts = new ArrayList<ATermAppl>();
      for( ATermAppl a : conjuncts ) {
        if( disjuncts.isEmpty() ) {
          addToList( a, isOr( a ), disjuncts );
        }
        else {
          List<ATermAppl> thisArgs = new ArrayList<ATermAppl>();
          List<ATermAppl> newDisjuncts = new ArrayList<ATermAppl>();
          addToList( a, isOr( a ), thisArgs );

          for( ATermAppl a1 : thisArgs ) {
            for( ATermAppl b : disjuncts ) {
              List<ATermAppl> list = new ArrayList<ATermAppl>();
              addToList( a1, isAnd( a1 ), list );
              addToList( b, isAnd( b ), list );             
              newDisjuncts.add( makeAnd( toSet( list ) ) );
            }
          }
          disjuncts = newDisjuncts;
        }
      }

      dnf = makeOr( toSet( disjuncts ) );

    }
    /*
     * If the term is a disjunction merge each element into DNF
     */
    else if( ORFUN.equals( fun ) ) {
      ATermList disjuncts = (ATermList) term.getArgument( 0 );
      MultiListIterator i = new MultiListIterator( disjuncts );
      List<ATermAppl> args = new ArrayList<ATermAppl>();
      while( i.hasNext() ) {
        ATermAppl a = i.next();
        if( isOr( a ) )
          i.append( (ATermList) a.getArgument( 0 ) );
        else
          args.add( dnfFromNnf( a ) );
      }
      dnf = makeOr( toSet( args ) );
    }
View Full Code Here


    AFun fun = elConcept.getAFun();
   
    if( fun.equals( ATermUtils.ANDFUN ) ) {
      ATermList conjuncts = (ATermList) elConcept.getArgument( 0 );
      Set<ATermAppl> set = CollectionUtils.makeSet();
      for( MultiListIterator i = new MultiListIterator( conjuncts ); i.hasNext(); ) {
        ATermAppl c = i.next();
        if( ATermUtils.isAnd( c ) ) {
          i.append( (ATermList) c.getArgument( 0 ) );
        }
        else if( c.equals( ATermUtils.BOTTOM ) ) {
          return ATermUtils.BOTTOM;
        }
        else if( !c.equals( ATermUtils.TOP ) ) {
View Full Code Here

//            }

            boolean equivalent = axiom.getAFun().equals( ATermUtils.EQCLASSFUN );
            if( equivalent ) {
              Iterator<ATermAppl> i = ATermUtils.isAnd( term )
                ? new MultiListIterator( (ATermList) term.getArgument( 0 ) )
                : Collections.singleton( term ).iterator();
              Bool knownType = Bool.TRUE;
              while( i.hasNext() && knownType.isTrue() ) {
                term = i.next();
                knownType = isKnownType( pNode, term, SetUtils.<ATermAppl>emptySet() );
View Full Code Here

    }
   
    public Iterator<ATermAppl> getNominals(ATermAppl term) {
      if( isOneOf( term ) ) {
        ATermList list = (ATermList) term.getArgument( 0 );
        return new MultiListIterator( list );
      }
      else if( isNominal( term ) ) {
        return IteratorUtils.singletonIterator( term );
      }
     
View Full Code Here

//            }

            boolean equivalent = axiom.getAFun().equals( ATermUtils.EQCLASSFUN );
            if( equivalent ) {
              Iterator<ATermAppl> i = ATermUtils.isAnd( term )
                ? new MultiListIterator( (ATermList) term.getArgument( 0 ) )
                : Collections.singleton( term ).iterator();
              Bool knownType = Bool.TRUE;
              while( i.hasNext() && knownType.isTrue() ) {
                term = i.next();
                knownType = isKnownType( pNode, term, SetUtils.<ATermAppl>emptySet() );
View Full Code Here

              simp = TOP;
            }
            else {
        Set<ATermAppl> set = new HashSet<ATermAppl>();
        List<ATermAppl> negations = new ArrayList<ATermAppl>();
        MultiListIterator i = new MultiListIterator( conjuncts );
        while( i.hasNext() ) {
          ATermAppl c = i.next();
          if( c.equals( TOP ) ) {
                      continue;
                    }
                    else if( c.equals( BOTTOM ) ) {
                      return BOTTOM;
                    }
                    else if( isAnd( c ) ) {
                      i.append( (ATermList) c.getArgument( 0 ) );
                    }
                    else if( isNot( c ) ) {
                      negations.add( c );
                    }
                    else {
View Full Code Here

   * @return
   */
  public static ATermAppl makeSimplifiedAnd(Collection<ATermAppl> conjuncts) {
    Set<ATermAppl> set = new HashSet<ATermAppl>();
    List<ATermAppl> negations = new ArrayList<ATermAppl>();
    MultiListIterator listIt = new MultiListIterator( EMPTY_LIST );
    Iterator<ATermAppl> i = new PairIterator<ATermAppl>( conjuncts.iterator(), listIt );
    while( i.hasNext() ) {
      ATermAppl c = i.next();
      if( c.equals( TOP ) ) {
              continue;
            }
            else if( c.equals( BOTTOM ) ) {
              return BOTTOM;
            }
            else if( isAnd( c ) ) {
              listIt.append( (ATermList) c.getArgument( 0 ) );
            }
            else if( isNot( c ) ) {
              negations.add( c );
            }
            else {
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.utils.iterator.MultiListIterator

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.