dfa

Implementing a code to simulate a finite automaton nondeterministic in c++

徘徊边缘 提交于 2019-11-29 03:00:14
问题 I'm doing an assignment for automata theory, which I have to determine whether a word is accepted or not by a transition function for a deterministic finite automaton I have this input file: 6 8 0 2 2 5 0 0 a 0 1 a 1 1 b 1 2 c 1 3 c 3 4 d 4 4 d 4 5 d 3 aaabcccc aabbbbcdc acdddddd The input starts with 4 integers, the first is the number of state for the automaton, next is the number of transitions of the automaton, the third number is the initial state, and then the number of final states.

NFA/DFA implementation in C#

懵懂的女人 提交于 2019-11-28 21:40:00
问题 Does anyone know of any good NFA and DFA implementation in C#, possibly implementing as well conversions between both? What I would like would be to be able to construct a NFA and then convert it automatically to a DFA, but without having to write my own code which would take a very long time. There is this Python code which perhaps I could use and integrate with C# using IronPython, but Python is slow. 回答1: Take a look at my series of posts about this subject: Regular Expression Engine in C#

Is L = {a^n b^m | n>m} a regular or irregular language?

浪尽此生 提交于 2019-11-28 11:25:27
I have troubles in solving/proving this problem. Any ideas please? Grijesh Chauhan L = {a n b m | n > m} is not regular language. Yes, the problem is tricky at first few try and deserve vote-up. Pumping Lemma a necessary property of regular language is tool for formal proof that language is not regular language. Formal definition: Pumping lemma for regular languages Let L be a regular language. Then there exists an integer p ≥ 1 depending only on L such that every string w in L of length at least p ( p is called the "pumping length") can be written as w = xyz (i.e., w can be divided into three

【正则表达式介绍篇】

徘徊边缘 提交于 2019-11-28 10:49:28
原文: http://blog.gqylpy.com/gqy/381      正则表达式 ,又称规则表达式。(英语:Regular Expression,在代码中常简写为Regex、regexp或RE),计算机科学的一个概念。正则表达式通常被用来检索、替换那些符合某个模式(规则)的文本。     许多程序设计语言都支持利用正则表达式进行字符串操作。例如,在 Perl 中就内建了一个功能强大的正则表达式引擎。正则表达式这个概念最初是由 Unix 中工具软件(例如 sed 和 grep )普及开的。正则表达式通常缩写称“regex”, 单数 有regexp、regex, 复数 regexps、regexes、regexen。 *** 概念     正则表达式是对 字符串 操作的一种逻辑公式,就是用事先定义好的一些特殊字符、及这个特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑。 简介     正则表达式是对字符串(包括普通字符(例如,a到z之间的字母)和特殊字符(称为“元字符”))操作的一种逻辑公式,就是用事先定义好的一些特定字符、及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑。正则表达式是一种文本模式,模式描述在搜索文本时要匹配的一个或多个字符串。 起源     正则表达式的“鼻祖

Modelling a Finite Deterministic Automaton via this data

微笑、不失礼 提交于 2019-11-28 10:00:22
问题 I have this input file: 2 3 2 1 ab 1 0 2 0 2 0 2 0 3 abaa aab aba 3 3 2 ade 0 1 2 1 2 0 2 1 0 1 2 2 2 a de The first line represents the number of test cases. Each test case starts with 3 integers, the first is the number of state for the automaton, next is the number of symbols in the alphabet and then the number of final states. The next line is the alphabet. The symbols appear together. Then there's a number of lines equal to the number of states that describe the transition function. The

Why L={wxw^R| w, x belongs to {a,b}^+ } is a regular language

爱⌒轻易说出口 提交于 2019-11-28 09:32:57
Using pumping lemma, we can easily prove that the language L1 = {WcW^R|W ∈ {a,b}*} is not a regular language . (the alphabet is {a,b,c}; W^R represents the reverse string W) However, If we replace character c with "x"(x ∈ {a,b}+) , say, L2 = {WxW^R| x, W ∈ {a,b}^+} , then L2 is a regular language . Could you give me some ideas? Grijesh Chauhan If we replace character c with x where (x ∈ {a,b} + ), say, L2 = {WXW R | x, W ∈ {a,b} + }, then L2 is a regular language. Yes, L2 is Regular Language :). You can write regular expression for L2 too. Language L2 = {WXW R | x, W ∈ {a,b} + } means: string

【正则表达式介绍篇】

不打扰是莪最后的温柔 提交于 2019-11-27 20:24:06
原文: http://blog.gqylpy.com/gqy/381 "     正则表达式 ,又称规则表达式。(英语:Regular Expression,在代码中常简写为Regex、regexp或RE),计算机科学的一个概念。正则表达式通常被用来检索、替换那些符合某个模式(规则)的文本。     许多程序设计语言都支持利用正则表达式进行字符串操作。例如,在 Perl 中就内建了一个功能强大的正则表达式引擎。正则表达式这个概念最初是由 Unix 中工具软件(例如 sed 和 grep )普及开的。正则表达式通常缩写称“regex”, 单数 有regexp、regex, 复数 regexps、regexes、regexen。 *** 概念     正则表达式是对 字符串 操作的一种逻辑公式,就是用事先定义好的一些特殊字符、及这个特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑。 简介     正则表达式是对字符串(包括普通字符(例如,a到z之间的字母)和特殊字符(称为“元字符”))操作的一种逻辑公式,就是用事先定义好的一些特定字符、及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑。正则表达式是一种文本模式,模式描述在搜索文本时要匹配的一个或多个字符串。 起源     正则表达式的“鼻祖

【正则表达式介绍篇】

蹲街弑〆低调 提交于 2019-11-27 19:54:18
原文: http://blog.gqylpy.com/gqy/381 "     正则表达式 ,又称规则表达式。(英语:Regular Expression,在代码中常简写为Regex、regexp或RE),计算机科学的一个概念。正则表达式通常被用来检索、替换那些符合某个模式(规则)的文本。     许多程序设计语言都支持利用正则表达式进行字符串操作。例如,在 Perl 中就内建了一个功能强大的正则表达式引擎。正则表达式这个概念最初是由 Unix 中工具软件(例如 sed 和 grep )普及开的。正则表达式通常缩写称“regex”, 单数 有regexp、regex, 复数 regexps、regexes、regexen。 *** 概念     正则表达式是对 字符串 操作的一种逻辑公式,就是用事先定义好的一些特殊字符、及这个特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑。 简介     正则表达式是对字符串(包括普通字符(例如,a到z之间的字母)和特殊字符(称为“元字符”))操作的一种逻辑公式,就是用事先定义好的一些特定字符、及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑。正则表达式是一种文本模式,模式描述在搜索文本时要匹配的一个或多个字符串。 起源     正则表达式的“鼻祖

DFA vs NFA engines: What is the difference in their capabilities and limitations?

徘徊边缘 提交于 2019-11-27 17:15:30
I am looking for a non-technical explanation of the difference between DFA vs NFA engines, based on their capabilities and limitations. David Thornley Deterministic Finite Automatons (DFAs) and Nondeterministic Finite Automatons (NFAs) have exactly the same capabilities and limitations. The only difference is notational convenience. A finite automaton is a processor that has states and reads input, each input character potentially setting it into another state. For example, a state might be "just read two Cs in a row" or "am starting a word". These are usually used for quick scans of text to

What will be the DFA for the regular expression 0(0+1)*0+1(0+1)*1?

孤人 提交于 2019-11-27 16:22:39
This is the DFA i have drawn- Is it correct? I am confused because q4 state has 2 different transitions for same input symbol which violates the rule of DFA , but I can't think of any other solution. Your DFA is not correct. your DFA is completely wrong so I don't comment DFA for RE: 0(1 + 0)*0 + 1(1 + 0)*1 Language Description : if string start with 0 it should end with 0 or if string start with 1 it should end with 1 . hence two final states (state-5, state-4). state-4 : accepts 1(1 + 0)*1 state-5 : accepts 0(1 + 0)*0 state-1 : start state. DFA : EDIT : + Operator in Regular Expression (0 +