| 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 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 <stdio.h> |
| 21 | #include "fact.h"cxx . . $ `<file>/FaCT++.C/fact.h`/ |
| 22 | |
| 23 | void print2Darraycxx . . $ print2Darray(7240d775d6ca6bef). ( const char*** names ) |
| 24 | { |
| 25 | printfcxx . . $ printf(581fddd72a8db8fc).("[\n"); |
| 26 | int n=0; |
| 27 | const char** syns = names[0]; |
| 28 | while ( syns != NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! ) |
| 29 | { |
| 30 | printfcxx . . $ printf(581fddd72a8db8fc).("["); |
| 31 | int m = 0; |
| 32 | const char* name; |
| 33 | while ( (name = syns[m++]) != NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! ) |
| 34 | printfcxx . . $ printf(581fddd72a8db8fc).("%s ", name); |
| 35 | printfcxx . . $ printf(581fddd72a8db8fc).("]\n"); |
| 36 | syns=names[++n]; |
| 37 | } |
| 38 | printfcxx . . $ printf(581fddd72a8db8fc).("]\n"); |
| 39 | } |
| 40 | |
| 41 | int maincxx . . $ main(b126dc7c1de90089). ( void ) |
| 42 | { |
| 43 | putscxx . . $ puts(5c4306d8553b3696).("Starting FaCT++ C interface tests"); |
| 44 | // create kernel |
| 45 | fact_reasoning_kernelcxx . . $ fact_reasoning_kernel#* k = fact_reasoning_kernel_newcxx . . $ fact_reasoning_kernel_new(28e9d7dd6f515579).(); |
| 46 | |
| 47 | // create classes C,D, property R |
| 48 | putscxx . . $ puts(5c4306d8553b3696).("Creating entities"); |
| 49 | fact_concept_expressioncxx . . $ fact_concept_expression#* c = fact_conceptcxx . . $ fact_concept(2e05ad31311a6113).(k,"C"); |
| 50 | fact_concept_expressioncxx . . $ fact_concept_expression#* d = fact_conceptcxx . . $ fact_concept(2e05ad31311a6113).(k,"D"); |
| 51 | fact_individual_expressioncxx . . $ fact_individual_expression#* i = fact_individualcxx . . $ fact_individual(570125aa55df19e5).(k,"I"); |
| 52 | fact_o_role_expressioncxx . . $ fact_o_role_expression#* r = fact_object_rolecxx . . $ fact_object_role(1f9ec7b9122f3b04).(k,"R"); |
| 53 | |
| 54 | // create C [= ER.T, ER.T [= D |
| 55 | putscxx . . $ puts(5c4306d8553b3696).("Creating axioms"); |
| 56 | fact_concept_expressioncxx . . $ fact_concept_expression#* some = fact_o_existscxx . . $ fact_o_exists(7cb4a414e79a2027). ( k, r, fact_topcxx . . $ fact_top(254067e1cc007d96).(k)); |
| 57 | fact_implies_conceptscxx . . $ fact_implies_concepts(a057e2b9494f5e1c). ( k, c, some ); |
| 58 | fact_implies_conceptscxx . . $ fact_implies_concepts(a057e2b9494f5e1c). ( k, some, d ); |
| 59 | fact_instance_ofcxx . . $ fact_instance_of(e328f32d1c01e02d). ( k, i, c ); |
| 60 | |
| 61 | // classify KB is not necessary: it's done automatically depending on a query |
| 62 | putscxx . . $ puts(5c4306d8553b3696).("Classifying ontology"); |
| 63 | fact_classify_kbcxx . . $ fact_classify_kb(26409078a160b9a5).(k); |
| 64 | |
| 65 | // check whether C [= D |
| 66 | putscxx . . $ puts(5c4306d8553b3696).("Is C subsumed by D?"); |
| 67 | if ( fact_is_subsumed_bycxx . . $ fact_is_subsumed_by(1d45acc05db55301).(k,c,d) ) |
| 68 | putscxx . . $ puts(5c4306d8553b3696).("Yes!\n"); |
| 69 | else |
| 70 | putscxx . . $ puts(5c4306d8553b3696).("No...\n"); |
| 71 | |
| 72 | // create a concept actor and use it to get all superclasses of C |
| 73 | putscxx . . $ puts(5c4306d8553b3696).("All superclasses of C:"); |
| 74 | fact_actorcxx . . $ fact_actor#* actor = fact_concept_actor_newcxx . . $ fact_concept_actor_new(9303d6e05c25e76d).(); |
| 75 | fact_get_sup_conceptscxx . . $ fact_get_sup_concepts(61757da891428bc8).(k,c,0,&actor); |
| 76 | print2Darraycxx . . $ print2Darray(7240d775d6ca6bef).(fact_get_elements_2dcxx . . $ fact_get_elements_2d(7f33d4e3ca83ba3a).(actor)); |
| 77 | fact_actor_freecxx . . $ fact_actor_free(534c382c4221b972).(actor); |
| 78 | |
| 79 | // create an individual actor and use it to get all instances of C |
| 80 | putscxx . . $ puts(5c4306d8553b3696).("All instances of C:"); |
| 81 | fact_actorcxx . . $ fact_actor#* i_actor = fact_individual_actor_newcxx . . $ fact_individual_actor_new(9303d6e05c25e76d).(); |
| 82 | fact_get_instancescxx . . $ fact_get_instances(f4220f0a4f97e42a).(k, c, &i_actor); |
| 83 | print2Darraycxx . . $ print2Darray(7240d775d6ca6bef).(fact_get_elements_2dcxx . . $ fact_get_elements_2d(7f33d4e3ca83ba3a).(i_actor)); |
| 84 | fact_actor_freecxx . . $ fact_actor_free(534c382c4221b972).(i_actor); |
| 85 | |
| 86 | // get all the properties |
| 87 | putscxx . . $ puts(5c4306d8553b3696).("All object properties:"); |
| 88 | fact_o_role_expressioncxx . . $ fact_o_role_expression#* o_top = fact_object_role_topcxx . . $ fact_object_role_top(1636ce7f1effb735).(k); |
| 89 | actor = fact_o_role_actor_newcxx . . $ fact_o_role_actor_new(9303d6e05c25e76d).(); |
| 90 | fact_get_sub_rolescxx . . $ fact_get_sub_roles(b72a409f6a38abd6).(k,(fact_role_expressioncxx . . $ fact_role_expression#*)o_top,0,&actor); |
| 91 | print2Darraycxx . . $ print2Darray(7240d775d6ca6bef).(fact_get_elements_2dcxx . . $ fact_get_elements_2d(7f33d4e3ca83ba3a).(actor)); |
| 92 | fact_actor_freecxx . . $ fact_actor_free(534c382c4221b972).(actor); |
| 93 | |
| 94 | // we done so let's free memory |
| 95 | putscxx . . $ puts(5c4306d8553b3696).("Destroying reasoning kernel"); |
| 96 | fact_reasoning_kernel_freecxx . . $ fact_reasoning_kernel_free(26409078a160b9a5).(k); |
| 97 | putscxx . . $ puts(5c4306d8553b3696).("All done"); |
| 98 | return 0; |
| 99 | } |