automata

Pumping lemma (Regular language)

余生颓废 提交于 2019-12-07 05:04:05
问题 I need some help with a pumping lemma problem. L = { {a,b,c}* | #a(L) < #b(L) < #c(L) } This is what I got so far: y = uvw is the string from the pumping lemma. I let y = abbc^n, n is the length from the pumping lemma. y is in L because the number of a:s is less than the number of b:s, and the number of b:s is less than the number of c:s. I let u = a, v = bb and w = c^n. |uv| < y, as stated in pumping lemma. If I "pump" (bb)^2 then i get y = abbbbc^n which violates the rule #b(L) < #c(L). Is

Convert regular expression to CFG

被刻印的时光 ゝ 提交于 2019-12-07 01:33:10
问题 How can I convert some regular language to its equivalent Context Free Grammar? Is it necessary to construct the DFA corresponding to that regular expression or is there some rule for such a conversion? For example, consider the following regular expression 01+10(11) * How can I describe the grammar corresponding to the above RE? 回答1: Change A+B to grammar G -> A G -> B Change A* to G -> (empty) G -> A G Change AB to G -> AB and proceed recursively on A and B. Base cases are empty language

Construct Context free Grammar

大兔子大兔子 提交于 2019-12-06 04:42:16
How can I construct a context free grammar for the following language: L = {a^l b^m c^n d^p | l+n==m+p; l,m,n,p >=1} I started by attempting: S -> abcd | aAbBcd | abcCdD | aAbcdD | AabBcCd and then A = something else... but I couldn't get this working. . I was wondering how can we remember how many c's shud be increased for the no. of b's increased? For example: string : abbccd The grammar is : S1 -> a S1 d | S2 S2 -> S3 S4 S3 -> a S3 b | epsilon S4 -> S5 S6 S5 -> b S5 c | epsilon S6 -> c S6 d | epsilon Rule 1 adds equal number of a's and d's. Rule 3 adds equal number of a's and b's. Rule 5

Fixing unescaped XML entities in Java with Regex?

若如初见. 提交于 2019-12-06 02:46:34
问题 I have some badly formatted XML that I must parse. Fixing the problem upstream is not possible. The (current) problem is that ampersand characters are not always escaped properly, so I need to convert & into & If & is already there, I don't want to change it to &amp; . In general, if any well-formed entity is already there, I don't want to destroy it. I don't think that it's possible, in general, to know all entities that could appear in any particular XML document, so I want a solution where

Pumping lemma (Regular language)

浪尽此生 提交于 2019-12-05 09:08:56
I need some help with a pumping lemma problem. L = { {a,b,c}* | #a(L) < #b(L) < #c(L) } This is what I got so far: y = uvw is the string from the pumping lemma. I let y = abbc^n, n is the length from the pumping lemma. y is in L because the number of a:s is less than the number of b:s, and the number of b:s is less than the number of c:s. I let u = a, v = bb and w = c^n. |uv| < y, as stated in pumping lemma. If I "pump" (bb)^2 then i get y = abbbbc^n which violates the rule #b(L) < #c(L). Is this right ? Am I on the "right path" ? Thanks The main idea of the pumping lemma is to tell you that

Using finite automata as keys to a container

空扰寡人 提交于 2019-12-03 20:34:44
I have a problem where I really need to be able to use finite automata as the keys to an associative container. Each key should actually represent an equivalence class of automata, so that when I search, I will find an equivalent automaton (if such a key exists), even if that automaton isn't structurally identical. An obvious last-resort approach is of course to use linear search with an equivalence test for each key checked. I'm hoping it's possible to do a lot better than this. I've been thinking in terms of trying to impose an arbitrary but consistent ordering, and deriving an ordered

PDA to accept a language of strings containing more a's than b's

老子叫甜甜 提交于 2019-12-03 08:44:06
Produce a PDA to recognise the following language : the language of strings containing more a's than b's I have been struggling with this question for several days now, I seem to have hit a complete mental block. Would any one be able to provide some guidance or direction to how I can solve this problem? Divyanjali Your problem of "more a's than b's" can be solved by PDA. All you have to do is: When input is a and the stack is either empty or has an a on the top, push a on the stack; pop b , if b is the top. When input is b and the stack is either empty or has an b on the top, push b on the

Levenshtein DFA in .NET

杀马特。学长 韩版系。学妹 提交于 2019-12-03 01:35:38
Good afternoon, Does anyone know of an "out-of-the-box" implementation of Levenshtein DFA ( deterministic finite automata ) in .NET (or easily translatable to it)? I have a very big dictionary with more than 160000 different words, and I want to, given an inicial word w , find all known words at Levenshtein distance at most 2 of w in an efficient way. Of course, having a function which computes all possible edits at edit distance one of a given word and applying it again to each of these edits solves the problem (and in a pretty straightforwad way). The problem is effiency --- given a 7 letter

How to compare two LTLs?

限于喜欢 提交于 2019-12-02 09:04:37
问题 How can I compare two LTLs to see if one can contradict each other? I ask this because I have a hierarchical state machine and LTLs describing the behavior in each state. I need to know if a local LTL can contradict a global LTL. I saw in the Article 'Feature Specification and Automated Conflict Detection' that two LTLs properties f and g are inconsistent iff L(f) intersection L(g) is empty. And this is exactly the model checking question with f as the program and ¬g as the property. Can

Testing intersection of two regular languages

自古美人都是妖i 提交于 2019-12-01 18:19:44
问题 I want to test whether two languages have a string in common. Both of these languages are from a subset of regular languages described below and I only need to know whether there exists a string in both languages, not produce an example string. The language is specified by a glob-like string like /foo/**/bar/*.baz where ** matches 0 or more characters, and * matches zero or more characters that are not / , and all other characters are literal. Any ideas? thanks, mike EDIT: I implemented