Opened 6 years ago

Closed 6 years ago

#16758 closed defect (fixed)

FiniteStateMachine.composition: check types

Reported by: cheuberg Owned by:
Priority: major Milestone: sage-6.3
Component: finite state machines Keywords: composition
Cc: skropf, dkrenn Merged in:
Authors: Clemens Heuberger Reviewers: Daniel Krenn
Report Upstream: N/A Work issues:
Branch: 61f6acf (Commits) Commit: 61f6acf619b2c13010ea4c420743fc05fededc8b
Dependencies: Stopgaps:

Description (last modified by cheuberg)

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.

Change History (4)

comment:1 Changed 6 years ago by cheuberg

  • Authors set to Clemens Heuberger
  • Branch set to u/cheuberg/fsm/composition-types
  • Commit set to 61f6acf619b2c13010ea4c420743fc05fededc8b
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

5704b11trac #16758: Add failing doctests
6dc0263trac #16758: Disallow composition with automaton
61f6acftrac #16758: Use class of outer machine in composition

comment:2 Changed 6 years ago by dkrenn

  • Reviewers set to Daniel Krenn

comment:3 Changed 6 years ago by dkrenn

  • Status changed from needs_review to positive_review

Fine for me.

comment:4 Changed 6 years ago by vbraun

  • Branch changed from u/cheuberg/fsm/composition-types to 61f6acf619b2c13010ea4c420743fc05fededc8b
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.