我陷入了以下问题:
“常规语言恰好是有限自动机所接受的语言。鉴于这一事实,表明如果语言被某个有限自动机接受,那么也将被某些有限自动机接受;由所有单词组成的颠倒了。” L
我陷入了以下问题:
“常规语言恰好是有限自动机所接受的语言。鉴于这一事实,表明如果语言被某个有限自动机接受,那么也将被某些有限自动机接受;由所有单词组成的颠倒了。” L
Answers:
因此,给定规则语言,我们知道(本质上根据定义)它被某个有限自动机接受,因此存在一组状态,这些状态具有适当的转换,当且仅当输入是是L中的字符串。我们甚至可以坚持认为,只有一种接受状态可以简化事情。接受反向语言我们所要做的就是反转转换的方向,将开始状态更改为接受状态,并将接受状态更改为开始状态。然后我们有一个机器,是“倒退”相比原来的,并接受语言大号[R 。
你必须证明你总是可以构造接受字符串中的有限自动机给出接受字符串在有限自动机。这是执行此操作的过程。
让我们将所有这些形式化;我们首先说明定理。
定理。如果是常规语言,则也是如此。
让是一个NFA和让。下面定义的 -NFA 接受该语言。
证明。首先,我们证明以下语句:从路径到在标记当且仅当从路径到在与标记(的反向)为。通过对的长度进行归纳来证明。
让和一些而代为保证 。由于有标记有路径从到在每一个国家中的定义(3 从在每一个状态)和路径中的到以w R标记的状态的路径,则存在一个从q s到q A标记为ϵ w R = w R的路径。这证明了定理。
注意,这也证明了。
如果我的证明中有格式错误或缺陷,请进行编辑。
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 into a regular expression for . To do so, we'll define a function on regular expressions that accepts as input a regular expression for some language , then produces a regular expression for the language . This is defined inductively on the structure of regular expressions:
You can formally prove this construction correct as an exercise.
Hope this helps!
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).
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)
.
Using regular expressions, prove that if is a regular language then the \emph{reversal} of , , is also regular. In particular, given a regular expression that describes , show by induction how to convert it into a regular expression that describes . Your proof should not make recourse to NFAs.
We will assume that we are given a regular expression that describes . 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 to . When dealing with these break the components up as much as possible: , but you cannot break associative order between different comprehensions of course.
When
When , we have the empty string which is already reversed thus the mechanism does not change
When is just a letter, as in , the reversal is just that letter,
When , we have a single constituent so we just reverse that constituent and thus
When where k is odd, we have a regular expression which can be written as . 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
When where k is even, we have a regular expression generally which can be written as . 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
Okay the hard part is done. Let us look to the operator. This is merely a union of sets. So given two strings, , the reverse of is only . 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 , is only . Reversal can just move through them.
Thus to reverse this we simply follow the rules. To reverse the outer union we simply reverse its two components. To reverse this: kleene star, we simply reverse what is inside it . Then to reverse a concatenation, we index and then switch greatest with least. So we start with and get . To reverse that single letter, we reach our base case and get . This process outlined above describes an inductive description of this change.