Missing } inserted, yet braces are balanced

Regard the following document:

\documentclass[a4paper,reqno]{amsart}

\usepackage{amssymb,amsmath,amsthm,fullpage}

\begin{document}

For each $k$ we denote by $\lambda_k$ the $k$th symmetric polynomial
in the $x_i$s; that is, we define
$\textstyle\lambda_k := \sum_\mathrm{I\subseteq\mathbb{N}_n such that |I|=k}x_I.$

\end{document}


When I try to compile it, I get:

! Missing } inserted.
<inserted text>
}
l.9 ...\mathrm{$I\subseteq\mathbb{N}_n$ such that $|I|=k$}
x_I.\]


Why? The braces are surely balanced.

(Surrounding the call to \mathrm in a set of braces makes no difference.)

-

The \mathrm macro sets its input in a roman font, but it is still in (display) math mode. So the $s inside \mathrm are confusing TeX. It's as if you are trying to embed math mode within display math mode. I think what you want instead is $\textstyle \lambda_k := \sum_{\text{I\subseteq\N_n such that |I|=k}}x_I.$  But that won't work either until you tell TeX what you mean by \N. So if you insert into the preamble or someplace else before the first use: \newcommand{\N}{\mathbb{N}}  your document will successfully compile. A few comments: • Why are you using \textstyle? In display math some symbols like the \sum operator are bigger. Try it without; you might like TeX's default choices. • Whitespace is your friend. When I type displayed equations I put the $ and $ on their own lines and indent the equation in the middle. That way the source somewhat resembles the final document in that displayed math mode is "displayed." • You might find this discussion we had on colon-equals interesting: How to typseset$:=\$ correctly?
I realised a few moments ago that I had used \mathrm when I meant \textrm. –  Hammerite Feb 25 '11 at 1:05
With regards to \textstyle - I don't like the huge operators, fractions etc. TeX uses for displayed maths, but apart from that, if you have a large subscript to add to an operator it looks stupid because the operator floats centred above the subscript in a sea of whitespace. (Yes, I know it is possible to have TeX use the larger operator and position the subscript the way it is positioned when using \textstyle.) –  Hammerite Feb 25 '11 at 1:13
@Hammerite: If you want to avoid large subscripts taking up horizontal space you can use \mathclap. See for example “Why do I have so much free space on the left-hand side of my tikz diagram?”. –  Matthew Leingang Feb 25 '11 at 1:27