3 ms·
Prolog indeed seems eminently suitable for this use case. For example, let us consider the first use case shown on the page: graql>> match $x isa
by zmonx 9y ago
Prolog indeed seems eminently suitable for this use case.
For example, let us consider the first use case shown on the page:
graql>>
match
$x isa movie;
$y isa person;
$z isa movie value "Avatar";
($x, $y) isa directorship;
($y, $z) isa directorship;
select $x;
This finds movies directed by the director of Avatar.
Here are a few relations in Prolog that we can use for this example:
movie('Avatar').
movie('Titanic').
movie('Aliens').
movie('Terminator 2: Judgement Day').
person('James Cameron').
directorship(X, Y) :- movie_director(X, Y).
directorship(X, Y) :- movie_director(Y, X).
movie_director('Avatar', 'James Cameron').
movie_director('Titanic', 'James Cameron').
movie_director('Aliens', 'James Cameron').
movie_director('Terminator 2: Judgement Day', 'James Cameron').
These are Prolog facts and rules that suffice to illustrate this use case.
In Prolog, we can query this database as follows:
?- findall(X, (movie(X),
person(Y),
movie(Z), Z = 'Avatar',
directorship(X, Y),
directorship(Y, Z)), Xs).
Note how closely this query corresponds to the initial example!
Prolog answers with:
Xs = ['Avatar', 'Titanic', 'Aliens', 'Terminator 2: Judgement Day'].
Note that this is in fact more complete than what the example shows:
results>>
[
{"isa": "movie", "value": "Titanic"},
{"isa": "movie", "value": "Aliens"},
{"isa": "movie", "value": "Terminator 2: Judgement Day"}
]
Interestingly, this misses Avatar!
- doctormiko 9y agoHi, Grakn developer here. In fact you have just caught a mistake in our website! If you run that query on a live system, it will return Avatar: we missed a line in the example query specifying that we want movies different from Avatar. We will fix the website asap