# Homework Help: How to define a function involving strings?

1. Jul 23, 2012

### DevNeil

1. The problem statement, all variables and given/known data

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?

3. 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: Jul 23, 2012
2. Jul 23, 2012

### clamtrox

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?

3. Jul 23, 2012

### DevNeil

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?

4. Jul 23, 2012

### clamtrox

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?

5. Jul 23, 2012

### DevNeil

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 :)

6. Jul 23, 2012

### clamtrox

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.

7. Jul 23, 2012

### vela

Staff Emeritus
You could just list all 16 ordered pairs (x,f(x)) in X×Y.