// Souffle - A Datalog Compiler
// Copyright (c) 2016, Oracle and/or its affiliates. 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


.comp Impl {
    .decl R(x: number)
    R(0). R(1). R(2).
}

.comp A<T> {
    .init impl = T
    .decl Base(x: number)
    Base(x) :- impl.R(x).
}

.comp Derived<K> : A<K> {
    .decl Deriv(x:number)
    Deriv(42).
    Deriv(n) :- Base(n).
}

.init d = Derived<Impl>
.init a = A<Impl>

.decl DerivedOut(x: number)
.output DerivedOut()
.decl AOut(x: number)
.output AOut()

DerivedOut(x) :- d.Deriv(x).
AOut(x) :- a.Base(x).
