正则语言和正则语法之间的区别

发布于 2025-01-03 10:00:45 字数 139 浏览 5 评论 0原文

我的书对常规语法和常规语言给出了类似但略有不同的解释。 我怀疑这是错误的,正则语言和正则语法是一样的吗? 我的书的定义是: 如果所有产生式都是 V​​-> ,则语法是正则的。 aW或V→Wa,其中V、W非终结符或终结符,“a”终结符。W也可以为空或与V相同。

My book gives similar but slightly different explanations of regular grammar and regular language.
I doubt it's wrong, is a regular language the same thing of a regular grammar?
The definition of my book is:
A grammar is regular if all the productions are V-> aW or V->Wa with V,W non terminal or terminal symbols, "a" terminal symbol.W can also be empty or be the same of V.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

跨年 2025-01-10 10:00:45

正则语法和正则语言是两个不同的术语:

  1. 语言是一组(可能是无限的)有效的终结符号序列。
  2. 语法定义哪些是有效序列。

相同的语言可以用不同类别的语法(常规语法、上下文无关语法等)来表示。 如果一种语言可以用规则的语法表示,则该语言被称为规则语言。另一方面,正则语法总是定义正则语言。您发布的是常规语法的定义。

请参阅此维基百科帖子了解更多信息。

Regular grammars and regular languages are two different terms:

  1. A language is a (possibly infinite) set of valid sequences of terminal symbols.
  2. A grammar defines which are the valid sequences.

The same language could be represented with different class of grammars (regular, context free, etc.). A language is said to be regular if it can be represented with a regular grammar. On the othet hand, a regular grammar always defines a regular language. What you have posted is the definition of the regular grammar.

See this Wikipedia post for further information.

胡大本事 2025-01-10 10:00:45

形式语法是一组规则,而形式语言是一组字符串。

正则语法是描述正则语言的形式语法。

根据 维基百科

[T]左正则语法准确地生成所有正则语言。正确的正则语法描述了所有此类语言的逆向,即也正是正则语言。

如果允许混合左正则和右正则规则,我们仍然有一个线性语法,但不一定是正则语法。

在上面,左正则规则是V->Wa形式的规则(右正则,V->aW形式)。

A formal grammar is a set of rules, whereas a formal language is a set of strings.

A regular grammar is a formal grammar that describes a regular language.

According to Wikipedia:

[T]he left regular grammars generate exactly all regular languages. The right regular grammars describe the reverses of all such languages, that is, exactly the regular languages as well.

If mixing of left-regular and right-regular rules is allowed, we still have a linear grammar, but not necessarily a regular one.

In the above, left-regular rules are rules of the form V->Wa (right-regular, of the form V->aW).

月隐月明月朦胧 2025-01-10 10:00:45

我认为如果我解释了语言语法之间的区别,您的疑问将自动得到解决。

语言是一组字母表上的一组字符串,满足编码为语法的某些规则,而
语法用于生成语言。

所以基本上语法表示字符串的语法规则,并且可以用语法的起始符号生成的字符串集合称为语法的语言

I think if I explain the difference between a language and grammar, your queries will automatically get resolved.

A language is a set of strings over some set of alphabets satisfying certain rules encoded as grammars, while
Grammars are used to generate languages.

So basically grammars denote the syntactical rules of a string and the set of strings that can be generated with the start symbol of the grammar is called the Language of the grammar

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文