Class: Gisele::Analysis::Glts::WeakEquivalence

Inherits:
Stamina::TransitionSystem::Equivalence
  • Object
show all
Defined in:
lib/gisele/analysis/glts/equivalence.rb

Overview

Implements a weak equivalence relation based on structural equivalence and equal events and guards.

Instance Method Summary collapse

Instance Method Details

#equivalent_edges?(e, f) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/gisele/analysis/glts/equivalence.rb', line 22

def equivalent_edges?(e, f)
  (e[:event] == f[:event]) &&
  (e[:guard] == f[:guard])
end

#equivalent_states?(s, t) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/gisele/analysis/glts/equivalence.rb', line 16

def equivalent_states?(s, t)
  (s.initial?   == t.initial?) &&
  (s.accepting? == t.accepting?) &&
  (s.error?     == t.error?)
end

#equivalent_systems?(s, t) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'lib/gisele/analysis/glts/equivalence.rb', line 8

def equivalent_systems?(s, t)
  (s.state_count == t.state_count) &&
  (s.edge_count  == t.edge_count)  &&
  (s.alphabet    == t.alphabet)    &&
  (s.data        == t.data)        &&
  (s.c0          == t.c0)
end

#find_edge_counterpart(reference_state, operand_edge) ⇒ Object



27
28
29
30
# File 'lib/gisele/analysis/glts/equivalence.rb', line 27

def find_edge_counterpart(reference_state, operand_edge)
  expected = operand_edge.marks(:event, :guard)
  reference_state.out_edges.find{|e| e.marks(:event, :guard) == expected }
end