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

// Range
// Check if a given value is in the specified range_, has inclusive and exclusive cases for both the minimum and maximum.

.decl range_(minimum:number, maximum:number)
.input range_()

.decl inclusive_inclusive(x:number)
.output inclusive_inclusive()
inclusive_inclusive(x)    :- range_(x, _).
inclusive_inclusive(x+1)  :- inclusive_inclusive(x), x+1 <= y, range_(_, y).

.decl inclusive_exclusive(x:number)
.output inclusive_exclusive()
inclusive_exclusive(x)    :- range_(x, _).
inclusive_exclusive(x+1)  :- inclusive_exclusive(x), x+1 < y, range_(_, y).

.decl exclusive_inclusive(x:number)
.output exclusive_inclusive()
exclusive_inclusive(x+1)  :- range_(x, _).
exclusive_inclusive(x+1)  :- exclusive_inclusive(x), x+1 <= y, range_(_, y).

.decl exclusive_exclusive(x:number)
.output exclusive_exclusive()
exclusive_exclusive(x+1)  :- range_(x, _).
exclusive_exclusive(x+1)  :- exclusive_exclusive(x), x+1 < y, range_(_, y).
