Class: Stamina::Automaton::Equivalence

Inherits:
TransitionSystem::Equivalence show all
Defined in:
lib/stamina-core/stamina/automaton/equivalence.rb

Overview

Implements the equivalence relation commonly used on canonical DFAs

Instance Method Summary collapse

Methods inherited from TransitionSystem::Equivalence

#call, #equivalent_edges!, #equivalent_states!, #equivalent_systems!, #fail, #find_edge_counterpart

Instance Method Details

#equivalent_edges?(e, f) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/stamina-core/stamina/automaton/equivalence.rb', line 20

def equivalent_edges?(e, f)
  e.symbol == f.symbol
end

#equivalent_states?(s, t) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/stamina-core/stamina/automaton/equivalence.rb', line 14

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)


7
8
9
10
11
12
# File 'lib/stamina-core/stamina/automaton/equivalence.rb', line 7

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)
end