class Bud::MapLattice
Public Class Methods
new(i={})
click to toggle source
# File lib/bud/lattice-lib.rb, line 91 def initialize(i={}) reject_input(i) unless i.class == Hash i.each_pair do |k,val| reject_input(i) if k.class <= Bud::Lattice reject_input(i) unless val.class <= Bud::Lattice end @v = i end
Public Instance Methods
do_apply(sym, args)
click to toggle source
# File lib/bud/lattice-lib.rb, line 157 def do_apply(sym, args) rv = {} @v.each_pair do |k, val| res = val.send(sym, *args) raise Bud::Error unless res.kind_of? Bud::Lattice rv[k] = res end wrap_unsafe(rv) end
inspect()
click to toggle source
# File lib/bud/lattice-lib.rb, line 107 def inspect "<#{self.class.wrapper}: #{@v.inspect}>" end
lt_eq(i)
click to toggle source
Return true if this map is strictly smaller than or equal to the given map. “x” is strictly smaller than or equal to “y” if:
(a) every key in "x" also appears in "y" (b) for every key k in "x", x[k] <= y[k]
NB: For this to be a morphism, we require that (a) “self” is deflationary (or fixed) (b) the input lattice value is inflationary (or fixed). We currently don't have a way to express (a) in the type system.
# File lib/bud/lattice-lib.rb, line 206 def lt_eq(i) reject_input(i, "lt_eq") unless i.class <= self.class @v.each do |k, v| unless i.key?(k).reveal == true return Bud::BoolLattice.new(false) end unless v.lt_eq(i.at(k).reveal).reveal == true return Bud::BoolLattice.new(false) end end return Bud::BoolLattice.new(true) end
merge(i)
click to toggle source
# File lib/bud/lattice-lib.rb, line 100 def merge(i) rv = @v.merge(i.reveal) do |k, lhs_v, rhs_v| lhs_v.merge(rhs_v) end wrap_unsafe(rv) end