简体   繁体   English

正则表达式简化问题

[英]Regular Expression Simplification Issue

I'm trying to understand the equivalence between regular expressions α and β defined below, but I'm losing my mind over conflicting information. 我试图理解下面定义的正则表达式α和β之间的等价关系,但由于信息冲突而迷失了方向。

a+b:   a or b
ab:    concatenation of a and b
$:     empty string

α = (1*+0)+(1*+0) (0+1)*($+0+1) α= (1 * + 0)+(1 * + 0) (0 + 1)*($ + 0 + 1)

β = (1*+0) (0+1)*($+0+1) β= (1 * + 0) (0 + 1)*($ + 0 + 1)

https://ivanzuzak.info/noam/webapps/regex_simplifier/ says, that α is equivalent to β . https://ivanzuzak.info/noam/webapps/regex_simplifier/表示α等于β

My school however teaches that concatenation has stronger binding than union, meaning that: 但是,我学校教导说,级联比联合具有更强的约束力,这意味着:

11*+0 =/= 1(1*+0) 11 * + 0 = / = 1(1 * + 0)

Which would mean that my α looks like this with parentheses: 这意味着我的α像这样用括号括起来:

α = (1*+0) + ( (1*+0)(0+1)*($+0+1) ) α= (1 * + 0)+ ((1 * + 0)(0 + 1)*($ + 0 + 1))

and that 然后

α =/= ( (1*+0) + (1*+0) ) (0+1)*($+0+1) α= / = ((1 * + 0)+(1 * + 0)) (0 + 1)*($ + 0 + 1)


I hope it's clear what my problem is, I'd appreciate any kind of help. 我希望很清楚我的问题是什么,我将不胜感激。 Thanks. 谢谢。

Usually, two regular expressions are considered equivalent when they match the same set of words. 通常,当两个正则表达式匹配同一组单词时,它们被认为是等效的。

How they match it is not relevant. 它们如何匹配并不重要。 Therefore it doesn't matter which of the operators has greater precedence. 因此,哪个运算符具有更高的优先级并不重要。

Note the subtle difference between being equal (in written form) and being equivalent (having the same effect). 请注意,相等(书面形式)和等同(具有相同效果)之间的细微差别。

Alright, it turns out that I have misunderstood why b+b <=> b. 好的,事实证明我误解了为什么b + b <=> b。

It's that L1∪L2 <=> L2, if L1 is subset of L2. 如果L1是L2的子集,那就是L1∪L2<=> L2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM