Question: Define a language S containing words over the alphabet = {a, b} inductively in the following way: The empty word is in S : S

Define a language S containing words over the alphabet = {a, b} inductively in the following way:

  • The empty word is in S: S.

  • If u, v S, then auavb S.

  • If u, v, w S, then buavaw S.

  1. (1p) Use recursion to define two functions #a, #b * that return the number of occurrences of a and b, respectively, in their input.

  2. (2p) Use induction to prove that w S. #a(w) = 2 #b(w).

    Hint: You might want to show that #a(auavb)=2+#a(u)+#a(v). How do you prove this? This property follows from a lemma that you can perhaps prove by induction: u,v*.#a(uv)=#a(u)+#a(v).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!