// 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

// Tests alpha-reduction when the same argument name is used in the rule and the appearance.
// E.g. if `a(x, y) :- rule.` is a rule, and `a(y, x)` appears in another rule's body.

.decl a(x:number, y:number) inline
a(0, 0).
a(x, y) :- b(x), b(y), x != y.

.decl b(x:number)
b(0).
b(x+1) :- b(x), x < 10.

.decl c(x:number, y:number)
c(x, y) :- a(y, x), x % 2 != 0, x = y - 2.
.output c()
