如何显示“反向”常规语言是常规语言


19

我陷入了以下问题:

“常规语言恰好是有限自动机所接受的语言。鉴于这一事实,表明如果语言L被某个有限自动机接受,那么也将被某些有限自动机接受;由所有单词组成的颠倒了。” LLRLRL


1
好吧,您是否尝试过构建可以接受的自动机LR?这可能有助于举一个例子。
吉尔斯(Gilles)'所以

谢谢您的回复。我不确定该怎么做。我确定任何L ^ R都会被某种语言接受,因为它是由相同的“字母”构成的,因此也将成为常规语言。我不确定如何去证明它,或如何画一个例子。
2012年

2
欢迎!对于诸如家庭作业这样的基本问题,我们喜欢该问题是否包含发问人的(重要)工作。您当然已经尝试了一些可以共享的东西(然后我们可以用来指导您正确的方向)。如果没有,我建议您重新检查您的定义并听从Gilles的建议。
拉斐尔

3
@Victoria“它是由相同的“字母”构成的,因此也将成为常规语言” –哦,nonono。{anbmaon,m,oN}{anbmann,mN}{anbnannN}都在相同的定义字母,但属于非常不同的语言类别。
拉斐尔

1
本章末尾的另一个问题要求我证明没有有限的自动机可以接受给定字母上的所有回文。我认为,要证明这一点取决于以下事实:如果考虑所有可能的回文(无长度限制),则状态是无限的,而机器是有限状态机。
2012年

Answers:


26

因此,给定规则语言,我们知道(本质上根据定义)它被某个有限自动机接受,因此存在一组状态,这些状态具有适当的转换,当且仅当输入是是L中的字符串。我们甚至可以坚持认为,只有一种接受状态可以简化事情。接受反向语言我们所要做的就是反转转换的方向,将开始状态更改为接受状态,并将接受状态更改为开始状态。然后我们有一个机器,是“倒退”相比原来的,并接受语言大号[R LLLR


非常感谢Luke-我想我明白您的意思。您发现了-我绝对没有有限自动机的实践经验!我会“投票”给你,但显然我没有足够的分数。对于那个很抱歉!
2012年

很好,您应该能够“接受”您喜欢的答案(投票按钮下方应有一个勾号)。同样,Saadtaame的更正式答案是继我之后的绝佳下一步。
Luke Mathieson,2012年

5
假设只有一种接受状态,我们要么必须允许 -transitions,或具有 ε 大号。我知道,两者都不是真正的限制,所以答案是可以的。ϵϵL
Hendrik 2013年1

1
是的,这个主意对我来说似乎很明显。棘手的部分是验证它是正确的。
没人

24

你必须证明你总是可以构造接受字符串中的有限自动机LR给出接受字符串在有限自动机L。这是执行此操作的过程。

  1. 反转自动机中的所有链接
  2. 添加一个新状态(称为qs
  3. 从状态q s到每个最终状态绘制一个标记为ϵ的链接qs
  4. 将所有最终状态转换为正常状态
  5. 将初始状态转换为最终状态
  6. 制作qs初始状态

让我们将所有这些形式化;我们首先说明定理。

定理。如果L是常规语言,则LR也是如此。

A=(QA,ΣA,δA,qA,FA)是一个NFA和让L=L(A)。下面定义的ϵ -NFA AR接受该语言LR

  1. AR=(QA{qs},ΣA,δAR,qs,{qA})qsQA
  2. pδA(q,a)qδAR(p,a),其中,aΣAq,pQA
  3. ϵclosure(qs)=FA

证明。首先,我们证明以下语句:从路径qpA标记w当且仅当从路径pqAR与标记wR(的反向w)为q,pQA。通过对w的长度进行归纳来证明。

  1. 基本情况:|w|=1
    保持通过的定义δAR
  2. 归纳法:假设该语句适用于长度<n单词,并让|w|=nw=xa
    pδA(q,w)=δA(q,xa)
    我们知道,δA(q,xa)=pδA(p,a) pδA(q,x)
    xa少于的话n符号。通过归纳假设,pδAR(p,a)qδAR(p,xR) 这意味着,qδAR(p,axR)pδA(q,xa)

q=qAp=s一些sFA而代wRaxR保证qδAR(s,wR) sFA。由于有标记有路径ϵqs到在每一个国家FA中的定义(3 AR从在每一个状态)和路径FA中的到以w R标记的状态qA的路径,则存在一个从q sq A标记为ϵ w R = w R的路径。这证明了定理。wRϵwR=wRqsqA

注意,这也证明了(LR)R=L

如果我的证明中有格式错误或缺陷,请进行编辑。


1
What do you mean by ϵclosure(qs)=FA?
user124384

But you can't have ϵ transition in deterministic regular languages can you!?
yukashima huksay

@yukashimahuksay True, but you can also always take a non-deterministic finite automaton and turn it into a deterministic finite automaton. They are equivalent.
Pro Q

12

To add to the automata-based transformations described above, you can also prove that regular languages are closed under reversal by showing how to convert a regular expression for L into a regular expression for LR. To do so, we'll define a function REV on regular expressions that accepts as input a regular expression R for some language L, then produces a regular expression R for the language LR. This is defined inductively on the structure of regular expressions:

  1. REV(ϵ)=ϵ
  2. REV()=
  3. REV(a)=a for any aΣ
  4. REV(R1R2)=REV(R2)REV(R1)
  5. REV(R1|R2)=REV(R1)|REV(R2)
  6. REV(R)=REV(R)
  7. REV((R))=(REV(R))

You can formally prove this construction correct as an exercise.

Hope this helps!


Hi! I landed here because I was thinking about the idea of reversed regular expressions, as a way of optimizing a right-anchored match against a string: feed the characters to the reverse automaton, in reverse order. One pass. I wrote down the algebraic properties of regex reversal, and it matches your table almost exactly, even using the rev() notation. :) I also put down REV(R1&R2) = REV(R1)&REV(R2); I have a regex implementation which has intersection. Yes; I'm thinking of adding an operator for reversal perhaps R\r (reverse preceding regex element).
Kaz

Here is a tricky one: what is the algebraic rule for REV(~R): regex negation? REV(~R) is the reverse of the set of all strings outside of R. Is that the same as ~REV(R): the set of all strings outside of the reverse of the set denoted by R? This is not clear at all because any palindromes in R are also in REV(R).
Kaz

1

Using regular expressions, prove that if L is a regular language then the \emph{reversal} of L, LR={wR:wL}, is also regular. In particular, given a regular expression that describes L, show by induction how to convert it into a regular expression that describes LR. Your proof should not make recourse to NFAs.

We will assume that we are given a regular expression that describes L. Let us first look at the concatination operator (), and then we can move onto more advanced operators. So our cases of concatenation deal with the length of what is being concatenated. So first we will break all concatenations from ab to ab. When dealing with these break the components up as much as possible: (aba)b(aba)b, but you cannot break associative order between different comprehensions of course.

When R

When s=ϵ, we have the empty string which is already reversed thus the mechanism does not change

When s is just a letter, as in sΣ, the reversal is just that letter, s

When s=σ, we have a single constituent so we just reverse that constituent and thus σR

When s=(σ0σ1...σk1σk) where k is odd, we have a regular expression which can be written as (σ0σ1...σk1σk). The reversal of these even length strings is simple. Merely switch the 0 index with the k index. Then Switch the 1 index with k-1 index. Continue till the each element was switched once. Thus the last element is now the first in the reg ex, and the first is the last. The second to last is the second and the second is the second to last. Thus we have a reversed reg ex which will accept the reversed string (first letter is the last etc.) And of course we reverse each constituent. Thus we would get (σkRσk1R...σ1Rσ0R)

When s=(σ0σ1...σk/2...σk1σk) where k is even, we have a regular expression generally which can be written as (σ0σ1...σk1σk). The reversal of these even length strings is simple. Merely switch the 0 index with the k index. Then Switch the 1 index with k-1 index. Continue till the each element was switched once, but the k/2 element (an integer because k is even). Thus the last element is now the first in the reg ex, and the first is the last. The second to last is the second and the second is the second to last. Thus we have a reversed reg ex which will accept the reversed string (first letter is the last etc.). And that middle letter. And of course we reverse each constituent. Thus we would get (σkRσk1R...σk/2R...σ1Rσ0R)

Okay the hard part is done. Let us look to the operator. This is merely a union of sets. So given two strings, s1,s2, the reverse of s1s2 is only s1Rs2R. The union will not change. And this makes sense. This will only add strings to a set. It does not matter which order they are added to the set, all that matters is that they are.

The kleene star operator is the same. It is merely adding strings to a set, not telling us how we should construt the string persay. So to reverse a kleene star of a string s, is only ((sR)). Reversal can just move through them.

Thus to reverse this (((ab)(a))((ab)(b)))R we simply follow the rules. To reverse the outer union we simply reverse its two components. To reverse this: ((ab)(a)) kleene star, we simply reverse what is inside it (((ab)(a))R). Then to reverse a concatenation, we index and then switch greatest with least. So we start with ((ab)(a))R and get ((a)R(ab)R). To reverse that single letter, we reach our base case and get (a)R(a). This process outlined above describes an inductive description of this change.

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.