Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: How to define a function involving strings?

  1. Jul 23, 2012 #1
    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. jcsd
  3. Jul 23, 2012 #2
    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?
  4. Jul 23, 2012 #3
    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?
  5. Jul 23, 2012 #4
    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?
  6. Jul 23, 2012 #5
    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 :)
  7. Jul 23, 2012 #6
    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.
  8. Jul 23, 2012 #7


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    You could just list all 16 ordered pairs (x,f(x)) in X×Y.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook