From 01f700ec4db2ddf188a49e0208b47e30e1efecfe Mon Sep 17 00:00:00 2001 From: vandechat96 Date: Tue, 28 Feb 2023 23:41:09 +0100 Subject: [PATCH] start of pip3 --- pip3/1.db | 7 +++++++ pip3/2.db | 5 +++++ pip3/rep.lp | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 pip3/1.db create mode 100644 pip3/2.db create mode 100644 pip3/rep.lp diff --git a/pip3/1.db b/pip3/1.db new file mode 100644 index 0000000..4ba7a98 --- /dev/null +++ b/pip3/1.db @@ -0,0 +1,7 @@ +left(1,wine). left(1,year). right(1,quality). +left(2,wine). left(2,year). right(2,price). +row(10,wine,chablis). row(10,year,1995). row(10,quality,good). row(10,price,17). +row(11,wine,chablis). row(11,year,1996). row(11,quality,excellent). row(11,price,23). +row(12,wine,rothschild). row(12,year,1997). row(12,quality,good). row(12,price,29). +row(13,wine,rothschild). row(13,year,1997). row(13,quality,excellent). row(13,price,29). +row(14,wine,rothschild). row(14,year,1997). row(14,quality,bof). row(14,price,29). diff --git a/pip3/2.db b/pip3/2.db new file mode 100644 index 0000000..4c79f8a --- /dev/null +++ b/pip3/2.db @@ -0,0 +1,5 @@ +left(3,course). right(3,prof). +left(4,prof). left(4,hour). right(4,course). +row(14,prof,tom). row(14,course,se). row(14,hour,8). +row(15,prof,ann). row(15,course,se). row(15,hour,8). +row(16,prof,ann). row(16,course,krr). row(16,hour,8). diff --git a/pip3/rep.lp b/pip3/rep.lp new file mode 100644 index 0000000..e17f25b --- /dev/null +++ b/pip3/rep.lp @@ -0,0 +1,28 @@ +%#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).