// Souffle - A Datalog Compiler
// Copyright (c) 2017, 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

// This code tests magic set on an arity 0 output relation.

.pragma "magic-transform" "*"

.decl a(x:symbol)
.decl g(x:symbol)
.decl e(x:symbol)
.decl h(x:symbol, y:symbol)
.decl c(x:symbol)
.decl b(x:symbol, y:symbol)
.decl goal()

.output goal()

b("bbb", "ccc").
h("ddd", "eee").
c("fff").
g("ggg").

a(X) :- g(X).
a(X) :- b(X, Y), a(Y).
e(X) :- c(X), a(X), h(X, Y), c(Y), a(Y).
goal() :- e("bbb").
