I want to typeset an equation for a paper. In the field of computer science we can define an equation that depends upon the form of one of it's arguments. I want to typeset this with LaTeX & amsmath
.
I might write it as follows in a program, I'm using a familiar example:
fib 0 = 1
fib 1 = 1
fib X = (fib (X - 1)) + (fib (X - 2))
This could be typeset to appear as:
fib X = { 1 if X < 2
{ (fib (X - 1)) + (fib (X - 2)) otherwise
And I know how to do this using amsmath's align and case environments. But I'd prefer the pattern match or guards to appear on the left of the equation, the same way they would in the program above. Can someone point me at how I can do this?
This is what I have so far using \begin{array}{llcl} but the spacing doesn't look right. This is the actual equation I'm trying to typeset, fibs is just a familiar example.
$$
\begin{array}{llcl}
\operatorname{prodtime}\,V & X = Y &=& 0 \\
\operatorname{prodtime}\,V & X = f(\ldots) &=& 0 \\
\operatorname{prodtime}\,V & p(X_1,\,\ldots,\,X_n) &=&
\operatorname{prodtime}\,V\,(\operatorname{body}\,p) \\
\operatorname{prodtime}\,V & V = \,f(X_1,\,\ldots,\,X_n) &=&
\operatorname{prodtime}\,V\,(\operatorname{body}\,f) \\
\operatorname{prodtime}\,V & X_0(X_1,\,\ldots,\,X_n) &=& time\_of\_call \\
\operatorname{prodtime}\,V & m(X_1,\,\ldots,\,X_n) &=& time\_of\_call \\
\operatorname{prodtime}\,V & foreign(\ldots) &=& 0 \\
\operatorname{prodtime}\,V & G_{head},\,G_{tail}
\end{array}
$$
fib
example condensed the expression into a single subject, while your newer example hasprodtime
at every row/item. What exactly are you after? – Werner May 23 '12 at 5:12