parsing arguments for functions



Hello,
 Suppose I have a function f(x,y) which does different operations for 
different types of arguments.  How can I parse the arguments of f(x,y) 
and decide what properties x and y have?

For instance, the function f(x,y) = x*y already does this, say for x, y 
real numbers or matrices.

How can I do this for other types of arguments? 

For instance, consider real closed intervals [a,b] denoted by Interval(a,b).

Then, the usual definition of the multiplication  is
  Interval(a,b)*Interval(c,d) = Interval(min(ac,ad,bc,bd),max(ac,ad,bc,bd))

Suppose  f(x,y) = x*y
   Then, I would like to have '*' defined so that
  if x, y are real numbers, then f(x,y) = x*y is the usual product,
 but if x=Interval(a,b) and y=Interval(c,d), then
   f(Interval(a,b),Interval(c,d)) = 
Interval(min(ac,ad,bc,bd),max(ac,ad,bc,bd))

Is there a simple way this can be done?

TIA for any suggestions.

-sen