// Souffle - A Datalog Compiler
// Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved
// Licensed under the Universal Permissive License v 1.0 as shown at:
// - https://opensource.org/licenses/UPL
// - <souffle root>/licenses/SOUFFLE-UPL.txt

// Test Case adopted from Ocaml datalog

.type Node <: symbol

.decl reachable (node1:Node, node2:Node)
.output reachable ()
.decl same_clique (node1:Node, node2:Node)
.output same_clique ()
.decl edge (node1:Node, node2:Node)
.output edge ()
.decl leg (node1:Node, node2:Node)
.output leg ()

leg(X,Z) :- edge(X,Y), edge(Y,Z).

reachable(X,Y) :- edge(X,Y).
reachable(X,Y) :- edge(X,Z), reachable(Z,Y).
same_clique(X,Y) :- reachable(X,Y), reachable(Y,X).

edge("a", "b").
edge("b", "c").
edge("c", "d").
edge("d", "a").

reachable("e","f").
