简体   繁体   中英

Regex and grammar free context conversion

Can the following CFG be converted to a Regex?

在此处输入图像描述

Someone said that this could be it regex: (ab* a + b)*

is this true and why? I cant seem to understand it

It's not a regular language.

Consider the subset of the language with exactly one b . (In other words, the intersection of the language with a*ba* .) If the language were regular, that subset would also be regular, since it would be the intersection of two regular languages.

But it's not regular, since it consists of strings in which the number of a s following the b is at least as large as the number of a s preceding the b , and that is not a regular language ("regular languages can't count").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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