Permalink
Browse files

Fix a bug in equivalence algorithm when bijection is not found.

  • Loading branch information...
1 parent 668cadb commit 8384bdc997bcaaf2ca8a257fca004333e7db36bd @blambeau committed Oct 4, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/stamina-core/stamina/transition_system/equivalence.rb
@@ -63,7 +63,9 @@ def propagate(deco, edge)
symbol = edge.symbol
source = reference.ith_state(deco)
eq_edge = algo.find_edge_counterpart(source, edge)
- algo.fail("No such transition `#{symbol}` from #{source}") unless eq_edge
+ unless eq_edge
+ algo.fail("No such transition `#{symbol}` from #{source}")
+ end
algo.equivalent_edges!(edge, eq_edge)
algo.equivalent_states!(edge.target, eq_edge.target)
eq_edge.target.index
@@ -89,8 +91,9 @@ def call(ts1, ts2, &explain)
fail "No initial state on ts1" unless i1
fail "No initial state on ts2" unless i2
equivalent_states!(i1, i2)
- EquivThroughDeco.new(ts2, self).call(ts1, {})
- return true
+ mapping = {}
+ EquivThroughDeco.new(ts2, self).call(ts1, mapping)
+ return !mapping.any?{|k,v| v.nil?}
end
return false
ensure

0 comments on commit 8384bdc

Please sign in to comment.