Package org.mindswap.pellet

Examples of org.mindswap.pellet.KnowledgeBase


    return options;
  }

  @Override
  public void run() {
    KnowledgeBase kb = getKB();

    startTask( "consistency check" );
    boolean isConsistent = kb.isConsistent();
    finishTask( "consistency check" );

    if( isConsistent )
      output( "Consistent: Yes" );
    else {
      output( "Consistent: No" );
      output( "Reason: " + kb.getExplanation() );
    }
  }
View Full Code Here


    // that bug is triggered regardless of the traversal order
    // in getTransitivePropertyValues function. With the bug
    // if we visit b before c we will miss the value e and if we visit c
    // before b we miss the value d.

    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl a = term( "a" );
    ATermAppl b = term( "b" );
    ATermAppl c = term( "c" );
    ATermAppl d = term( "d" );
    ATermAppl e = term( "e" );

    ATermAppl p = term( "p" );
    ATermAppl r = term( "r" );
    ATermAppl s = term( "s" );

    kb.addObjectProperty( p );
    kb.addObjectProperty( r );
    kb.addObjectProperty( s );

    kb.addTransitiveProperty( r );
    kb.addTransitiveProperty( s );

    kb.addSubProperty( r, p );
    kb.addSubProperty( s, p );

    kb.addIndividual( a );
    kb.addIndividual( b );
    kb.addIndividual( c );
    kb.addIndividual( d );
    kb.addIndividual( e );

    kb.addPropertyValue( r, a, b );
    kb.addPropertyValue( r, b, c );
    kb.addPropertyValue( r, b, d );
    kb.addPropertyValue( s, a, c );
    kb.addPropertyValue( s, c, b );
    kb.addPropertyValue( s, c, e );

    assertTrue( kb.hasPropertyValue( a, p, b ) );
    assertTrue( kb.hasPropertyValue( a, p, c ) );
    assertTrue( kb.hasPropertyValue( a, p, d ) );
    assertTrue( kb.hasPropertyValue( a, p, e ) );
    assertIteratorValues( kb.getPropertyValues( p, a ).iterator(), new ATermAppl[] { b, c, d, e } );
  }
View Full Code Here

   * Test that an individual added to a complete ABox isn't discarded if
   * backtracking occurs in that ABox
   */
  @Test
  public void backtrackPreservesAssertedIndividuals() {
    KnowledgeBase kb = new KnowledgeBase();

    kb.addIndividual( term( "x" ) );

    kb.addClass( term( "C" ) );
    kb.addClass( term( "D" ) );

    kb.addDatatypeProperty( term( "p" ) );
    kb.addFunctionalProperty( term( "p" ) );

    kb.addSubClass( term( "C" ), ATermUtils.makeSomeValues( term( "p" ), ATermUtils
        .makeValue( ATermUtils.makePlainLiteral( "0" ) ) ) );
    kb.addSubClass( term( "D" ), ATermUtils.makeSomeValues( term( "p" ), ATermUtils
        .makeValue( ATermUtils.makePlainLiteral( "1" ) ) ) );

    kb.addType( term( "x" ), ATermUtils.makeOr( ATermUtils.makeList( new ATerm[] {
        term( "C" ), term( "D" ) } ) ) );

    /*
     * At this point we can get onto one of two branches. In one p(x,"0"),
     * in the other p(x,"1") The branch point is a concept disjunction and
     * we're provoking a datatype clash.
     */
    assertTrue( kb.isConsistent() );

    /*
     * Add the individual to the now completed ABox
     */
    kb.addIndividual( term( "y" ) );

    assertTrue( kb.isConsistent() );
    assertNotNull( kb.getABox().getIndividual( term( "y" ) ) );

    /*
     * This assertion causes a clash regardless of which branch we are on
     */
    kb.addPropertyValue( term( "p" ), term( "x" ), ATermUtils.makePlainLiteral( "2" ) );

    assertFalse( kb.isConsistent() );

    /*
     * In 2.0.0-rc5 (and perhaps earlier, this assertion fails)
     */
    assertNotNull( kb.getABox().getIndividual( term( "y" ) ) );
  }
View Full Code Here

    assertSubClass( kb, and( min( p, 2, c ), min( p, 2, not( c ) ) ), min( p, 4, TOP ) );
  }

  @Test
  public void testQualifiedCardinalityDataProperty() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl c = restrict( Datatypes.INTEGER, minInclusive( literal( 10 ) ) );
    ATermAppl d = restrict( Datatypes.INTEGER, maxInclusive( literal( 20 ) ) );

    ATermAppl p = term( "p" );
    ATermAppl f = term( "f" );
    ATermAppl sub = Datatypes.SHORT;
    ATermAppl sup = Datatypes.INTEGER;

    kb.addDatatype(sub);
    kb.addDatatype(sup);
    kb.addDatatypeProperty( p );
    kb.addDatatypeProperty( f );
    kb.addFunctionalProperty( f );

    assertSatisfiable( kb, and( min( p, 2, and( c, d ) ), max( p, 2, c ), some( p, or( and( c,
        not( d ) ), c ) ) ) );
    assertSubClass( kb, min( p, 4, TOP_LIT ), min( p, 2, TOP_LIT ) );
    assertNotSubClass( kb, min( p, 1, TOP_LIT ), min( p, 2, TOP_LIT ) );
View Full Code Here

    assertSubClass( kb, and( min( p, 2, c ), min( p, 2, not( c ) ) ), min( p, 4, TOP_LIT ) );
  }

  @Test
  public void testQualifiedCardinality3() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl c = term( "z" );
    ATermAppl d = term( "d" );
    ATermAppl e = term( "e" );
    ATermAppl notD = term( "notD" );

    ATermAppl p = term( "p" );

    ATermAppl x = term( "x" );
    ATermAppl y3 = term( "y3" );

    kb.addObjectProperty( p );
    kb.addClass( c );
    kb.addClass( d );
    kb.addClass( e );
    kb.addClass( notD );

    kb.addDisjointClass( d, notD );
    // kb.addSubClass( c, or(e,not(d)) );

    kb.addIndividual( x );
    kb.addIndividual( y3 );

    kb.addType( x, and( min( p, 2, and( d, e ) ), max( p, 2, d ) ) );
    kb.addType( y3, not( e ) );
    kb.addType( y3, some( inv( p ), value( x ) ) );
    kb.addType( y3, or( d, c ) );

    assertTrue( kb.isConsistent() );
  }
View Full Code Here

    assertTrue( kb.isConsistent() );
  }

  @Test
  public void testSelfRestrictions() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl c = term( "c" );
    ATermAppl d = term( "d" );

    ATermAppl p = term( "p" );

    kb.addClass( c );
    kb.addClass( d );

    kb.addObjectProperty( p );

    kb.addRange( p, d );

    kb.addSubClass( c, and( self( p ), some( p, TOP ) ) );

    assertTrue( kb.isConsistent() );

    assertTrue( kb.isSatisfiable( c ) );
    assertTrue( kb.isSubClassOf( c, d ) );

  }
View Full Code Here

  @Test
  /**
   * Test for the enhancement required in #252
   */
  public void testBooleanDatatypeConstructors() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl nni = Datatypes.NON_NEGATIVE_INTEGER;
    ATermAppl npi = Datatypes.NON_POSITIVE_INTEGER;
    ATermAppl ni = Datatypes.NEGATIVE_INTEGER;
    ATermAppl pi = Datatypes.POSITIVE_INTEGER;
    ATermAppl f = Datatypes.FLOAT;

    ATermAppl s = term( "s" );
    kb.addDatatypeProperty( s );

    assertSatisfiable( kb, some( s, pi ) );
    assertSatisfiable( kb, some( s, not ( pi ) ) );
    assertUnsatisfiable( kb, some( s, and( pi, ni ) ) );
    assertUnsatisfiable( kb, some( s, and( f, or( pi, ni ) ) ) );
View Full Code Here

    assertSatisfiable( kb, some( s, and( nni, npi ) ) );
  }

  @Test
  public void testSelfRestrictionRestore() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl C = term( "c" );
    ATermAppl D = term( "d" );

    ATermAppl p = term( "p" );
    ATermAppl q = term( "q" );

    ATermAppl a = term( "a" );

    kb.addClass( C );
    kb.addClass( D );

    kb.addObjectProperty( p );
    kb.addObjectProperty( q );

    kb.addSubClass( C, or( not( self( p ) ), not( self( q ) ) ) );

    kb.addIndividual( a );
    kb.addType( a, C );

    assertTrue( kb.isConsistent() );

    assertFalse( kb.isType( a, not( self( p ) ) ) );
    assertFalse( kb.isType( a, not( self( q ) ) ) );
  }
View Full Code Here

    assertFalse( kb.isType( a, not( self( q ) ) ) );
  }

  @Test
  public void testReflexive1() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl c = term( "c" );
    ATermAppl d = term( "d" );
    ATermAppl sub = term( "sub" );
    ATermAppl sup = term( "sup" );

    ATermAppl p = term( "p" );
    ATermAppl r = term( "r" );
    ATermAppl weakR = term( "weakR" );

    ATermAppl x = term( "x" );
    ATermAppl y = term( "y" );

    kb.addClass( c );
    kb.addClass( d );
    kb.addClass( sub );
    kb.addClass( sup );
    kb.addSubClass( sub, sup );
    kb.addSubClass( some( weakR, TOP ), self( weakR ) );

    kb.addObjectProperty( p );
    kb.addObjectProperty( r );
    kb.addObjectProperty( weakR );
    kb.addReflexiveProperty( r );
    kb.addRange( r, d );

    kb.addIndividual( x );
    kb.addType( x, self( p ) );
    kb.addType( x, not( some( weakR, value( x ) ) ) );
    kb.addIndividual( y );
    kb.addPropertyValue( weakR, y, x );

    assertTrue( kb.isConsistent() );

    assertTrue( kb.isSubClassOf( and( c, self( p ) ), some( p, c ) ) );
    assertTrue( kb.isSubClassOf( and( c, min( r, 1, not( c ) ) ), min( r, 2, TOP ) ) );
    assertTrue( kb.isSubClassOf( min( r, 1, c ), d ) );
    assertTrue( kb.hasPropertyValue( x, p, x ) );
    assertTrue( kb.hasPropertyValue( y, weakR, y ) );
    assertTrue( kb.isDifferentFrom( x, y ) );
    assertTrue( kb.isDifferentFrom( y, x ) );
    assertTrue( kb.isType( x, some( r, value( x ) ) ) );
    assertTrue( kb.isSatisfiable( and( self( p ), self( inv( p ) ), max( p, 1, TOP ) ) ) );
  }
View Full Code Here

    assertTrue( kb.isSatisfiable( and( self( p ), self( inv( p ) ), max( p, 1, TOP ) ) ) );
  }

  @Test
  public void testReflexive2() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl a = term( "a" );
    ATermAppl c = term( "c" );
    ATermAppl r = term( "r" );

    kb.addIndividual( a );
    kb.addClass( c );
    kb.addSubClass( c, all( r, BOTTOM ) );
    kb.addSubClass( c, oneOf( a ) );

    kb.addObjectProperty( r );
    kb.addReflexiveProperty( r );

    assertSatisfiable( kb, c, false );
  }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.KnowledgeBase

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.