├── .bumpversion.cfg ├── .github ├── hooks │ └── commit-msg ├── scripts │ └── bumpversion.sh └── workflows │ ├── build-and-publish.yml │ ├── build-and-test.yml │ ├── codacy-analysis.yml │ └── codeql-analysis.yml ├── .gitignore ├── .pylintrc ├── CITATION.cff ├── CMakeLists.txt ├── FaCT++.C ├── CMakeLists.txt ├── fact.cpp ├── fact.h └── test.c ├── FaCT++.JNI ├── Axioms.cpp ├── CMakeLists.txt ├── Expressions.cpp ├── FaCTPlusPlus.cpp ├── JNIActor.h ├── JNIMonitor.h ├── JNISupport.h ├── KnowledgeExploration.cpp ├── MemoryStat.cpp ├── MemoryStat.h ├── Modularity.cpp ├── Queries.cpp ├── SaveLoad.cpp ├── tJNICache.h └── uk_ac_manchester_cs_factplusplus_FaCTPlusPlus.h ├── FaCT++.Java ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── uk │ │ │ └── ac │ │ │ └── manchester │ │ │ └── cs │ │ │ └── factplusplus │ │ │ ├── AxiomPointer.java │ │ │ ├── ClassPointer.java │ │ │ ├── DataPropertyPointer.java │ │ │ ├── DataTypeExpressionPointer.java │ │ │ ├── DataTypeFacet.java │ │ │ ├── DataTypePointer.java │ │ │ ├── DataValuePointer.java │ │ │ ├── FaCTPlusPlus.java │ │ │ ├── FaCTPlusPlusException.java │ │ │ ├── FaCTPlusPlusProgressMonitor.java │ │ │ ├── IndividualPointer.java │ │ │ ├── NodePointer.java │ │ │ ├── ObjectPropertyPointer.java │ │ │ ├── Pointer.java │ │ │ ├── QuietProgressMonitor.java │ │ │ ├── owlapiv3 │ │ │ ├── FaCTPlusPlusReasoner.java │ │ │ ├── FaCTPlusPlusReasonerFactory.java │ │ │ ├── ModuleMethod.java │ │ │ └── OWLKnowledgeExplorationReasonerWrapper.java │ │ │ └── protege │ │ │ ├── FaCTPlusPlusFactory.java │ │ │ └── FaCTPlusPlusRenderingViewComponent.java │ └── resources │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── lib │ │ └── native │ │ │ ├── 32bit │ │ │ ├── FaCTPlusPlusJNI.dll │ │ │ ├── libFaCTPlusPlusJNI.jnilib │ │ │ └── libFaCTPlusPlusJNI.so │ │ │ └── 64bit │ │ │ ├── FaCTPlusPlusJNI.dll │ │ │ ├── libFaCTPlusPlusJNI.jnilib │ │ │ └── libFaCTPlusPlusJNI.so │ │ └── plugin.xml │ └── test │ ├── java │ ├── bugs │ │ ├── AddIndividualsAfterLoadingTestCase.java │ │ ├── DebugVerifyComplianceUniversityTestCase.java │ │ ├── VerifyComplianceBase.java │ │ ├── VerifyComplianceHostTestCase.java │ │ ├── VerifyComplianceMereologyTestCase.java │ │ ├── VerifyComplianceMiniTambisTestCase.java │ │ ├── VerifyComplianceOWLSNewFeaturesTestCase.java │ │ ├── VerifyComplianceOWLSTestCase.java │ │ ├── VerifyCompliancePeopleTestCase.java │ │ ├── VerifyComplianceUniversityTestCase.java │ │ └── debug │ │ │ └── FppBrokenTestCase.java │ ├── conformancetests │ │ ├── Changed.java │ │ ├── FixedTestCase.java │ │ ├── HasSelfSupportTestCase.java │ │ ├── JUnitRunner.java │ │ ├── JUnitRunnerFromFile.java │ │ ├── NewFeaturesTestCase.java │ │ ├── OWL2TestCase.java │ │ ├── ProcessesTestCase.java │ │ ├── RDFBasedTestCase.java │ │ ├── StrangeTestCase.java │ │ ├── TestClasses.java │ │ ├── TestDateTime.java │ │ ├── TopObjectPropertyTestCase.java │ │ ├── WebOnt208TestCase.java │ │ ├── WebOnt661TestCase.java │ │ ├── WebOntTestCase.java │ │ ├── WebOnt_AnnotationProperty_002_TestCase.java │ │ ├── WebOnt_allValuesFrom_001_TestCase.java │ │ ├── WebOnt_description_logic_209_TestCase.java │ │ ├── WebOnt_description_logic_602_TestCase.java │ │ ├── WebOnt_miscellaneous_002_TestCase.java │ │ └── WebOnt_miscellaneous_wine_TestCase.java │ └── testbase │ │ └── TestBase.java │ └── resources │ ├── AF_OWLS.owl.xml │ ├── AF_miniTambis.owl.xml │ └── host.owl ├── FaCT++.Python ├── .gitignore ├── CMakeLists.txt ├── COPYING ├── MANIFEST.in ├── README.md ├── coras │ ├── bin │ │ ├── coras-debug │ │ ├── coras-load-report │ │ └── coras-query │ ├── coras │ │ ├── __init__.py │ │ ├── cli.py │ │ ├── core.py │ │ ├── debug.py │ │ ├── parser.py │ │ ├── query.py │ │ └── util.py │ ├── doc │ │ ├── cmd.rst │ │ └── tests.rst │ └── integration │ │ ├── family │ │ └── family.n3 │ │ ├── foaf │ │ ├── 01-foaf.sq │ │ ├── 01-result.csv │ │ ├── 02-foaf.sq │ │ ├── 02-result.csv │ │ ├── 03-foaf-ex.n3 │ │ ├── 03-foaf.sq │ │ ├── 03-result.csv │ │ ├── foaf.rdf │ │ └── tbl-foaf-card.n3 │ │ ├── test_coras.py │ │ ├── tsars │ │ ├── 01-result.csv │ │ ├── 01-tsars.sq │ │ ├── 02-result.csv │ │ ├── 02-tsars.sq │ │ └── tsars.rdf │ │ └── zebra │ │ ├── 01-result.csv │ │ ├── 01-zebra.sq │ │ ├── 02-result.csv │ │ ├── 02-zebra.sq │ │ └── zebra.n3 ├── examples │ ├── describe.py │ ├── imply-class.py │ ├── people.rdf │ ├── pizza.owl │ ├── rdf-to-lisp.py │ ├── run-lisp.py │ ├── run-rdf.py │ ├── shuffle-lisp.py │ ├── t_fast.txt │ ├── t_slow.txt │ ├── test-data-cardinality.py │ ├── test-disjoint-classes.py │ ├── test-object-cardinality.py │ ├── test-people.py │ ├── test-pizza.py │ ├── test-property-large.py │ ├── test-property.py │ ├── test-sparql.py │ ├── tsars_corr.lisp │ ├── tsars_corr.rdf │ ├── tsars_orig.lisp │ ├── tsars_orig.rdf │ ├── zebra-dump.py │ ├── zebra-puzzle.py │ ├── zebra_corr.n3 │ ├── zebra_corr_fast_order.lisp │ ├── zebra_corr_slow_order.lisp │ ├── zebra_orig.n3 │ ├── zebra_orig_fast_order.lisp │ └── zebra_orig_slow_order.lisp ├── lib │ ├── FaCT++ │ └── Kernel ├── pyfactxx │ ├── CMakeLists.txt │ ├── __init__.py │ ├── coras │ ├── lib_factxx.pyx │ └── tests │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── test_concept.py │ │ ├── test_d_role.py │ │ ├── test_instance.py │ │ ├── test_o_role.py │ │ ├── test_one_to_one.py │ │ ├── test_query_instances.py │ │ └── test_set_op.py ├── pyproject.toml ├── setup.cfg └── setup.py ├── FaCT++ ├── AD.cpp ├── CMakeLists.txt ├── FaCT.cpp ├── comparser.h ├── comscanner.h ├── lispgrammar.h ├── parser.cpp ├── parser.h ├── scanner.cpp └── scanner.h ├── Kernel ├── Actor.cpp ├── Actor.h ├── AtomicDecomposer.cpp ├── AtomicDecomposer.h ├── BiPointer.h ├── Blocking.cpp ├── BuildDAG.cpp ├── CGLabel.h ├── CMakeLists.txt ├── CWDArray.cpp ├── CWDArray.h ├── CascadedCache.cpp ├── ConceptWithDep.h ├── DLConceptTaxonomy.cpp ├── DLConceptTaxonomy.h ├── DataReasoning.cpp ├── DataReasoning.h ├── DataTypeCenter.cpp ├── DataTypeCenter.h ├── DataTypeComparator.h ├── DeletelessAllocator.h ├── DepSet.h ├── ExtendedDataRange.cpp ├── ExtendedSyntacticLocalityChecker.h ├── GeneralSyntacticLocalityChecker.h ├── Incremental.cpp ├── Input.cpp ├── Kernel.cpp ├── Kernel.h ├── KnowledgeExplorer.cpp ├── KnowledgeExplorer.h ├── LeveLogger.cpp ├── LeveLogger.h ├── LocalityChecker.cpp ├── LocalityChecker.h ├── LogicFeature.cpp ├── LogicFeature.h ├── Modularity.h ├── ModuleMethod.h ├── ModuleType.h ├── OntologyBasedModularizer.h ├── Preprocess.cpp ├── PriorityMatrix.h ├── ProgressIndicatorInterface.h ├── RAutomaton.cpp ├── RAutomaton.h ├── RDF_URIs.h ├── Reasoner.cpp ├── Reasoner.h ├── ReasonerNom.cpp ├── ReasonerNom.h ├── Relevance.cpp ├── RoleMaster.cpp ├── RoleMaster.h ├── SaveLoad.cpp ├── SaveLoadManager.cpp ├── SaveLoadManager.h ├── SearchableStack.h ├── SemanticLocalityChecker.h ├── SigIndex.h ├── SortedReasoning.cpp ├── SyntacticLocalityChecker.h ├── Tactic.cpp ├── TaxGatheringWalker.h ├── Taxonomy.cpp ├── Taxonomy.h ├── TaxonomyCreator.cpp ├── TaxonomyCreator.h ├── ToDoList.h ├── TripleGatherer.h ├── WalkerInterface.h ├── configure.cpp ├── configure.h ├── counter.h ├── cpm.h ├── cppi.h ├── dir_util.cpp ├── dir_util.h ├── dlCompletionGraph.cpp ├── dlCompletionGraph.h ├── dlCompletionTree.cpp ├── dlCompletionTree.h ├── dlCompletionTreeArc.h ├── dlDag.cpp ├── dlDag.h ├── dlTBox.cpp ├── dlTBox.h ├── dlVHash.h ├── dlVHashImpl.h ├── dlVertex.cpp ├── dlVertex.h ├── dltree.cpp ├── dltree.h ├── dumpInterface.cpp ├── dumpInterface.h ├── dumpLisp.cpp ├── dumpLisp.h ├── eFPPCantRegName.h ├── eFPPCycleInRIA.h ├── eFPPInconsistentKB.h ├── eFPPNonSimpleRole.h ├── eFPPSaveLoad.h ├── eFPPTimeout.h ├── eFaCTPlusPlus.h ├── flags.h ├── fpp_assert.h ├── globaldef.h ├── grammar.h ├── growingArrayP.h ├── ifOptions.cpp ├── ifOptions.h ├── logging.h ├── mergeableLabel.h ├── modelCacheConst.h ├── modelCacheIan.cpp ├── modelCacheIan.h ├── modelCacheInterface.h ├── modelCacheSingleton.h ├── parseTime.cpp ├── parseTime.h ├── procTimer.h ├── tAxiom.cpp ├── tAxiom.h ├── tAxiomSet.cpp ├── tAxiomSet.h ├── tBranchingContext.h ├── tConcept.cpp ├── tConcept.h ├── tCounter.h ├── tDLAxiom.cpp ├── tDLAxiom.h ├── tDLExpression.h ├── tDag2Interface.cpp ├── tDag2Interface.h ├── tDataEntry.h ├── tDataType.h ├── tDataTypeBool.h ├── tDataTypeManager.h ├── tDepSet.h ├── tExpressionManager.cpp ├── tExpressionManager.h ├── tExpressionPrinterLISP.h ├── tExpressionTranslator.h ├── tFastSet.h ├── tHeadTailCache.h ├── tIndividual.h ├── tKBFlags.h ├── tLabeller.h ├── tLexeme.h ├── tNAryQueue.h ├── tNECollection.h ├── tNameSet.h ├── tNamedEntry.h ├── tOntology.h ├── tOntologyAtom.h ├── tOntologyLoader.h ├── tOntologyPrinterLISP.h ├── tProgressMonitor.h ├── tRareSaveStack.h ├── tRelated.h ├── tRestorer.h ├── tRole.cpp ├── tRole.h ├── tSaveList.h ├── tSaveStack.h ├── tSetAsTree.h ├── tSignature.h ├── tSignatureUpdater.h ├── taxNamEntry.h ├── taxVertex.cpp ├── taxVertex.h └── tsttree.h ├── README.md └── eclipsefiles └── classpathForOWLAPI4 /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.8.1 3 | parse = (?P\d+)\.(?P\d+)\.(?P\d+) 4 | serialize = {major}.{minor}.{patch} 5 | commit = True 6 | tag = True 7 | 8 | [bumpversion:file:FaCT++.Python/pyfactxx/__init__.py] 9 | search = __version__ = "{current_version}" 10 | replace = __version__ = "{new_version}" 11 | 12 | [bumpversion:file(version):Kernel/Kernel.cpp] 13 | search = Version = "{current_version}-SNAPSHOT" 14 | replace = Version = "{new_version}-SNAPSHOT" 15 | 16 | [bumpversion:file(version):FaCT++.Java/pom.xml] 17 | search = {current_version}-SNAPSHOT 18 | replace = {new_version}-SNAPSHOT 19 | 20 | [bumpversion:file(version):FaCT++.Java/src/main/resources/plugin.xml] 21 | search = {current_version}-SNAPSHOT 22 | replace = {new_version}-SNAPSHOT 23 | 24 | [bumpversion:file(version):FaCT++.Java/src/main/resources/META-INF/MANIFEST.MF] 25 | search = Bundle-Version: {current_version} 26 | replace = Bundle-Version: {new_version} 27 | -------------------------------------------------------------------------------- /.github/hooks/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | declare -r msg=$(< $1); 4 | if grep "Bump version" <<< "$msg" > /dev/null 2>&1; then 5 | today=`date +"%d %B %Y"` 6 | if ! grep "${today}" Kernel/Kernel.cpp > /dev/null 2>&1; then 7 | sed -i "s/ReleaseDate = \"\(.*\)\"/ReleaseDate = \"${today}\"/" Kernel/Kernel.cpp 8 | echo "Release date set; please try committing once again" 9 | exit 1; 10 | else 11 | exit 0; 12 | fi 13 | else 14 | exit 0; 15 | fi -------------------------------------------------------------------------------- /.github/scripts/bumpversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | args="$*" 4 | 5 | while [ $# -gt 0 ] ; do 6 | if [[ "$1" == "--dry-run" ]]; then 7 | echo "Dry run, no change intended" 8 | dryrun=1 9 | fi 10 | shift 11 | done 12 | if [[ -z "$dryrun" ]]; then 13 | today=`date +"%d %B %Y"` 14 | sed -i "s/ReleaseDate = \"\(.*\)\"/ReleaseDate = \"${today}\"/" Kernel/Kernel.cpp 15 | echo "Release date set" 16 | fi 17 | 18 | bumpversion $args 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/build-and-publish.yml: -------------------------------------------------------------------------------- 1 | name: Build and publish pyfactxx 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | build: 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: ["ubuntu-20.04", "windows-latest"] 13 | python-version: ["3.7", "3.8", "3.9", "3.10"] 14 | defaults: 15 | run: 16 | working-directory: ./FaCT++.Python 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | - uses: ilammy/msvc-dev-cmd@v1 21 | - name: Set up Python ${{ matrix.python-version }} 22 | uses: actions/setup-python@v3 23 | with: 24 | python-version: ${{ matrix.python-version }} 25 | - name: Install dependencies 26 | run: | 27 | python -m pip install --upgrade pip 28 | pip install setuptools wheel auditwheel scikit-build cmake cython 29 | - name: Build a wheel 30 | run: | 31 | python setup.py bdist_wheel 32 | - name: Audit a wheel 33 | if: runner.os == 'Linux' 34 | run: | 35 | auditwheel repair --plat manylinux_2_27_x86_64 dist/* 36 | rm -rf dist/* 37 | mv wheelhouse/* dist 38 | - name: Upload artifact 39 | uses: actions/upload-artifact@v3 40 | with: 41 | name: ${{ runner.os }}-${{ matrix.python-version }} 42 | path: FaCT++.Python/dist/pyfactxx* 43 | 44 | publish: 45 | runs-on: ubuntu-latest 46 | needs: build 47 | defaults: 48 | run: 49 | working-directory: ./FaCT++.Python 50 | steps: 51 | - uses: actions/checkout@v3 52 | - name: Set up Python 3.8 53 | uses: actions/setup-python@v3 54 | with: 55 | python-version: 3.8 56 | - name: Install dependencies 57 | run: | 58 | python -m pip install --upgrade pip 59 | pip install setuptools wheel auditwheel scikit-build cmake cython 60 | - name: Build a source distribution 61 | run: | 62 | python setup.py sdist 63 | - name: Download artifacts 64 | uses: actions/download-artifact@v3 65 | with: 66 | path: FaCT++.Python/wheels/ 67 | - name: Move wheels 68 | run: | 69 | mv wheels/*/*.whl dist/ 70 | - name: Publish packages 71 | uses: pypa/gh-action-pypi-publish@release/v1 72 | with: 73 | user: __token__ 74 | password: ${{ secrets.PYPI_API_TOKEN }} 75 | packages_dir: FaCT++.Python/dist -------------------------------------------------------------------------------- /.github/workflows/build-and-test.yml: -------------------------------------------------------------------------------- 1 | name: Build and test pyfactxx 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ $default-branch, "wheels" ] 7 | pull_request: 8 | branches: [ $default-branch, "wheels" ] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | defaults: 15 | run: 16 | working-directory: ./FaCT++.Python 17 | strategy: 18 | matrix: 19 | python-version: ["3.7", "3.8", "3.9", "3.10"] 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - uses: ilammy/msvc-dev-cmd@v1 24 | - name: Set up Python ${{ matrix.python-version }} 25 | uses: actions/setup-python@v3 26 | with: 27 | python-version: ${{ matrix.python-version }} 28 | - name: Install dependencies 29 | run: | 30 | python -m pip install --upgrade pip 31 | pip install scikit-build cmake cython pytest pytest-cov 32 | - name: Install package 33 | working-directory: ./FaCT++.Python 34 | run: | 35 | pip install -e . 36 | - name: Test with pytest 37 | run: | 38 | pytest FaCT++.Python 39 | -------------------------------------------------------------------------------- /.github/workflows/codacy-analysis.yml: -------------------------------------------------------------------------------- 1 | name: Codacy Security Scan 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [ master ] 9 | schedule: 10 | - cron: '32 23 * * 5' 11 | 12 | jobs: 13 | codacy-security-scan: 14 | name: Codacy Security Scan 15 | runs-on: ubuntu-latest 16 | steps: 17 | # Checkout the repository to the GitHub Actions runner 18 | - name: Checkout code 19 | uses: actions/checkout@v2 20 | 21 | # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis 22 | - name: Run Codacy Analysis CLI 23 | uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b 24 | with: 25 | # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository 26 | # You can also omit the token and run the tools that support default configurations 27 | project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} 28 | verbose: true 29 | output: results.sarif 30 | format: sarif 31 | # Adjust severity of non-security issues 32 | gh-code-scanning-compat: true 33 | # Force 0 exit code to allow SARIF file generation 34 | # This will handover control about PR rejection to the GitHub side 35 | max-allowed-issues: 2147483647 36 | 37 | # Upload the SARIF file generated in the previous step 38 | - name: Upload SARIF results file 39 | uses: github/codeql-action/upload-sarif@v1 40 | with: 41 | sarif_file: results.sarif 42 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [ master ] 9 | schedule: 10 | - cron: '30 3 * * 0' 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | permissions: 17 | actions: read 18 | contents: read 19 | security-events: write 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | language: [ 'cpp', 'java', 'python' ] 25 | 26 | steps: 27 | - name: Checkout repository 28 | uses: actions/checkout@v2 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v1 33 | with: 34 | languages: ${{ matrix.language }} 35 | # If you wish to specify custom queries, you can do so here or in a config file. 36 | # By default, queries listed here will override any specified in a config file. 37 | # Prefix the list here with "+" to use these queries and those in the config file. 38 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 39 | 40 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 41 | # If this step fails, then you should remove it and run the build manually (see below) 42 | - name: Autobuild 43 | uses: github/codeql-action/autobuild@v1 44 | 45 | # ℹ️ Command-line programs to run using the OS shell. 46 | # 📚 https://git.io/JvXDl 47 | 48 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 49 | # and modify them (or add more) to build your code if your project 50 | # uses a compiled language 51 | 52 | #- run: | 53 | # make bootstrap 54 | # make release 55 | 56 | - name: Perform CodeQL Analysis 57 | uses: github/codeql-action/analyze@v1 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .pytest_cache 3 | .classpath 4 | *~ 5 | /bin/ 6 | build/** 7 | .vscode 8 | .coverage 9 | 10 | # cmake files 11 | CMakeCache.txt 12 | *.cmake 13 | Makefile 14 | CMakeFiles/ 15 | 16 | # Targets 17 | fact_test 18 | libfact.so 19 | libKernel.* -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | title: pyfactxx 3 | type: software 4 | license: GPL-3.0 5 | authors: 6 | - given-names: Artur 7 | family-names: Wroblewski 8 | orcid: 'https://orcid.org/0009-0003-8000-5716' 9 | - given-names: Ivan 10 | family-names: Rygaev 11 | orcid: 'https://orcid.org/0000-0003-4135-6954' 12 | - given-names: Andrey 13 | family-names: Sobolev 14 | orcid: 'https://orcid.org/0000-0001-5086-6601' 15 | - given-names: Evgeny 16 | family-names: Blokhin 17 | orcid: 'https://orcid.org/0000-0002-5333-3947' 18 | doi: 10.5281/zenodo.7693502 19 | url: 'https://github.com/tilde-lab/pyfactxx' 20 | repository-artifact: 'https://pypi.org/project/pyfactxx' 21 | keywords: 22 | - semantic web 23 | - OWL 24 | - ontology 25 | - rdflib 26 | - reasoner 27 | - description logic 28 | - owlapi 29 | - reasoner benchmark 30 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(factplusplus) 3 | 4 | # global definition 5 | set(CMAKE_CXX_STANDARD 11) 6 | 7 | option(FPP_USE_LOGGING "Switch on FaCT++ internal logging" OFF) 8 | 9 | # define warnings/optimisaiton flags for GCC/CLANG compilers 10 | if (NOT MSVC) 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -ffast-math -fPIC -fomit-frame-pointer") 12 | # Additional warnings (from GCC 6.2) 13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic -Wsuggest-override") 14 | else() 15 | # Set exception handling in VC++ 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") 17 | # Disable warning about treating int as bool in VC++ 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") 19 | endif() 20 | 21 | if (FPP_USE_LOGGING) 22 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LOGGING=1") 23 | endif() 24 | 25 | add_subdirectory(Kernel) 26 | add_subdirectory(FaCT++) 27 | add_subdirectory(FaCT++.C) 28 | add_subdirectory(FaCT++.JNI) 29 | add_subdirectory(FaCT++.Python) 30 | -------------------------------------------------------------------------------- /FaCT++.C/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | 3 | set(SOURCE_FILES 4 | fact.cpp 5 | fact.h 6 | ) 7 | 8 | add_library(fact SHARED ${SOURCE_FILES}) 9 | target_link_libraries(fact LINK_PUBLIC Kernel) 10 | 11 | add_executable(fact_test test.c) 12 | target_link_libraries(fact_test LINK_PUBLIC Kernel fact) 13 | 14 | # allow library users to find headers 15 | target_include_directories(fact PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 16 | -------------------------------------------------------------------------------- /FaCT++.JNI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | 3 | # We are using JNI and need to #include 4 | find_package(JNI REQUIRED) 5 | 6 | set(SOURCE_FILES 7 | Axioms.cpp 8 | Expressions.cpp 9 | FaCTPlusPlus.cpp 10 | JNIActor.h 11 | JNIMonitor.h 12 | JNISupport.h 13 | KnowledgeExploration.cpp 14 | MemoryStat.cpp 15 | MemoryStat.h 16 | Modularity.cpp 17 | Queries.cpp 18 | SaveLoad.cpp 19 | tJNICache.h 20 | uk_ac_manchester_cs_factplusplus_FaCTPlusPlus.h 21 | ) 22 | 23 | # JNI Library should be declared as MODULE 24 | add_library(FaCTPlusPlusJNI MODULE ${SOURCE_FILES}) 25 | target_link_libraries(FaCTPlusPlusJNI LINK_PUBLIC Kernel) 26 | # Include search path for jni.h and jni_md.h 27 | include_directories( 28 | ${JAVA_INCLUDE_PATH} 29 | ${JAVA_INCLUDE_PATH2} 30 | ) 31 | 32 | # allow library users to find headers 33 | target_include_directories(FaCTPlusPlusJNI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 34 | -------------------------------------------------------------------------------- /FaCT++.JNI/MemoryStat.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2013-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MEMORYSTAT_H 21 | #define MEMORYSTAT_H 22 | 23 | #include 24 | #include 25 | 26 | #include "procTimer.h" 27 | 28 | /// class for measuring time and memory 29 | class MemoryStatistics 30 | { 31 | protected: // members 32 | TsProcTimer timer; 33 | std::string operation; 34 | size_t startMem; 35 | 36 | public: 37 | /// c'tor: start timer, save memory usage 38 | explicit MemoryStatistics ( const std::string& name ); 39 | /// d'tor: dump taken time and memory usage 40 | ~MemoryStatistics(); 41 | }; // MemoryStatistics 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /FaCT++.Java/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/AxiomPointer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2007, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class AxiomPointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/ClassPointer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2009-2010, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class ClassPointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/DataPropertyPointer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2009-2010, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class DataPropertyPointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/DataTypeExpressionPointer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2009-2010, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class DataTypeExpressionPointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/DataTypeFacet.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /** 4 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 5 | * Group, 10-Jul-2006 6 | */ 7 | public class DataTypeFacet extends Pointer {} 8 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/DataTypePointer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2009-2010, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class DataTypePointer extends DataTypeExpressionPointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/DataValuePointer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2010, University of Manchester 3 | * 4 | * Modifications to the initial code base are copyright of their 5 | * respective authors, or their employers as appropriate. Authorship 6 | * of the modifications may be determined from the ChangeLog placed at 7 | * the end of this file. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | package uk.ac.manchester.cs.factplusplus; 24 | 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class DataValuePointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/FaCTPlusPlusException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | import org.semanticweb.owlapi.model.OWLRuntimeException; 4 | 5 | /* 6 | * Copyright (C) 2007, University of Manchester 7 | * 8 | * Modifications to the initial code base are copyright of their 9 | * respective authors, or their employers as appropriate. Authorship 10 | * of the modifications may be determined from the ChangeLog placed at 11 | * the end of this file. 12 | * 13 | * This library is free software; you can redistribute it and/or 14 | * modify it under the terms of the GNU Lesser General Public 15 | * License as published by the Free Software Foundation; either 16 | * version 2.1 of the License, or (at your option) any later version. 17 | 18 | * This library is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * Lesser General Public License for more details. 22 | 23 | * You should have received a copy of the GNU Lesser General Public 24 | * License along with this library; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | */ 27 | /** 28 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 29 | * Group, 10-Jul-2006 30 | */ 31 | public class FaCTPlusPlusException extends OWLRuntimeException { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | /** 36 | * @param message 37 | * message 38 | */ 39 | public FaCTPlusPlusException(String message) { 40 | super(message); 41 | } 42 | 43 | /** 44 | * @param message 45 | * message 46 | * @param cause 47 | * cause 48 | */ 49 | public FaCTPlusPlusException(String message, Throwable cause) { 50 | super(message, cause); 51 | } 52 | 53 | /** 54 | * @param cause 55 | * cause 56 | */ 57 | public FaCTPlusPlusException(Throwable cause) { 58 | super(cause); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/FaCTPlusPlusProgressMonitor.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /** 4 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 5 | * Group, 10-Jul-2006 6 | */ 7 | public interface FaCTPlusPlusProgressMonitor { 8 | 9 | /** 10 | * @param classCount 11 | * number of classes 12 | */ 13 | void setClassificationStarted(int classCount); 14 | 15 | /** 16 | * move to next class 17 | */ 18 | void nextClass(); 19 | 20 | /** 21 | * finish classification 22 | */ 23 | void setFinished(); 24 | 25 | /** 26 | * @return true if cancelled 27 | */ 28 | boolean isCancelled(); 29 | } 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/IndividualPointer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2010, University of Manchester 3 | * 4 | * Modifications to the initial code base are copyright of their 5 | * respective authors, or their employers as appropriate. Authorship 6 | * of the modifications may be determined from the ChangeLog placed at 7 | * the end of this file. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | package uk.ac.manchester.cs.factplusplus; 24 | 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class IndividualPointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/NodePointer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2010, University of Manchester 3 | * 4 | * Modifications to the initial code base are copyright of their 5 | * respective authors, or their employers as appropriate. Authorship 6 | * of the modifications may be determined from the ChangeLog placed at 7 | * the end of this file. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | package uk.ac.manchester.cs.factplusplus; 24 | 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class NodePointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/ObjectPropertyPointer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2010, University of Manchester 3 | * 4 | * Modifications to the initial code base are copyright of their 5 | * respective authors, or their employers as appropriate. Authorship 6 | * of the modifications may be determined from the ChangeLog placed at 7 | * the end of this file. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | package uk.ac.manchester.cs.factplusplus; 24 | 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class ObjectPropertyPointer extends Pointer {} 30 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/Pointer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2009-2010, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class Pointer { 30 | 31 | private long node = 0; 32 | 33 | /** 34 | * @return node pointer 35 | */ 36 | public long getNode() { 37 | return node; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return (int) node; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object obj) { 47 | if (obj == null) { 48 | return false; 49 | } 50 | if (this == obj) { 51 | return true; 52 | } 53 | if (!(obj instanceof Pointer)) { 54 | return false; 55 | } 56 | return ((Pointer) obj).node == node; 57 | } 58 | 59 | @Override 60 | public final String toString() { 61 | return this.getClass().getSimpleName() + "[" + node + "]"; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/QuietProgressMonitor.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus; 2 | 3 | /* 4 | * Copyright (C) 2006, University of Manchester 5 | * 6 | * Modifications to the initial code base are copyright of their 7 | * respective authors, or their employers as appropriate. Authorship 8 | * of the modifications may be determined from the ChangeLog placed at 9 | * the end of this file. 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | /** 26 | * @author Matthew Horridge, The University Of Manchester, Medical Informatics 27 | * Group, 10-Jul-2006 28 | */ 29 | public class QuietProgressMonitor implements FaCTPlusPlusProgressMonitor { 30 | 31 | @Override 32 | public void setClassificationStarted(int classCount) {} 33 | 34 | @Override 35 | public void nextClass() {} 36 | 37 | @Override 38 | public void setFinished() {} 39 | 40 | @Override 41 | public boolean isCancelled() { 42 | return false; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/owlapiv3/ModuleMethod.java: -------------------------------------------------------------------------------- 1 | /* This file is part of the OWL API. 2 | * The contents of this file are subject to the LGPL License, Version 3.0. 3 | * Copyright 2014, The University of Manchester 4 | * 5 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 7 | * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. 8 | * 9 | * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ 13 | package uk.ac.manchester.cs.factplusplus.owlapiv3; 14 | 15 | /** 16 | * Module methods - for use with Chiara and Dmitry's implementation of 17 | * modularisation and atomic decomposition, as implemented in FaCT++/OWLAPITOOLS 18 | */ 19 | public enum ModuleMethod { 20 | /** Standard syntactic modules */ 21 | SYNTACTIC_STANDARD, 22 | /** Syntactic modules with counting */ 23 | SYNTACTIC_COUNTING, 24 | /** Semantic modules */ 25 | SEMANTIC 26 | } 27 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/java/uk/ac/manchester/cs/factplusplus/protege/FaCTPlusPlusRenderingViewComponent.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.factplusplus.protege; 2 | 3 | import org.protege.editor.owl.ui.view.ontology.AbstractOntologyRenderingViewComponent; 4 | import org.semanticweb.owlapi.model.OWLOntology; 5 | 6 | import java.io.Writer; 7 | 8 | /* 9 | * Copyright (C) 2007, University of Manchester 10 | * 11 | * Modifications to the initial code base are copyright of their 12 | * respective authors, or their employers as appropriate. Authorship 13 | * of the modifications may be determined from the ChangeLog placed at 14 | * the end of this file. 15 | * 16 | * This library is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU Lesser General Public 18 | * License as published by the Free Software Foundation; either 19 | * version 2.1 of the License, or (at your option) any later version. 20 | 21 | * This library is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | * Lesser General Public License for more details. 25 | 26 | * You should have received a copy of the GNU Lesser General Public 27 | * License along with this library; if not, write to the Free Software 28 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 29 | */ 30 | /** 31 | * Author: Matthew Horridge
32 | * The University Of Manchester
33 | * Bio-Health Informatics Group
34 | * Date: 08-Aug-2007
35 | *
36 | */ 37 | public class FaCTPlusPlusRenderingViewComponent extends 38 | AbstractOntologyRenderingViewComponent { 39 | 40 | protected void renderOntology(OWLOntology ontology, Writer writer) 41 | throws Exception { 42 | writer.append("Not implemented for owlapi v3"); 43 | // FaCTPlusPlusRenderer renderer = new FaCTPlusPlusRenderer(writer); 44 | // ontology.accept(renderer); 45 | // writer.flush(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Factplusplus Plug-in 4 | Bundle-SymbolicName: uk.ac.manchester.cs.owl.factplusplus;singleton:=true 5 | Bundle-Version: 1.8.1 6 | Bundle-Vendor: University of Manchester 7 | Bundle-Description: A Protege OWL wrapper for FaCT++ 8 | Update-Url: https://bitbucket.org/dtsarkov/factplusplus/downloads/config.autoupdate.Protege-5.0.txt 9 | Bundle-ClassPath: . 10 | Import-Package: org.osgi.framework, 11 | org.apache.log4j, 12 | javax.swing, 13 | javax.xml.datatype 14 | Require-Bundle: org.protege.common, 15 | org.protege.editor.core.application, 16 | org.protege.editor.owl, 17 | org.semanticweb.owl.owlapi 18 | Bundle-NativeCode: lib/native/64bit/FaCTPlusPlusJNI.dll; 19 | osname=win ; 20 | osname=WindowsNT ; 21 | osname=Windows NT ; 22 | osname=WinNT ; 23 | osname=WindowsXP ; 24 | osname=Windows XP ; 25 | osname=WinXP ; 26 | osname=WindowsVista ; 27 | osname=Windows Vista ; 28 | osname=Windows2003 ; 29 | osname=Windows2008 ; 30 | osname=Win7 ; 31 | osname=Windows7 ; 32 | osname=Windows 7 ; 33 | osname=Win8 ; 34 | osname=Windows8 ; 35 | osname=Windows 8 ; 36 | osname=Windows8.1 ; 37 | osname=Windows 8.1 ; 38 | processor=x86_64 ; 39 | processor=amd64 , 40 | lib/native/32bit/FaCTPlusPlusJNI.dll; 41 | osname=win ; 42 | osname=Windows95 ; 43 | osname=Windows 95 ; 44 | osname=Win95 ; 45 | osname=Windows98 ; 46 | osname=Windows 98 ; 47 | osname=Win98 ; 48 | osname=WindowsNT ; 49 | osname=Windows NT ; 50 | osname=WinNT ; 51 | osname=WindowsCE ; 52 | osname=Windows CE ; 53 | osname=WinCE ; 54 | osname=WindowsXP ; 55 | osname=Windows XP ; 56 | osname=WinXP ; 57 | osname=WindowsVista ; 58 | osname=Windows Vista ; 59 | osname=Windows2003 ; 60 | osname=Windows2008 ; 61 | osname=Win7 ; 62 | osname=Windows7 ; 63 | osname=Windows 7 ; 64 | osname=Win8 ; 65 | osname=Windows8 ; 66 | osname=Windows 8 ; 67 | osname=Windows8.1 ; 68 | osname=Windows 8.1 ; 69 | processor=i386 ; 70 | processor=x86 , 71 | lib/native/64bit/libFaCTPlusPlusJNI.so; 72 | osname=Linux ; 73 | processor=x86_64 ; 74 | processor=amd64 , 75 | lib/native/32bit/libFaCTPlusPlusJNI.so; 76 | osname=Linux ; 77 | processor=i386 , 78 | lib/native/64bit/libFaCTPlusPlusJNI.jnilib; 79 | osname=MacOSX ; 80 | osname=Mac OS X ; 81 | processor=x86_64 , 82 | lib/native/32bit/libFaCTPlusPlusJNI.jnilib; 83 | osname=MacOSX ; 84 | osname=Mac OS X ; 85 | processor=i386 86 | -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/lib/native/32bit/FaCTPlusPlusJNI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tilde-lab/pyfactxx/8f1cb7da36d8fe8f911b27275f80572f430af773/FaCT++.Java/src/main/resources/lib/native/32bit/FaCTPlusPlusJNI.dll -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/lib/native/32bit/libFaCTPlusPlusJNI.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tilde-lab/pyfactxx/8f1cb7da36d8fe8f911b27275f80572f430af773/FaCT++.Java/src/main/resources/lib/native/32bit/libFaCTPlusPlusJNI.jnilib -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/lib/native/32bit/libFaCTPlusPlusJNI.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tilde-lab/pyfactxx/8f1cb7da36d8fe8f911b27275f80572f430af773/FaCT++.Java/src/main/resources/lib/native/32bit/libFaCTPlusPlusJNI.so -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/lib/native/64bit/FaCTPlusPlusJNI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tilde-lab/pyfactxx/8f1cb7da36d8fe8f911b27275f80572f430af773/FaCT++.Java/src/main/resources/lib/native/64bit/FaCTPlusPlusJNI.dll -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/lib/native/64bit/libFaCTPlusPlusJNI.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tilde-lab/pyfactxx/8f1cb7da36d8fe8f911b27275f80572f430af773/FaCT++.Java/src/main/resources/lib/native/64bit/libFaCTPlusPlusJNI.jnilib -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/lib/native/64bit/libFaCTPlusPlusJNI.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tilde-lab/pyfactxx/8f1cb7da36d8fe8f911b27275f80572f430af773/FaCT++.Java/src/main/resources/lib/native/64bit/libFaCTPlusPlusJNI.so -------------------------------------------------------------------------------- /FaCT++.Java/src/main/resources/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 11 | 12 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/bugs/VerifyComplianceHostTestCase.java: -------------------------------------------------------------------------------- 1 | package bugs; 2 | 3 | import org.junit.Test; 4 | import org.semanticweb.owlapi.model.OWLClass; 5 | 6 | @SuppressWarnings("javadoc") 7 | public class VerifyComplianceHostTestCase extends VerifyComplianceBase { 8 | 9 | @Override 10 | protected String input() { 11 | return "/host.owl"; 12 | } 13 | 14 | @Test 15 | public void shouldPassgetSubClassesDbXreftrue() { 16 | OWLClass Nothing = C("http://www.w3.org/2002/07/owl#Nothing"); 17 | OWLClass DbXref = C("http://www.geneontology.org/formats/oboInOwl#DbXref"); 18 | // expected Nothing 19 | // actual__ DbXref, true 20 | equal(reasoner.getSubClasses(DbXref, true), Nothing); 21 | } 22 | 23 | @Test 24 | public void shouldPassgetSubClassesSynonymtrue() { 25 | OWLClass Nothing = C("http://www.w3.org/2002/07/owl#Nothing"); 26 | OWLClass Synonym = C("http://www.geneontology.org/formats/oboInOwl#Synonym"); 27 | // expected Nothing 28 | // actual__ Synonym, true 29 | equal(reasoner.getSubClasses(Synonym, true), Nothing); 30 | } 31 | 32 | @Test 33 | public void shouldPassgetSubClassesDefinitiontrue() { 34 | OWLClass Nothing = C("http://www.w3.org/2002/07/owl#Nothing"); 35 | OWLClass Definition = C("http://www.geneontology.org/formats/oboInOwl#Definition"); 36 | // expected Nothing 37 | // actual__ Definition, true 38 | equal(reasoner.getSubClasses(Definition, true), Nothing); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/bugs/VerifyComplianceMiniTambisTestCase.java: -------------------------------------------------------------------------------- 1 | package bugs; 2 | 3 | @SuppressWarnings("javadoc") 4 | public class VerifyComplianceMiniTambisTestCase extends VerifyComplianceBase { 5 | 6 | @Override 7 | protected String input() { 8 | return "/AF_miniTambis.owl.xml"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/conformancetests/Changed.java: -------------------------------------------------------------------------------- 1 | package conformancetests; 2 | 3 | /* This file is part of the JFact DL reasoner 4 | Copyright 2011-2013 by Ignazio Palmisano, Dmitry Tsarkov, University of Manchester 5 | This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 6 | This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 7 | You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | 12 | /** 13 | * Denotes a change in tests. 14 | * 15 | * @author ignazio 16 | */ 17 | @Retention(RetentionPolicy.CLASS) 18 | @Documented 19 | public @interface Changed { 20 | 21 | /** @return reason for the change to have happened */ 22 | String reason() default "Not OWL 2 Compliant"; 23 | } 24 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/conformancetests/HasSelfSupportTestCase.java: -------------------------------------------------------------------------------- 1 | package conformancetests; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | import org.semanticweb.owlapi.apibinding.OWLManager; 7 | import org.semanticweb.owlapi.io.StringDocumentSource; 8 | import org.semanticweb.owlapi.model.OWLOntology; 9 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 10 | import org.semanticweb.owlapi.model.OWLOntologyManager; 11 | import org.semanticweb.owlapi.reasoner.InferenceType; 12 | import org.semanticweb.owlapi.reasoner.OWLReasoner; 13 | 14 | import testbase.TestBase; 15 | 16 | @SuppressWarnings("javadoc") 17 | public class HasSelfSupportTestCase extends TestBase { 18 | 19 | @Test 20 | public void shouldBeConsistent() throws OWLOntologyCreationException { 21 | String input = "Prefix(owl:=)\n" 22 | + "Prefix(rdf:=)\n" 23 | + "Prefix(xml:=)\n" 24 | + "Prefix(xsd:=)\n" 25 | + "Prefix(rdfs:=)\n" 26 | + "\n" 27 | + "\n" 28 | + "Ontology(\n" 29 | + "SubClassOf( ObjectHasSelf())\n" 30 | + ")"; 31 | OWLOntologyManager m = OWLManager.createOWLOntologyManager(); 32 | OWLOntology o = m 33 | .loadOntologyFromOntologyDocument(new StringDocumentSource( 34 | input)); 35 | OWLReasoner r = factory().createReasoner(o); 36 | r.precomputeInferences(InferenceType.CLASS_HIERARCHY); 37 | assertTrue(r.isConsistent()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/conformancetests/JUnitRunnerFromFile.java: -------------------------------------------------------------------------------- 1 | package conformancetests; 2 | 3 | /* This file is part of the JFact DL reasoner 4 | Copyright 2011-2013 by Ignazio Palmisano, Dmitry Tsarkov, University of Manchester 5 | This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 6 | This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 7 | You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ 8 | import java.io.BufferedReader; 9 | import java.io.File; 10 | import java.io.FileInputStream; 11 | import java.io.InputStreamReader; 12 | import java.io.Reader; 13 | 14 | @SuppressWarnings("javadoc") 15 | public class JUnitRunnerFromFile extends JUnitRunner { 16 | 17 | public static String readFile(File f) { 18 | StringBuilder b = new StringBuilder(); 19 | try (FileInputStream in = new FileInputStream(f); 20 | Reader reader = new InputStreamReader(in); 21 | BufferedReader r = new BufferedReader(reader);) { 22 | String l = r.readLine(); 23 | while (l != null) { 24 | b.append(l); 25 | b.append('\n'); 26 | l = r.readLine(); 27 | } 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | throw new RuntimeException(e); 31 | } 32 | return b.toString(); 33 | } 34 | 35 | public JUnitRunnerFromFile(File premise, File consequence, String testId, 36 | TestClasses t, String description) { 37 | super(readFile(premise), readFile(consequence), testId, t, description); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/conformancetests/StrangeTestCase.java: -------------------------------------------------------------------------------- 1 | package conformancetests; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Set; 6 | 7 | import org.junit.Test; 8 | import org.semanticweb.owlapi.apibinding.OWLManager; 9 | import org.semanticweb.owlapi.model.IRI; 10 | import org.semanticweb.owlapi.model.OWLClass; 11 | import org.semanticweb.owlapi.model.OWLDataFactory; 12 | import org.semanticweb.owlapi.model.OWLOntology; 13 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 14 | import org.semanticweb.owlapi.model.OWLOntologyManager; 15 | import org.semanticweb.owlapi.reasoner.InferenceType; 16 | import org.semanticweb.owlapi.reasoner.NodeSet; 17 | import org.semanticweb.owlapi.reasoner.OWLReasoner; 18 | 19 | import testbase.TestBase; 20 | 21 | @SuppressWarnings("javadoc") 22 | public class StrangeTestCase extends TestBase { 23 | 24 | @Test 25 | public void shouldFindThreeSubclasses() throws OWLOntologyCreationException { 26 | OWLOntologyManager m = OWLManager.createOWLOntologyManager(); 27 | OWLOntology o = m.createOntology(); 28 | OWLDataFactory d = m.getOWLDataFactory(); 29 | m.addAxiom( 30 | o, 31 | d.getOWLSubClassOfAxiom(d.getOWLClass(IRI.create("urn:b")), 32 | d.getOWLClass(IRI.create("urn:c")))); 33 | m.addAxiom( 34 | o, 35 | d.getOWLSubClassOfAxiom(d.getOWLClass(IRI.create("urn:a")), 36 | d.getOWLClass(IRI.create("urn:b")))); 37 | OWLReasoner r = factory().createReasoner(o); 38 | r.precomputeInferences(InferenceType.CLASS_HIERARCHY); 39 | NodeSet subClasses = r.getSubClasses( 40 | d.getOWLClass(IRI.create("urn:c")), false); 41 | Set flat = subClasses.getFlattened(); 42 | assertEquals(flat.toString(), 3, flat.size()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/conformancetests/TestClasses.java: -------------------------------------------------------------------------------- 1 | package conformancetests; 2 | 3 | /* This file is part of the JFact DL reasoner 4 | Copyright 2011-2013 by Ignazio Palmisano, Dmitry Tsarkov, University of Manchester 5 | This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 6 | This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 7 | You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ 8 | @SuppressWarnings("javadoc") 9 | public enum TestClasses { 10 | POSITIVE_IMPL, NEGATIVE_IMPL, INCONSISTENCY, CONSISTENCY; 11 | } 12 | -------------------------------------------------------------------------------- /FaCT++.Java/src/test/java/testbase/TestBase.java: -------------------------------------------------------------------------------- 1 | package testbase; 2 | 3 | import org.junit.Before; 4 | import org.junit.BeforeClass; 5 | import org.semanticweb.owlapi.apibinding.OWLManager; 6 | import org.semanticweb.owlapi.model.OWLDataFactory; 7 | import org.semanticweb.owlapi.model.OWLOntology; 8 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 9 | import org.semanticweb.owlapi.model.OWLOntologyManager; 10 | import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; 11 | 12 | import uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory; 13 | 14 | import uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl; 15 | import uk.ac.manchester.cs.owl.owlapi.concurrent.NoOpReadWriteLock; 16 | 17 | @SuppressWarnings("javadoc") 18 | public class TestBase { 19 | 20 | protected static OWLDataFactory df; 21 | protected static OWLOntologyManager masterManager; 22 | protected OWLOntologyManager m; 23 | 24 | protected OWLOntology asString(OWLOntologyManager man, String resource) throws OWLOntologyCreationException { 25 | return man.loadOntologyFromOntologyDocument(getClass().getResourceAsStream(resource)); 26 | } 27 | 28 | @BeforeClass 29 | public static void setupManagers() { 30 | masterManager = OWLManager.createOWLOntologyManager(); 31 | df = masterManager.getOWLDataFactory(); 32 | } 33 | 34 | @Before 35 | public void setupManagersClean() { 36 | m = setupManager(); 37 | } 38 | 39 | protected static OWLOntologyManager setupManager() { 40 | OWLOntologyManager manager = new OWLOntologyManagerImpl(df, new NoOpReadWriteLock()); 41 | manager.getOntologyFactories().set(masterManager.getOntologyFactories()); 42 | manager.getOntologyParsers().set(masterManager.getOntologyParsers()); 43 | manager.getOntologyStorers().set(masterManager.getOntologyStorers()); 44 | manager.getIRIMappers().set(masterManager.getIRIMappers()); 45 | return manager; 46 | } 47 | 48 | protected static OWLReasonerFactory factory() { 49 | return new FaCTPlusPlusReasonerFactory(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /FaCT++.Python/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignored files from Python project 2 | __pycache__/ 3 | *.egg-info/ 4 | *.so 5 | dist/ 6 | MANIFEST 7 | 8 | # cythonized files 9 | pyfactxx/*.cpp 10 | pyfactxx/*.so 11 | 12 | # scikit-build files 13 | _skbuild/ 14 | -------------------------------------------------------------------------------- /FaCT++.Python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_VERBOSE_MAKEFILE ON) 2 | cmake_minimum_required(VERSION 3.13.0) 3 | set(CMAKE_CXX_STANDARD 11) 4 | find_program(PYTHON "python") 5 | 6 | if (PYTHON) 7 | 8 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 9 | 10 | set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") 11 | set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/pyfactxx/__init__.py") 12 | set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp") 13 | 14 | add_custom_command(OUTPUT ${OUTPUT} 15 | COMMAND ${PYTHON} ${SETUP_PY} build 16 | COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} 17 | DEPENDS ${DEPS}) 18 | 19 | add_custom_target(pyfactxx-build ALL DEPENDS ${OUTPUT}) 20 | 21 | install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") 22 | endif() -------------------------------------------------------------------------------- /FaCT++.Python/MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include CMakeLists.txt 2 | prune _skbuild/ 3 | recursive-include pyfactxx *.py *.pyx 4 | prune pyfactxx/tests 5 | graft lib 6 | include COPYING pyproject.toml README.md setup.py 7 | -------------------------------------------------------------------------------- /FaCT++.Python/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /FaCT++.Python/coras/bin/coras-debug: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Coras - OWL reasoning system 4 | # 5 | # Copyright (C) 2018 by Artur Wroblewski 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | import argparse 22 | import logging 23 | import os.path 24 | import pprint 25 | import sys 26 | 27 | import pyfactxx.coras 28 | from pyfactxx.coras.cli import load_and_parse 29 | 30 | logger = logging.getLogger('coras') 31 | 32 | parser = argparse.ArgumentParser() 33 | parser.add_argument('input', nargs='+', help='Ontology files') 34 | 35 | args = parser.parse_args() 36 | 37 | logging.basicConfig( 38 | format='%(levelname)s:%(asctime)s:%(name)s:%(message)s', 39 | level=logging.DEBUG 40 | ) 41 | 42 | crs = pyfactxx.coras.Coras() 43 | load_and_parse(crs, *args.input) 44 | # crs.realise() # TODO: check for consistency as well 45 | 46 | logger.debug( 47 | 'Python reference cache:\n{}' 48 | .format(pprint.pformat(crs._reasoner._cache)) 49 | ) 50 | 51 | # vim: sw=4:et:ai 52 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/bin/coras-load-report: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Coras - OWL reasoning system 4 | # 5 | # Copyright (C) 2018 by Artur Wroblewski 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | grep '^DEBUG:.*:coras.debug:\(unsupported\|meta\)' \ 22 | | sed 's/^DEBUG:.*:coras.debug://' \ 23 | | awk '$3 ~ /rdf-syntax-ns.type|rdf-schema.subPropertyOf|rdf-schema.domain|rdf-schema.range/ {print $1 " " $3 " " $4; next } { print $1 " " $3 }' \ 24 | | sort \ 25 | | uniq -c 26 | 27 | # vim: sw=4:et:ai 28 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/bin/coras-query: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Coras - OWL reasoning system 4 | # 5 | # Copyright (C) 2018 by Artur Wroblewski 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | import argparse 22 | import logging 23 | import os.path 24 | import sys 25 | 26 | import pyfactxx.coras 27 | from pyfactxx.coras.cli import load_and_parse 28 | 29 | parser = argparse.ArgumentParser() 30 | parser.add_argument( 31 | '-v', '--verbose', dest='verbose', help='Make a bunch of noise', 32 | action='store_true' 33 | ) 34 | parser.add_argument( 35 | 'query', 36 | help='File with SPARQL query to run against the ontology', 37 | ) 38 | parser.add_argument('input', nargs='+', help='Ontology files') 39 | 40 | args = parser.parse_args() 41 | 42 | if args.verbose: 43 | log_level = logging.DEBUG 44 | else: 45 | log_level = logging.INFO 46 | logging.basicConfig( 47 | format='%(levelname)s:%(asctime)s:%(name)s:%(message)s', 48 | level=log_level 49 | ) 50 | 51 | # silence very noisy parser debug statements; use `coras-debug` script instead 52 | for item in ('coras.debug', 'coras.parser'): 53 | logger = logging.getLogger(item) 54 | logger.setLevel(logging.INFO) 55 | 56 | crs = pyfactxx.coras.Coras() 57 | load_and_parse(crs, *args.input) 58 | crs.realise() 59 | 60 | with open(args.query) as f: 61 | sq = f.read() 62 | 63 | for row in crs.query(sq): 64 | print(' '.join(str(s) for s in row)) 65 | 66 | # vim: sw=4:et:ai 67 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/coras/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Coras - OWL reasoning system 3 | # 4 | # Copyright (C) 2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from .core import Coras 21 | 22 | # vim: sw=4:et:ai 23 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/coras/cli.py: -------------------------------------------------------------------------------- 1 | # 2 | # Coras - OWL reasoning system 3 | # 4 | # Copyright (C) 2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | def load_and_parse(crs, *input): 21 | crs.load_and_parse(*input) 22 | 23 | # vim: sw=4:et:ai 24 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/coras/debug.py: -------------------------------------------------------------------------------- 1 | # 2 | # Coras - OWL reasoning system 3 | # 4 | # Copyright (C) 2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import os 21 | import functools 22 | import itertools 23 | import logging 24 | from copy import deepcopy 25 | 26 | from rdflib.namespace import DC, RDF, RDFS, OWL, Namespace 27 | 28 | logger = logging.getLogger(__name__) 29 | 30 | DEBUG_ENABLED = int(os.environ.get('CORAS_PARSER_DEBUG', 0)) 31 | 32 | VS = Namespace('http://www.w3.org/2003/06/sw-vocab-status/ns#') 33 | META = { 34 | DC.description, 35 | DC.title, 36 | (RDF.type, RDF.Property), 37 | RDFS.comment, 38 | RDFS.label, 39 | RDFS.isDefinedBy, 40 | OWL.versionInfo, 41 | (RDF.type, OWL.AnnotationProperty), 42 | (RDF.type, OWL.Ontology), 43 | VS.term_status, 44 | } 45 | 46 | def register(f): 47 | @functools.wraps(f) 48 | def func(graph, *args): 49 | start_debug(graph) 50 | result = f(graph, *args) 51 | end_debug() 52 | return result 53 | return func 54 | 55 | def start_debug(graph): 56 | global GRAPH 57 | GRAPH = deepcopy(graph) 58 | 59 | def triples(f): 60 | global GRAPH 61 | 62 | @functools.wraps(f) 63 | def func(*args): 64 | triples = f(*args) 65 | 66 | triples, to_remove = itertools.tee(triples, 2) 67 | for t in to_remove: 68 | GRAPH.remove(t) 69 | 70 | return triples 71 | 72 | return func 73 | 74 | def end_debug(): 75 | global GRAPH 76 | 77 | for s, p, o in GRAPH: 78 | prefix = 'meta' if p in META or (p, o) in META else 'unsupported' 79 | logger.debug('{}: {}, {}, {}'.format(prefix, s, p, o)) 80 | del GRAPH 81 | 82 | # vim: sw=4:et:ai 83 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/coras/util.py: -------------------------------------------------------------------------------- 1 | # 2 | # Coras - OWL reasoning system 3 | # 4 | # Copyright (C) 2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import functools 21 | 22 | def dispatch(func): 23 | """ 24 | Like `functools.singledispatch` but for class methods. 25 | 26 | http://stackoverflow.com/a/24602374/722424 27 | """ 28 | dispatcher = functools.singledispatch(func) 29 | def wrapper(*args, **kw): 30 | return dispatcher.dispatch(args[1].__class__)(*args, **kw) 31 | wrapper.register = dispatcher.register 32 | functools.update_wrapper(wrapper, func) 33 | return wrapper 34 | 35 | # vim: sw=4:et:ai 36 | 37 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/doc/cmd.rst: -------------------------------------------------------------------------------- 1 | Command-line Tools 2 | ================== 3 | 4 | `coras-query` 5 | Run a SparQL query against an ontology. 6 | 7 | `coras-debug` 8 | Load a set of ontology files and show all possible debugging 9 | information. 10 | 11 | .. vim: sw=4:et:ai 12 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/doc/tests.rst: -------------------------------------------------------------------------------- 1 | Run unit tests:: 2 | 3 | $ pytest -v coras 4 | 5 | Run integration tests in parallel:: 6 | 7 | $ pytest -v -n8 integration/test_it.py 8 | 9 | .. vim: sw=4:et:ai 10 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/01-foaf.sq: -------------------------------------------------------------------------------- 1 | PREFIX foaf: 2 | 3 | SELECT ?name 4 | WHERE { 5 | ?person foaf:name ?name . 6 | } 7 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/01-result.csv: -------------------------------------------------------------------------------- 1 | Timothy Berners-Lee 2 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/02-foaf.sq: -------------------------------------------------------------------------------- 1 | PREFIX foaf: 2 | 3 | SELECT ?name ?homepage 4 | WHERE { 5 | ?person foaf:name ?name . 6 | ?person foaf:homepage ?homepage . 7 | } 8 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/02-result.csv: -------------------------------------------------------------------------------- 1 | Timothy Berners-Lee,https://www.w3.org/People/Berners-Lee/ 2 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/03-foaf-ex.n3: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | @prefix : <:>. 3 | 4 | :p1 foaf:name "A B". 5 | :p1 foaf:age 20. 6 | :p2 foaf:name "X Y". 7 | :p2 foaf:age 26. 8 | :p3 foaf:name "U1". 9 | :p3 foaf:age 17. 10 | :p4 foaf:name "U2". 11 | :p4 foaf:age 15. 12 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/03-foaf.sq: -------------------------------------------------------------------------------- 1 | PREFIX foaf: 2 | 3 | SELECT ?name ?age 4 | WHERE { 5 | ?p foaf:name ?name. 6 | ?p foaf:age ?age. 7 | FILTER (?age >= 18) 8 | } 9 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/foaf/03-result.csv: -------------------------------------------------------------------------------- 1 | X Y,26 2 | A B,20 3 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/test_coras.py: -------------------------------------------------------------------------------- 1 | # Coras - OWL reasoning system 2 | # 3 | # Copyright (C) 2018 by Artur Wroblewski 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | import csv 20 | import os.path 21 | from functools import partial 22 | 23 | import pytest 24 | 25 | from pyfactxx import coras 26 | from pyfactxx.coras.cli import load_and_parse 27 | 28 | import rdflib 29 | 30 | 31 | TESTS = [ 32 | ('foaf', '01-foaf.sq', ['foaf.rdf', 'tbl-foaf-card.n3'], '01-result.csv'), 33 | ('foaf', '02-foaf.sq', ['foaf.rdf', 'tbl-foaf-card.n3'], '02-result.csv'), 34 | ('foaf', '03-foaf.sq', ['foaf.rdf', '03-foaf-ex.n3'], '03-result.csv'), 35 | ('zebra', '01-zebra.sq', ['zebra.n3'], '01-result.csv'), 36 | ('zebra', '02-zebra.sq', ['zebra.n3'], '02-result.csv'), 37 | ('tsars', '01-tsars.sq', ['tsars.rdf'], '01-result.csv'), 38 | ('tsars', '02-tsars.sq', ['tsars.rdf'], '02-result.csv'), 39 | ] 40 | 41 | 42 | @pytest.mark.parametrize( 43 | 'prefix,query,ontologies,expected', 44 | TESTS, 45 | ) 46 | def test_coras(prefix, query, ontologies, expected): 47 | """Test coras RDFlib interface""" 48 | crs = coras.Coras() 49 | 50 | f_path = partial(os.path.join, os.path.dirname(__file__), prefix) 51 | f_open = lambda fn: open(f_path(fn)) 52 | 53 | files = (f_path(fn) for fn in ontologies) 54 | load_and_parse(crs, *files) 55 | crs.realise() 56 | 57 | with f_open(expected) as f: 58 | expected = list(csv.reader(f)) 59 | 60 | with f_open(query) as f: 61 | sq = f.read() 62 | 63 | result = crs.query(sq) 64 | result = [[str(s) for s in row] for row in result if all(not isinstance(s, rdflib.BNode) for s in row)] 65 | 66 | assert sorted(expected) == sorted(result) 67 | 68 | # vim: sw=4:et:ai 69 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/tsars/01-result.csv: -------------------------------------------------------------------------------- 1 | Mihail Fedorovich Romanov,Aleksei Mihailovich Romanov 2 | Petr I Alekseevich Romanov,Aleksei Petrovich Romanov 3 | Alexander II Nikolaevich Romanov,Alexander III Alexandrovich Romanov 4 | Nicholas I Pavlovich Romanov,Alexander II Nikolaevich Romanov 5 | Pavel I Petrovich Romanov,Alexander I Pavlovich Romanov 6 | Ivan V Alekseevich Romanov,Anna Ivanovna Romanova 7 | Karl Leopold Meklenburg-Shverinskiy,Anna Leopoldovna Meklenburg-Shverinskaya 8 | Petr I Alekseevich Romanov,Anna Petrovna Romanova 9 | Ivan V Alekseevich Romanov,Ekaterina Ivanovna Romanova 10 | Petr I Alekseevich Romanov,Elizaveta Petrovna Romanova 11 | Aleksei Mihailovich Romanov,Fedor Alekseevich Romanov 12 | Aleksei Mihailovich Romanov,Ivan V Alekseevich Romanov 13 | Anton Ulrich Braunshveig-Volfenbuttelskiy,Ivan VI Antonovich Braunshveig-Volfenbuttelskiy 14 | Alexander III Alexandrovich Romanov,Nicholas II Alexandrovich Romanov 15 | Pavel I Petrovich Romanov,Nicholas I Pavlovich Romanov 16 | Petr III Fedorovich Romanov,Pavel I Petrovich Romanov 17 | Aleksei Mihailovich Romanov,Petr I Alekseevich Romanov 18 | Aleksei Petrovich Romanov,Petr II Alekseevich Romanov 19 | Karl Friedrich Golshtein-Gottorpskiy,Petr III Fedorovich Romanov 20 | Aleksei Mihailovich Romanov,Sofia Aleksevna Romanova 21 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/tsars/01-tsars.sq: -------------------------------------------------------------------------------- 1 | SELECT ?s_name ?o_name 2 | WHERE { ?s ?o . ?s ?s_name . ?o ?o_name . } 3 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/tsars/02-result.csv: -------------------------------------------------------------------------------- 1 | Aleksei Mihailovich Romanov,Mihail Fedorovich Romanov 2 | Aleksei Petrovich Romanov,Petr I Alekseevich Romanov 3 | Alexander III Alexandrovich Romanov,Alexander II Nikolaevich Romanov 4 | Alexander II Nikolaevich Romanov,Nicholas I Pavlovich Romanov 5 | Alexander I Pavlovich Romanov,Pavel I Petrovich Romanov 6 | Anna Ivanovna Romanova,Ivan V Alekseevich Romanov 7 | Anna Leopoldovna Meklenburg-Shverinskaya,Karl Leopold Meklenburg-Shverinskiy 8 | Anna Petrovna Romanova,Petr I Alekseevich Romanov 9 | Ekaterina Ivanovna Romanova,Ivan V Alekseevich Romanov 10 | Elizaveta Petrovna Romanova,Petr I Alekseevich Romanov 11 | Fedor Alekseevich Romanov,Aleksei Mihailovich Romanov 12 | Ivan V Alekseevich Romanov,Aleksei Mihailovich Romanov 13 | Ivan VI Antonovich Braunshveig-Volfenbuttelskiy,Anton Ulrich Braunshveig-Volfenbuttelskiy 14 | Nicholas II Alexandrovich Romanov,Alexander III Alexandrovich Romanov 15 | Nicholas I Pavlovich Romanov,Pavel I Petrovich Romanov 16 | Pavel I Petrovich Romanov,Petr III Fedorovich Romanov 17 | Petr I Alekseevich Romanov,Aleksei Mihailovich Romanov 18 | Petr II Alekseevich Romanov,Aleksei Petrovich Romanov 19 | Petr III Fedorovich Romanov,Karl Friedrich Golshtein-Gottorpskiy 20 | Sofia Aleksevna Romanova,Aleksei Mihailovich Romanov 21 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/tsars/02-tsars.sq: -------------------------------------------------------------------------------- 1 | SELECT ?s_name ?o_name 2 | WHERE { ?s ?o . ?s ?s_name . ?o ?o_name . } 3 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/zebra/01-result.csv: -------------------------------------------------------------------------------- 1 | http://folk.uio.no/martige/what/2012/04/22/zebra#Norwegian 2 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/zebra/01-zebra.sq: -------------------------------------------------------------------------------- 1 | PREFIX z: 2 | 3 | SELECT ?person 4 | WHERE { 5 | ?person z:livesIn z:House1 6 | } 7 | 8 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/zebra/02-result.csv: -------------------------------------------------------------------------------- 1 | http://folk.uio.no/martige/what/2012/04/22/zebra#Japanese 2 | -------------------------------------------------------------------------------- /FaCT++.Python/coras/integration/zebra/02-zebra.sq: -------------------------------------------------------------------------------- 1 | PREFIX z: 2 | 3 | SELECT ?person 4 | WHERE { 5 | ?person z:hasPet z:Zebra 6 | } 7 | 8 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/describe.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | 4 | from pyfactxx import coras 5 | from pyfactxx.coras.cli import load_and_parse 6 | import rdflib 7 | 8 | 9 | def describe(crs, node, nsm, visited, with_inferences=False, level=1): 10 | 11 | if node in visited: 12 | return 13 | 14 | a_po = list(crs._graph.predicate_objects(node)) 15 | b_po = list(crs._query_graph.predicate_objects(node)) if with_inferences else [] 16 | 17 | a_set = set(a_po) 18 | predicate_objects = list(a_po) + [po for po in b_po if po not in a_set] 19 | 20 | for row in predicate_objects: 21 | 22 | if level == 1 or row[0] not in (rdflib.URIRef('http://www.w3.org/2000/01/rdf-schema#subClassOf'), rdflib.URIRef('http://www.w3.org/2002/07/owl#equivalentClass')): 23 | print('\t'*level, row[0].n3(nsm), end='') 24 | 25 | if isinstance(row[1], rdflib.BNode): 26 | print(' ', row[1].n3(nsm)) 27 | describe(crs, row[1], nsm, visited | {node}, with_inferences, level + 1) 28 | else: 29 | print(' ', row[1].n3(nsm)) 30 | 31 | if len(sys.argv) < 3: 32 | print("Usage: describe.py []") 33 | else: 34 | 35 | filename = sys.argv[1] 36 | URI = sys.argv[2] 37 | 38 | if len(sys.argv) > 3: 39 | with_inferences = (sys.argv[3] == '1') 40 | else: 41 | with_inferences = False 42 | 43 | crs = coras.Coras() 44 | load_and_parse(crs, filename) 45 | 46 | if with_inferences: 47 | crs.realise() 48 | 49 | nsm = crs._graph.namespace_manager 50 | node = rdflib.URIRef(URI) 51 | #node = rdflib.URIRef('http://emmo.info/emmo#EMMO_d67ee67e_4fac_4676_82c9_aec361dba698') # Property 52 | #node = rdflib.URIRef('http://emmo.info/emmo#EMMO_5b2222df_4da6_442f_8244_96e9e45887d1') # Matter 53 | print(node.n3(nsm)) 54 | describe(crs, node, nsm, set(), with_inferences) 55 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/imply-class.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import pyfactxx 21 | 22 | reasoner = pyfactxx.Reasoner() 23 | 24 | top_data = reasoner.data_top() 25 | 26 | cls = reasoner.concept('A') 27 | 28 | role = reasoner.data_role('R') 29 | reasoner.set_d_domain(role, cls) 30 | reasoner.set_d_range(role, reasoner.type_float) 31 | 32 | rt = reasoner.d_cardinality(1, role, top_data) 33 | reasoner.implies_concepts(cls, rt) 34 | 35 | # a is instance of A due to use of R 36 | a = reasoner.individual('a') 37 | reasoner.value_of_float(a, role, 1) 38 | 39 | print('a added, consistent:', reasoner.is_consistent()) 40 | print('a instance of A:', reasoner.is_instance(a, cls)) 41 | 42 | # vim: sw=4:et:ai 43 | 44 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/rdf-to-lisp.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | 4 | from pyfactxx import coras 5 | from pyfactxx.coras.cli import load_and_parse 6 | 7 | 8 | if len(sys.argv) < 3: 9 | print("Usage: rdf_to_lisp.py ") 10 | else: 11 | rdf_filename = sys.argv[1] 12 | lisp_filename = sys.argv[2] 13 | 14 | crs = coras.Coras() 15 | load_and_parse(crs, rdf_filename) 16 | #crs.realise() 17 | 18 | crs.reasoner.dump(lisp_filename) 19 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/run-lisp.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from datetime import datetime 4 | import random 5 | from statistics import mean, pstdev 6 | 7 | from pyfactxx import Reasoner 8 | 9 | 10 | if len(sys.argv) < 2: 11 | print("Usage: run_lisp.py ") 12 | else: 13 | filename = sys.argv[1] 14 | 15 | start = datetime.now() 16 | reasoner = Reasoner() 17 | reasoner.parse_lisp(filename) 18 | 19 | reasoner.realise() 20 | 21 | time = (datetime.now() - start).total_seconds() 22 | 23 | print("%2.2f sec" % time) 24 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/run-rdf.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from datetime import datetime 4 | from statistics import mean, pstdev 5 | 6 | from pyfactxx import coras 7 | from pyfactxx.coras.cli import load_and_parse 8 | 9 | 10 | if len(sys.argv) < 2: 11 | print('Usage: run_rdf.py []') 12 | else: 13 | filename = sys.argv[1] 14 | iterations = 5 15 | 16 | if len(sys.argv) > 2: 17 | iterations = int(sys.argv[2]) 18 | 19 | times = [] 20 | 21 | for i in range(iterations): 22 | 23 | start = datetime.now() 24 | 25 | crs = coras.Coras() 26 | load_and_parse(crs, filename) 27 | crs.realise() 28 | 29 | time = (datetime.now() - start).total_seconds() 30 | 31 | print(time) 32 | 33 | times.append(time) 34 | 35 | print(f"min: {min(times)}, max: {max(times)}") 36 | print(f"average: {mean(times)}, std dev: {pstdev(times)}") 37 | 38 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/shuffle-lisp.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from datetime import datetime 4 | import random 5 | from statistics import mean, pstdev 6 | 7 | from pyfactxx import Reasoner 8 | 9 | 10 | if len(sys.argv) < 2: 11 | print('Usage: shuffle_lisp.py []') 12 | else: 13 | filename = sys.argv[1] 14 | iterations = 20 15 | 16 | if len(sys.argv) > 2: 17 | iterations = int(sys.argv[2]) 18 | 19 | times = [] 20 | 21 | for i in range(iterations): 22 | with open(filename) as file: 23 | lines = file.readlines() 24 | 25 | random.shuffle(lines) 26 | 27 | with open('test.txt', 'w') as file: 28 | file.writelines(lines) 29 | 30 | start = datetime.now() 31 | reasoner = Reasoner() 32 | reasoner.parse_lisp('test.txt') 33 | 34 | reasoner.realise() 35 | 36 | time = (datetime.now() - start).total_seconds() 37 | 38 | print(time) 39 | 40 | times.append(time) 41 | 42 | print(f"min: {min(times)}, max: {max(times)}") 43 | print(f"average: {mean(times)}, std dev: {pstdev(times)}") 44 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-data-cardinality.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import pyfactxx 21 | 22 | reasoner = pyfactxx.Reasoner() 23 | top_data = reasoner.data_top() 24 | 25 | cls_a = reasoner.concept('CLS-A') 26 | c = reasoner.individual('C') 27 | reasoner.instance_of(c, cls_a) 28 | 29 | r = reasoner.data_role('R') 30 | reasoner.set_d_domain(r, cls_a) 31 | reasoner.set_d_range(r, reasoner.type_int) 32 | 33 | restriction_max_one = reasoner.max_d_cardinality(1, r, top_data) 34 | reasoner.implies_concepts(cls_a, restriction_max_one) 35 | 36 | reasoner.value_of_int(c, r, 1) 37 | print('consistent after first value:', reasoner.is_consistent()) 38 | 39 | reasoner.value_of_int(c, r, 2) 40 | print('consistent after 2nd value:', reasoner.is_consistent()) 41 | 42 | # vim: sw=4:et:ai 43 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-disjoint-classes.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import pyfactxx 21 | 22 | reasoner = pyfactxx.Reasoner() 23 | 24 | classes = [ 25 | reasoner.concept('A'), 26 | reasoner.concept('B'), 27 | reasoner.concept('C'), 28 | ] 29 | 30 | reasoner.disjoint_concepts(*classes) 31 | 32 | a = reasoner.individual('a') 33 | b = reasoner.individual('b') 34 | c = reasoner.individual('c') 35 | reasoner.instance_of(a, classes[0]) 36 | 37 | print('a is A, consistency:', reasoner.is_consistent()) 38 | 39 | # inconsistent, b is both instance of class B and C, but B and C are 40 | # disjoint 41 | reasoner.instance_of(b, classes[1]) 42 | reasoner.instance_of(b, classes[2]) 43 | print('b is B and b is C, consistency:', reasoner.is_consistent()) 44 | 45 | # vim: sw=4:et:ai 46 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-object-cardinality.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import pyfactxx 21 | 22 | reasoner = pyfactxx.Reasoner() 23 | 24 | cls_a = reasoner.concept('CLS-A') 25 | cls_b = reasoner.concept('CLS-B') 26 | reasoner.disjoint_concepts(cls_a, cls_b) 27 | 28 | r = reasoner.object_role('R') 29 | reasoner.set_o_domain(r, cls_a) 30 | reasoner.set_o_range(r, cls_b) 31 | 32 | c = reasoner.individual('C') 33 | reasoner.instance_of(c, cls_a) 34 | 35 | restriction_max_one_cls_b = reasoner.max_o_cardinality(1, r, cls_b) 36 | reasoner.implies_concepts(cls_a, restriction_max_one_cls_b) 37 | 38 | d = reasoner.individual('D') 39 | reasoner.instance_of(d, cls_b) 40 | reasoner.related_to(c, r, d) 41 | print('consistent after 1st instance:', reasoner.is_consistent()) 42 | 43 | # add another individual to class C, making ontology inconsistent 44 | x = reasoner.individual('X') 45 | reasoner.instance_of(x, cls_b) 46 | reasoner.related_to(c, r, x) 47 | reasoner.different_individuals(d, x) 48 | print('consistent after 2nd instance:', reasoner.is_consistent()) 49 | 50 | # vim: sw=4:et:ai 51 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-people.py: -------------------------------------------------------------------------------- 1 | 2 | from pyfactxx import coras 3 | from pyfactxx.coras.cli import load_and_parse 4 | import rdflib 5 | 6 | 7 | crs = coras.Coras() 8 | load_and_parse(crs, 'people.rdf') 9 | crs.realise() 10 | 11 | def test(scope): 12 | cat_owners = crs.query('ask where { }', scope=scope) 13 | print("Cat owners like cats", list(cat_owners)) 14 | 15 | old_ladies = crs.query('ask where { }', scope=scope) 16 | print("Old ladies own cats", list(old_ladies)) 17 | 18 | mad_cow = crs.query('ask where { }', scope=scope) 19 | print("Mad cow does not exist", list(mad_cow)) 20 | 21 | pete = crs.query('ask where { }', scope=scope) 22 | print("Pete is a person", list(pete)) 23 | 24 | spike = crs.query('ask where { }', scope=scope) 25 | print("Spike is an animal", list(spike)) 26 | 27 | print('\nWithout inferences:') 28 | test('asserted') 29 | 30 | print('\nWith inferences:') 31 | test('inferred') 32 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-pizza.py: -------------------------------------------------------------------------------- 1 | 2 | from pyfactxx import coras 3 | from pyfactxx.coras.cli import load_and_parse 4 | import rdflib 5 | 6 | 7 | def extract_name(node): 8 | node = str(node) 9 | return node[node.find('#') + 1:] 10 | 11 | crs = coras.Coras() 12 | load_and_parse(crs, 'pizza.owl') 13 | crs.realise() 14 | 15 | 16 | print('\nNamed pizzas:') 17 | named_pizzas = crs.query('select ?p where { ?p . } order by ?p', scope='asserted') 18 | 19 | for pizza_row in named_pizzas: 20 | print (extract_name(pizza_row[0]), 'is', end=' ') 21 | 22 | pizza_types = crs.query('select ?c where { ' + pizza_row[0].n3() + ' ?c . ?c . } order by ?c', scope='inferred') 23 | 24 | pizza_types = ', '.join(extract_name(type_row[0]) for type_row in pizza_types if not isinstance(type_row[0], rdflib.BNode) and str(type_row[0]).endswith('Pizza') and not str(type_row[0]).endswith('NamedPizza')) 25 | 26 | if pizza_types == '': 27 | print('special') 28 | else: 29 | print(pizza_types) 30 | 31 | print('\nUnsatisfiable (inconsistent) classes:') 32 | nothing = crs.query('select ?n where { ?n . } order by ?p', scope='both') 33 | for row in nothing: 34 | print(extract_name(row[0])) 35 | 36 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-property-large.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import pyfactxx 21 | import time 22 | 23 | reasoner = pyfactxx.Reasoner() 24 | 25 | start = time.time() 26 | individuals = [ 27 | reasoner.individual('i-{}'.format(i)) 28 | for i in range(10 ** 4) 29 | ] 30 | role = reasoner.object_role('R') 31 | 32 | reasoner.set_symmetric(role) 33 | reasoner.set_transitive(role) 34 | 35 | items = [iter(individuals)] * 4 36 | for i1, i2, i3, i4 in zip(*items): 37 | reasoner.related_to(i1, role, i2) 38 | reasoner.related_to(i2, role, i3) 39 | reasoner.related_to(i3, role, i4) 40 | 41 | print('setup done within {:.4f}s'.format(time.time() - start)) 42 | 43 | reasoner.realise() 44 | print('realised after {:.4f}s'.format(time.time() - start)) 45 | 46 | values = reasoner.get_role_fillers(individuals[-1], role) 47 | for v in values: 48 | print(v.name) 49 | 50 | print('total exec time {:.4f}s'.format(time.time() - start)) 51 | 52 | # vim: sw=4:et:ai 53 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-property.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import pyfactxx 21 | 22 | reasoner = pyfactxx.Reasoner() 23 | 24 | c = reasoner.individual('C') 25 | d = reasoner.individual('D') 26 | e = reasoner.individual('E') 27 | r = reasoner.object_role('R') 28 | 29 | reasoner.set_symmetric(r) 30 | reasoner.set_transitive(r) 31 | reasoner.related_to(c, r, d) 32 | reasoner.related_to(d, r, e) 33 | 34 | values = reasoner.get_role_fillers(d, r) 35 | for v in values: 36 | print(v.name) 37 | 38 | # vim: sw=4:et:ai 39 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/test-sparql.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from datetime import datetime 4 | 5 | from pyfactxx import coras 6 | from pyfactxx.coras.cli import load_and_parse 7 | 8 | 9 | if len(sys.argv) < 2: 10 | print('Usage: test_sparql.py ') 11 | else: 12 | filename = sys.argv[1] 13 | query = sys.argv[2] 14 | 15 | crs = coras.Coras() 16 | load_and_parse(crs, filename) 17 | crs.realise() 18 | 19 | print(*list(crs.query(query)), sep='\n') 20 | -------------------------------------------------------------------------------- /FaCT++.Python/examples/zebra-dump.py: -------------------------------------------------------------------------------- 1 | 2 | from pyfactxx import Reasoner 3 | from datetime import datetime 4 | 5 | 6 | def is_related_to(reasoner, name, property_name, property): 7 | i = reasoner.individual(name) 8 | values = reasoner.get_role_fillers(i, property) 9 | print(name, property_name, [v.name for v in values]) 10 | 11 | 12 | start = datetime.now() 13 | reasoner = Reasoner() 14 | reasoner.parse_lisp('t-fast.txt') 15 | reasoner.realise() 16 | 17 | 18 | is_related_to(reasoner, 'water', 'is drunk by', reasoner.inverse('drinks')) 19 | print(f'Time elapsed: {datetime.now() - start}') 20 | -------------------------------------------------------------------------------- /FaCT++.Python/lib/FaCT++: -------------------------------------------------------------------------------- 1 | ../../FaCT++ -------------------------------------------------------------------------------- /FaCT++.Python/lib/Kernel: -------------------------------------------------------------------------------- 1 | ../../Kernel -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13.0) 2 | project(pyfactxx) 3 | set(CMAKE_CXX_STANDARD 11) 4 | include(CMakePrintHelpers) 5 | 6 | find_package(PythonExtensions REQUIRED) 7 | find_package(Cython REQUIRED) 8 | 9 | add_subdirectory(${PYFACTXX_ROOT}/lib/Kernel ./Kernel) 10 | set(FACT_DIR ${PYFACTXX_ROOT}/lib/FaCT++) 11 | file(GLOB FACT_FILES "${FACT_DIR}/*.cpp") 12 | # TODO: How to create shared libKernel? 13 | # target_compile_definitions(Kernel PRIVATE BUILD_SHARED_LIBS) 14 | set_property(TARGET Kernel PROPERTY POSITION_INDEPENDENT_CODE ON) 15 | add_cython_target(_factxx lib_factxx.pyx CXX PY3) 16 | add_library(lib_factxx MODULE ${_factxx} ${FACT_FILES} Kernel) 17 | target_include_directories(lib_factxx PRIVATE ${FACT_DIR} Kernel) 18 | target_link_libraries(lib_factxx Kernel) 19 | python_extension_module(lib_factxx) 20 | 21 | install(TARGETS lib_factxx LIBRARY DESTINATION pyfactxx) 22 | 23 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 24 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 25 | include(CPack) 26 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from .lib_factxx import Reasoner # pylint: disable=no-name-in-module 21 | from .coras import Coras 22 | 23 | 24 | __version__ = "1.8.1" 25 | 26 | # vim: sw=4:et:ai 27 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/coras: -------------------------------------------------------------------------------- 1 | ../coras/coras -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | # vim: sw=4:et:ai 21 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/conftest.py: -------------------------------------------------------------------------------- 1 | """Pytest fixtures""" 2 | 3 | import pytest 4 | import pyfactxx 5 | 6 | 7 | @pytest.fixture 8 | def reasoner(): 9 | """ 10 | Get instance of a reasoner. 11 | """ 12 | return pyfactxx.Reasoner() 13 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/test_concept.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | 21 | def test_subclass(reasoner): 22 | """ 23 | Test subclasses. 24 | """ 25 | cls_a = reasoner.concept('A') 26 | cls_b = reasoner.concept('B') 27 | 28 | reasoner.implies_concepts(cls_a, cls_b) 29 | assert reasoner.is_subsumed_by(cls_a, cls_b) 30 | 31 | 32 | def test_subclass_instances(reasoner): 33 | """ 34 | Test instances of subclasses. 35 | """ 36 | child = reasoner.concept('child') 37 | person = reasoner.concept('person') 38 | 39 | a = reasoner.individual('a') 40 | reasoner.instance_of(a, child) 41 | 42 | # test precondition 43 | assert not reasoner.is_instance(a, person) 44 | 45 | reasoner.implies_concepts(child, person) 46 | assert reasoner.is_instance(a, person) 47 | 48 | 49 | def test_equal_concepts(reasoner): 50 | """ 51 | Test equal concepts. 52 | """ 53 | cls_a = reasoner.concept('A') 54 | cls_b = reasoner.concept('B') 55 | 56 | a = reasoner.individual('a') 57 | reasoner.instance_of(a, cls_a) 58 | 59 | reasoner.equal_concepts(cls_a, cls_b) 60 | 61 | assert reasoner.is_instance(a, cls_b) 62 | 63 | 64 | def test_disjoint_union(reasoner): 65 | """ 66 | Test union of concepts. 67 | """ 68 | cls_a = reasoner.concept('A') 69 | cls_b = reasoner.concept('B') 70 | cls_c = reasoner.concept('C') 71 | 72 | a = reasoner.individual('a') 73 | reasoner.instance_of(a, cls_a) 74 | 75 | reasoner.equal_concepts(cls_c, reasoner.union(cls_a, cls_b)) 76 | reasoner.disjoint_concepts(cls_a, cls_b) 77 | 78 | assert not reasoner.is_instance(a, cls_b) 79 | assert reasoner.is_instance(a, cls_c) 80 | 81 | # vim: sw=4:et:ai 82 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/test_d_role.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | 21 | def test_create_data_role(reasoner): 22 | """ Test creating data role. """ 23 | r = reasoner.data_role('R') 24 | assert 'R' == r.name 25 | 26 | 27 | def test_equivalent_roles(reasoner): 28 | """ Test creating equivalent data roles. """ 29 | r1 = reasoner.data_role('R1') 30 | cls = reasoner.concept('CLS') 31 | reasoner.set_d_domain(r1, cls) 32 | 33 | r2 = reasoner.data_role('R2') 34 | reasoner.equal_d_roles(r1, r2) 35 | 36 | # precondition 37 | assert r1 != r2 38 | 39 | # r1 and r2 are equivalent, so they have the same domain 40 | values = reasoner.get_d_domain(r2) 41 | assert 'CLS' == next(values).name 42 | assert next(values, None) is None 43 | 44 | 45 | def test_sub_property(reasoner): 46 | """ Test creating sub-property of a data property. """ 47 | r = reasoner.data_role('R') 48 | sub_r = reasoner.data_role('SR') 49 | reasoner.implies_d_roles(sub_r, r) 50 | assert reasoner.is_sub_d_role(sub_r, r) 51 | 52 | 53 | def test_get_d_domain(reasoner): 54 | """ Test getting data role domain. """ 55 | cls = reasoner.concept('CLS') 56 | r = reasoner.data_role('R') 57 | reasoner.set_d_domain(r, cls) 58 | 59 | values = reasoner.get_d_domain(r) 60 | assert 'CLS' == next(values).name 61 | assert next(values, None) is None 62 | 63 | 64 | def test_get_d_domain_top(reasoner): 65 | """ Test getting data role domain when no domain set. """ 66 | top = reasoner.concept_top() 67 | r = reasoner.data_role('R') 68 | i = reasoner.individual('i') 69 | reasoner.value_of_int(i, r, 1) 70 | 71 | values = reasoner.get_d_domain(r) 72 | assert [top] == list(values) 73 | 74 | # vim: sw=4:et:ai 75 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/test_instance.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | 21 | def test_one_of(reasoner): 22 | """Test `one of` axiom.""" 23 | colors = [reasoner.individual(c) for c in ['blue', 'yellow']] 24 | 25 | color = reasoner.concept('Color') 26 | a_color = reasoner.one_of(*colors) 27 | reasoner.equal_concepts(color, a_color) 28 | 29 | blue = reasoner.individual('blue') 30 | assert reasoner.is_instance(blue, color) 31 | 32 | # vim: sw=4:et:ai 33 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/test_one_to_one.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | 21 | def test_diff_concepts(reasoner): 22 | """Test different concepts""" 23 | c1 = reasoner.concept('C1') 24 | c2 = reasoner.concept('C2') 25 | assert c1 is not c2 26 | 27 | 28 | def test_same_concepts(reasoner): 29 | """Test same concepts""" 30 | c1 = reasoner.concept('C') 31 | c2 = reasoner.concept('C') 32 | assert c1 is c2 33 | 34 | 35 | def test_diff_individuals(reasoner): 36 | """Test different individuals""" 37 | i1 = reasoner.individual('i1') 38 | i2 = reasoner.individual('i2') 39 | assert i1 is not i2 40 | 41 | 42 | def test_same_individuals(reasoner): 43 | """Test same individuals""" 44 | i1 = reasoner.individual('i') 45 | i2 = reasoner.individual('i') 46 | assert i1 is i2 47 | 48 | 49 | def test_diff_object_roles(reasoner): 50 | """Test different object roles""" 51 | r1 = reasoner.object_role('r1') 52 | r2 = reasoner.object_role('r2') 53 | assert r1 is not r2 54 | 55 | 56 | def test_same_object_roles(reasoner): 57 | """Test same object roles""" 58 | r1 = reasoner.object_role('r') 59 | r2 = reasoner.object_role('r') 60 | assert r1 is r2 61 | 62 | 63 | def test_diff_data_roles(reasoner): 64 | """Test different data roles""" 65 | r1 = reasoner.data_role('r1') 66 | r2 = reasoner.data_role('r2') 67 | assert r1 is not r2 68 | 69 | 70 | def test_same_data_roles(reasoner): 71 | """Test same data roles""" 72 | r1 = reasoner.data_role('r') 73 | r2 = reasoner.data_role('r') 74 | assert r1 is r2 75 | 76 | # vim: sw=4:et:ai 77 | -------------------------------------------------------------------------------- /FaCT++.Python/pyfactxx/tests/test_set_op.py: -------------------------------------------------------------------------------- 1 | # 2 | # pyfactxx - Python interface to FaCT++ reasoner 3 | # 4 | # Copyright (C) 2016-2018 by Artur Wroblewski 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | 21 | def test_intersection_subclass(reasoner): 22 | """ 23 | Test intersection of classes. 24 | 25 | From OWL 2 primer:: 26 | 27 | SubClassOf( 28 | :Grandfather 29 | ObjectIntersectionOf(:Man :Parent) 30 | ) 31 | """ 32 | cls_p = reasoner.concept('Parent') 33 | cls_m = reasoner.concept('Man') 34 | cls_g = reasoner.concept('Grandfather') 35 | 36 | cls = reasoner.intersection(cls_p, cls_m) 37 | reasoner.implies_concepts(cls_g, cls) 38 | 39 | i = reasoner.individual('John') 40 | reasoner.instance_of(i, cls_g) 41 | reasoner.realise() 42 | 43 | assert reasoner.is_instance(i, cls_m) 44 | assert reasoner.is_instance(i, cls_p) 45 | 46 | 47 | def test_intersection_eq(reasoner): 48 | """ 49 | Test intersection of classes. 50 | 51 | From OWL 2 primer:: 52 | 53 | EquivalentClasses( 54 | :Mother 55 | ObjectIntersectionOf(:Woman :Parent) 56 | ) 57 | """ 58 | cls_p = reasoner.concept('Parent') 59 | cls_w = reasoner.concept('Woman') 60 | cls_m = reasoner.concept('Mother') 61 | 62 | cls = reasoner.intersection(cls_p, cls_m) 63 | reasoner.equal_concepts(cls, cls_m) 64 | 65 | a = reasoner.individual('Alice') 66 | reasoner.instance_of(a, cls_m) 67 | reasoner.realise() 68 | 69 | # is a woman, but not a parent yet 70 | assert not reasoner.is_instance(a, cls_w) 71 | 72 | # becomes a parent, so mother as well 73 | reasoner.instance_of(a, cls_p) 74 | reasoner.realise() 75 | assert reasoner.is_instance(a, cls_m) 76 | 77 | # vim: sw=4:et:ai 78 | -------------------------------------------------------------------------------- /FaCT++.Python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "cython>0.25", 5 | "wheel", 6 | "scikit-build", 7 | "cmake", 8 | "ninja; platform_system!='Windows'" 9 | ] 10 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /FaCT++.Python/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = pyfactxx 3 | description = Python bindings to FaCT++ reasoner 4 | author = Artur Wroblewski 5 | author_email = wrobell@riseup.net 6 | maintainer = Ivan Rygaev, Andrey Sobolev 7 | maintainer_email = ir@tilde.pro 8 | url = https://github.com/tilde-lab/pyfactxx 9 | long_description = file: README.md 10 | long_description_content_type = text/markdown 11 | license = GNU GPL 3.0 12 | license_files = file: COPYING 13 | classifiers = 14 | Development Status :: 4 - Beta 15 | Intended Audience :: Science/Research 16 | Topic :: Scientific/Engineering :: Artificial Intelligence 17 | License :: OSI Approved :: GNU General Public License v3 (GPLv3) 18 | Programming Language :: C++ 19 | Programming Language :: Cython 20 | Programming Language :: Lisp 21 | Programming Language :: Python :: 3 22 | Programming Language :: Python :: 3.6 23 | Programming Language :: Python :: 3.7 24 | Programming Language :: Python :: 3.8 25 | Programming Language :: Python :: 3.9 26 | Programming Language :: Python :: 3.10 27 | 28 | [options] 29 | zip_safe = False 30 | include_package_data = True 31 | python_requires = >=3.7 32 | install_requires = rdflib 33 | tests_require = pytest, pytest-cov 34 | 35 | [sdist] 36 | formats = zip 37 | 38 | [tool:pytest] 39 | addopts = --cov=pyfactxx 40 | 41 | [coverage:report] 42 | show_missing = 1 43 | partial_branches = 1 44 | 45 | -------------------------------------------------------------------------------- /FaCT++.Python/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # pyfactxx - Python interface to FaCT++ reasoner 4 | # 5 | # Copyright (C) 2016-2018 by Artur Wroblewski 6 | # Copyright (C) 2021-2022 by Ivan Rygaev 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | # 21 | 22 | import re 23 | import ast 24 | import pathlib 25 | from skbuild import setup 26 | 27 | 28 | root = pathlib.Path(__file__).parent.resolve() 29 | DEBUG = False 30 | 31 | _version_re = re.compile(r'__version__\s+=\s+(.*)') 32 | 33 | with open('pyfactxx/__init__.py', 'rb') as f: 34 | version = str(ast.literal_eval(_version_re.search( 35 | f.read().decode('utf-8')).group(1))) 36 | 37 | config = 'Debug' if DEBUG else 'Release' 38 | cmake_args = [ 39 | f'-DCMAKE_BUILD_TYPE={config}', 40 | f'-DPYFACTXX_ROOT={root.as_posix()}' 41 | ] 42 | 43 | setup( 44 | version=version, 45 | packages=[ 46 | "pyfactxx", 47 | "pyfactxx.coras"], 48 | package_dir={ 49 | "pyfactxx": "pyfactxx", 50 | "pyfactxx.coras": "pyfactxx/coras"}, 51 | cmake_source_dir=str(root/'pyfactxx'), 52 | cmake_args=cmake_args 53 | ) 54 | -------------------------------------------------------------------------------- /FaCT++/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(FaCT++) 2 | cmake_minimum_required(VERSION 2.8.11) 3 | 4 | set(SOURCE_FILES 5 | AD.cpp 6 | comparser.h 7 | comscanner.h 8 | FaCT.cpp 9 | lispgrammar.h 10 | parser.cpp 11 | parser.h 12 | scanner.cpp 13 | scanner.h 14 | ) 15 | 16 | # Executable 17 | add_executable(FaCT++ ${SOURCE_FILES}) 18 | target_link_libraries(FaCT++ LINK_PUBLIC Kernel) 19 | -------------------------------------------------------------------------------- /FaCT++/comparser.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef COMPARSER_H 21 | #define COMPARSER_H 22 | 23 | #include "comscanner.h" 24 | 25 | /// generic class for parsing with usage of scanner derived from CommonScanner 26 | template 27 | class CommonParser 28 | { 29 | protected: // members 30 | /// used scanner 31 | Scanner scan; 32 | /// last scanned token 33 | GenericToken Current; 34 | 35 | protected: // methods 36 | /// get current token 37 | GenericToken Code ( void ) const { return Current; } 38 | /// receive (and save) next token 39 | void NextLex ( void ) { Current = scan.GetLex(); } 40 | /// ensure that current token has given value; return error if it's not a case 41 | void MustBe ( GenericToken t, const char* message = nullptr ) const 42 | { 43 | if ( Current != t ) 44 | scan.error(message); 45 | } 46 | /// ensure that current token has given value; return error if it's not a case; get new token 47 | void MustBeM ( GenericToken t, const char* message = nullptr ) 48 | { MustBe ( t, message ); NextLex (); } 49 | /// general error message 50 | [[noreturn]] void parseError ( const char* p ) const { scan.error(p); } 51 | 52 | public: // interface 53 | /// c'tor 54 | explicit CommonParser ( std::istream* in ) : scan ( in ) { NextLex (); } 55 | /// empty d'tor 56 | virtual ~CommonParser() = default; 57 | }; // CommonParser 58 | 59 | #endif // _COMMON_PARSER_HPP 60 | -------------------------------------------------------------------------------- /FaCT++/scanner.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | //------------------------------------------------------------------------- 21 | // 22 | // Scanner class for FaCT++ 23 | // 24 | //------------------------------------------------------------------------- 25 | #ifndef SCANNER_H 26 | #define SCANNER_H 27 | 28 | #include "lispgrammar.h" 29 | #include "comscanner.h" 30 | 31 | /// more-or-less general simple scanner implementation 32 | class TsScanner: public CommonScanner 33 | { 34 | protected: // methods 35 | /// fill buffer with name in '|'-s; c should be starting '|' 36 | void FillNameBuffer ( register char c ); 37 | /// fill buffer with legal ID chars, starting from c 38 | void FillBuffer ( register char c ); 39 | /// check if given character is legal in ID 40 | bool isLegalIdChar ( char c ) const; 41 | 42 | public: // interface 43 | /// c'tor 44 | explicit TsScanner ( std::istream* inp ) : CommonScanner(inp) {} 45 | 46 | /// get next token from stream 47 | LispToken GetLex ( void ); 48 | /// get keyword for a command by given text in buffer; @return BAD_LEX if no keyword found 49 | LispToken getCommandKeyword ( void ) const; 50 | /// get keyword for a concept/role expression; @return BAD_LEX if no keyword found 51 | LispToken getExpressionKeyword ( void ) const; 52 | /// get keyword for a concept/role special name; @return ID if no keyword found 53 | LispToken getNameKeyword ( void ) const; 54 | }; // TsScanner 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Kernel/Actor.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "Actor.h" 21 | #include "tConcept.h" 22 | 23 | /// check whether actor is applicable to the ENTRY 24 | bool 25 | Actor :: applicable ( const EntryType* entry ) const 26 | { 27 | if ( isRole ) // object- or data-role 28 | { 29 | if ( isStandard ) // object role 30 | return true; 31 | else // data role -- need only direct ones and TOP/BOT 32 | return entry->getId() >= 0; 33 | } 34 | else // concept or individual: standard are concepts 35 | return static_cast(entry)->isSingleton() != isStandard; 36 | } 37 | -------------------------------------------------------------------------------- /Kernel/BiPointer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef BIPOINTER_H 21 | #define BIPOINTER_H 22 | 23 | typedef int BipolarPointer; 24 | 25 | inline BipolarPointer createBiPointer ( int index, bool pos ) { return (pos ? index : -index); } 26 | inline BipolarPointer createBiPointer ( unsigned int index, bool pos ) { return createBiPointer ( (int)index, pos ); } 27 | 28 | inline bool isCorrect ( BipolarPointer p ) { return (p!=0); } 29 | inline bool isValid ( BipolarPointer p ) { return (p!=0); } 30 | inline bool isPositive ( BipolarPointer p ) { return (p>0); } 31 | inline bool isNegative ( BipolarPointer p ) { return (p<0); } 32 | 33 | inline unsigned int getValue ( BipolarPointer p ) { return (p>0?(unsigned int)p:(unsigned int)-p); } 34 | 35 | inline BipolarPointer inverse ( BipolarPointer p ) { return -p; } 36 | inline BipolarPointer getPositive ( BipolarPointer p ) { return (p>0?p:-p); } 37 | inline BipolarPointer getNegative ( BipolarPointer p ) { return (p<0?p:-p); } 38 | 39 | const BipolarPointer bpINVALID = 0; 40 | const BipolarPointer bpTOP = 1; 41 | const BipolarPointer bpBOTTOM = -1; 42 | 43 | #endif // BIPOINTER_H 44 | -------------------------------------------------------------------------------- /Kernel/DataTypeCenter.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "taxNamEntry.h" 21 | #include "DataTypeCenter.h" 22 | #include "DataReasoning.h" 23 | 24 | DataTypeCenter :: ~DataTypeCenter() 25 | { 26 | for ( iterator p = begin(), p_end = end(); p < p_end; ++p ) 27 | delete *p; 28 | } 29 | 30 | TDataType* 31 | DataTypeCenter :: getTypeByName ( const std::string& name ) const 32 | { 33 | // special case whatever you want here 34 | 35 | // go through all types and check the name 36 | for ( const_iterator p = begin(), p_end = end(); p < p_end; ++p ) 37 | if ( name == (*p)->getType()->getName() ) 38 | return *p; 39 | 40 | return nullptr; 41 | } 42 | 43 | void 44 | DataTypeCenter :: setLocked ( bool val ) 45 | { 46 | if ( val ) 47 | return; 48 | 49 | for ( iterator p = begin(), p_end = end(); p < p_end; ++p ) 50 | (*p)->setLocked(val); 51 | } 52 | 53 | void 54 | DataTypeCenter :: initDataTypeReasoner ( DataTypeReasoner& DTReasoner ) const 55 | { 56 | for ( const_iterator p = begin(), p_end = end(); p < p_end; ++p ) 57 | { 58 | TDataEntry* type = (*p)->getType(); 59 | if ( isValid(type->getBP()) ) 60 | DTReasoner.registerDataType(type); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Kernel/DeletelessAllocator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2005-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef DELETELESSALLOCATOR_H 21 | #define DELETELESSALLOCATOR_H 22 | 23 | #include "growingArrayP.h" 24 | 25 | /** 26 | * Class for the allocator that does not allowed 'delete'. Instead 27 | * it allows user to reuse all allocated memory. 28 | */ 29 | template 30 | class DeletelessAllocator: public growingArrayP 31 | { 32 | public: 33 | /// get a new object from the heap 34 | T* get ( void ) 35 | { 36 | this->ensureHeapSize(); 37 | return this->Base[this->last++]; 38 | } 39 | }; // DeletelessAllocator 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Kernel/DepSet.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef DEPSET_H 21 | #define DEPSET_H 22 | 23 | #include "tDepSet.h" 24 | 25 | // define type for dependency set 26 | typedef TDepSet DepSet; 27 | 28 | // common operations with the dep-set 29 | template 30 | inline O& operator << ( O& o, const DepSet& s ) 31 | { return s.print(o); } 32 | 33 | inline DepSet operator + ( const DepSet& ds1, const DepSet& ds2 ) 34 | { 35 | DepSet ret(ds1); 36 | return ret += ds2; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Kernel/LeveLogger.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | #include "LeveLogger.h" 23 | #include "configure.h" 24 | 25 | // define local private stream 26 | namespace { 27 | std::ofstream LLprivate; 28 | } 29 | // define LL as a reference to the real ofstream 30 | std::ostream& LL = LLprivate; 31 | 32 | bool LeveLogger :: initLogger ( unsigned int l, const char* filename ) 33 | { 34 | // init file 35 | LLprivate.open(filename); 36 | 37 | if ( LL.bad() ) 38 | return true; 39 | 40 | // init level 41 | allowedLevel = l; 42 | LL << "Init allowedLevel = " << allowedLevel << "\n"; 43 | 44 | return false; 45 | } 46 | 47 | bool LeveLogger :: initLogger ( Configuration& Config ) 48 | { 49 | // try to load LeveLogger's config section 50 | if ( Config.useSection ( "LeveLogger" ) ) 51 | return true; 52 | 53 | unsigned int l; 54 | 55 | // try to load allowance level 56 | if ( Config.checkValue ( "allowedLevel" ) ) 57 | l = 0; 58 | else 59 | l = (unsigned int) Config.getLong (); 60 | 61 | // try to load input value 62 | if ( Config.checkValue ( "file" ) ) 63 | return true; 64 | 65 | return initLogger ( l, Config.getString() ); 66 | } 67 | 68 | // the only element of LL 69 | LeveLogger LLM; 70 | -------------------------------------------------------------------------------- /Kernel/LeveLogger.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef LEVELOGGER_H 21 | #define LEVELOGGER_H 22 | 23 | #include 24 | 25 | #include "globaldef.h" 26 | 27 | class Configuration; 28 | 29 | class LeveLogger 30 | { 31 | private: // members 32 | /// the allowed logging level; init it once for the whole session 33 | unsigned int allowedLevel = 0; 34 | 35 | public: // interface 36 | /// sets output file and allowedLevel by given values 37 | bool initLogger ( unsigned int l, const char* filename ); 38 | /** sets output file and allowedLevel by config file. 39 | * The values will be taken from Config|[LeveLogger]|{allowedLevel,file} 40 | * Default level is 0, but the file name is mandatory. 41 | */ 42 | bool initLogger ( Configuration& Config ); 43 | 44 | /// @return true if LEVEL will be allowed 45 | bool isWritable ( unsigned int level ) const 46 | { 47 | if ( USE_LOGGING ) 48 | return level <= allowedLevel; 49 | else 50 | return false; 51 | } 52 | }; // LeveLogger 53 | 54 | /// the only main logger/manager for all usage 55 | extern LeveLogger LLM; 56 | /// file stream to be used by LLM; be sure that every OP with LL is guarded by LLM 57 | extern std::ostream& LL; 58 | 59 | // macro for checking if LL is writable and then return 60 | #define CHECK_LL_RETURN(val) \ 61 | if (!LLM.isWritable(val)) return 62 | 63 | // macro for checking if LL is writable and then return value 64 | #define CHECK_LL_RETURN_VALUE(val,ret) \ 65 | if (!LLM.isWritable(val)) return (ret) 66 | 67 | #endif // LEVELOGGER_H 68 | -------------------------------------------------------------------------------- /Kernel/LocalityChecker.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2014-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | // locality checking 21 | #include "SemanticLocalityChecker.h" 22 | #include "SyntacticLocalityChecker.h" 23 | #include "ExtendedSyntacticLocalityChecker.h" 24 | 25 | /// @return a locality checker corresponding to a given method 26 | LocalityChecker* createLocalityChecker ( ModuleMethod moduleMethod, TSignature* pSig ) 27 | { 28 | switch ( moduleMethod ) 29 | { 30 | case SYN_LOC_STD: return new SyntacticLocalityChecker(pSig); 31 | case SYN_LOC_COUNT: return new ExtendedSyntacticLocalityChecker(pSig); 32 | case SEM_LOC: return new SemanticLocalityChecker(pSig); 33 | default: fpp_unreachable(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Kernel/ModuleMethod.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2011-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MODULEMETHOD_H 21 | #define MODULEMETHOD_H 22 | 23 | enum ModuleMethod { SYN_LOC_STD, SYN_LOC_COUNT, SEM_LOC }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Kernel/ModuleType.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2011-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MODULETYPE_H 21 | #define MODULETYPE_H 22 | 23 | enum ModuleType { M_TOP, M_BOT, M_STAR }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Kernel/OntologyBasedModularizer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2012-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef ONTOLOGYBASEDMODULARIZER_H 21 | #define ONTOLOGYBASEDMODULARIZER_H 22 | 23 | #include "Modularity.h" 24 | #include "tOntology.h" 25 | 26 | class OntologyBasedModularizer 27 | { 28 | protected: // members 29 | /// ontology to work with 30 | const TOntology& Ontology; 31 | /// pointer to a modularizer 32 | TModularizer* Modularizer; 33 | 34 | public: // interface 35 | /// init c'tor 36 | OntologyBasedModularizer ( const TOntology& ontology, ModuleMethod moduleMethod ) 37 | : Ontology(ontology) 38 | { 39 | Modularizer = new TModularizer(moduleMethod); 40 | Modularizer->preprocessOntology(Ontology.getAxioms()); 41 | } 42 | /// d'tor 43 | ~OntologyBasedModularizer() { delete Modularizer; } 44 | 45 | /// get module 46 | const AxiomVec& getModule ( const AxiomVec& From, const TSignature& sig, ModuleType type ) 47 | { 48 | Modularizer->extract ( From, sig, type ); 49 | return Modularizer->getModule(); 50 | } 51 | /// get module 52 | const AxiomVec& getModule ( const TSignature& sig, ModuleType type ) 53 | { return getModule ( Ontology.getAxioms(), sig, type ); } 54 | /// get access to a modularizer 55 | TModularizer* getModularizer ( void ) { return Modularizer; } 56 | }; // OntologyBasedModularizer 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Kernel/ProgressIndicatorInterface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef PROGRESSINDICATORINTERFACE_H 21 | #define PROGRESSINDICATORINTERFACE_H 22 | 23 | /// interface of the progress indicator 24 | class ProgressIndicatorInterface 25 | { 26 | protected: // members 27 | /// limit of the progress: indicate [0..uLimit] 28 | unsigned long uLimit = 0; 29 | /// current value of an indicator 30 | unsigned long uCurrent = 0; 31 | 32 | protected: // methods 33 | /// initial exposure method: can be overridden in derived classes 34 | virtual void initExposure ( void ) {} 35 | /// indicate current value somehow 36 | virtual void expose ( void ) = 0; 37 | /// check whether the limit is reached 38 | bool checkMax ( void ) 39 | { 40 | if ( uCurrent > uLimit ) 41 | { 42 | uCurrent = uLimit; 43 | return true; 44 | } 45 | else 46 | return false; 47 | } 48 | 49 | public: // interface 50 | /// empty c'tor 51 | ProgressIndicatorInterface() = default; 52 | /// init c'tor 53 | explicit ProgressIndicatorInterface ( unsigned long limit ) { setLimit (limit); } 54 | /// empty d'tor 55 | virtual ~ProgressIndicatorInterface() = default; 56 | 57 | /// set indicator to a given VALUE 58 | void setIndicator ( unsigned long value ) 59 | { 60 | if ( uCurrent != value ) 61 | { 62 | uCurrent = value; 63 | checkMax (); 64 | expose (); 65 | } 66 | } 67 | /// increment current value of an indicator to DELTA steps 68 | void incIndicator ( unsigned long delta = 1 ) { setIndicator(uCurrent+delta); } 69 | /// set indicator to 0 70 | void reset ( void ) { setIndicator (0); } 71 | /// set the limit of an indicator to a given VALUE 72 | void setLimit ( unsigned long limit ) { uLimit = limit; reset(); initExposure(); } 73 | }; // ProgressIndicatorInterface 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Kernel/SaveLoadManager.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2013-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | #include "SaveLoadManager.h" 23 | #include "tNamedEntry.h" 24 | 25 | bool 26 | SaveLoadManager :: existsContent ( void ) const 27 | { 28 | // context is there if a file can be opened 29 | return !std::ifstream(filename).fail(); 30 | } 31 | 32 | void 33 | SaveLoadManager :: clearContent ( void ) const 34 | { 35 | remove(filename.c_str()); 36 | } 37 | 38 | void 39 | SaveLoadManager :: prepare ( bool input ) 40 | { 41 | // close all previously open streams 42 | delete ip; 43 | delete op; 44 | ip = nullptr; 45 | op = nullptr; 46 | 47 | // open a new one 48 | if ( input ) 49 | ip = new std::ifstream(filename); 50 | else 51 | op = new std::ofstream(filename); 52 | } 53 | 54 | void 55 | SaveLoadManager :: registerE ( const TNamedEntry* p ) 56 | { 57 | neMap.add(const_cast(p)); 58 | if ( p->getEntity() != nullptr ) 59 | eMap.add(const_cast(p->getEntity())); 60 | } 61 | 62 | #if 0 63 | bool 64 | SaveLoadManager :: clearContent ( void ) const 65 | { 66 | #ifdef WINDOWS 67 | SHFILEOPSTRUCT file_op = { 68 | nullptr, 69 | FO_DELETE, 70 | dirname.c_str(), // FIXME!! fully qualified name expected 71 | "", 72 | FOF_NOCONFIRMATION | 73 | FOF_NOERRORUI | 74 | FOF_SILENT, 75 | false, 76 | 0, 77 | "" }; 78 | SHFileOperation(&file_op); 79 | #endif 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /Kernel/TaxGatheringWalker.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2015-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TAXGATHERINGWALKER_H 21 | #define TAXGATHERINGWALKER_H 22 | 23 | #include "WalkerInterface.h" 24 | #include "taxVertex.h" 25 | 26 | /// taxonomy walkers that gathers all the relevant nodes 27 | class TaxGatheringWalker : public WalkerInterface 28 | { 29 | protected: // members 30 | /// vertices that satisfy the condition 31 | std::vector found; 32 | 33 | protected: // methods 34 | /// check whether actor is applicable to the ENTRY 35 | virtual bool applicable ( const ClassifiableEntry* entry ) const = 0; 36 | /// @return true iff current entry is visible 37 | bool tryEntry ( const ClassifiableEntry* p ) const { return !p->isSystem() && applicable(p); } 38 | /// @return true if at least one entry of a vertex V is visible 39 | bool tryVertex ( const TaxonomyVertex& v ) const 40 | { 41 | if ( tryEntry(v.getPrimer()) ) 42 | return true; 43 | for ( const auto& synonym: v.synonyms() ) 44 | if ( tryEntry(synonym) ) 45 | return true; 46 | return false; 47 | } 48 | 49 | public: // interface 50 | /// clear found 51 | virtual void clear ( void ) { found.clear(); } 52 | 53 | /// taxonomy walking method. 54 | /// @return true if node was processed 55 | /// @return false if node can not be processed in current settings 56 | bool apply ( const TaxonomyVertex& v ) override 57 | { 58 | if ( tryVertex(v) ) 59 | { 60 | found.push_back(&v); 61 | return true; 62 | } 63 | return false; 64 | } 65 | }; // TaxGatheringWalker 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Kernel/WalkerInterface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef WALKERINTERFACE_H 21 | #define WALKERINTERFACE_H 22 | 23 | class Taxonomy; 24 | class TaxonomyVertex; 25 | 26 | /// base class for taxonomy walkers that provide necessary interface 27 | class WalkerInterface 28 | { 29 | public: // interface 30 | /// empty d'tor 31 | virtual ~WalkerInterface() = default; 32 | 33 | /// taxonomy walking method. 34 | /// @return true if node was processed 35 | /// @return false if node can not be processed in current settings 36 | virtual bool apply ( const TaxonomyVertex& v ) = 0; 37 | /// remove indirect nodes in the given taxonomy according to direction 38 | virtual void removeIndirect ( Taxonomy*, bool ) {} 39 | }; // WalkerInterface 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Kernel/counter.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2010-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef COUNTER_H 21 | #define COUNTER_H 22 | 23 | /// class counter from Wikipedia:curiously recurring template pattern 24 | template 25 | struct counter 26 | { 27 | /// number of created T-objects 28 | static unsigned int objects_created; 29 | /// number of alive T-objects ATM of checking 30 | static unsigned int objects_alive; 31 | /// c'tor: inc counters 32 | counter ( void ) 33 | { 34 | ++objects_created; 35 | ++objects_alive; 36 | } 37 | /// d'tor: dec counters 38 | virtual ~counter() 39 | { 40 | --objects_alive; 41 | } 42 | }; // counter 43 | 44 | template unsigned int counter::objects_created(0); 45 | template unsigned int counter::objects_alive(0); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Kernel/cpm.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef CPM_H 21 | #define CPM_H 22 | 23 | #include "tProgressMonitor.h" 24 | #include "cppi.h" 25 | 26 | /// console-based progress monitor 27 | class ConsoleProgressMonitor: public TProgressMonitor 28 | { 29 | protected: 30 | /// real indication 31 | CPPI ind; 32 | 33 | public: 34 | // interface 35 | 36 | /// informs about beginning of classification with number of concepts to be classified 37 | void setClassificationStarted ( unsigned int nConcepts ) override { ind.setLimit(nConcepts); } 38 | /// informs about beginning of classification of a given CONCEPT 39 | void nextClass ( void ) override { ind.incIndicator(); } 40 | }; // ConsoleProgressMonitor 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Kernel/cppi.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef CPPI_H 21 | #define CPPI_H 22 | 23 | /* 24 | * Console percent progress indicator 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "ProgressIndicatorInterface.h" 31 | 32 | class CPPI: public ProgressIndicatorInterface 33 | { 34 | protected: // members 35 | /// previous and current numbers shown 36 | unsigned int oldPercent = 0; 37 | unsigned int curPercent = 0; 38 | 39 | protected: // methods 40 | /// initial exposition 41 | void initExposure ( void ) override { std::cerr << " 0%"; } 42 | /// expose current value 43 | void expose ( void ) override 44 | { 45 | curPercent = (unsigned int)(((float)uCurrent/uLimit)*100); 46 | 47 | // don't do anything if figure doesn't change 48 | if ( curPercent != oldPercent ) 49 | { 50 | std::cerr << "\b\b\b\b\b" << std::setw(4) << curPercent << '%'; 51 | oldPercent = curPercent; 52 | } 53 | } 54 | 55 | public: // interface 56 | /// empty c'tor 57 | CPPI ( void ) 58 | : ProgressIndicatorInterface() 59 | {} 60 | /// init c'tor 61 | explicit CPPI ( unsigned long limit ) 62 | : ProgressIndicatorInterface(limit) 63 | {} 64 | }; // CPPI 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Kernel/dir_util.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2014-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "dir_util.h" 24 | 25 | // MinGW GCC up to version 6.2 does not have permissions parameter in mkdir() 26 | #if defined(__MINGW32__) || defined(__MINGW64__) 27 | # define mkdir(path, permissions) mkdir(path) 28 | #endif 29 | 30 | /// create a directory by a path; @return 0 if success, -1 if not 31 | int dirCreate ( const char *path ) 32 | { 33 | struct stat st; 34 | int status = 0; 35 | #ifndef _MSC_VER 36 | if (stat(path, &st) != 0) 37 | { 38 | /* Directory does not exist. EEXIST for race condition */ 39 | if (mkdir(path, 0777) != 0 && errno != EEXIST) 40 | status = -1; 41 | } 42 | else if (!S_ISDIR(st.st_mode)) 43 | { 44 | errno = ENOTDIR; 45 | status = -1; 46 | } 47 | #endif 48 | return status; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Kernel/dir_util.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2014-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef DIR_UTIL_H 21 | #define DIR_UTIL_H 22 | 23 | // interface to the directory creation/deletion 24 | 25 | /// create a directory by a path; @return 0 if success, -1 if not 26 | int dirCreate ( const char* path ); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Kernel/dlVHash.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef DLVHASH_H 21 | #define DLVHASH_H 22 | 23 | #include 24 | #include 25 | #include "dlVertex.h" 26 | #include "tRole.h" 27 | 28 | /// naive and simple hash table for DL Vertices 29 | class dlVHashTable 30 | { 31 | protected: // types 32 | /// hashed IDs of the DL vertices 33 | typedef std::list HashLeaf; 34 | /// hash table by itself 35 | typedef std::map HashTable; 36 | 37 | protected: // members 38 | /// host DAG that contains actual nodes; 39 | const DLDag& host; 40 | /// HT for nodes 41 | HashTable Table; 42 | 43 | protected: // methods 44 | /// get a (very simple) hash of the vertex 45 | static BipolarPointer hash ( const DLVertex& v ) 46 | { 47 | BipolarPointer sum = 0; 48 | if ( v.getRole() != nullptr ) 49 | sum += v.getRole()->getId(); 50 | if ( v.getProjRole() != nullptr ) 51 | sum += v.getProjRole()->getId(); 52 | sum += v.getC(); 53 | sum += v.getNumberLE(); 54 | for ( const auto& arg: v ) 55 | sum += arg; 56 | return sum; 57 | } 58 | 59 | /// insert new POSition into a given LEAF 60 | static void insert ( HashLeaf& leaf, BipolarPointer pos ) { leaf.push_back(pos); } 61 | /// locate vertex V in a given LEAF 62 | BipolarPointer locate ( const HashLeaf& leaf, const DLVertex& v ) const; 63 | 64 | public: // interface 65 | /// empty c'tor 66 | explicit dlVHashTable ( const DLDag& dag ) : host(dag) {} 67 | 68 | /// add an element (given by a POSition) to hash 69 | void addElement ( BipolarPointer pos ); 70 | /// locate given vertex in the hash 71 | BipolarPointer locate ( const DLVertex& v ) const; 72 | }; // dlVHashTable 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Kernel/dlVHashImpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef DLVHASHIMPL_H 21 | #define DLVHASHIMPL_H 22 | 23 | // implementation of DLVertex Hash; to be included after DLDag definition 24 | 25 | inline BipolarPointer 26 | dlVHashTable :: locate ( const HashLeaf& leaf, const DLVertex& v ) const 27 | { 28 | for ( const auto& bp: leaf ) 29 | if ( v == host[bp] ) 30 | return bp; 31 | 32 | return bpINVALID; 33 | } 34 | 35 | inline BipolarPointer 36 | dlVHashTable :: locate ( const DLVertex& v ) const 37 | { 38 | auto p = Table.find(hash(v)); 39 | return p == Table.end() ? bpINVALID : locate ( p->second, v ); 40 | } 41 | 42 | inline void 43 | dlVHashTable :: addElement ( BipolarPointer pos ) 44 | { 45 | insert ( Table[hash(host[pos])], pos ); 46 | } 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Kernel/dumpLisp.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "dumpLisp.h" 21 | 22 | void dumpLisp :: startOp ( diOp Op ) 23 | { 24 | if ( Op == diAnd || Op == diOr ) 25 | incIndent(); 26 | 27 | o << "("; 28 | 29 | switch (Op) 30 | { 31 | case diErrorOp: 32 | default: 33 | fpp_unreachable(); 34 | // concept expressions 35 | case diNot: 36 | o << "not"; 37 | break; 38 | case diAnd: 39 | o << "and"; 40 | break; 41 | case diOr: 42 | o << "or"; 43 | break; 44 | case diExists: 45 | o << "some"; 46 | break; 47 | case diForall: 48 | o << "all"; 49 | break; 50 | case diGE: 51 | o << "atleast"; 52 | break; 53 | case diLE: 54 | o << "atmost"; 55 | break; 56 | } 57 | 58 | contOp(Op); 59 | } 60 | 61 | void dumpLisp :: startAx ( diAx Ax ) 62 | { 63 | o << "("; 64 | 65 | switch (Ax) 66 | { 67 | case diErrorAx: 68 | default: 69 | fpp_unreachable(); 70 | // concept axioms 71 | case diDefineC: 72 | o << "defprimconcept"; 73 | break; 74 | case diImpliesC: 75 | o << "implies_c"; 76 | break; 77 | case diEqualsC: 78 | o << "equal_c"; 79 | break; 80 | // role axioms 81 | case diDefineR: 82 | o << "defprimrole"; 83 | break; 84 | case diTransitiveR: 85 | o << "transitive"; 86 | break; 87 | case diFunctionalR: 88 | o << "functional"; 89 | break; 90 | case diImpliesR: 91 | o << "implies_r"; 92 | break; 93 | case diEqualsR: 94 | o << "equal_r"; 95 | break; 96 | case diDomainR: 97 | o << "domain"; 98 | break; 99 | case diRangeR: 100 | o << "range"; 101 | break; 102 | }; 103 | 104 | contAx(Ax); 105 | } 106 | -------------------------------------------------------------------------------- /Kernel/eFPPCantRegName.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFPPCANTREGNAME_H 21 | #define EFPPCANTREGNAME_H 22 | 23 | #include 24 | 25 | #include "eFaCTPlusPlus.h" 26 | 27 | /// exception thrown in case name can't be registered 28 | class EFPPCantRegName: public EFaCTPlusPlus 29 | { 30 | private: // members 31 | /// error string 32 | std::string str; 33 | /// name string 34 | std::string Name; 35 | 36 | public: // interface 37 | /// c'tor: create an output string 38 | EFPPCantRegName ( const std::string& name, const std::string& type ) 39 | : EFaCTPlusPlus() 40 | , Name(name) 41 | { 42 | str = "Unable to register '"; 43 | str += name; 44 | str += "' as a "; 45 | str += type; 46 | reason = str.c_str(); 47 | } 48 | 49 | /// get access to the unregistered name 50 | const char* getName ( void ) const { return Name.c_str(); } 51 | }; // EFPPCantRegName 52 | 53 | #endif 54 | 55 | 56 | -------------------------------------------------------------------------------- /Kernel/eFPPCycleInRIA.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2007-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFPPCYCLEINRIA_H 21 | #define EFPPCYCLEINRIA_H 22 | 23 | #include "eFaCTPlusPlus.h" 24 | 25 | /// exception thrown in case there is a (disallowed) cycle in a role-inclusion axiom 26 | class EFPPCycleInRIA: public EFaCTPlusPlus 27 | { 28 | private: // members 29 | /// saved name of the role 30 | const std::string roleName; 31 | /// error string 32 | std::string str; 33 | 34 | public: // interface 35 | /// c'tor: create an output string 36 | explicit EFPPCycleInRIA ( const std::string& name ) 37 | : EFaCTPlusPlus() 38 | , roleName(name) 39 | { 40 | str = "Role '"; 41 | str += name; 42 | str += "' appears in a cyclic role inclusion axioms"; 43 | reason = str.c_str(); 44 | } 45 | 46 | /// access to the role 47 | const char* getRoleName ( void ) const { return roleName.c_str(); } 48 | }; // EFPPCycleInRIA 49 | 50 | #endif 51 | 52 | 53 | -------------------------------------------------------------------------------- /Kernel/eFPPInconsistentKB.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2007-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFPPINCONSISTENTKB_H 21 | #define EFPPINCONSISTENTKB_H 22 | 23 | #include "eFaCTPlusPlus.h" 24 | 25 | class EFPPInconsistentKB: public EFaCTPlusPlus 26 | { 27 | public: // interface 28 | EFPPInconsistentKB ( void ) : EFaCTPlusPlus("FaCT++ Kernel: Inconsistent KB") {} 29 | }; // EFPPInconsistentKB 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Kernel/eFPPNonSimpleRole.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2007-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFPPNONSIMPLEROLE_H 21 | #define EFPPNONSIMPLEROLE_H 22 | 23 | #include "eFaCTPlusPlus.h" 24 | 25 | /// exception thrown in case non-simple role used where only simple role can be used 26 | class EFPPNonSimpleRole: public EFaCTPlusPlus 27 | { 28 | private: // members 29 | /// saved name of the role 30 | const std::string roleName; 31 | /// error string 32 | std::string str; 33 | 34 | public: // interface 35 | /// c'tor: create an output string 36 | explicit EFPPNonSimpleRole ( const std::string& name ) 37 | : EFaCTPlusPlus() 38 | , roleName(name) 39 | { 40 | str = "Non-simple role '"; 41 | str += name; 42 | str += "' is used as a simple one"; 43 | reason = str.c_str(); 44 | } 45 | 46 | /// access to the role 47 | const char* getRoleName ( void ) const { return roleName.c_str(); } 48 | }; // EFPPNonSimpleRole 49 | 50 | #endif 51 | 52 | 53 | -------------------------------------------------------------------------------- /Kernel/eFPPSaveLoad.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFPPSAVELOAD_H 21 | #define EFPPSAVELOAD_H 22 | 23 | #include 24 | 25 | #include "eFaCTPlusPlus.h" 26 | 27 | /// exception thrown for the save/load operations 28 | class EFPPSaveLoad: public EFaCTPlusPlus 29 | { 30 | private: // members 31 | /// error string 32 | std::string str; 33 | 34 | public: // interface 35 | /// c'tor with a given "what" string 36 | explicit EFPPSaveLoad ( const std::string& why ) 37 | : EFaCTPlusPlus() 38 | , str(why) 39 | { 40 | reason = str.c_str(); 41 | } 42 | /// c'tor "Char not found" 43 | explicit EFPPSaveLoad ( const char c ) 44 | : EFaCTPlusPlus() 45 | { 46 | str = "Expected character '"; 47 | str += c; 48 | str += "' not found"; 49 | reason = str.c_str(); 50 | } 51 | /// c'tor: create an output string for the bad filename 52 | EFPPSaveLoad ( const std::string& filename, bool save ) 53 | : EFaCTPlusPlus() 54 | { 55 | const char* action = save ? "save" : "load"; 56 | const char* prep = save ? "to" : "from"; 57 | str = "Unable to "; 58 | str += action; 59 | str += " internal state "; 60 | str += prep; 61 | str += " file '"; 62 | str += filename; 63 | str += "'"; 64 | reason = str.c_str(); 65 | } 66 | }; // EFppSaveLoad 67 | 68 | #endif 69 | 70 | 71 | -------------------------------------------------------------------------------- /Kernel/eFPPTimeout.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2009-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFPPTIMEOUT_H 21 | #define EFPPTIMEOUT_H 22 | 23 | #include "eFaCTPlusPlus.h" 24 | 25 | class EFPPTimeout: public EFaCTPlusPlus 26 | { 27 | public: // interface 28 | EFPPTimeout ( void ) : EFaCTPlusPlus("FaCT++ Kernel: operation timeout") {} 29 | }; // EFPPTimeout 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Kernel/eFaCTPlusPlus.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2007-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EFACTPLUSPLUS_H 21 | #define EFACTPLUSPLUS_H 22 | 23 | #include 24 | 25 | /// general FaCT++ exception 26 | class EFaCTPlusPlus: public std::exception 27 | { 28 | protected: 29 | /// reason of the exception 30 | const char* reason = "FaCT++.Kernel: General exception"; 31 | 32 | public: 33 | /// empty c'tor 34 | EFaCTPlusPlus() = default; 35 | /// init c'tor 36 | explicit EFaCTPlusPlus ( const char* str ) 37 | : exception() 38 | , reason(str) 39 | {} 40 | 41 | /// reason 42 | const char* what ( void ) const noexcept override { return reason; } 43 | }; // EFaCTPlusPlus 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Kernel/fpp_assert.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2009-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef FPP_ASSERT_H 21 | #define FPP_ASSERT_H 22 | 23 | #include "eFaCTPlusPlus.h" 24 | 25 | /// assertion exception 26 | class EFPPAssertion: public EFaCTPlusPlus 27 | { 28 | public: // interface 29 | /// the default constructor 30 | explicit EFPPAssertion ( const char* reason ) : EFaCTPlusPlus(reason) {} 31 | }; // EFPPAssertion 32 | 33 | #undef fpp_assert 34 | #undef fpp_assert_ 35 | #undef fpp_assert__ 36 | #undef fpp_unreachable 37 | 38 | /// assert() helpers 39 | #define fpp_assert__(e,file,line) \ 40 | throw EFPPAssertion(file ":" #line ": assertion '" e "' fails") 41 | #define fpp_assert_(e,f,l) fpp_assert__(#e,f,l) 42 | 43 | #ifdef NDEBUG 44 | # define fpp_assert(e) ((void)(false && (e))) 45 | #else 46 | # define fpp_assert(e) ((void)((e) ? 0 : fpp_assert_ ( e, __FILE__, __LINE__ ))) 47 | #endif 48 | 49 | #define fpp_unreachable() fpp_assert_ ( unreachable, __FILE__, __LINE__ ) 50 | 51 | 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Kernel/globaldef.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef GLOBALDEF_H 21 | #define GLOBALDEF_H 22 | 23 | // global definitions for FaCT++ Reasoning Kernel 24 | 25 | // define unused attribute for parameters and (un)likely macro for conditions 26 | #if defined(__GNUC__) && (__GNUC__ >= 4) 27 | # define ATTR_UNUSED __attribute__((unused)) 28 | # define likely(cond) __builtin_expect((cond),1) 29 | # define unlikely(cond) __builtin_expect((cond),0) 30 | #else 31 | # define ATTR_UNUSED 32 | # define likely(cond) (cond) 33 | # define unlikely(cond) (cond) 34 | #endif 35 | 36 | // uncomment this to have a DAG usage statistics printed 37 | //#define RKG_PRINT_DAG_USAGE 38 | 39 | // uncomment this to have sorted ontology reasoning 40 | #define RKG_USE_SORTED_REASONING 41 | 42 | // set the default value of USE_LOGGING 43 | 44 | #ifndef USE_LOGGING 45 | # define USE_LOGGING 0 46 | #endif 47 | 48 | //#define ENABLE_CHECKING 49 | 50 | // set to 1 to allow dynamic backjumping 51 | #ifndef RKG_USE_DYNAMIC_BACKJUMPING 52 | # define RKG_USE_DYNAMIC_BACKJUMPING 0 53 | #endif 54 | 55 | // set to 1 to update role's R&D from super-roles 56 | #ifndef RKG_UPDATE_RND_FROM_SUPERROLES 57 | # define RKG_UPDATE_RND_FROM_SUPERROLES 0 58 | #endif 59 | 60 | // uncomment this to allow simple rules processing 61 | //#define RKG_USE_SIMPLE_RULES 62 | 63 | // set to 1 to support fairness constraints 64 | #ifndef RKG_USE_FAIRNESS 65 | # define RKG_USE_FAIRNESS 0 66 | #endif 67 | 68 | // uncomment the following line if IR is defined as a list of elements in node label 69 | #define RKG_IR_IN_NODE_LABEL 70 | 71 | // this value is used in classes Reasoner, CGraph and RareSaveStack 72 | constexpr unsigned int InitBranchingLevelValue = 1; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Kernel/grammar.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | //------------------------------------------------------------------------- 21 | // 22 | // Grammar for FaCT++ 23 | // 24 | //------------------------------------------------------------------------- 25 | #ifndef GRAMMAR_H 26 | #define GRAMMAR_H 27 | 28 | // constants for symbols 29 | enum Token { 30 | AND, 31 | OR, 32 | NOT, 33 | INV, 34 | RCOMPOSITION, // role composition 35 | PROJINTO, // role projection into 36 | PROJFROM, // role projection from 37 | SELF, 38 | 39 | TOP, 40 | BOTTOM, 41 | EXISTS, 42 | FORALL, 43 | GE, 44 | // ATLEAST = GE, 45 | LE, 46 | // ATMOST = LE, 47 | 48 | // common meta-symbols 49 | DATAEXPR, // any data expression: data value, [constrained] datatype 50 | 51 | // more precise ID's discretion 52 | CNAME, // name of a concept 53 | INAME, // name of a singleton 54 | RNAME, // name of a role 55 | DNAME, // name of a data role 56 | }; 57 | 58 | // some multi-case defines 59 | 60 | // any name (like ID) 61 | #define NAME CNAME: case INAME: case RNAME: case DNAME 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Kernel/logging.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef LOGGING_H 21 | #define LOGGING_H 22 | 23 | #include "LeveLogger.h" 24 | 25 | // constants for use by different logger users 26 | enum 27 | { 28 | llAlways = 0, 29 | llStartCfyConcepts = 0, // "start classifying * concepts" message 30 | llStartCfyEntry = 1, // "start classifying entry" message 31 | llBegSat = 1, // "begin sat/sub test" message 32 | llSatResult = 1, // "sat/sub does [NOT] holds" message 33 | llTaxTrying = 2, // "Try C [= D" message 34 | llCDConcept = 2, // "completely defines concept" message 35 | llTSList = 2, // print list of TS's 36 | llTaxInsert = 2, // "insert C with parents={} and children={}" message 37 | llDagSat = 3, // "checking SAT of DAG entry" message 38 | llSatTime = 3, // print time for the test 39 | llRStat = 5, // local reasoning statistic 40 | llSRInfo = 15, // node save/restore info 41 | llSRState = 15, // s/r info of the reasoning state 42 | llGTA = 10, // general tactic action 43 | llCDAction = llGTA, // any concrete domain info 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Kernel/mergeableLabel.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MERGEABLELABEL_H 21 | #define MERGEABLELABEL_H 22 | 23 | /// implementation of labels that could be compared and merged to each other 24 | class mergeableLabel 25 | { 26 | protected: // members 27 | /// sample for all equivalent labels 28 | mergeableLabel* pSample; 29 | 30 | public: // interface 31 | /// empty c'tor 32 | mergeableLabel ( void ) : pSample(this) {} 33 | /// copy c'tor 34 | mergeableLabel ( mergeableLabel& p ) : pSample(p.resolve()) {} 35 | /// assignment 36 | mergeableLabel& operator = ( mergeableLabel& p ) { pSample = p.resolve(); return *this; } 37 | 38 | // general interface 39 | 40 | /// are 2 labels equal; works only for normalised labels 41 | bool operator == ( const mergeableLabel& p ) const { return (pSample == p.pSample); } 42 | /// are 2 labels different; works only for normalised labels 43 | bool operator != ( const mergeableLabel& p ) const { return (pSample != p.pSample); } 44 | /// make 2 labels equal 45 | void merge ( mergeableLabel& p ) 46 | { 47 | mergeableLabel* sample = p.resolve(); 48 | resolve(); 49 | if ( pSample != sample ) 50 | pSample->pSample = sample; 51 | } 52 | /// make label's depth <= 2; @return sample of the label 53 | mergeableLabel* resolve ( void ) 54 | { 55 | // check if current node is itself sample 56 | if ( !isSample() ) 57 | pSample = pSample->resolve(); 58 | 59 | return pSample; 60 | } 61 | /// is given label a sample label 62 | bool isSample ( void ) const { return (pSample == this); } 63 | }; // mergeableLabel 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Kernel/parseTime.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2011-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "parseTime.h" 21 | 22 | /// fills TM with a time value from string STR; @return true iff fail to load 23 | static bool 24 | fillTmByString ( const char* str, struct tm* tm ) 25 | { 26 | return strptime ( str, "%Y-%m-%dT%H:%M:%S%z", tm ) != nullptr; 27 | } 28 | /// this function gets a string representing time in an ISO 8601 format and returns time_t value built out of it 29 | time_t parseTimeString ( const char* str ) 30 | { 31 | struct tm temp; 32 | // decode time value in format YYYY-MM-DDThh:mm:ssTZ, as in xsd:dateTime 33 | fillTmByString ( str, &temp ); 34 | return timegm(&temp); 35 | } 36 | -------------------------------------------------------------------------------- /Kernel/parseTime.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2011-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef PARSETIME_H 21 | #define PARSETIME_H 22 | 23 | #include 24 | 25 | /// this function gets a string representing time in an ISO 8601 format and returns time_t value built out of it 26 | time_t parseTimeString ( const char* str ); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Kernel/tCounter.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TCOUNTER_H 21 | #define TCOUNTER_H 22 | 23 | /** define class that allows user to have an integer with restricted 24 | * access (i.e. get value, increment and reset). This is useful when 25 | * integral value used as a static var of some class 26 | */ 27 | template 28 | class TCounter 29 | { 30 | public: // type interface 31 | /// define integral type of a counter 32 | typedef T IntType; 33 | 34 | protected: // members 35 | /// counter itself 36 | IntType counter; 37 | 38 | public: // interface 39 | /// init c'tor 40 | explicit TCounter ( const IntType n ) : counter(n) {} 41 | /// copy c'tor 42 | template 43 | explicit TCounter ( const TCounter& copy ) : counter(copy.counter) {} 44 | /// assignment 45 | template 46 | TCounter& operator= ( const TCounter& copy ) 47 | { 48 | counter = copy.counter; 49 | return *this; 50 | } 51 | 52 | // operators 53 | 54 | /// get value of a counter 55 | IntType val ( void ) const { return counter; } 56 | /// increment value of a counter; @return new value 57 | IntType inc ( void ) { return ++counter; } 58 | /// set new value of a counter 59 | void reset ( const IntType n ) { counter = n; } 60 | }; // TCounter 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /Kernel/tDLAxiom.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2011-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "tDLAxiom.h" 21 | #include "tSignature.h" 22 | #include "tSignatureUpdater.h" 23 | 24 | /// d'tor: delete signature if it was created 25 | TDLAxiom :: ~TDLAxiom() 26 | { 27 | delete sig; 28 | } 29 | 30 | /// build signature of an axiom 31 | void 32 | TDLAxiom :: buildSignature ( void ) 33 | { 34 | sig = new TSignature(); 35 | TSignatureUpdater Updater(*sig); 36 | accept(Updater); 37 | } 38 | -------------------------------------------------------------------------------- /Kernel/tDataType.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2005-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TDATATYPE_H 21 | #define TDATATYPE_H 22 | 23 | #include "tDataEntry.h" 24 | #include "tNECollection.h" 25 | 26 | /// class for representing general data type 27 | class TDataType: public TNECollection 28 | { 29 | protected: // members 30 | /// data type 31 | TDataEntry* Type; 32 | /// data type 33 | std::vector Expr; 34 | 35 | protected: // methods 36 | /// register data value in the datatype 37 | void registerNew ( TDataEntry* p ) override { p->setHostType(Type); } 38 | 39 | public: // interface 40 | /// c'tor: create the TYPE entry 41 | explicit TDataType ( const std::string& name ) 42 | : TNECollection(name) 43 | { Type = new TDataEntry(name); } 44 | /// no copy c'tor 45 | TDataType ( const TDataType& ) = delete; 46 | /// no assignment 47 | TDataType& operator = ( const TDataType& ) = delete; 48 | /// d'tor: delete data type entry and all the expressions 49 | ~TDataType() override 50 | { 51 | for ( auto& p: Expr ) 52 | delete p; 53 | delete Type; 54 | } 55 | 56 | // access to the type 57 | 58 | /// get RW access to the type entry (useful for relevance etc) 59 | TDataEntry* getType ( void ) { return Type; } 60 | /// get RO access to the type entry 61 | const TDataEntry* getType ( void ) const { return Type; } 62 | 63 | /// create new expression of the type 64 | TDataEntry* getExpr ( void ) 65 | { 66 | TDataEntry* ret = registerElem(new TDataEntry("expr")); 67 | Expr.push_back(ret); 68 | return ret; 69 | } 70 | }; // TDataType 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /Kernel/tDataTypeBool.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2009-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TDATATYPEBOOL_H 21 | #define TDATATYPEBOOL_H 22 | 23 | #include "tDataType.h" 24 | 25 | class TDataTypeBool: public TDataType 26 | { 27 | public: 28 | /// c'tor: make 2 elements of the domain and lock the type 29 | TDataTypeBool ( void ) : TDataType("bool") 30 | { 31 | get("false"); 32 | get("true"); 33 | setLocked(true); 34 | } 35 | }; // TDataTypeBool 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Kernel/tExpressionManager.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2010-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "tExpressionManager.h" 21 | 22 | TExpressionManager :: TExpressionManager ( void ) 23 | : CTop(new TDLConceptTop) 24 | , CBottom(new TDLConceptBottom) 25 | , DTop(new TDLDataTop) 26 | , DBottom(new TDLDataBottom) 27 | , ORTop(new TDLObjectRoleTop) 28 | , ORBottom(new TDLObjectRoleBottom) 29 | , DRTop(new TDLDataRoleTop) 30 | , DRBottom(new TDLDataRoleBottom) 31 | , InverseRoleCache(this) 32 | , OneOfCache(this) 33 | { 34 | } 35 | 36 | TExpressionManager :: ~TExpressionManager() 37 | { 38 | clear(); 39 | delete CTop; 40 | delete CBottom; 41 | delete ORTop; 42 | delete ORBottom; 43 | delete DRTop; 44 | delete DRBottom; 45 | delete DTop; 46 | delete DBottom; 47 | } 48 | 49 | void 50 | TExpressionManager :: clear ( void ) 51 | { 52 | // clear all the names but the datatypes 53 | NS_C.clear(); 54 | NS_I.clear(); 55 | NS_OR.clear(); 56 | NS_DR.clear(); 57 | InverseRoleCache.clear(); 58 | OneOfCache.clear(); 59 | // delete all the recorded references 60 | for ( auto& expr: RefRecorder ) 61 | delete expr; 62 | RefRecorder.clear(); 63 | } 64 | 65 | /// clear the TNamedEntry cache for all elements of all name-sets 66 | void 67 | TExpressionManager :: clearNameCache ( void ) 68 | { 69 | clearEntriesCache(NS_C); 70 | clearEntriesCache(NS_I); 71 | clearEntriesCache(NS_OR); 72 | clearEntriesCache(NS_DR); 73 | clearEntriesCache(NS_DT); 74 | } 75 | -------------------------------------------------------------------------------- /Kernel/tHeadTailCache.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2010-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef THEADTAILCACHE_H 21 | #define THEADTAILCACHE_H 22 | 23 | #include 24 | 25 | /// Template class for the cache element. Assumes that new elements of a HEADTYPE 26 | /// are constructed using a single argument of a TAILTYPE. Uniqueness of a tails 27 | /// leads to the uniqueness of a constructed object 28 | template 29 | class THeadTailCache 30 | { 31 | protected: // types 32 | /// auxiliary map 33 | typedef std::map CacheMap; 34 | 35 | protected: // members 36 | /// map tail into an object head(tail) 37 | CacheMap Map; 38 | 39 | protected: // methods 40 | /// the way to create an object by a given tail 41 | virtual HeadType* build ( TailType* ) = 0; 42 | 43 | public: // interface 44 | /// empty c'tor 45 | THeadTailCache() = default; 46 | /// empty d'tor 47 | virtual ~THeadTailCache() = default; 48 | 49 | /// get an object corresponding to Head.Tail 50 | HeadType* get ( TailType* tail ) 51 | { 52 | // try to find cached dep-set 53 | auto p = Map.find(tail); 54 | if ( p != Map.end() ) 55 | return p->second; 56 | 57 | // no cached entry -- create a new one and cache it 58 | HeadType* concat = build(tail); 59 | Map[tail] = concat; 60 | return concat; 61 | } 62 | }; // THeadTailCache 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Kernel/tKBFlags.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TKBFLAGS_H 21 | #define TKBFLAGS_H 22 | 23 | #include "flags.h" 24 | 25 | /// flags that reflects KB structure: GCIs, etc 26 | class TKBFlags: public Flags 27 | { 28 | public: // interface 29 | /// empty c'tor 30 | TKBFlags() = default; 31 | /// copy c'tor 32 | TKBFlags ( const TKBFlags& flags ) = default; 33 | 34 | /// register flag for GCIs 35 | FPP_ADD_FLAG(GCI,0x1); 36 | /// register flag for Range and Domain axioms 37 | FPP_ADD_FLAG(RnD,0x2); 38 | /// register flag for Reflexive roles 39 | FPP_ADD_FLAG(Reflexive,0x4); 40 | }; // TKBFlags 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Kernel/tLabeller.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TLABELLER_H 21 | #define TLABELLER_H 22 | 23 | #include "fpp_assert.h" 24 | #include "tCounter.h" 25 | 26 | /** define class that implements support for labelling entries with 27 | * cheap 'unselect' operation. An external entity is 'marked' iff 28 | * it's value equal to the internal counter. 29 | */ 30 | class TLabeller 31 | { 32 | private: // internal type definition 33 | /// type of a counter 34 | typedef TCounter LabelCounter; 35 | 36 | public: // type interface 37 | /// define integral type of a label 38 | typedef LabelCounter::IntType LabelType; 39 | 40 | protected: // members 41 | /// counter 42 | LabelCounter counter{1}; 43 | 44 | public: // interface 45 | 46 | // operations with Labeller 47 | 48 | /// create a new label value 49 | void newLabel ( void ) 50 | { 51 | counter.inc(); 52 | fpp_assert ( counter.val() != 0 ); 53 | } 54 | 55 | // operations with Labels 56 | 57 | /// set given label's value to the counter's one 58 | void set ( LabelType& lab ) const { lab = counter.val(); } 59 | /// clear given label's value (independent of a labeller) 60 | static void clear ( LabelType& lab ) { lab = 0; } 61 | /// check if given label is labelled 62 | bool isLabelled ( const LabelType& lab ) const { return (lab == counter.val()); } 63 | }; // TLabeller 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Kernel/tProgressMonitor.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TPROGRESSMONITOR_H 21 | #define TPROGRESSMONITOR_H 22 | 23 | /// progress monitor and canceller for the classification 24 | class TProgressMonitor 25 | { 26 | public: 27 | /// empty c'tor 28 | TProgressMonitor() = default; 29 | /// empty d'tor 30 | virtual ~TProgressMonitor() = default; 31 | 32 | // interface 33 | 34 | /// informs about beginning of classification with number of concepts to be classified 35 | virtual void setClassificationStarted ( unsigned int ) {} 36 | /// informs about beginning of classification of a given CONCEPT 37 | virtual void nextClass ( void ) {} 38 | /// informs that the reasoning is done 39 | virtual void setFinished ( void ) {} 40 | // @return true iff reasoner have to be stopped 41 | virtual bool isCancelled ( void ) { return false; } 42 | }; // TProgressMonitor 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Kernel/tRelated.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TRELATED_H 21 | #define TRELATED_H 22 | 23 | #include "tIndividual.h" 24 | #include "tRole.h" 25 | 26 | /// class for represent individual relation :R 27 | class TRelated 28 | { 29 | public: // members 30 | TIndividual* a = nullptr; 31 | TIndividual* b = nullptr; 32 | TRole* R = nullptr; 33 | 34 | public: // interface 35 | /// empty c'tor 36 | TRelated() = default; 37 | /// init c'tor 38 | TRelated ( TIndividual* a_, TIndividual* b_, TRole* R_ ) : a(a_), b(b_), R(R_) {} 39 | /// copy c'tor 40 | TRelated ( const TRelated& ) = default; 41 | /// assignment 42 | TRelated& operator = ( const TRelated& ) = default; 43 | 44 | /// simplify structure wrt synonyms 45 | void simplify ( void ) 46 | { 47 | R = resolveSynonym(R); 48 | a = resolveSynonym(a); 49 | b = resolveSynonym(b); 50 | a->addRelated(this); 51 | } 52 | /// get access to role wrt the FROM direction 53 | TRole* getRole ( void ) const { return R; } 54 | }; // TRelated 55 | 56 | // TIndividual RELATED-dependent method' implementation 57 | inline void 58 | TIndividual :: updateToldFromRelated ( void ) 59 | { 60 | RoleSSet RolesProcessed; 61 | updateTold ( RelatedIndex.begin(), RelatedIndex.end(), RolesProcessed ); 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Kernel/tRestorer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TRESTORER_H 21 | #define TRESTORER_H 22 | 23 | /** 24 | * Generic class for restore some property. 25 | * Usually inherited class has a pointer to object to be restored and restore info 26 | */ 27 | class TRestorer 28 | { 29 | protected: // members 30 | /// restore level 31 | unsigned int lev = 0; 32 | 33 | public: // interface 34 | /// empty d'tor 35 | virtual ~TRestorer() = default; 36 | /// restore an object based on saved information 37 | virtual void restore ( void ) = 0; 38 | 39 | // level operations 40 | 41 | /// set restore level 42 | void setLevel ( unsigned int l ) { lev = l; } 43 | /// get restore level 44 | unsigned int level ( void ) const { return lev; } 45 | }; // TRestorer 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Kernel/tSaveStack.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TSAVESTACK_H 21 | #define TSAVESTACK_H 22 | 23 | #include "growingArrayP.h" 24 | #include "fpp_assert.h" 25 | 26 | /** 27 | * Template stack for Saving/Restoring internal state of template parameter. 28 | * Implemented as a growing array of pointers with more ops 29 | */ 30 | template 31 | class TSaveStack: public growingArrayP 32 | { 33 | public: // interface 34 | // stack operations 35 | 36 | /// get a new object from the stack;it will be filled by caller 37 | T* push ( void ) 38 | { 39 | this->ensureHeapSize(); 40 | return this->Base[this->last++]; 41 | } 42 | /// get an object from the top of the stack 43 | T* pop ( void ) { return this->Base[--this->last]; } 44 | /// get an object from a fixed depth 45 | T* pop ( unsigned int depth ) 46 | { 47 | fpp_assert ( this->last >= depth ); 48 | this->last = depth; 49 | return pop(); 50 | } 51 | /// get an object from a fixed depth 52 | T* top ( unsigned int depth ) 53 | { 54 | fpp_assert ( this->last >= depth ); 55 | this->last = depth; 56 | return this->Base[depth-1]; 57 | } 58 | }; // TSaveStack 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Kernel/tsttree.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the FaCT++ DL reasoner 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester 3 | Copyright (C) 2015-2017 Dmitry Tsarkov 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef TSTTREE_H 21 | #define TSTTREE_H 22 | 23 | template < class T > 24 | class TsTTree 25 | { 26 | private: // members 27 | /// element in the tree node 28 | T elem; 29 | /// pointer to left subtree 30 | TsTTree *left; 31 | /// pointer to right subtree 32 | TsTTree *right; 33 | 34 | public: // interface 35 | /// default c'tor 36 | explicit TsTTree ( const T& Init, TsTTree *l = nullptr, TsTTree *r = nullptr ) 37 | : elem(Init) 38 | , left(l) 39 | , right(r) 40 | {} 41 | /// no copy c'tor 42 | TsTTree ( const TsTTree& ) = delete; 43 | /// no assignment 44 | TsTTree& operator = ( const TsTTree& ) = delete; 45 | /// d'tor 46 | ~TsTTree() = default; 47 | 48 | // access to members 49 | 50 | T& Element ( void ) { return elem; } 51 | const T& Element ( void ) const { return elem; } 52 | 53 | TsTTree* Left ( void ) const { return left; } 54 | TsTTree* Right ( void ) const { return right; } 55 | 56 | void SetLeft ( TsTTree *l ) { left = l; } 57 | void SetRight ( TsTTree *r ) { right = r; } 58 | 59 | TsTTree* clone ( void ) const 60 | { 61 | TsTTree* p = new TsTTree(Element()); 62 | if ( left ) 63 | p->SetLeft(left->clone()); 64 | if ( right ) 65 | p->SetRight(right->clone()); 66 | return p; 67 | } 68 | }; // TsTTree 69 | 70 | /// delete the whole tree 71 | template 72 | void deleteTree ( TsTTree* t ) 73 | { 74 | if ( t ) 75 | { 76 | deleteTree(t->Left()); 77 | deleteTree(t->Right()); 78 | delete t; 79 | } 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /eclipsefiles/classpathForOWLAPI4: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------