Debian Codegraph @

FaCT++.Python/pyfactxx/tests/test_concept.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_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