import vcsn

"""
Explanation: automaton.star(algo = "auto")
Build an automaton that recognizes the Kleene star of the input automaton.
The algorithm has to be one of these:

"general": general star, no additional preconditions.
"standard": standard star.
"auto": default parameter, same as "standard" if parameters fit the standard preconditions, "general" otherwise.

Preconditions:
- "standard": automaton has to be standard.
Postconditions:
- "standard": the result automaton is standard.
- "general": the context of the result automaton is nullable.
See also:
- automaton.multiply
End of explanation
"""


%%automaton a
context = "lan_char, b"
$ -> s
s -> A \e
A -> s \e
s -> $

ctx = vcsn.context('lal_char, q')
aut = lambda e: ctx.expression(e).standard()

"""
Explanation: This is what the general algorithm for star outputs, given an automaton A and s being a new state.
The transition from s to A represents each initial transition of A.
The transition from A to s represents each final transition of A.
End of explanation
"""


aut('a+b').star("standard")

"""
Explanation: Examples
Standard
End of explanation
"""


aut('a+b').star("general")

"""
Explanation: General
End of explanation
"""


