#16758: FiniteStateMachine.composition: check types
-------------------------------------+-------------------------------------
       Reporter:  cheuberg           |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.3
      Component:  finite state       |   Resolution:
  machines                           |    Merged in:
       Keywords:  composition        |    Reviewers:
        Authors:  Clemens Heuberger  |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:  u/cheuberg/fsm     |  61f6acf619b2c13010ea4c420743fc05fededc8b
  /composition-types                 |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------
Changes (by {'newvalue': u'Clemens Heuberger', 'oldvalue': ''}):

 * status:  new => needs_review
 * commit:   => 61f6acf619b2c13010ea4c420743fc05fededc8b
 * branch:   => u/cheuberg/fsm/composition-types
 * author:   => Clemens Heuberger


Old description:

> The output of an automaton should not be feedable into a transducer
> (because there is none); when composing an automaton with a transducer,
> the result should be an automaton.
>
> The aim would be:
>
> {{{
> sage: from sage.combinat.finite_state_machine import (
> ....:     is_Automaton, is_Transducer)
> sage: T = Transducer([(0, 0, 0, 0)], initial_states=[0])
> sage: A = Automaton([(0, 0, 0)], initial_states=[0])
> sage: T.composition(A, algorithm='direct')
> Traceback (most recent call last):
> ...
> TypeError: Composition with automaton is not possible.
> sage: T.composition(A, algorithm='explorative')
> Traceback (most recent call last):
> ...
> TypeError: Composition with automaton is not possible.
> sage: A.composition(A, algorithm='direct')
> Traceback (most recent call last):
> ...
> TypeError: Composition with automaton is not possible.
> sage: A.composition(A, algorithm='explorative')
> Traceback (most recent call last):
> ...
> TypeError: Composition with automaton is not possible.
> sage: is_Automaton(A.composition(T, algorithm='direct'))
> True
> sage: is_Automaton(A.composition(T, algorithm='explorative'))
> True
> }}}
>
> I'll prepare a patch.

New description:

 The output of an automaton should not be feedable into a transducer
 (because there is none); when composing an automaton with a transducer,
 the result should be an automaton.

 The aim would be:

 {{{
 sage: from sage.combinat.finite_state_machine import (
 ....:     is_Automaton, is_Transducer)
 sage: T = Transducer([(0, 0, 0, 0)], initial_states=[0])
 sage: A = Automaton([(0, 0, 0)], initial_states=[0])
 sage: T.composition(A, algorithm='direct')
 Traceback (most recent call last):
 ...
 TypeError: Composition with automaton is not possible.
 sage: T.composition(A, algorithm='explorative')
 Traceback (most recent call last):
 ...
 TypeError: Composition with automaton is not possible.
 sage: A.composition(A, algorithm='direct')
 Traceback (most recent call last):
 ...
 TypeError: Composition with automaton is not possible.
 sage: A.composition(A, algorithm='explorative')
 Traceback (most recent call last):
 ...
 TypeError: Composition with automaton is not possible.
 sage: is_Automaton(A.composition(T, algorithm='direct'))
 True
 sage: is_Automaton(A.composition(T, algorithm='explorative'))
 True
 }}}

 This is now achieved by this patch.

--

Comment:

 New commits:
 
||[http://git.sagemath.org/sage.git/commit/?id=5704b119ea88d6aca50f2184bdd2e98b9b68708d
 5704b11]||{{{trac #16758: Add failing doctests}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=6dc0263a933affbc89820c328a13606f47db70ae
 6dc0263]||{{{trac #16758: Disallow composition with automaton}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=61f6acf619b2c13010ea4c420743fc05fededc8b
 61f6acf]||{{{trac #16758: Use class of outer machine in composition}}}||

--
Ticket URL: <http://trac.sagemath.org/ticket/16758#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to