add datalog

This commit is contained in:
Super_JK
2022-06-05 15:43:00 +02:00
parent 9dbd108c36
commit 93062cd7fa
6 changed files with 3353 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
S(1).
S(2).
S(3).
S(4).
S(5).
S(6).
S(7).
S(8).
S(9).
S(10).
S(11).
A(1, 2).
A(3, 1).
A(2, 4).
A(4, 3).
A(3, 5).
A(5, 4).
A(4, 6).
A(10, 7).
A(10, 8).
A(10, 9).
A(7, 8).
A(7, 9).
A(8, 9).

6
datalog/ex1.dl Normal file
View File

@@ -0,0 +1,6 @@
A1(X) :- movie("Dancing with Wolves",X,_).
A2(X) :- movie(X,"Steven Spielberg",_).
A3(X) :- screenplay(X,"Dancing with Wolves").
A4(X) :- A2(X), not screenplay("John Travolta", X).
A5(X) :- screenplay(X,"Lord of War"), screenplay(X,"National Treasure").
A6(X) :- movie(X,_,Y), screenplay(Z,X), actor(Z,Y).

18
datalog/ex2.dl Normal file
View File

@@ -0,0 +1,18 @@
A1(X) :- step(ID,_,"GARE CENTRALE",_), line(ID,_,X,_).
A2(X) :- step(_,_,"GARE CENTRALE",X).
A3(X) :- step(ID,DIR,"GARE CENTRALE",Z), step(ID,DIR,Z,X).
S(ID,DIR,X) :- step(ID,DIR,"GARE CENTRALE",X).
S(ID,DIR,X) :- S(ID,DIR,Z), step(ID,DIR,Z,X).
A4(X) :- S(_,_,X).
IDS(ID1,ID2) :- step(ID1,_,_,X), step(ID1,_,"AUMALE",_), step(ID2,_,X,_), step(ID2,_,"ESPLANADE",_).
A5(C) :- line(X,_,_,C), IDS(X,_).
A5(C) :- line(X,_,_,C), IDS(_,X).
A6(X) :- line(_,_,X,_), not A1(X).
SNS(ID,DIR,X,Y) :- step(ID,DIR,X,Z),step(ID,DIR,Z,Y), not Y = X.
SNS(ID,DIR,X,Y) :- SNS(ID,DIR,X,Z), step(ID,DIR,Z,Y), not Y = X.
A7(ID,X) :- SNS(ID,DIR,X,Y), step(ID,DIR,Y,X).
NotTermnial(X) :- step(ID,DIR,_,X),step(ID,DIR,X,_).
Junction(X) :- step(ID1,_,_,X), step(ID2,_,X,_), not ID1 = ID2.
A8(X) :- step(_,_,_,X), not NotTermnial(X), not Junction(X).
A9(C, S) :- step(L1,city,S,_), step(L2,city,S,_), line(L1,_,bus,C), line(L2,_,bus,C), not L1=L2.

7
datalog/ex3.dl Normal file
View File

@@ -0,0 +1,7 @@
%— movie : {Title, Author, Year}
% — screenplay : {Actor, Movie}
%— actor : {Name, BirthYear}
A1(X) :- movie(X,Y,_), Y != "Steven Spielberg".
A2(X) :- movie(X,"Steven Spielberg",_), not screenplay("Tom Cruise",X).
A3(X) :- movie(M,"Steven Spielberg",_), actor(X,_), not screenplay(X,M).

98
datalog/movies.dl Normal file
View File

@@ -0,0 +1,98 @@
movie("Amblin", "Steven Spielberg", 1968).
movie("Saturday Night Fever", "John Badham", 1977).
movie("Following", "Christopher Nolan", 1998).
movie("Dancing with Wolves", "Kevin Costner", 1990).
movie("The Silence of the Lambs", "Jonathan Demme", 1991).
movie("Face Off", "John Woo", 1997).
movie("Jaws", "Steven Spielberg", 1975).
movie("Batman Begins", "Christopher Nolan", 2005).
movie("Top Gun", "Tony Scott", 1986).
movie("The War of the Worlds", "Steven Spielberg", 2005).
movie("National Treasure", "Jon Turtletaub", 2004).
movie("Raiders of the Lost Ark", "Steven Spielberg", 1981).
movie("Rain Man", "Barry Levinson", 1988).
movie("Interstellar", "Christopher Nolan", 2014).
movie("Oblivion", "Joseph Kosinski", 2013).
movie("Lord of War", "Andrew Niccol", 2005).
movie("Hook", "Steven Spielberg", 1991).
movie("Mission: Impossible", "Brian de Palma", 1996).
movie("Dunkirk", "Christopher Nolan", 2017).
movie("Carrie", "Brian De Palma", 1976).
movie("Minority Report", "Steven Spielberg", 2002).
movie("Color Out of Space", "Richard Stanley", 2019).
movie("Pulp Fiction", "Quentin Tarantino", 1994).
movie("The Taking of Pelham 123", "Tony Scott", 2009).
screenplay("Kevin Costner", "Dancing with Wolves").
screenplay("Jodie Foster", "The Silence of the Lambs").
screenplay("Tom Cruise", "Top Gun").
screenplay("Jodie Foster", "Dancing with Wolves").
screenplay("John Travolta", "The Taking of Pelham 123").
screenplay("Tom Cruise", "Rain Man").
screenplay("Tom Cruise", "Oblivion").
screenplay("Anthony Hopkins", "The Silence of the Lambs").
screenplay("Val Kilmer", "Top Gun").
screenplay("Tom Cruise", "Mission: Impossible").
screenplay("Nicolas Cage", "Color Out of Space").
screenplay("Morgan Freeman", "Oblivion").
screenplay("John Travolta", "Carrie").
screenplay("Tom Cruise", "Minority Report").
screenplay("Jean Reno", "Mission: Impossible").
screenplay("Dustin Hoffman", "Rain Man").
screenplay("Melissa Leo", "Oblivion").
screenplay("Nicolas Cage", "National Treasure").
screenplay("Vanessa Redgrave", "Mission: Impossible").
screenplay("John Travolta", "Saturday Night Fever").
screenplay("Colin Farrell", "Minority Report").
screenplay("Madeleine Arthur", "Color Out of Space").
screenplay("Sean Bean", "National Treasure").
screenplay("John Travolta", "Pulp Fiction").
screenplay("Tom Cruise", "The War of the Worlds").
screenplay("Samantha Morton", "Minority Report").
screenplay("Mary McDonnell", "Dancing with Wolves").
screenplay("Dakota Fanning", "The War of the Worlds").
screenplay("Sissy Spacek", "Carrie").
screenplay("Uma Thurman", "Pulp Fiction").
screenplay("Denzel Washington", "The Taking of Pelham 123").
screenplay("Karen Gorney", "Saturday Night Fever").
screenplay("Diane Kruger", "National Treasure").
screenplay("Bruce Willis", "Pulp Fiction").
screenplay("John Travolta", "Face Off").
screenplay("Nicolas Cage", "Lord of War").
screenplay("Nicolas Cage", "Face Off").
screenplay("Gina Gershon", "Face Off").
screenplay("Jared Leto", "Lord of War").
screenplay("Graham Greene", "Dancing with Wolves").
screenplay("Piper Laurie", "Carrie").
screenplay("Ian Holm", "Lord of War").
screenplay("Tom Everett", "Dancing with Wolves").
actor("Kevin Costner", 1955).
actor("Jodie Foster", 1962).
actor("Tom Everett", 1948).
actor("Ian Holm", 1931).
actor("Piper Laurie", 1932).
actor("Graham Greene", 1904).
actor("Jared Leto", 1971).
actor("Gina Gershon", 1962).
actor("Nicolas Cage", 1964).
actor("John Travolta", 1954).
actor("Bruce Willis", 1955).
actor("Diane Kruger", 1976).
actor("Karen Gorney", 1945).
actor("Denzel Washington", 1954).
actor("Uma Thurman", 1970).
actor("Sissy Spacek", 1949).
actor("Dakota Fanning", 1994).
actor("Tom Cruise", 1962).
actor("Anthony Hopkins", 1937).
actor("Val Kilmer", 1959).
actor("Morgan Freeman", 1937).
actor("Jean Reno", 1948).
actor("Dustin Hoffman", 1937).
actor("Melissa Leo", 1960).
actor("Vanessa Redgrave", 1937).
actor("Colin Farrell", 1976).
actor("Madeleine Arthur", 1997).
actor("Sean Bean", 1959).

3200
datalog/stib.dl Normal file

File diff suppressed because it is too large Load Diff