question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow DFA transition function to be partial

See original GitHub issue

When I studied Automata Theory (and in the literature), the transition function for a DFA could be partial, this is, that there could be some states which do not have an associated transition for a symbol in the alphabet. In my particular case, I was trying to get this automata:

But, as I said, some states do not have an associated transition for a symbol (take for example state b). This, in principle, accomplishes the DFA restrictions since there is no state such that for a symbol in the alphabet there is more than one associated transition. When trying to obtain the above DFA using the transition function:

{
'': {'a': 'a', 'b': 'b'},
'a': {'b': 'ab', 'a': 'aa'},
'b': {'b': 'bb'},
'aa': {'a': 'aa', 'b': 'ab'},
'bb': {'a': 'ba'},
'ab': {'b': 'bb'},
'ba': {'a': 'aa'}
}

I get an exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/guillermh/.local/lib/python3.9/site-packages/automata/fa/dfa.py", line 23, in __init__
    self.validate()
  File "/home/guillermh/.local/lib/python3.9/site-packages/automata/fa/dfa.py", line 67, in validate
    self._validate_transitions(start_state, paths)
  File "/home/guillermh/.local/lib/python3.9/site-packages/automata/fa/dfa.py", line 59, in _validate_transitions
    self._validate_transition_missing_symbols(start_state, paths)
  File "/home/guillermh/.local/lib/python3.9/site-packages/automata/fa/dfa.py", line 29, in _validate_transition_missing_symbols
    raise exceptions.MissingSymbolError(
automata.base.exceptions.MissingSymbolError: state b is missing transitions for symbol a

I think there is a method _validate_transition_missing_symbols in automata.fa.dfa which is the culprit of this thing. I would make a pull request but right now I haven’t got the time to learn how to implement and run tests and testing code coverage (I’m pretty novice in contributing tasks). But I opened this issue in order to notify about the possible misconception about the formalities of DFA. Thank you beforehand!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
caleb531commented, Aug 16, 2021

@alkkem Alright, I’ve released Automata v5 with the allow_partial parameter! Hope you enjoy, and let me know if you run into any issues:

https://github.com/caleb531/automata/releases/tag/v5.0.0

1reaction
alkkemcommented, Jul 13, 2021

@caleb531 Hehe, you have cited the same page that I found when I was trying to figure out what the problem was.

Thank you for taking this in consideration 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

In a DFA, does the restriction for a total transition function ...
A DFA is a quintuple ⟨Σ,Q,q0,F,δ⟩, where Σ,Q are non-empty finite sets, ... For example, you might allow δ to be a partial...
Read more >
Efficient Minimization of DFAs with Partial Transition Functions
Abstract: Let PT-DFA mean a deterministic finite automaton whose transition relation is a partial function. We present an algorithm for ...
Read more >
1 On DFA
δ : Q × Σ → Q, a total transition function; ... A DFA is said to accept a string s if its...
Read more >
Formal Definition of DFA
Alternative Definition of Transition. 28 if we change the transition function ẟ from a total function to a partial function.
Read more >
Finite Automata
Entries of a transition table contain the values “accept”,. “error”, next states. e.g., Figure 3 ... a partial function from Q × ∑...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found