Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lfa:lab05-nfa-python [2020/11/02 10:55]
lfa
lfa:lab05-nfa-python [2020/11/08 13:11] (current)
dmihai
Line 34: Line 34:
 You'll find in //​nfa_skel.rar//​ a class that already reads the input and forms the NFA. You'll find in //​nfa_skel.rar//​ a class that already reads the input and forms the NFA.
  
-Also, you can use the **graphvizNFA** method to get a graphical representation ​for the NFA, but you will have to install the //​graphviz//​ library.+Also, you can use the **graphvizNFA** method to get a graphical representation ​of the NFA, but you will have to install the //​graphviz//​ library.
 <​code>​ <​code>​
    pip install graphviz    pip install graphviz
Line 41: Line 41:
 Implement (in Python) an NFA class that supports the following methods: Implement (in Python) an NFA class that supports the following methods:
  
-1. **step(configuration)** ​returns a list including ​all reachable configurations in //one step//​. ​An epsilon transition is also considered a step. +1. **step(configuration)** 
 +  * returns a list with all reachable configurations in //one step//. 
 +  * an epsilon transition is also considered a step. 
  
-2. **kstep(configuration,​ k)** returns a list including all reachable configurations in //k steps//. An epsilon transition is also considered a step. +2. **kstep(configuration,​ k)** 
 +  * returns a list including all reachable configurations in //k steps// 
 +  * an epsilon transition is also considered a step. 
 +  * the final list contains only the states where we stopped, not the entire path to them. 
 +  * if no transitions are available and $ k > 0 $, return an empty list
  
-3. **accept(self,​ word: Word)** ​True or False if the NFA accepts the given word. To simplify this task, you can use the kstep function.+3. **accept(self,​ word: Word)** 
 +  * True or False if the NFA accepts the given word.
  
-4. **epsilonClosure(self,​ state: State)** ​the set of all states where we can go from the current state by going through epsilon transitions+4. **epsilonClosure(self,​ state: State)** 
 +  * the set of all states where we can go from the current state by going through epsilon transitions
  
-5. **emptyLanguage(self)** ​True or False if the NFA's accepted language is the Empty Language+5. **emptyLanguage(self)** 
 +  * True or False if the NFA's accepted language is the Empty Language
  
 {{:​lfa:​nfa_skel.rar|}} {{:​lfa:​nfa_skel.rar|}}