Comments (2)
Hi,
The pushdown automata accepting by empty stack and the pushdown automata accepting by final state have the same representation based on 7-tuples (see Hopcroft or Wikipedia for the complete definition). Therefore, Pyformlang represents them with the same class and it is the user who decides whether they want the language represented by final state acceptance or empty stack acceptance. It is true that it can be confusing when performing transformations between CFG and these two acceptance modes: Nothing indicates that you must use your PDA by accepting by final states or by empty stack to obtain a language equivalent to what you were manipulating before.
For the two functions to_final_state()
and to_empty_stack()
, the input and output are what we expect. to_final_state()
supposes that the user provides a PDA P that generates by empty stack a language L and it returns a PDA P' that generates by final states the same language L (but it generates another language by empty stack).
For the functions to_pda()
(applied to a CFG) and to_cfg()
, it is important to remember that the transformation involves two representations of the same language. The first one is a context-free grammar and the second is a push-down automaton when accepting by empty stack. However, nothing forces the user to use the PDA to accept by empty stack only.
I tried to clarify a bit the documentation. Also, for the intersection function, it was not clear that it involves a PDA when accepting by final state.
What are your thoughts about it? Do you think we should add the possibility to force the acceptance mode and add warning messages?
from pyformlang.
Ah yes right, this makes it more clear for me. I'm not quite sure about enforcing the acceptance mode, but I think this would make it more clear and possible for the user to check in which mode the PDA is.
Maybe some sort of a boolean indicating the acceptance mode, which is given to the PDA on creation and of which the PDA keeps track on its own later on (conversions...). For backwards compatibility reasons, this attribute could be set to some kind of ignore checks
value (but this eliminates the thought of using a boolean for this).
But this is just my opinion, and to be honest, I'm not that experienced in programming in bigger structures ;)
from pyformlang.
Related Issues (10)
- Standard regular expression HOT 1
- pyformlang.regular_expression.regex_objects.MisformedRegexError: Wrong parenthesis regex Regex HOT 1
- Is there algorith to convert epsNFA to NFA (remove epsilon transitions)? HOT 7
- Bug with braces and brackets in character ranges in PythonRegex HOT 10
- Trouble with epsilon in CFG HOT 3
- Trouble with Regex HOT 1
- Bug with CNF HOT 1
- Bug with to_normal_form() function HOT 2
- AttributeError: module 'pyformlang' has no attribute 'regular_expression' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyformlang.