// Souffle - A Datalog Compiler
// Copyright (c) 2020, 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
// Test that indexed inequalities are correctly computed for various types

.decl rel_1(x:unsigned)
.output rel_1

rel_1(0).
rel_1(x+1) :- rel_1(x), x >= 0, x < 5.

.decl rel_2(x:unsigned)
.output rel_2

rel_2(2^32-5).
rel_2(x+1) :- rel_2(x), x >= 2^32-5, x < 2^32-1.

.decl rel_3(x:float)
.output rel_3

rel_3(64.0).
rel_3(x / 2) :- rel_3(x), x >= 0.001.

.decl rel_4(x:float)
.output rel_4

rel_4(x) :- rel_3(x), x >= 0.04, x <= 0.2.

.decl rel_5(x:number, y:symbol, z:float, a:number)
.output rel_5

rel_5(0, "apple", 3.0, 0).
rel_5(x-1, "strawberry", z+0.125, a-2) :- rel_5(x, _, z, a), x >= -5, z <= 5.0, a > -12.
rel_5(x, "mango", z, a) :- rel_5(x, _, z, a), x >= -3, z <= 4.0, a > -10.

.decl rel_6(s1: number, s2: number, s3: number, s4: number, s5: number, s6: number, s7: number)
rel_6(1,2,3,4,5,6,7).

.decl rel_7(x:number)
.output rel_7

rel_7(x) :- rel_6(1,_,3,4,5,_,_), rel_6(1,2,y,4,5,6,7), rel_6(_,2,3,4,5,6,_), rel_6(_,2,_,4,_,6,_), rel_6(1,_,_,4,_,_,_), rel_6(_,_,x,_,_,_,_), x > 3, y > 3.
