Testing intersection of two regular languages

后端 未结 2 1644
说谎
说谎 2021-01-18 15:12

I want to test whether two languages have a string in common. Both of these languages are from a subset of regular languages described below and I only need to know whether

2条回答
  •  无人共我
    2021-01-18 15:35

    I just did a quick search and this problem is decidable (aka can be done), but I don't know of any good algorithms to do it. One is solution is:

    1. Convert both regular expressions to NFAs A and B
    2. Create a NFA, C, that represents the intersection of A and B.
    3. Now try every string from 0 to the number of states in C and see if C accepts it (since if the string is longer it must repeat states at one point).

    I know this might be a little hard to follow but this is only way I know how.

提交回复
热议问题