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.
-
(1p) Use recursion to define two functions #a, #b * that return the number of occurrences of a and b, respectively, in their input.
-
(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
Get step-by-step solutions from verified subject matter experts
