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

// Tests the use of the 'true' and 'false' constant literal constraints

.decl a(x:number)
a(0).
a(x+1) :- a(x), x < 999.

.decl b(x:number)
.output b()
b(1).
b(x) :- b(x), x < 1000, false.

.decl c(x:number)
.output c()
c(0) :- true.
c(1) :- false.
c(2) :- true.
c(3) :- false.
c(4) :- true, false.
c(5) :- true, true, true, true, true, 1=1, true, true.
c(6) :- 1=1, 2=2, 3=3, false, 4=4.
c(7) :- 1=1, false, false, false, false, false, 2=2.

.decl d(x:number)
.output d()
d(x) :- a(x), false.
d(x) :- b(x), true.
d(x) :- c(x), true.

// Test with aggregators
.decl e(x:number, y:symbol, z:number)
.output e()
// TODO: see comment on PR #595
// e(0, "fail", sum 1 : { false }).
// e(1, "fail", sum 1 : { false } + count : { false }).
e(2, "pass", count : { false } + count : { true }).
e(3, "pass", sum x : { true, b(x) }).
e(4, "pass", count : { a(_), true }).
e(5, "pass", count : { a(_), false}).
