Package aterm

Examples of aterm.AFun


   
    ciSub.addTrigger(trigger);
  }

  private void toELSubClassAxioms(ATermAppl axiom) {
    AFun fun = axiom.getAFun();
    ATermAppl sub = (ATermAppl) axiom.getArgument(0);
    ATermAppl sup = (ATermAppl) axiom.getArgument(1);
   
    ATermAppl subEL = ELSyntaxUtils.simplify(sub);
    if (fun.equals(ATermUtils.SUBFUN)) {
      if (ATermUtils.isPrimitive(sup) || ATermUtils.isBottom(sup)) {
        createConceptsFromAxiom(subEL, sup);
        return;
      }
     
      ATermAppl supEL = ELSyntaxUtils.simplify(sup);
      createConceptsFromAxiom(subEL, supEL);
    } else if (fun.equals( ATermUtils.EQCLASSFUN )) {
      ATermAppl supEL = ELSyntaxUtils.simplify(sup);
      createConceptsFromAxiom(subEL, supEL);
      createConceptsFromAxiom(supEL, subEL);
    } else {
      throw new IllegalArgumentException("Axiom " + axiom + " is not EL.");
View Full Code Here


     * TODO: Avoid processing DataOneOf when forcing into NNF
     */

    ATermAppl dnf;

    final AFun fun = term.getAFun();

    /*
     * If the term is a conjunction, each conjunct must be converted to dnf
     * and then element-wise distributed.
     */
 
View Full Code Here

    return true;
  }

  private boolean processClasses() {
    for( ATermAppl axiom : m_KB.getTBox().getAssertedAxioms() ) {
      AFun fun = axiom.getAFun();

      if( fun.equals( ATermUtils.DISJOINTSFUN ) ) {
        m_Expressivity.setHasDisjointClasses( true );

        ATermList args = (ATermList) axiom.getArgument( 0 );
        for( ; !args.isEmpty(); args = args.getNext() ) {
          if( !isEL( (ATermAppl) args.getFirst() ) ) {
            return false;
          }
        }
      }
      else {
        ATermAppl sub = (ATermAppl) axiom.getArgument( 0 );
        ATermAppl sup = (ATermAppl) axiom.getArgument( 1 );

        if( !isEL( sub ) || !isEL( sup ) ) {
          return false;
        }

        if( fun.equals( ATermUtils.SUBFUN ) ) {
          if( ATermUtils.isBottom( simplify( sup ) ) ) {
            m_Expressivity.setHasDisjointClasses( true );
          }
        }
        else if( fun.equals( ATermUtils.EQCLASSFUN ) ) {
          if( ATermUtils.isBottom( simplify( sub ) )
              || ATermUtils.isBottom( simplify( sup ) ) ) {
            m_Expressivity.setHasDisjointClasses( true );
          }
        }
        else if( fun.equals( ATermUtils.DISJOINTFUN ) ) {
          m_Expressivity.setHasDisjointClasses( true );
        }
        else {
          return false;
        }
View Full Code Here

    translateSuper(head, sup, freeVar, var);
    m_Rules.add(new Rule(head, body));
  }

  private void translateSub(List<ClauseEntry> outBody, ATermAppl sub, FreeVariableStore freeVar, Node currentVar) {
    AFun fun = sub.getAFun();
    if (ATermUtils.isPrimitive(sub) || ATermUtils.isBottom(sub)) {
      outBody.add(makeSubclassTriple(currentVar, m_Names.get(sub)));
    } else if (fun.equals( ATermUtils.ANDFUN )) {
      ATermList list = (ATermList) sub.getArgument(0);
     
      while( !list.isEmpty() ) {
        ATermAppl conj = (ATermAppl) list.getFirst();
        translateSub(outBody, conj, freeVar, currentVar);
        list = list.getNext();
      }
    } else if (fun.equals( ATermUtils.SOMEFUN )) {
      ATermAppl prop = (ATermAppl) sub.getArgument(0);
      ATermAppl q = (ATermAppl) sub.getArgument(1);
      Node nextVar = freeVar.next();
      outBody.add(makeSubOfSomeTriple(currentVar, prop, nextVar));
      translateSub(outBody, q, freeVar, nextVar);
View Full Code Here

      assert false;
    }
  }
 
  private void translateSuper(List<ClauseEntry> outHead, ATermAppl sup, FreeVariableStore freeVar, Node currentVar) {
    AFun fun = sup.getAFun();
    if (ATermUtils.isPrimitive(sup) || ATermUtils.isBottom(sup)) {
      outHead.add(makeSubclassTriple(currentVar, m_Names.get(sup)));
    } else if (fun.equals( ATermUtils.ANDFUN )) {
      ATermList list = (ATermList) sup.getArgument(0);
     
      while( !list.isEmpty() ) {
        ATermAppl conj = (ATermAppl) list.getFirst();
        translateSuper(outHead, conj, freeVar, currentVar);
        list = list.getNext();
      }
    } else if (fun.equals( ATermUtils.SOMEFUN )) {
      ATermAppl prop = (ATermAppl) sup.getArgument(0);
      ATermAppl q = (ATermAppl) sup.getArgument(1);
     
      if (!ATermUtils.isPrimitive(q) && !ATermUtils.isBottom(q)) {
        //Normalization - breaking complex concepts within someValues
View Full Code Here

      assert false;
    }
  }

  private void translateSuperSome(ATermAppl anon, ATermAppl sup) {
    AFun fun = sup.getAFun();
    if( ATermUtils.isPrimitive( sup ) || ATermUtils.isBottom( sup ) ) {
      m_Facts.add( makeSubclassFact( anon, sup ) );
    }
    else if( fun.equals( ATermUtils.ANDFUN ) ) {
      ATermList list = (ATermList) sup.getArgument( 0 );

      while( !list.isEmpty() ) {
        ATermAppl conj = (ATermAppl) list.getFirst();
        translateSuperSome( anon, conj );
        list = list.getNext();
      }
    }
    else if( fun.equals( ATermUtils.SOMEFUN ) ) {
      ATermAppl prop = (ATermAppl) sup.getArgument( 0 );
      ATermAppl q = (ATermAppl) sup.getArgument( 1 );

      if( !ATermUtils.isPrimitive( q ) && !ATermUtils.isBottom( q ) ) {
        // Normalization - breaking complex concepts within someValues
View Full Code Here

   
    taxonomy = new GenericTaxonomyBuilder().build( subsumers );
  }
 
  private void toELSubClassAxioms(ATermAppl axiom) {
    AFun fun = axiom.getAFun();
    ATermAppl sub = (ATermAppl) axiom.getArgument(0);
    ATermAppl sup = (ATermAppl) axiom.getArgument(1);
   
    ATermAppl subEL = ELSyntaxUtils.simplify(sub);
    if (fun.equals(ATermUtils.SUBFUN)) {
      if (ATermUtils.isPrimitive(sup) || ATermUtils.isBottom(sup)) {
        addSubclassRule(subEL, sup);
        return;
      }
     
      ATermAppl supEL = ELSyntaxUtils.simplify(sup);
      addSubclassRule(subEL, supEL);
    } else if (fun.equals( ATermUtils.EQCLASSFUN )) {
      ATermAppl supEL = ELSyntaxUtils.simplify(sup);
      addSubclassRule(subEL, supEL);
      addSubclassRule(supEL, subEL);
    } else {
      throw new IllegalArgumentException("Axiom " + axiom + " is not EL.");
View Full Code Here

   *
   * @param concept
   * @return
   */
  public static boolean isEL(ATermAppl concept) {
    AFun fun = concept.getAFun();

    boolean isEL = false;
    if( ATermUtils.isPrimitive( concept ) || ATermUtils.isBottom( concept ) ) {
      isEL = true;
    }
    else if( fun.equals( ATermUtils.ANDFUN ) ) {
      ATermList listEL = (ATermList) concept.getArgument( 0 );

      while( !listEL.isEmpty() ) {
        if( !isEL( (ATermAppl) listEL.getFirst() ) ) {
          break;
        }
        listEL = listEL.getNext();
      }
      isEL = listEL.isEmpty();
    }
    else if( fun.equals( ATermUtils.SOMEFUN ) ) {
      ATermAppl p = (ATermAppl) concept.getArgument( 0 );
      ATermAppl q = (ATermAppl) concept.getArgument( 1 );
      isEL = ATermUtils.isPrimitive(p) && isEL( q );
    }
    else {
View Full Code Here

   * @throws InternalReasonerException
   *             if the concept is not an LE class expression
   */
  public static ATermAppl simplify(ATermAppl elConcept) throws InternalReasonerException {
    ATermAppl simp = elConcept;
    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 ) ) {
          set.add( c );
        }
      }

      if( set.size() > 1 ) {
        simp = ATermUtils.makeAnd( ATermUtils.toSet( set ) );
      }
      else if( set.size() == 1 ) {
        simp = set.iterator().next();
      }
    }
    else if( fun.equals( ATermUtils.SOMEFUN ) ) {
      ATerm p = elConcept.getArgument( 0 );
      ATermAppl q = (ATermAppl) elConcept.getArgument( 1 ); // complex
      // role?
      ATermAppl qSimp = simplify( q );
      if( qSimp.equals( ATermUtils.BOTTOM ) ) {
View Full Code Here

  public OntBuilder(KnowledgeBase originalKB) {
    this.originalKB = originalKB;
  }

  public void add(ATermAppl axiom) {
    AFun afun = axiom.getAFun();
    if( afun.equals( ATermUtils.EQCLASSFUN ) ) {       
      ATermAppl c1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl c2 = (ATermAppl) axiom.getArgument( 1 );

      defineClass( c1 );
      defineClass( c2 );
      kb.addEquivalentClass( c1, c2 );
    }
    else if( afun.equals( ATermUtils.SUBFUN ) ) {
      ATermAppl c1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl c2 = (ATermAppl) axiom.getArgument( 1 );

      defineClass( c1 );
      defineClass( c2 );
      kb.addSubClass( c1, c2 );
    }
    else if( afun.equals( ATermUtils.DISJOINTSFUN ) ) {
      ATermList concepts = (ATermList) axiom.getArgument( 0 );
     
      for( ATermList l = concepts; !l.isEmpty(); l = l.getNext() )
        defineClass( (ATermAppl) l.getFirst() );           
      kb.addDisjointClasses( concepts );
    }
    else if( afun.equals( ATermUtils.DISJOINTFUN ) ) {
      ATermAppl c1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl c2 = (ATermAppl) axiom.getArgument( 1 );

      defineClass( c1 );
      defineClass( c2 );
      kb.addDisjointClass( c1, c2 );
    }
    else if( afun.equals( ATermUtils.DISJOINTPROPSFUN ) ) {
      ATermList props = (ATermList) axiom.getArgument( 0 );
     
      for( ATermList l = props; !l.isEmpty(); l = l.getNext() )
        defineProperty( l.getFirst() );
      kb.addDisjointProperties( props );
    }
    else if( afun.equals( ATermUtils.DISJOINTPROPFUN ) ) {
      ATermAppl p1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl p2 = (ATermAppl) axiom.getArgument( 1 );

      defineProperty( p1 );
      defineProperty( p2 );
      kb.addDisjointProperty( p1, p2 );
    }
    else if( afun.equals( ATermUtils.SUBPROPFUN ) ) {
      ATerm p1 = axiom.getArgument( 0 );
      ATermAppl p2 = (ATermAppl) axiom.getArgument( 1 );

      defineProperty( p1 );
      defineProperty( p2 );
      kb.addSubProperty( p1, p2 );
    }
    else if( afun.equals( ATermUtils.EQPROPFUN ) ) {
      ATermAppl p1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl p2 = (ATermAppl) axiom.getArgument( 1 );

      defineProperty( p1 );
      defineProperty( p2 );
      kb.addEquivalentProperty( p1, p2 );
    }
    else if( afun.equals( ATermUtils.DOMAINFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl c = (ATermAppl) axiom.getArgument( 1 );

      defineProperty( p );
      defineClass( c );
      kb.addDomain( p, c );
    }
    else if( afun.equals( ATermUtils.RANGEFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl c = (ATermAppl) axiom.getArgument( 1 );

      defineProperty( p );
      defineClass( c );
      kb.addRange( p, c );
    }
    else if( afun.equals( ATermUtils.INVPROPFUN ) ) {
      ATermAppl p1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl p2 = (ATermAppl) axiom.getArgument( 1 );

      kb.addObjectProperty( p1 );
      kb.addObjectProperty( p2 );
      kb.addInverseProperty( p1, p2 );
    }
    else if( afun.equals( ATermUtils.TRANSITIVEFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      kb.addObjectProperty( p );
      kb.addTransitiveProperty( p );
    }
    else if( afun.equals( ATermUtils.FUNCTIONALFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      defineProperty( p );
      kb.addFunctionalProperty( p );
    }
    else if( afun.equals( ATermUtils.INVFUNCTIONALFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      kb.addObjectProperty( p );
      kb.addInverseFunctionalProperty( p );
    }
    else if( afun.equals( ATermUtils.SYMMETRICFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      kb.addObjectProperty( p );
      kb.addSymmetricProperty( p );
    }
    else if( afun.equals( ATermUtils.ASYMMETRICFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      kb.addObjectProperty( p );
      kb.addAsymmetricProperty( p );
    }
    else if( afun.equals( ATermUtils.REFLEXIVEFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      kb.addObjectProperty( p );
      kb.addReflexiveProperty( p );
    }
    else if( afun.equals( ATermUtils.IRREFLEXIVEFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );

      kb.addObjectProperty( p );
      kb.addIrreflexiveProperty( p )
    }
    else if( afun.equals( ATermUtils.TYPEFUN ) ) {
      ATermAppl ind = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl cls = (ATermAppl) axiom.getArgument( 1 );

      kb.addIndividual( ind );
      defineClass( cls );
      kb.addType( ind, cls );
    }
    else if( afun.equals( ATermUtils.PROPFUN ) ) {
      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl s = (ATermAppl) axiom.getArgument( 1 );
      ATermAppl o = (ATermAppl) axiom.getArgument( 2 );

      kb.addIndividual( s );
      if( ATermUtils.isLiteral( o ) ) {
        kb.addDatatypeProperty( p );
      }
      else {
        kb.addObjectProperty( p );
        kb.addIndividual( o );
      }
      kb.addPropertyValue( p, s, o );
    }
    else if( afun.equals( ATermUtils.NOTFUN )
        && ((ATermAppl) axiom.getArgument( 0 )).getAFun().equals( ATermUtils.PROPFUN ) ) {
      axiom = (ATermAppl) axiom.getArgument( 0 );

      ATermAppl p = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl s = (ATermAppl) axiom.getArgument( 1 );
      ATermAppl o = (ATermAppl) axiom.getArgument( 2 );
     
      kb.addIndividual( s );
      if( ATermUtils.isLiteral( o ) ) {
        kb.addDatatypeProperty( p );
      }
      else {
        kb.addObjectProperty( p );
        kb.addIndividual( o );
      }
      kb.addNegatedPropertyValue( p, s, o );     
    }
    else if( afun.equals( ATermUtils.SAMEASFUN ) ) {
      ATermAppl ind1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl ind2 = (ATermAppl) axiom.getArgument( 1 );

      kb.addIndividual( ind1 );
      kb.addIndividual( ind2 );
      kb.addSame( ind1, ind2 );
    }
    else if( afun.equals( ATermUtils.DIFFERENTFUN ) ) {
      ATermAppl ind1 = (ATermAppl) axiom.getArgument( 0 );
      ATermAppl ind2 = (ATermAppl) axiom.getArgument( 1 );

      kb.addIndividual( ind1 );
      kb.addIndividual( ind2 );
      kb.addDifferent( ind1, ind2 );
    }
    else if( afun.equals( ATermUtils.ALLDIFFERENTFUN ) ) {
      ATermList inds = (ATermList) axiom.getArgument( 0 );
     
      for( ATermList l = inds; !l.isEmpty(); l = l.getNext() )
        kb.addIndividual( (ATermAppl) l.getFirst() );
      kb.addAllDifferent( inds );
    }
    else if( afun.equals( ATermUtils.RULEFUN ) ) {
      Set<RuleAtom> antecedent = new HashSet<RuleAtom>(); // Body
      Set<RuleAtom> consequent = new HashSet<RuleAtom>(); // Head

      ATermList head = (ATermList) axiom.getArgument( 1 );
      ATermList body = (ATermList) axiom.getArgument( 2 );
View Full Code Here

TOP

Related Classes of aterm.AFun

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.