How to define a function involving strings?

  • Thread starter Thread starter DevNeil
  • Start date Start date
  • Tags Tags
    Function Strings
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 3K views
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.