Debian Codegraph @

FaCT++.Python/pyfactxx/tests/test_set_op.py

raw symbols SCIP
1 #
2 # pyfactxx - Python interface to FaCT++ reasoner
3 #
4 # Copyright (C) 2016-2018 by Artur Wroblewski <[email protected]>
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 <http://www.gnu.org/licenses/>.
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