lib/lrama/counterexamples.rb in lrama-0.6.9 vs lib/lrama/counterexamples.rb in lrama-0.6.10
- old
+ new
@@ -1,15 +1,17 @@
+# frozen_string_literal: true
+
require "set"
-require "lrama/counterexamples/derivation"
-require "lrama/counterexamples/example"
-require "lrama/counterexamples/path"
-require "lrama/counterexamples/production_path"
-require "lrama/counterexamples/start_path"
-require "lrama/counterexamples/state_item"
-require "lrama/counterexamples/transition_path"
-require "lrama/counterexamples/triple"
+require_relative "counterexamples/derivation"
+require_relative "counterexamples/example"
+require_relative "counterexamples/path"
+require_relative "counterexamples/production_path"
+require_relative "counterexamples/start_path"
+require_relative "counterexamples/state_item"
+require_relative "counterexamples/transition_path"
+require_relative "counterexamples/triple"
module Lrama
# See: https://www.cs.cornell.edu/andru/papers/cupex/cupex.pdf
# 4. Constructing Nonunifying Counterexamples
class Counterexamples
@@ -169,26 +171,26 @@
result.concat(sis)
target_state_item = si
break
end
- if !si.item.beginning_of_rule?
+ if si.item.beginning_of_rule?
+ key = [si.state, si.item.lhs]
+ @reverse_productions[key].each do |item|
+ state_item = StateItem.new(si.state, item)
+ queue << (sis + [state_item])
+ end
+ else
key = [si, si.item.previous_sym]
@reverse_transitions[key].each do |prev_target_state_item|
next if prev_target_state_item.state != prev_state_item.state
sis.shift
result.concat(sis)
result << prev_target_state_item
target_state_item = prev_target_state_item
i = j
queue.clear
break
- end
- else
- key = [si.state, si.item.lhs]
- @reverse_productions[key].each do |item|
- state_item = StateItem.new(si.state, item)
- queue << (sis + [state_item])
end
end
end
else
# Find reverse transition