There seem to be at least 2 issues in the Automaton.process method, which 
is found in  sage.combinat.finite_state_machine. They appear in Sage 10.3. 

Unexpected errors are thrown and incorrect outputs result from calling 
Automaton.process() when, in various combinations (a) instances of 
FSMTransition are declared by the label of an FSMState rather than by the 
instance of FSMState itself, (b) the input tape for processing is 
encapsulated in a tuple, rather than a list, and (c) the inputs contain 
commas, e.g. if the alphabet contains tuples. The documentation suggests 
that (a) and (b) should make no difference, and makes no mention of any 
issues with (c).

For instance: 

from sage.combinat.finite_state_machine import FSMTransition, Automaton, 
FSMState

#Test 1
my_state = FSMState(1)
my_transition = FSMTransition(1, 1, ('a','a'))
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process([('a','a')])
#throws a ValueError with message "State 1 does not belong to a finite 
state machine"

#Test 2
my_state = FSMState(1)
my_transition = FSMTransition(1, 1, ('a','a'))
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process((('a','a')))
#returns the incorrect output (False, None), which indicates that (‘a’, 
‘a’) was not the label of a transition starting at the initial state. 
Expected output is (False, 1).

#Test 3
my_state = FSMState(1)
my_transition = FSMTransition(my_state, my_state, ('a','a'))
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process([('a','a')])
#returns the expected output (False, 1)

#Test 4
my_state = FSMState(1)
my_transition = FSMTransition(my_state, my_state, ('a','a'))
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process((('a','a')))
#returns the incorrect output (False, None), which indicates that (‘a’, 
‘a’) was not the label of a transition starting at the initial state. 
Expected output is (False, 1).

#Test 5
my_state = FSMState(1)
my_transition = FSMTransition(1, 1, ('a'))
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process(['a'])
#throws a ValueError with message "State 1 does not belong to a finite 
state machine"

#Test 6
my_state = FSMState(1)
my_transition = FSMTransition(1, 1, 'a')
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process(('a'))
#throws a ValueError with message "State 1 does not belong to a finite 
state machine"

#Test 7
my_state = FSMState(1)
my_transition = FSMTransition(my_state, my_state, 'a')
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process(['a'])
#returns the expected output (False, 1)

#Test 8
my_state = FSMState(1)
my_transition = FSMTransition(my_state, my_state, 'a')
my_automaton = Automaton([my_transition], initial_states = [my_state])
my_automaton.process(('a'))
#returns the expected output (False, 1)

My best guess is that these bugs have to do with the way FSMStates are 
assigned the .transitions attribute. In other tests, calling 
Automaton.process has thrown AttributeErrors in lines that ask for this 
attribute.

Best,

Daniel Levitin

P.S. I would be happy to try to fix this myself, but I do not understand 
the way the process iterator works. If someone here is familiar with this 
module and is willing to explain it to me, I would appreciate it.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/b0553c27-55b6-4912-86b2-e316d7322c32n%40googlegroups.com.

Reply via email to