patternMinor
Prove: possible to construct automata accepting all strings of other automata sans 1-length strings
Viewed 0 times
alllengthautomatasanspossibleproveacceptingconstructotherstrings
Problem
I believe that I have a procedure for doing this, but I don't know how to approach the proof (and for that matter I'm not entirely sure the procedure is correct).
Here's the exact problem statement:
Given DFA $A = (\Sigma, Q, q_0, F, \delta)$ construct DFA $B$ from $A$ s.t. it accepts all words of the language of $A$ which have length distinct from 1.
And here's pseudocode that has to solve the problem followed by some explanation:
The code tries to be more or less Python. Auxiliary functions do what their name
Here's the exact problem statement:
Given DFA $A = (\Sigma, Q, q_0, F, \delta)$ construct DFA $B$ from $A$ s.t. it accepts all words of the language of $A$ which have length distinct from 1.
And here's pseudocode that has to solve the problem followed by some explanation:
def ensure_word_length_ne_one(alphabet,
states,
initial,
final,
transition_function)
loops = [i for i in alphabet if transition_function(initial, i) == initial)]
new = make_new_accepting_state()
# all arcs to the states directly accessible from the initial state
# except the arcs from the initial state
backarcs = [(arc.source, arc.destination, arc.input)
for arc in arcs_to(set(for arc in arcs_from(initial))) -
set(arcs_from(initial))]
for input in loops:
# Remove all loops from the first state
add_transition(initial, new, input)
remove_transition(initial, initial, input)
add_transition(new, new, input)
for input in alphabet:
# Bounce back from the new state to the first state
add_transition(new, initial, input)
for source, destination, input in backarcs:
# For each state directly reachable
# from the first state reattach
# all inbound transitions
# to the new state
new = make_new_accepting_state()
remove_transition(source, destination, input)
add_transition(source, new, input)
outbound = [(arc.input, arc.destination) for arc in arcs_from(new)]
for input, destination in outbound:
# Bounce back from the new state
# to the states immediately
# reachable from source state
add_transition(new, destination, input)The code tries to be more or less Python. Auxiliary functions do what their name
Solution
Basically, the answer is what @Shaull says in the comments: construct a product automaton with the one that accepts all strings of length unequal 1.
What we use here is the fact that regular languages are closed under intersection. The product construction takes two automata, and simulates them in parallel. States are pairs of states of the original two automata. The combination accepts if both components accept.
But you ask for "minimal operations". So, have a look at what is in fact the automaton that accepts strings of length not 1. It simply has three states "zero", "one" and "many" with a loop for each letter at the last state. It simply counts letters up to length two (and then keeps in that state).
The product construction for this specific automaton is rather straightforward. Set aside a copy of your original automaton $A$. (You might add label "many" to each of the states, but that is extra.) Now add to these fresh copies of the original initial state and all states reachable in one step from the initial state. If the initial state has a loop, it is copied twice. (If you fancy it these get extra labels "zero" and "one"). Now remove final states from the "one"s and copy the original wiring.
Like I said, this is just a particular case of the product construction. In fact it might be even what is in your own pseudo code.
What we use here is the fact that regular languages are closed under intersection. The product construction takes two automata, and simulates them in parallel. States are pairs of states of the original two automata. The combination accepts if both components accept.
But you ask for "minimal operations". So, have a look at what is in fact the automaton that accepts strings of length not 1. It simply has three states "zero", "one" and "many" with a loop for each letter at the last state. It simply counts letters up to length two (and then keeps in that state).
The product construction for this specific automaton is rather straightforward. Set aside a copy of your original automaton $A$. (You might add label "many" to each of the states, but that is extra.) Now add to these fresh copies of the original initial state and all states reachable in one step from the initial state. If the initial state has a loop, it is copied twice. (If you fancy it these get extra labels "zero" and "one"). Now remove final states from the "one"s and copy the original wiring.
Like I said, this is just a particular case of the product construction. In fact it might be even what is in your own pseudo code.
Context
StackExchange Computer Science Q#46896, answer score: 3
Revisions (0)
No revisions yet.