This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
TP-KRR/pip3/rep.lp
2023-02-28 23:41:09 +01:00

29 lines
1.1 KiB
Plaintext

%#show violate/3.
#show reprowID/1.
%#show unreprowID/1.
% I and J have a different value on the attribute A of functional dependecy F
% For the left and right part
diffRight(I,J,F) :- right(F,A), row(I,A,X), row(J,A,Y), X != Y.
diffLeft(I,J,F) :- left(F,A), row(I,A,X), row(J,A,Y), X != Y.
% I and J conflict on functional dependecy F
violate(I,J,F) :- diffRight(I,J,F), not diffLeft(I,J,F).
% Simple projection of the row identifers violated
violated(I) :- violate(I,G1,G2).
% I is in the repair because it conflict with nothing
reprowID(I) :- row(I,G1,G2), not violated(I).
% I is in the repair because it conflict with J but it is not in it
%reprowID(I) :- violated(I), violate(I,J,G), unreprowID(J).
% Choose a I that conflict but the other row must not be there
reprowID(I) :- violated(I), not unreprowID(I).
unreprowID(I) :- violated(I), not reprowID(I).
:- violate(I,J,G), reprowID(I), reprowID(J).
% There mut be at least one row that remain for a violated functional dependecy F
represented(F) :- reprowID(I), violate(I,G,F).
:- left(F,G1), violate(G2,G3,F), not represented(F).