How to define a function involving strings?

  • Thread starter Thread starter DevNeil
  • Start date Start date
  • Tags Tags
    Function Strings
AI Thread Summary
The discussion revolves around defining a function f from the set of strings X of length 4 over {a,b} to the set Y of strings of length 3. The function is defined as f(alpha) = the first three characters of alpha, and it is clarified that f is not one-to-one (injective) since different strings in X can map to the same string in Y. Participants also discuss the formal definition of a function, emphasizing that it must assign a unique element in Y for each element in X. The conversation concludes with the suggestion that listing all ordered pairs could help clarify the function's behavior. Understanding whether the function is onto (surjective) remains a point of inquiry.
DevNeil
Messages
4
Reaction score
0

Homework Statement



We have a problem set on my Discrete Mathematics class:

Let X be the set of strings over {a,b} of length 4 and let Y be the set of the strings over {a,b} of length 3. Define function f from X to Y by the rule:

f(alpha) = string consisting of the first three characters of alpha.

Is f one-to-one? is f onto?

The Attempt at a Solution


I don't know where to start but what I understand on the problem is that X is a set with {aaaa,bbbb,aaab...etc} and Y has {aaa,bbb,aab...etc}. Do I need to list all the elements of the sets? I was also confused by the alpha variable. Hoping for your answers. Thanks.
 
Last edited:
Physics news on Phys.org
Alpha is any element in the set X, so any string of length 4. Your function f takes an element of X and maps it into an element of Y. For example, f(bbaa) = bba.

What does it mean for f to be one-to-one or onto?
 
clamtrox said:
Alpha is any element in the set X, so any string of length 4. Your function f takes an element of X and maps it into an element of Y. For example, f(bbaa) = bba.

What does it mean for f to be one-to-one or onto?

You need to state if it's injective(1to1) or surjective(onto) or bijective(injective && surjective). I can say that this is not one-to-one (injective) because as counterexample f(aabb) = aab , f(aaba)= aab, same result but different alpha.

Can you also tell me how to define the function formally?
 
DevNeil said:
You need to state if it's injective(1to1) or surjective(onto) or bijective(injective && surjective). I can say that this is not one-to-one (injective) because as counterexample f(aabb) = aab , f(aaba)= aab, same result but different alpha.

And then you only need to figure out if it's onto. That should be straightforward too.

DevNeil said:
Can you also tell me how to define the function formally?
The definition you were given looks pretty formal to me. Is there something wrong with it?
 
clamtrox said:
And then you only need to figure out if it's onto. That should be straightforward too.


The definition you were given looks pretty formal to me. Is there something wrong with it?

Ohh... I am thinking of a function that was mathematically defined. So another question, is this an acceptable definition of a function? I am having a hard time defining it. Thanks for your time :)
 
DevNeil said:
Ohh... I am thinking of a function that was mathematically defined. So another question, is this an acceptable definition of a function? I am having a hard time defining it. Thanks for your time :)

A function f:X->Y is just a rule that gives you a unique element of Y for each element of X. In this case, the rule is simple: drop the last digit.
 
You could just list all 16 ordered pairs (x,f(x)) in X×Y.
 
Back
Top