-
Notifications
You must be signed in to change notification settings - Fork 0
/
concept.lp
40 lines (31 loc) · 934 Bytes
/
concept.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
% Extracting formal concepts from a formal context.
% This do not scale well.
% The context used is the following.
% f g h i j k
rel(a,(f;g)). % a × ×
rel(b,(g;h;j;k)). % b × × × ×
rel(c,(i;j;k)). % c × × ×
rel(d,(g;i)). % d × ×
rel(e,(f;g;h;i)). % e × × × ×
% 9 concepts are found in this context:
% a e × f g
% a b d e × g
% b × g h j k
% c × i j k
% b c × j k
% c d e × i
% d e × g i
% e × f g h i
% b e × g h
% Each of these concepts will be generated in its own answer set with the following code.
% X is an object if in relation with all attributes.
obj(X):- rel(X,_) ; rel(X,Y): att(Y).
% Y is an attribute if in relation with all objects.
att(Y):- rel(_,Y) ; rel(X,Y): obj(X).
% Avoid answer sets containing no objects.
:- not obj(X):obj(X).
% Avoid answer sets containing no attributes.
:- not att(Y):att(Y).
#show.
#show obj/1.
#show att/1.