Why is {a^nb^n | n >= 0} not regular?

前端 未结 5 542
野趣味
野趣味 2020-12-01 14:38

In a CS course I\'m taking there is an example of a language that is not regular:

{a^nb^n | n >= 0}

I can understand that it is not regu

5条回答
  •  借酒劲吻你
    2020-12-01 15:08

    Assume L = {anbn | n ≥ 0} is regular. Then we can use the pumping lemma.

    Let n be the pumping lemma number. Consider w = anbn∈L. The pumping lemma states that you can divide w into xyz such that xy ≤ n, y ≥ 1 and ∀ i∈ℕ0: xyiz∈L.

    Using the first two rules we can easily see that no matter how we divide w into xyz, y will always consist of only as and that it will contain at least one such letter. With rule 3 we conclude that an-kbn∈L where k = |y| ≥ 1. But n-k ≠ n violates the definition of L, so that an-kbn∉L. This is a contradiction

提交回复
热议问题