-
Notifications
You must be signed in to change notification settings - Fork 0
/
ooasp_aux_kb.lp
73 lines (53 loc) · 1.99 KB
/
ooasp_aux_kb.lp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
% Copyright (c) 2024 Siemens AG Oesterreich
% SPDX-License-Identifier: MIT
#program base.
#const use_dl = false.
% transitive closure
ooasp_subclass(SUB,SUPER2) :-
ooasp_subclass(SUB,SUPER1),
ooasp_subclass(SUPER1,SUPER2).
ooasp_subclass_ref(C1,C2):-ooasp_subclass(C1,C2).
ooasp_subclass_ref(C,C):-ooasp_class(C).
% derive domain for boolean attributes
ooasp_attr_enum(C,N,true) :-
ooasp_attr(C,N,boolean).
ooasp_attr_enum(C,N,false) :-
ooasp_attr(C,N,boolean).
% true, if attribute has domain
ooasp_attr_hasdomain(C,N) :-
ooasp_attr_enum(C,N,D).
ooasp_attr_enum(C,N,MIN..MAX) :-
ooasp_attr(C,N,enumint),
ooasp_attr_minInclusive(C,N,MIN),
ooasp_attr_maxInclusive(C,N,MAX).
ooasp_attr_fdom(C,N,MIN..MAX) :-
ooasp_attr(C,N,int),
ooasp_attr_minInclusive(C,N,MIN),
ooasp_attr_maxInclusive(C,N,MAX).
% leafclasses are classes without subclasses
ooasp_leafclass(C) :-
ooasp_class(C),
not ooasp_subclass(_,C).
% ooasp_assoc_limit(ASSOC,min,1,C1,C2MIN,C2)
% The association ASSOC must be from a C1 object to at least C2MIN objects of class C2
ooasp_assoc_limit(ASSOC,min,1,C1,C2MIN,C2):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX).
ooasp_assoc_limit(ASSOC,max,1,C1,C2MAX,C2):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX).
ooasp_assoc_limit(ASSOC,min,2,C2,C1MIN,C1):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX).
ooasp_assoc_limit(ASSOC,max,2,C2,C1MAX,C1):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX).
ooasp_smallest_assoc(ASSOC,C1,1):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX),
#false : ooasp_assoc(ASSOC',C1',_,_,_,_,_),
ooasp_subclass(C1', C1),
ooasp_assoc_specialization(ASSOC',ASSOC).
ooasp_smallest_assoc(ASSOC,C2,2):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX),
#false : ooasp_assoc(ASSOC',_,_,_,C2',_,_),
ooasp_subclass(C2', C2),
ooasp_assoc_specialization(ASSOC',ASSOC).
ooasp_smallest_assoc(ASSOC):-
ooasp_assoc(ASSOC,C1,C1MIN,C1MAX,C2,C2MIN,C2MAX),
not ooasp_assoc_specialization(_,ASSOC).