This is my question from one of the past paper exams, I am solving it it but I am not sure.
The question is following:
A certain subset A of the set {0,1}* is defined recursively as follows:
Base case: λ ∈ A.
Constructor case 1: If s ∈ A then 0s ∈ A.
Constructor case 2: If s ∈ A then 10s ∈ A.
Constructor case 3: If s ∈ A then 11s ∈ A.
A certain function f : {x,y,z}* --> {0,1}* is defined recursively as follows:
Base case: f(λ) = λ.
Constructor case 1: f(xs) = 0f(s) = <0, f(s)>
Constructor case 2: f(ys) = 10f(s) = <1, <0, f(s)>>
Constructor case 3: f(zs) = 11f(s) = <1, <1, f(s)>>
Prove that f is injective.
Prove that f({x,y,z}*) = A.
This is my solution:
In injective function if f(x)=f(y), then x=y.
Let's define a predicate P(s) ---> {0,1}*
Where for every t ∈ {x,y,z}*
If we can prove that s=t when f(s)=f(t)
Then we can conclude that function f is injective.
Base Case:
In Base case λ ∈ A
As well as f(λ) = λ, therefore
f(s) = f(t) as both equal to λ
Constructor Case:
Case 1;
f(xs) = 0f(s) = <0, f(s)>
f(xt) = 0f(t) = <0, f(t)>
f(xs)=f(xt) => s = t
Case 2 and 3 the same way.
Therefore, we conclude that the function f is injective.
- I do not understand how to do this