I'm trying to find out what the algorithm would be by being given two languages L1 and L2 to determine if they are equivalent (L1 = L2).
我试图通过给出两种语言L1和L2来确定算法是什么,以确定它们是否相等(L1 = L2)。
It's surprisingly difficult to come up with one as I've found, although I am pretty sure it needs to be converted to a DFA first and then reduce each of them to a minimal DFA..
我发现它很难想出一个,虽然我很确定它需要首先转换为DFA,然后将它们减少到最小的DFA。
Also, I know that if L1 - L2 and L2 - L1 are empty, then L1 = L2.
另外,我知道如果L1-L2和L2-L1为空,则L1 = L2。
Anyone good with theory here?
谁在这里有理论的好处?
2 个解决方案
#1
1
You can find a description of a reasonably efficient algorithm for testing r.e. equality here:
您可以找到一个合理有效的测试算法的描述r.e.平等在这里:
http://arxiv.org/PS_cache/arxiv/pdf/0907/0907.5058v1.pdf
http://arxiv.org/PS_cache/arxiv/pdf/0907/0907.5058v1.pdf
Dig through references of the article to find other solutions that may be less efficient, but easier to implement.
挖掘文章的参考资料,找出效率较低但更容易实施的其他解决方案。
#2
1
Here's a conceptually simple answer (assuming L1 and L2 are regular).
这是一个概念上简单的答案(假设L1和L2是常规的)。
1) Find DFAs D1 and D2 for L1 and L2 respectively.
1)分别找到L1和L2的DFA D1和D2。
2) Construct D'1 and D'2 from D1 and D2 by swapping accepting/non-accepting states (note that D'1 accepts exactly ~L1 and D'2 accepts ~L2 where ~ means "complement of")
2)通过交换接受/不接受状态从D1和D2构造D'1和D'2(注意D'1完全接受~L1和D'2接受~L2,其中〜表示“补充”)
3) Use the standard product construction three times to produce a DFA that accepts exactly (L1 intersect ~L2) union (L2 intersect ~L1)
3)使用标准产品结构三次产生一个完全接受(L1交叉~L2)联合的DFA(L2交叉~L1)
4) Check to see if the DFA from part 3 accepts any strings by checking each accepting state for reachability from the start state.
4)检查第3部分中的DFA是否接受任何字符串,方法是从开始状态检查每个接受状态是否可达。
5) If the DFA from part 3 accepts any strings, then L1 <> L2. Otherwise, L1=L2
5)如果第3部分的DFA接受任何字符串,则L1 <> L2。否则,L1 = L2
There are a huge number of heuristics you could use to speed this up, but conceptually, this is probably the simplest algorithm. A good reference for the product construction in part 3 is "Automata and Computability" by Dexter Kozen.
您可以使用大量的启发式来加快速度,但从概念上讲,这可能是最简单的算法。第3部分中产品构造的一个很好的参考是Dexter Kozen的“Automata and Computability”。
#1
1
You can find a description of a reasonably efficient algorithm for testing r.e. equality here:
您可以找到一个合理有效的测试算法的描述r.e.平等在这里:
http://arxiv.org/PS_cache/arxiv/pdf/0907/0907.5058v1.pdf
http://arxiv.org/PS_cache/arxiv/pdf/0907/0907.5058v1.pdf
Dig through references of the article to find other solutions that may be less efficient, but easier to implement.
挖掘文章的参考资料,找出效率较低但更容易实施的其他解决方案。
#2
1
Here's a conceptually simple answer (assuming L1 and L2 are regular).
这是一个概念上简单的答案(假设L1和L2是常规的)。
1) Find DFAs D1 and D2 for L1 and L2 respectively.
1)分别找到L1和L2的DFA D1和D2。
2) Construct D'1 and D'2 from D1 and D2 by swapping accepting/non-accepting states (note that D'1 accepts exactly ~L1 and D'2 accepts ~L2 where ~ means "complement of")
2)通过交换接受/不接受状态从D1和D2构造D'1和D'2(注意D'1完全接受~L1和D'2接受~L2,其中〜表示“补充”)
3) Use the standard product construction three times to produce a DFA that accepts exactly (L1 intersect ~L2) union (L2 intersect ~L1)
3)使用标准产品结构三次产生一个完全接受(L1交叉~L2)联合的DFA(L2交叉~L1)
4) Check to see if the DFA from part 3 accepts any strings by checking each accepting state for reachability from the start state.
4)检查第3部分中的DFA是否接受任何字符串,方法是从开始状态检查每个接受状态是否可达。
5) If the DFA from part 3 accepts any strings, then L1 <> L2. Otherwise, L1=L2
5)如果第3部分的DFA接受任何字符串,则L1 <> L2。否则,L1 = L2
There are a huge number of heuristics you could use to speed this up, but conceptually, this is probably the simplest algorithm. A good reference for the product construction in part 3 is "Automata and Computability" by Dexter Kozen.
您可以使用大量的启发式来加快速度,但从概念上讲,这可能是最简单的算法。第3部分中产品构造的一个很好的参考是Dexter Kozen的“Automata and Computability”。