001/**
002 * Copyright (C) 2007 - 2016, Jens Lehmann
003 *
004 * This file is part of DL-Learner.
005 *
006 * DL-Learner is free software; you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation; either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * DL-Learner is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package org.dllearner.core;
020
021import java.util.Set;
022import java.util.SortedSet;
023
024import org.dllearner.core.owl.DatatypePropertyHierarchy;
025import org.dllearner.core.owl.Hierarchy;
026import org.dllearner.core.owl.ObjectPropertyHierarchy;
027import org.semanticweb.owlapi.model.OWLClass;
028import org.semanticweb.owlapi.model.OWLClassExpression;
029import org.semanticweb.owlapi.model.OWLDataProperty;
030import org.semanticweb.owlapi.model.OWLDataRange;
031import org.semanticweb.owlapi.model.OWLObjectProperty;
032import org.semanticweb.owlapi.model.OWLProperty;
033
034/**
035 * Reasoning requests related to the schema of the knowledge base.
036 * 
037 * @author Jens Lehmann
038 *
039 */
040public interface SchemaReasoner {
041        
042        /**
043         * Returns all named classes, which are not satisfiable, i.e. cannot 
044         * have instances.
045         * @return The set of inconsistent classes.
046         */
047        Set<OWLClass> getInconsistentClasses();
048        
049        /**
050         * Returns the domain of this object property. (Theoretically, there could
051         * be more than one domain axiom. However, this can be considered a modelling
052         * error.)
053         * @param objectProperty An object property in the knowledge base.
054         * @return The rdfs:domain of <code>objectProperty</code>
055         */
056        OWLClassExpression getDomain(OWLObjectProperty objectProperty);
057        
058        /**
059         * Returns the domain of this data property.
060         * @param datatypeProperty An data property in the knowledge base.
061         * @return The rdfs:domain of <code>datatypeProperty</code>
062         */
063        OWLClassExpression getDomain(OWLDataProperty datatypeProperty);
064        
065        /**
066         * Returns the range of this object property.
067         * @param objectProperty An object property in the knowledge base.
068         * @return The rdfs:range of <code>objectProperty</code>
069         */
070        OWLClassExpression getRange(OWLObjectProperty objectProperty);
071        
072        /**
073         * Returns the range of this data property.
074         * @param datatypeProperty An data property in the knowledge base.
075         * @return The rdfs:range of <code>datatypeProperty</code>
076         */
077        OWLDataRange getRange(OWLDataProperty datatypeProperty);
078        
079        /**
080         * Checks whether <code>superClass</code> is a super class of <code>subClass</code>.
081         * @param superClass The (supposed) super class.
082         * @param subClass The (supposed) sub class.
083         * @return Whether <code>superClass</code> is a super class of <code>subClass</code>.
084         */
085        boolean isSuperClassOf(OWLClassExpression superClass, OWLClassExpression subClass);
086        
087        /**
088         * Checks whether <code>class1</code> is equivalent to <code>class2</code>.
089         * @param class1 The first class.
090         * @param class2 The second class2.
091         * @return Whether <code>class1</code> is equivalent to <code>class2</code>.
092         */
093        boolean isEquivalentClass(OWLClassExpression class1, OWLClassExpression class2);
094        
095        /**
096         * Checks whether <code>class1</code> is disjoint with <code>class2</code>.
097         * @param class1 The first class.
098         * @param class2 The second class2.
099         * @return Whether <code>class1</code> is disjoint with <code>class2</code>.
100         */
101        boolean isDisjoint(OWLClass class1, OWLClass class2);
102                
103        /**
104         * Returns all asserted owl:equivalence class axioms for the given class.
105         * @param namedClass A named class in the background knowledge.
106         * @return A set of descriptions asserted to be equal to the named class.
107         */
108        Set<OWLClassExpression> getAssertedDefinitions(OWLClass namedClass);
109        
110        /**
111         * Checks which of <code>superClasses</code> are super classes of <code>subClass</code>
112         * @param superClasses A set of (supposed) super classes.
113         * @param subClasses The (supposed) sub class.
114         * @return The subset of <code>superClasses</code>, which satisfy the superclass-subclass relationship.
115         */
116        Set<OWLClassExpression> isSuperClassOf(Set<OWLClassExpression> superClasses, OWLClassExpression subClasses);
117
118        /**
119         * Computes and returns the class hierarchy of the knowledge base.
120         *
121         * @return The subsumption hierarchy of this knowledge base.
122         */
123        Hierarchy<OWLClassExpression> getClassHierarchy();
124        
125        /**
126         * Returns direct super classes in the class hierarchy.
127         * 
128         * @param description
129         *            Atomic concept, top, or bottom.
130         * @return A set of more general concepts.
131         */
132        SortedSet<OWLClassExpression> getSuperClasses(OWLClassExpression description);
133
134        /**
135         * Returns direct sub classes in the class hierarchy.
136         * 
137         * @param description
138         *            Atomic concept, top, or bottom.
139         * @return A set of more special concepts.
140         */
141        SortedSet<OWLClassExpression> getSubClasses(OWLClassExpression description);
142
143        /**
144         * Computes and returns the object property hierarchy of the knowledge base.
145         * @return The object property hierarchy of the knowlege base.
146         */
147        ObjectPropertyHierarchy getObjectPropertyHierarchy();
148        
149        /**
150         * Returns more general concepts in the subsumption hierarchy.
151         * 
152         * @see ObjectPropertyHierarchy#getMoreGeneralRoles(OWLObjectProperty)
153         * @param objectProperty
154         *            Atomic concept, top, or bottom.
155         * @return A set of more general concepts.
156         */
157        SortedSet<OWLObjectProperty> getSuperProperties(OWLObjectProperty objectProperty);
158
159        /**
160         * Returns more special concepts in the subsumption hierarchy.
161         * 
162         * @see ObjectPropertyHierarchy#getMoreSpecialRoles(OWLObjectProperty)
163         * @param objectProperty
164         *            Atomic concept, top, or bottom.
165         * @return A set of more special concepts.
166         */
167        SortedSet<OWLObjectProperty> getSubProperties(OWLObjectProperty objectProperty);
168
169        /**
170         * TODO Outdated in OWL 2, because the universal role is the most general.
171         * @see ObjectPropertyHierarchy#getMostGeneralRoles()
172         * @return The most general roles.
173         */
174        SortedSet<OWLObjectProperty> getMostGeneralProperties();
175
176        /**
177         * TODO Outdated in OWL, because the bottom role is the most specific.
178         * @see ObjectPropertyHierarchy#getMostSpecialRoles()
179         * @return The most special roles.
180         */
181        SortedSet<OWLObjectProperty> getMostSpecialProperties();
182
183        /**
184         * Computes and returns the data property hierarchy of the knowledge base.
185         * @return The data property hierarchy of the knowlege base.
186         */
187        DatatypePropertyHierarchy getDatatypePropertyHierarchy();
188        
189        /**
190         * Returns more general concepts in the subsumption hierarchy.
191         * 
192         * @see DatatypePropertyHierarchy#getMoreGeneralRoles(OWLDataProperty)
193         * @param dataProperty
194         *            Atomic concept, top, or bottom.
195         * @return A set of more general concepts.
196         */
197        SortedSet<OWLDataProperty> getSuperProperties(OWLDataProperty dataProperty);
198
199        /**
200         * Returns more special concepts in the subsumption hierarchy.
201         * 
202         * @see DatatypePropertyHierarchy#getMoreSpecialRoles(OWLDataProperty)
203         * @param dataProperty
204         *            Atomic concept, top, or bottom.
205         * @return A set of more special concepts.
206         */
207        SortedSet<OWLDataProperty> getSubProperties(OWLDataProperty dataProperty);
208
209        /**
210         * @see DatatypePropertyHierarchy#getMostGeneralRoles()
211         * @return The most general roles.
212         */
213        SortedSet<OWLDataProperty> getMostGeneralDatatypeProperties();
214
215        /**
216         * @see DatatypePropertyHierarchy#getMostSpecialRoles()
217         * @return The most special roles.
218         */
219        SortedSet<OWLDataProperty> getMostSpecialDatatypeProperties();
220
221        /**
222         * Computes all super properties for the given property.
223         * @param property the property
224         * @return all super properties
225         */
226        <T extends OWLProperty> SortedSet<T> getSuperProperties(T property);
227
228        /**
229         * Computes all sub properties for the given property.
230         * @param property the property
231         * @return all sub properties
232         */
233        <T extends OWLProperty> SortedSet<T> getSubProperties(T property);
234        
235}