Find the regular expression for the language on E={a,b}

安稳与你 提交于 2019-12-08 13:11:36

问题


L = w : (na(w) - nb(w)) mod 3 /= 0

How can I go about finding the regular expression for this language?

I understand that it means that the number of As minus the number of Bs cannot be a multiple of 3. So a - b cannot be 3,6,9,12, etc.

But I am still having trouble putting it into a regular expression. I tried first making it a DFA or NFA but I couldn't do that either.

Any help is appreciated!


回答1:


I would go about it by dividing the list of words on {a,b} into three cases:

  • L1 = w : (na(w) - nb(w)) mod 3 = 1
  • L2 = w : (na(w) - nb(w)) mod 3 = 2
  • L3 = w : (na(w) - nb(w)) mod 3 = 3

L is then L1 U L2, and you should be able to create expressions relating L1, L2, and L3. You should then be able to eliminate things and end up with a regular expression on {a,b}.



来源:https://stackoverflow.com/questions/19214574/find-the-regular-expression-for-the-language-on-e-a-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!