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

//
// Aggregate 4
//
// Test if aggregation works correctly with unsigned
//

.decl A(x:unsigned)
.decl C(x:unsigned)
.output C

A(1).
A(2).
A(3).
A(0xffffffff).


C(y)              :- y = max a : A(a).          // 0xffffffff
C(y)              :- y = min a : A(a).          // 1
C(y)              :- y = sum a : {A(a), a < 4}. // 6
C(to_unsigned(y)) :- y = count : {A(_)}.        // 4
