简体   繁体   English

构建一个仅接受单词 baa、ab 和 abb 且不接受其他更长或更短字符串的 FA

[英]Build an FA that accepts only the words baa, ab, and abb and no other strings longer or shorter

I have been trying solve this problem for a while now for a university assignment.我一直在尝试解决这个问题一段时间来完成大学作业。 I'm required to build a DFA and an NFA for the above question.我需要为上述问题建立一个 DFA 和一个 NFA。 So far I have been able to solve the DFA, but can not find a solution for a proper NFA after multiple tries.到目前为止,我已经能够解决 DFA,但在多次尝试后找不到合适的 NFA 的解决方案。

The solution of my DFA for the language provided above:我的 DFA 针对上面提供的语言的解决方案:

我的 DFA 针对上面提供的语言的解决方案:

My attempts for the NFA are down below.我对 NFA 的尝试如下。 I apologize for my messy handwriting but these were just rough works that I was drawing out on the go.我为我凌乱的笔迹道歉,但这些只是我在 go 上绘制的粗略作品。

My first attempt:我的第一次尝试:

我第一次尝试解决 NFA

My second attempt:我的第二次尝试:

我第二次尝试解决 NFA

My third attempt:我的第三次尝试:

我第三次尝试解决 NFA

There's only three words, so just make three parallel paths for your NFA, using a transition function like the following:只有三个词,所以只需为您的 NFA 创建三个并行路径,使用转换 function 如下所示:

Input State输入 State Input Symbol输入符号 Output States Output 状态
[start] [开始] a一个 [ab], [a.bb] [ab],[a.bb]
[start] [开始] b b [b.aa] [b.aa]
[ab] [ab] b b [ab#] [ab#]
[a.bb] [a.bb] b b [ab.b] [ab.b]
[ab.b] [ab.b] b b [abb#] [abb#]
[b.aa] [b.aa] a一个 [ba.a] [ba.a]
[ba.a] [ba.a] a一个 [baa#] [咩#]

Here, state names are in brackets ([..]) and state names that end with "#" are terminal.在这里,state 名称在括号 ([..]) 中,以“#”结尾的 state 名称是终端名称。

Generally it's considered easier to make an NFA than a DFA, so the usual method is to first make an NFA and then make the DFA by modifying the NFA by changing multiple output states to a single intermediate state.通常认为制作 NFA 比 DFA 更容易,因此通常的方法是先制作 NFA,然后通过将多个 output 状态更改为单个中间 state 来修改 NFA 来制作 DFA。

If you followed this method for the above NFA, then the resulting DFA would look something like this (I have appended an "*" to the intermediate state names):如果您对上述 NFA 遵循此方法,则生成的 DFA 将如下所示(我已将“*”附加到中间 state 名称):

Input State输入 State Input Symbol输入符号 Output State Output State
[start] [开始] a一个 [ab*] [ab*]
[start] [开始] b b [b.aa] [b.aa]
[ab*] [ab*] b b [ab.*] [ab.*]
[ab.*] [ab.*] (e) (e) [ab#] [ab#]
[ab.*] [ab.*] b b [abb.*] [缩写*]
[abb.*] [缩写*] (e) (e) [abb#] [abb#]
[b.aa] [b.aa] a一个 [ba.a] [ba.a]
[ba.a] [ba.a] a一个 [baa#] [咩#]

I've been a bit loose about all of the empty symbol/end-of-input transitons to terminal states.我对所有空符号/输入结束转换到终端状态有点松懈。 If you need me to fill al of them in, them I can do that.如果你需要我填写所有这些,我可以做到。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 给定一个文件如何生成只接受文件中存在的那些单词的NFA? - Given a file how to generate an NFA that accepts only those words present in the file? 是否有两个状态 TG 接受来自 {a, b}* 的所有输入字符串,这些字符串不在 EVEN-EVEN 中? - Is there a two state TG that accepts all the input strings from {a, b}* that are not in EVEN-EVEN? “ <a>-&gt; ab|ac”的扩展BNF是什么?</a> - What's the Extended BNF of “<A> -> ab|ac”? 我需要制作一个 function ,它需要一段文本并输出文本中所有唯一单词的列表。 output 列表将包含字符串 - I need to make a function that takes a body of text and outputs a list of all unique words in the text. The output list will contain strings 如何从单个输入中获取两个字符串(单词之间用空格分隔) - How to get two strings from a single input (words separated by a space) 如何创建一个接受语言的下推自动机? - How to create a pushdown automata which accepts a language? 设T = { <M> | M是TM,只要接受w}就接受$ w ^ R $。 表明T是不可判定的 - Let T = {<M> | M is a TM that accepts $w^R$ whenever it accepts w}. Show that T is undecidable 如何在棋盘游戏中使用循环编写较短的代码 - How can I write shorter code by using loops in a board game 如果一个函数接受两个数组,并且该函数将在O(n)中一次迭代每个数组 - if a function accepts two arrays and that function will iterate each array one time is in O(n) 寻找非确定性有限自动机(NFA)接受给定NFA接受的语言的补充的方法是什么? - What are the ways to find a Non-Deterministic Finite Automata (NFA) that accepts complementary of the language accepted by a given NFA?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM