bloom-lang / bud

Prototype Bud runtime (Bloom Under Development)
http://bloom-lang.net
Other
854 stars 60 forks source link

BudCollection#inspected yields wrong results w/ delta evaluation #283

Closed neilconway closed 11 years ago

neilconway commented 11 years ago

Consider this program:

require 'rubygems'
require 'bud'

class InspectTest
  include Bud

  state do
    table :in_t, [:v]
    table :inspect_res, [:v]
  end

  bloom do
    inspect_res <= in_t.inspected
  end
end

i = InspectTest.new
i.in_t <+ [[5]]
i.tick
puts i.inspect_res.to_a.sort.inspect
i.in_t <+ [[6]]
i.tick
puts i.inspect_res.to_a.sort.inspect

Expected results:

[["[5]"]]
[["[5]"], ["[5, 6]"]]

Observed results:

[["[5]"]]
[["[5]"], ["[6]"]]

The problem is that inspected is only called on delta values, but it is not a morphism; hence it should be evaluated over the "complete" value of in_t at every tick.

neilconway commented 11 years ago

On second thought, this is fine: I was under the impression that inspected returned a single tuple for the entire input collection, which would make it non-monotonic. inspected actually returns a collection (with one row per input tuple), so not only is the current behavior right, I think it is conservative: we can treat inspected as a monotonic predicate.