/*
 * Souffle - A Datalog Compiler
 * Copyright (c) 2019 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 nested aggregates are disallowed.

.decl Prime, D(x:number)

Prime(2).
Prime(3).
Prime(5).
Prime(7).
Prime(11).

// Sums all prime sums that are less than 10. So 2 + 3 is fine, but 2 + 3 + 5 + 7 is not.
D(s) :- s = sum y : { Prime(n), y = sum z : { Prime(z), z < n }, y < 10 }.

.output Prime, D()
