PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX : <http://josd.github.io/eye/reasoning#>

(_:X _:Y) log:negativeSurface {
    () log:negativeSurface {
        _:X :fibonacci _:Y.
    }.
    (_:X 0 1) :fib _:Y.
}.

(_:A _:B) log:negativeSurface {
    () log:negativeSurface {
        (0 _:A _:B) :fib _:A.
    }.
}.

(_:A _:B) log:negativeSurface {
    () log:negativeSurface {
        (1 _:A _:B) :fib _:B.
    }.
}.

(_:A _:B _:X _:Y) log:negativeSurface {
    () log:negativeSurface {
        (_:X _:A _:B) :fib _:Y.
    }.
    _:X math:greaterThan 1.
    (_:X 1) math:difference _:C.
    (_:A _:B) math:sum _:D.
    (_:C _:B _:D) :fib _:Y.
}.

# queries
(_:X) log:querySurface {
    1 :fibonacci _:X.
}.

(_:X) log:querySurface {
    2 :fibonacci _:X.
}.

(_:X) log:querySurface {
    3 :fibonacci _:X
}.

(_:X) log:querySurface {
    91 :fibonacci _:X.
}.

(_:X) log:querySurface {
    283 :fibonacci _:X.
}.

(_:X) log:querySurface {
    3674 :fibonacci _:X.
}.
