// Souffle - A Datalog Compiler
// Copyright (c) 2016, The Souffle Developers. 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

// : defines a directed graph
.decl _?(x:number, y:number)
.input _?(filename="input.facts")

// ? defines the transitive closure
.decl ?(x:number, y:number)
?(A,B) :- _?(A,B).
?(A,C) :- _?(A,B), ?(B,C).

// A and B are related if there is more than one path between them, which paths are not connected.
.decl really_really_long_relation_string(x:number, y:number)
.output really_really_long_relation_string()
really_really_long_relation_string(A, B) :- ?(A, C), ?(A, D), ?(C, B), ?(D, B), !?(C,D), !?(D,C).

.decl a_1234_?another_one_(x:number, y:number)
.output a_1234_?another_one_(filename="a_1234_another_one_.csv")
a_1234_?another_one_(A,B) :- really_really_long_relation_string(A,C), really_really_long_relation_string(C,B).

.decl a_?_extended?_relation_name(x:number, y:number)
.output a_?_extended?_relation_name(filename="a__extended_relation_name.csv")
a_?_extended?_relation_name(A,B) :- really_really_long_relation_string(C,A), really_really_long_relation_string(C,B), A != B.
a_?_extended?_relation_name(A,B) :- really_really_long_relation_string(A, B), a_?_extended?_relation_name(A,C), a_?_extended?_relation_name(C,B).
a_?_extended?_relation_name(A,B) :- really_really_long_relation_string(A, B), a_?_extended?_relation_name(A,C), a_?_extended?_relation_name(B,C).
