module Validate

Public Instance Methods

collapse(left, right) click to toggle source
# File lib/bud/labeling/labeling.rb, line 128
def collapse(left, right)
  return [right] if left == 'Bot'
  return [left] if right == 'Bot'
  return [left] if left == right
  return ['D'] if left == 'D' or right == 'D'
  # CALM
  return ['D'] if left == 'A' and right =~ /N/
  # sometimes we cannot reduce
  return [left, right]
end
do_collapse(left, right) click to toggle source
# File lib/bud/labeling/labeling.rb, line 112
def do_collapse(left, right)
  l = left.pop
  r = right.shift
  left + collapse(l, r) + right
end
labelof(op, nm) click to toggle source
# File lib/bud/labeling/labeling.rb, line 118
def labelof(op, nm)
  if op == "<~"
    "A"
  elsif nm
    "N"
  else
    "Bot"
  end
end
validate() click to toggle source
# File lib/bud/labeling/labeling.rb, line 87
def validate
  dp = Set.new
  divergent_preds.each do |p| 
    dp.add(p.coll)
  end
  report = []
  full_path.to_a.each do |p|
    state = ["Bot"]
    start_a = -1
    p.label.each_with_index do |lbl, i|
      if lbl == "A"
        start_a = i + 1
      end
      os = state.first
      state = do_collapse(state, [lbl])
    end
    if dp.include? p.head
      report << (p.to_a + [:unguarded, ["D"]])
    else
      report << (p.to_a + [:path, state])
    end
  end
  return report
end