\documentclass[11pt]{article}
\bibliographystyle{alpha}
\usepackage{fullpage}
\input{preamble}
\renewcommand{\R}{\mathcal{R}} %these two are very specific to thsi
\renewcommand{\F}{\mathcal{F}} %file. was just lazy

\newcommand{\mr}{\mathcal{M}_\mathcal{R}} %M_r

\title{Fast Integer Multiplication Using Modular Arithmetic}
\author{Anindya De, Piyush P Kurur%
  \thanks{Research supported through Research I Foundation project
    NRNM/CS/20030163}, %
  Chandan Saha\\%
  Dept. of Computer Science and Engineering\\%
  Indian Institute of Technology, Kanpur\\%
  Kanpur, UP, India, 208016\\%
  {\tt \{anindya,ppk,csaha\}@cse.iitk.ac.in}%
  \and  Ramprasad Saptharishi%
  \thanks{Research done while visiting IIT Kanpur %
    under Project FLW/DST/CS/20060225}\\%
  Chennai Mathematical Institute\\%
  Plot H1, SIPCOT IT Park\\%
  Padur PO, Siruseri, India, 603103\\%
  and\\%
  Dept. of Computer Science and Engineering\\%
  Indian Institute of Technology, Kanpur\\%
  Kanpur, UP, India, 208016\\%
  {\tt ramprasad@cmi.ac.in}
}
\begin{document}
\maketitle
\begin{abstract}
We give an $O(N\cdot \log N\cdot 2^{O(\log^*N)})$ algorithm for
multiplying two $N$-bit integers that improves the $O(N\cdot \log
N\cdot \log\log N)$ algorithm by
Sch\"{o}nhage-Strassen~\cite{scho}. Both these algorithms use modular
arithmetic. Recently, F\"{u}rer~\cite{Furer} gave an $O(N\cdot \log
N\cdot 2^{O(\log^*N)})$ algorithm which however uses arithmetic over
complex numbers as opposed to modular arithmetic. In this paper, we
use multivariate polynomial multiplication along with ideas {}from
F\"{u}rer's algorithm to achieve this improvement in the modular
setting.  Our algorithm can also be viewed as a $p$-adic version of
F\"{u}rer's algorithm. Thus, we show that the two seemingly different
approaches to integer multiplication, modular and complex arithmetic,
are similar.
\end{abstract}

\section{Introduction}

Computing the product of two $N$-bit integers is an important problem
in algorithmic number theory and algebra. A naive approach leads to an
algorithm that uses $O(N^2)$ bit operations. Karatsuba \cite{Karatsuba} showed that some multiplication operations of
such an algorithm can be replaced by less costly addition operations
which reduces the overall running time of the algorithm to
$O(N^{\log_23})$ bit operations. Shortly afterwards this result was
improved by Toom \cite{Toom} who showed that for any $\varepsilon>0$,
integer multiplication can be done in $O(N^{1+\varepsilon})$
time. This led to the question as to whether the time complexity can
be improved further by replacing the term $O(N^{\epsilon})$ by a
poly-logarithmic factor. In a major breakthrough, Sch\"{o}nhage and
Strassen~\cite{scho} gave two efficient algorithms for multiplying
integers using fast polynomial multiplication. One of the algorithms
achieved a running time of $O(N\cdot \log N\cdot \log\log N\ldots
2^{O(\log^*N)})$ using arithmetic over complex numbers (approximated
to suitable precision), while the other used arithmetic modulo
carefully chosen integers to improve the complexity further to
$O(N\cdot \log N\cdot \log\log N)$. Despite many efforts, the modular
algorithm remained the best until a recent remarkable result by
F\"{u}rer \cite{Furer}. F\"{u}rer gave an algorithm that uses
arithmetic over complex numbers and runs in $O(N\cdot\log N\cdot
2^{O(\log^\ast N)})$ time. Till date this is the best time complexity
result known for integer multiplication.

Sch\"{o}nhage and Strassen introduced two seemingly different
approaches to integer multiplication -- using complex and modular
arithmetic. F\"{u}rer's algorithm improves the time complexity in the
complex arithmetic setting by cleverly reducing some costly
multiplications to simple shift. However, the algorithm
needs to approximate the complex numbers to certain precisions during
computation. This introduces the added task of bounding the total
truncation errors in the analysis of the algorithm. On the contrary,
in the modular setting the error analysis is virtually absent. In
addition, modular arithmetic gives a discrete approach to a discrete
problem like integer multiplication. Therefore it is natural to ask
whether we can achieve a similar improvement in time complexity of
this problem in the modular arithmetic setting. In this paper, we
answer this question affirmatively. We give an $O(N\cdot \log{N}\cdot
2^{O(\log^{*}{N})})$ algorithm for integer multiplication using
modular arithmetic, thus matching the improvement made by F\"{u}rer.

\subsection*{Overview of our result}

As is the case in both Sch\"{o}nhage-Strassen's and F\"{u}rer's
algorithms, we start by reducing the problem to polynomial
multiplication over a ring $\R$ by properly encoding the given
integers. Polynomials can be multiplied efficiently using Discrete
Fourier Transforms (DFT), which uses special roots of unity. For
instance, to multiply two polynomials of degree less than $M$ using
the Fourier transform, we require a \emph{principal} $2M$-th root of
unity (see Definition~\ref{def-principal-root} for \emph{principal
  root}). An efficient way of computing the DFT of a polynomial is
through the Fast Fourier Transform (FFT). In addition, if
multiplications by these roots are efficient, we get a faster
algorithm. Since multiplication by $2$ is a shift, it would be good to
have a ring with $2$ as a root of unity. One way to construct such a
ring in the modular setting is to consider rings of the form $\R =
\Z/(2^M + 1) \Z$ as is the case in Sch\"{o}nhage and
Strassen~\cite{scho}. However, this makes the size of $\R$ equal to
$2^M$, which although works in case of Sch\"{o}nhage and Strassen's
algorithm, is a little too large to handle in our case. We would
like to find a ring whose size is bounded by some polynomial in $M$
and which also contains a principal $2M$-th root of unity. In fact, it
is this choice of ring that poses the primary challenge in adapting
F\"{u}rer's algorithm and making it work in the discrete setting. In
order to overcome this hurdle we choose the ring to be $\R =
\Z/p^c\Z$, for a prime $p$ and a constant $c$ such that $p^c =
poly(M)$. The ring $\Z/p^c\Z$, has a principal $2M$-th root of unity
if and only if $2M$ divides $p-1$, which means that we need to search
for a prime $p$ in the arithmetic progression $\inbrace{1 + i\cdot
  2M}_{i>0}$. To make this search computationally efficient, we need
the degree of the polynomials $M$ to be sufficiently small compared to
the input size. It turns out that this can be achieved by considering
multivariate polynomials instead of univariate polynomials. We use
enough variables to make sure that the search for such a prime does
not affect the overall running time; the number of variables finally
chosen is a constant as well. In fact, the use of multivariate
polynomial multiplications and a small ring are the main steps where
our algorithm differs {}from earlier algorithms by
Sch\"{o}nhage-Strassen and F\"{u}rer.\\

The use of \emph{inner} and \emph{outer} DFT plays a central role in
both F\"{u}rer's as well as our algorithm. Towards understanding the
notion of inner and outer DFT in the context of multivariate
polynomials, we present a group theoretic interpretation of Discrete
Fourier Transform (DFT). Arguing along the line of F\"{u}rer
\cite{Furer} we show that repeated use of efficient computation of
inner DFT's using some special roots of unity in $\R$ makes the
overall process efficient and leads to an $O(N\cdot \log{N}\cdot
2^{O(\log^{*}{N})})$ time algorithm.

\section{The Ring, the Prime and the Root of Unity}\label{ring_section}

We work with the ring $\R = \Z[\alpha]/(p^c, \alpha^m + 1)$ for some
$m$, a constant $c$ and a prime $p$. Elements of $\R$ are thus $m-1$
degree polynomials over $\alpha$ with coefficients {}from $\Z/p^c\Z$. By
construction, $\alpha$ is a $2m$-th root of unity and multiplication
of any element in $\R$ by any power of $\alpha$ can be achieved by
shifting operations --- this property is crucial in making some
multiplications in the FFT less costly
(Section~\ref{fourier_analysis}).

Given an $N$-bit number $a$, we encode it as a $k$-variate polynomial
over $\R$ with degree in each variable less than $M$. The parameters
$M$ and $m$ are powers of two such that $M^k$ is roughly
$\frac{N}{\log^2N}$ and $m$ is roughly $\log{N}$. The parameter $k$
will ultimately be chosen a constant (see Section
\ref{complexity_section}). We now explain the details of this
encoding.

\subsection{Encoding Integers into multivariate
  Polynomials}\label{encoding_section}

Given an $N$-bit integer $a$, we first break these $N$ bits into $M^k$
blocks of roughly $\frac{N}{M^k}$ bits each. This corresponds to
representing $a$ in base $q = 2^{\frac{N}{M^k}}$.  Let $a = a_0 +
\ldots + a_{M^k-1}q^{M^k - 1}$ where $a_i < q$. The number $a$ is
converted into a polynomial as follows:
\begin{enumerate}
\item Express $i$ in base $M$ as $i = i_1 + i_2M + \cdots +
  i_kM^{k-1}$. \label{base_M_item}
\item Encode each term $a_iq^i$ as the monomial $a_i\cdot
  X_1^{i_1}\cdots X_k^{i_k}$. As a result, the number $a$
  gets converted to the polynomial $\sum_{i=0}^{M^k - 1}
  a_i\cdot X_1^{i_1}\cdots X_k^{i_k}$.
\end{enumerate}

Further, we break each $a_i$ into $\frac{m}{2}$ equal sized blocks
where the number of bits in each block is $u = \frac{2N}{M^k\cdot m}$.
Each coefficient $a_i$ is then encoded as polynomial in $\alpha$ of
degree less than $\frac{m}{2}$. The polynomials are then padded with
zeroes to stretch their degrees to $m$. Thus, the $N$-bit number $a$
is converted to a $k$-variate polynomial $a(X)$ over
$\Z[\alpha]/(\alpha^m + 1)$.\\

Given integers $a$ and $b$, each of $N$ bits, we encode them as
polynomials $a(X)$ and $b(X)$ and compute the product polynomial. The
product $a\cdot b$ can be recovered by substituting $X_s =
q^{M^{s-1}}$, for $1\leq s\leq k$, and $\alpha = 2^u$ in the
polynomial $a(X)\cdot b(X)$.  The coefficients in the product
polynomial could be as large as $M^k\cdot m\cdot 2^{2u}$ and hence it
is sufficient to do arithmetic modulo $p^c$ where $p^c > M^k\cdot
m\cdot 2^{2u}$. Therefore, $a(X)$ can indeed be considered as a
polynomial over $\R = \Z[\alpha]/(p^c, \alpha^m + 1)$. Our choice of
the prime $p$ ensures that $c$ is in fact a constant (see
Section~\ref{complexity_section}).

\subsection{Choosing the prime}\label{prime_section}

The prime $p$ should be chosen such that the ring $\Z/p^c\Z$ has a
\emph{principal} $2M$-th root of unity, which is required for
polynomial multiplication using FFT. A principal root of unity is
defined as follows.

\begin{definition}\label{def-principal-root}
An $n$-th root of unity $\zeta\in \R$ is said to be \emph{primitive}
if it generates a cyclic group of order $n$ under
multiplication. Furthermore, it is said to be \emph{principal} if $n$
is coprime to the characteristic of $\R$ and $\zeta$ satisfies
$\sum_{i=0}^{n-1}\zeta^{ij}=0$ for all $0< j < n$.
\end{definition}
\noindent
In $\Z/p^c\Z$, a $2M$-th root of unity is principal if and only if
$2M\mid p-1$ (see also Section~\ref{Qp_section}). As a result, we need
to choose the prime $p$ {}from the arithmetic progression $\inbrace{1 +
i\cdot 2M}_{i> 0}$, which is the main bottleneck of our approach.  We
now explain how this bottleneck can be circumvented.

An upper bound for the least prime in an arithmetic progression is
given by the following theorem \cite{Linnik}:

\begin{theorem}[Linnik]\label{linnik_theorem}
There exist absolute constants $\ell$ and $L$ such that for any pair
of coprime integers $d$ and $n$, the least prime $p$ such that
$p\equiv d\bmod{n}$ is less than $\ell n^L$.
\end{theorem}

Heath-Brown\cite{Brown} showed that the \emph{Linnik constant} $L\leq
5.5$. Recall that $M$ is chosen such that $M^k$ is
$\Theta\inparen{\frac{N}{\log^2N}}$. If we choose $k=1$, that is if we
use univariate polynomials to encode integers, then the parameter $M =
\Theta\inparen{\frac{N}{\log^2N}}$. Hence the least prime $p\equiv
1\pmod{2M}$ could be as large as $N^L$. Since all known deterministic
sieving procedures take at least $N^L$ time this is clearly infeasible
(for a randomized approach see Section~\ref{ERH_section}). However, by
choosing a larger $k$ we can ensure that the least prime $p\equiv
1\pmod{2M}$ is $O(N^\varepsilon)$ for some constant $\varepsilon < 1$.

\begin{remark}\label{prime_time}
If $k$ is any integer greater than $L+1$, then $M^L =
O\inparen{N^{\frac{L}{L+1}}}$ and hence the least prime $p\equiv
1\bmod{2M}$ can be found in $o(N)$ time.
\end{remark}

\subsection{The Root of Unity}\label{root_section}

We require a principal $2M$-th root of unity in $\R$ to compute the
Fourier transforms. This root $\rho(\alpha)$ should also have the
property that its $\inparen{\frac{M}{m}}$-th power is $\alpha$, so as
to make some multiplications in the FFT efficient
(Lemma~\ref{lem-Fmk}). Such a root can be computed by interpolation in
a way similar to that in F\"{u}rer's algorithm\cite[Section 3]{Furer},
but we briefly sketch the procedure for completeness.

We first obtain a $(p-1)$-th root of unity $\zeta$ in $\Z/p^c\Z$ by
lifting a generator of $\mathbb{F}_p^*$. The
$\inparen{\frac{p-1}{2M}}$-th power of $\zeta$ gives us a $2M$-th root
of unity $\omega$. A generator of $\mathbb{F}_p^*$ can be computed by
brute force, as $p$ is sufficiently small. Having obtained a
generator, we can use Hensel Lifting \cite[Theorem 2.23]{Zuckerman}.

\begin{lemma}
Let $\zeta_s$ be a primitive $(p-1)$-th root of unity in
$\Z/p^s\Z$. Then there exists a unique primitive $(p-1)$-th root of
unity $\zeta_{s+1}$ in $\Z/p^{s+1}\Z$ such that $\zeta_{s+1}\equiv
\zeta_s\pmod{p^s}$. This unique root is given by $\zeta_{s+1} =
\zeta_s - \frac{f(\zeta_s)}{f'(\zeta_s)}$ where $f(X) = X^{p-1} - 1$.
\end{lemma}

We need the following claims to compute the root $\rho(\alpha)$.

\begin{claim}\label{claim_for_rho} Let $\omega$ be a principal $2M$-th
  root of unity in
  $\Z/p^c\Z$.
  \begin{enumerate}
  \item[(a)] If $\sigma = \omega^{\frac{M}{m}}$, then $\sigma$ is a
    principal $2m$-th root of unity.
  \item[(b)] The polynomial $x^m+1 = \prod_{i=1}^{m}(x -
    \sigma^{2i-1})$ in $\Z/p^c\Z$. Moreover, for any $0\leq i<j\leq
    2m$, the ideals generated by $(x - \sigma^i)$ and $(x - \sigma^j)$
    are comaximal in $\Z[x]/p^c\Z$.
  \item[(c)] The roots $\inbrace{\sigma^{2i-1}}_{1\leq i \leq m}$ are
    distinct modulo $p$ and therefore the difference of any two of
    them is a unit in $\Z[x]/p^c\Z$.
  \end{enumerate}
\end{claim}

We then, through interpolation, solve for a polynomial $\rho(\alpha)$
such that $\rho(\sigma^{2i+1}) = \omega^{2i+1}$ for all $1\leq i \leq
m$. Then,
\begin{eqnarray*}
  \rho(\sigma^{2i+1}) & = & \omega^{2i+1}\quad 1\leq i \leq m\\
  \implies   \inparen{\rho(\sigma^{2i+1})}^{M/m} & = &
  \omega^{(2i+1)M/m} = \sigma^{2i+1}\\
  \implies \inparen{\rho(\alpha)}^{M/m} & = & \alpha \pmod{\alpha -
    \sigma^{2i+1}}\quad 1\leq i \leq m\\
  \implies \inparen{\rho(\alpha)}^{M/m} & = & \alpha \pmod{ \alpha^m +
    1}
\end{eqnarray*}
The first two parts of the claim justify the Chinese
Remaindering. Finally, computing a polynomial $\rho(\alpha)$ such that
$\rho(\sigma^{2i+1}) = \omega^{2i+1}$ can be done through
interpolation.
$$
\rho(\alpha) = \sum_{i=1}^{m}\omega^{2i+1}\frac{\prod_{j\neq i}(\alpha
  - \sigma^{2j+1})}{\prod_{j\neq i}(\sigma^{2i+1} - \sigma^{2j+1})}
$$ The division by $(\sigma^{2i+1} - \sigma^{2j+1})$ is justified as
it is a unit in $\Z/p^c\Z$ (part (c) of Claim~\ref{claim_for_rho}).

\section{The Integer Multiplication Algorithm}\label{intmult_section}

We are given two integers $a,b< 2^N$ to multiply. We fix constants $k$
and $c$  whose values are given in
Section~\ref{complexity_section}. The algorithm is as follows:
\begin{enumerate}
\item Choose $M$ and $m$ as powers of two such that $M^k \approx
  \frac{N}{\log^2N}$ and $m \approx \log N$. Find the
  least prime $p\equiv 1\pmod{2M}$ (Remark~\ref{prime_time}).
\item Encode the integers $a$ and $b$ as $k$-variate polynomials
  $a(X)$ and $b(X)$ respectively over the ring $\R = \Z[\alpha]/(p^c,
  \alpha^m + 1)$ (Section~\ref{encoding_section}).
\item Compute the root $\rho(\alpha)$ (Section~\ref{root_section}).
\item Use $\rho(\alpha)$ as the principal $2M$-th root of unity to
  compute the Fourier transforms of the $k$-variate polynomials $a(X)$
  and $b(X)$. Multiply component-wise and take the inverse Fourier
  transform to obtain the product polynomial.
\item Evaluate the product polynomial at appropriate powers of two to
  recover the integer product and return it
  (Section~\ref{encoding_section}).
\end{enumerate}

The only missing piece is the Fourier transforms for multivariate
polynomials. The following section gives a group theoretic description
of FFT.

\section{Fourier Transform}\label{sect-FFT}

A convenient way to study polynomial multiplication is to interpret it
as multiplication in a \emph{group algebra}.

\begin{definition}[Group Algebra]
  Let $G$ be a group. The \emph{group algebra} of $G$ over a ring $R$
  is the set of formal sums $\sum_{g \in G} \alpha_g g$ where
  $\alpha_g \in R$ with addition defined point-wise and multiplication
  defined via convolution as follows
  $$ \left(\sum_g \alpha_g g\right) \left(\sum_h
  \beta_h h\right) = \sum_{u}\inparen{\sum_{gh=u} \alpha_g \beta_h}u $$
\end{definition}

Multiplying univariate polynomials over $R$ of degree less than $n$
can be seen as multiplication in the group algebra $R[G]$ where $G$ is
the cyclic group of order $2n$. Similarly, multiplying $k$-variate
polynomials of degree less than $n$ in each variable can be seen as
multiplying in the group algebra $R[G^k]$, where $G^k$ denotes the
$k$-fold product group $G\times\ldots \times G$.

In this section, we study the Fourier transform over the group algebra
$R[E]$ where $E$ is an \emph{additive abelian group}. Most of this,
albeit in a different form, is well known but is provided here for
completeness.\cite[Chapter 17]{Igor}

In order to simplify our presentation, we will fix the base ring to be
$\C$, the field of complex numbers. Let $n$ be the \emph{exponent} of
$E$, that is the maximum order of any element in $E$. A similar
approach can be followed for any other base ring as long as it has a
principal $n$-th root of unity.

We consider $\C[E]$ as a vector space with basis $\{ x \}_{x \in E}$
and use the Dirac notation to represent elements of $\C[E]$ --- the
vector $\ket{x}$, $x$ in $E$, denotes the element $1 . x$ of $\C[E]$.

\begin{definition}[Characters]
Let $E$ be an additive abelian group. A \emph{character} of $E$ is a
homomorphism {}from $E$ to $\C^*$.
\end{definition}

An example of a character of $E$ is the trivial character, which we
will denote by $1$, that assigns to every element of $E$ the complex
number $1$. If $\chi_1$ and $\chi_2$ are two characters of $E$ then
their product $\chi_1 . \chi_2$ is defined as $\chi_1 . \chi_2(x) =
\chi_1(x) \chi_2(x)$.

\begin{proposition}\cite[Chapter 17, Theorem 1]{Igor}
  Let $E$ be an additive abelian group of exponent $n$. Then the
  values taken by any character of $E$ are $n$-th roots of
  unity. Furthermore, the characters form a \emph{multiplicative
    abelian group} $\hat{E}$ which is isomorphic to $E$.
\end{proposition}

An important property that the characters satisfy is the following
\cite[Corollary 2.14]{Isaacs}.

\begin{proposition}[Schur's Orthogonality]
  Let $E$ be an additive abelian group. Then
  \[ \sum_{x \in E} \chi(x) =%
  \begin{cases}
    0 & \textrm{ if $\chi \neq 1$,}\\
    \# E &\textrm{ otherwise}
  \end{cases}
  \]
  \[
  \sum_{\chi \in \hat{E}} \chi(x) =%
  \begin{cases}
    0 & \textrm{ if $x \neq 0$,}\\
    \# E &\textrm{ otherwise.}
  \end{cases}
  \]
\end{proposition}

It follows {}from Schur's orthogonality that the collection of vectors
$\ket{\chi} = \sum_x \chi(x) \ket{x}$ forms a basis of $\C[E]$. We
will call this basis the \emph{Fourier basis} of $\C[E]$.

\begin{definition}[Fourier Transform]
Let $E$ be an additive abelian group and let $x \mapsto \chi_x$ be an
isomorphism between $E$ and $\hat{E}$. The \emph{Fourier transform}
over $E$ is the linear map {}from $\C[E]$ to $\C[E]$ that sends
$\ket{x}$ to $\ket{\chi_x}$.
\end{definition}

Thus, the Fourier transform is a change of basis {}from the point basis
$\{ \ket{x} \}_{x \in E}$ to the Fourier basis $\{
\ket{\chi_x}\}_{x\in E}$. The Fourier transform is unique only up to
the choice of the isomorphism $x \mapsto \chi_x$. This isomorphism is
determined by the choice of the principal root of unity.

\begin{remark}\label{rem-Fourier-inner}
Given an element $\ket{f} \in \C[E]$, to compute its Fourier transform
it is sufficient to compute the \emph{Fourier coefficients}
$\{\braket{\chi}{f} \}_{\chi \in \hat{E}}$.
\end{remark}

\subsection{Fast Fourier Transform}

We now describe the Fast Fourier Transform for general abelian groups
in the character theoretic setting. For the rest of the section fix an
additive abelian group $E$ over which we would like to compute the
Fourier transform. Let $A$ be any subgroup of $E$ and let $B =
E/A$. For any such pair of abelian groups $A$ and $B$, we have an
appropriate Fast Fourier transformation, which we describe in the rest
of the section.

\begin{proposition}\label{prop-character-lift}
  \begin{enumerate}
  \item Every character $\lambda$ of $B$ can be ``lifted'' to a
    character of $E$ (which will also be denoted by $\lambda$) defined
    as follows $\lambda(x) = \lambda(x + A)$.
  \item Let $\chi_1$ and $\chi_2$ be two characters of $E$ that when
    restricted to $A$ are identical. Then $\chi_1 = \chi_2 \lambda$ for
    some character $\lambda$ of $B$.
  \item The group $\hat{B}$ is (isomorphic to) a subgroup of $\hat{E}$
    with the quotient group $\hat{E}/\hat{B}$ being (isomorphic to)
    $\hat{A}$.
  \end{enumerate}
\end{proposition}

We now consider the task of computing the Fourier transform of an
element $\ket{f} = \sum f_x \ket{x}$ presented as a list of
coefficients $\{f_x\}$ in the point basis. For this, it is sufficient
to compute the Fourier coefficients $\{\braket{\chi}{f}\}$ for each
character $\chi$ of $E$ (Remark~\ref{rem-Fourier-inner}). To describe
the Fast Fourier transform we fix two sets of cosets representatives,
one of $A$ in $E$ and one of $\hat{B}$ in $\hat{E}$ as follows.

\begin{enumerate}
  \item For each $b \in B$, $b$ being a coset of $A$, fix a coset
    representative $x_b \in E$ such $b = x_b + A$.
  \item For each character $\varphi$ of $A$, fix a character
    $\chi_\varphi$ of $E$ such that $\chi_\varphi$ restricted to $A$ is
    the character $\varphi$. The characters $\{ \chi_\varphi \}$ form
    (can be thought of as) a set of coset representatives of $\hat{B}$
    in $\hat{E}$.
\end{enumerate}

Since $\{ x_b \}_{b \in B}$ forms a set of coset representatives, any
$\ket{f} \in \C[E]$ can be written uniquely as $\ket{f} = \sum f_{b,a}
\ket{x_b + a}$.

\begin{proposition}\label{prop-Fourier-coefficient}
  Let $\ket{f} = \sum f_{b,a}\ket{x_b + a}$ be an element of $\C[E]$.
  For each $b \in B$ and $\varphi \in \hat{A}$ let $\ket{f_b}\in
  \C[A]$ and $\ket{f_\varphi} \in \C[B]$ be defined as
  follows.
  \begin{eqnarray*}
    \ket{f_b} &= & \sum_{a \in A} f_{b,a} \ket {a}\\
    \ket{f_\varphi} & = &\sum_{b \in B} \overline{\chi}_{\varphi}(x_b)
    \braket{\varphi}{f_b} \ket{b}
  \end{eqnarray*}
  Then for any character $\chi$ of $E$, which can be expressed as
  $\chi = \lambda\cdot\chi_\varphi$, the Fourier coefficient
  $\braket{\chi}{f} = \braket{\lambda}{f_\varphi}$.
\end{proposition}
\begin{proof}Recall that $\lambda(x+A) = \lambda(x)$, and $\varphi$ is
  a restriction of the $\chi$ to the subgroup $A$.
\begin{eqnarray*}
\braket{\chi}{f} & = &
\sum_b\sum_a\overline{\chi}(x_b+a)f_{b,a}\\
& = & \sum_b\overline{\lambda}(x_b+a)\sum_a\overline{\chi}_\varphi(x_b+a)f_{b,a}\\
& = &
\sum_b\overline{\lambda}(b)\overline{\chi}_\varphi(x_b)\sum_a\overline{\varphi}(a)f_{b,a}\\
& = &
\sum_b\overline{\lambda}(b)\overline{\chi}_\varphi(x_b)\braket{\varphi}{f_b}\\
& = & \braket{\lambda}{f_\varphi}
\end{eqnarray*}
\end{proof}
We are now ready to describe the Fast Fourier transform given an
element $\ket{f} = \sum f_x \ket{x}$.
\begin{enumerate}
\item \label{step_inner_dft} For each $b \in B$ compute the Fourier
  transforms of $\ket{f_b}$. This requires $\# B$ many Fourier
  transforms over $A$.
\item \label{step_bad_mult}As a result of the previous step we have
  for each $b \in B$ and $\varphi \in \hat{A}$ the Fourier
  coefficients $\braket{\varphi}{f_b}$. Compute for each $\varphi$ the
  vectors $\ket{f_\varphi} = \sum_{b \in B}
  \overline{\chi}_{\varphi}(x_b) \braket{\varphi}{f_b} \ket{b}$. This
  requires $\# \hat{A} . \# B = \# E$ many multiplications by roots of
  unity.
\item \label{step_outer_dft} For each $\varphi \in \hat{A}$ compute
  the Fourier transform of $\ket{f_\varphi}$. This requires $\#\hat{A}
  = \# A$ many Fourier transforms over $B$.\label{item-Fourier-B}
\item Any character $\chi$ of $E$ is of the
  form $\chi_\varphi \lambda$ for some $\varphi \in \hat{A}$ and
  $\lambda \in \hat{B}$. Using
  Proposition~\ref{prop-Fourier-coefficient} we have at the end of
  Step~\ref{item-Fourier-B} all the Fourier coefficients
  $\braket{\chi}{f} = \braket{\lambda}{f_\varphi}$.
\end{enumerate}

If the quotient group $B$ itself has a subgroup that is isomorphic to
$A$ then we can apply this process recursively on $B$ to obtain a
divide and conquer procedure to compute the Fourier transform. In the
standard FFT we use $E = \Z/2^n\Z$. The subgroup $A$ is $2^{n-1}E$
which is isomorphic to $\Z/2\Z$ and the quotient group $B$ is
$\Z/2^{n-1}\Z$.

\subsection{Analysis of the Fourier Transform}\label{fourier_analysis}

Our goal is to multiply $k$-variate polynomials over $\R$, with the
degree in each variable less than $M$. This can be achieved by
embedding the polynomials into the algebra of the product group $E =
\inparen{\frac{\Z}{2M\cdot \Z}}^k$ and multiplying them as elements of
the algebra. Since the exponent of $E$ is $2M$, we require a principal
$2M$-th root of unity in the ring $\R$. We shall use the root
$\rho(\alpha)$ (as defined in Section~\ref{root_section}) for the
Fourier transform over $E$.

For every subgroup $A$ of $E$, we have a corresponding FFT. We choose
the subgroup $A$ as $\inparen{\frac{\Z}{2m\cdot \Z}}^k$ and let $B$ be
the quotient group $E/A$. The group $A$ has exponent $2m$ and $\alpha$
is a principal $2m$-th root of unity. Since $\alpha$ is a power of
$\rho(\alpha)$, we can use it for the Fourier transform over $A$. As
multiplications by powers of $\alpha$ are just shifts, this makes
Fourier transform over $A$ efficient.

Let $\F(2M,k)$ denote the complexity of computing the Fourier transform
over $\inparen{\frac{\Z}{2M\cdot \Z}}^k$. We have
\begin{equation}
\F(2M,k) = \inparen{\frac{M}{m}}^k \F(2m,k) + M^k
\mathcal{M}_\R+(2m)^k\F\inparen{\frac{M}{m},k}
\label{first_recursive_step}
\end{equation}
where $\mathcal{M}_\R$ denotes the complexity of multiplications in
$\R$. The first term comes {}from the $\# B$ many Fourier transforms
over $A$ (Step~\ref{step_inner_dft} of FFT), the second term
corresponds to the multiplications by roots of unity
(Step~\ref{step_bad_mult}) and the last term comes {}from the $\# A$
many Fourier transforms over $B$ (Step~\ref{step_outer_dft}).

Since $A$ is a subgroup of $B$ as well, Fourier transforms over $B$
can be recursively computed in a similar way, with $B$ playing the
role of $E$. Therefore, by simplifying the recurrence in
Equation~\ref{first_recursive_step} we get:
\begin{equation}
\F(2M,k) = O\inparen{\frac{M^k\log M}{m^k\log m}\F(2m,k) +
  \frac{M^k\log M}{\log m}\mr}
\label{eqn_with_Fa}
\end{equation}

\begin{lemma}\label{lem-Fmk}
$\F(2m,k) = O(m^{k+1}\log m\cdot \log p)$
\end{lemma}
\begin{proof}
The FFT over a group of size $n$ is usually done by taking $2$-point
FFT's followed by $\frac{n}{2}$-point FFT's. This involves $O(n\log
n)$ multiplications by roots of unity and additions in base
ring. Using this method, Fourier transforms over $A$ can be computed
with $O(m^k\log m)$ multiplications and additions in $\R$. Since each
multiplication is between an element of $\R$ and a power of $\alpha$,
this can be efficiently achieved through shifting operations. This is
dominated by the addition operation, which takes $O(m\log p)$ time,
since this involves adding $m$ coefficients {}from $\Z/p^c\Z$.
\end{proof}

Therefore, {}from Equation~\ref{eqn_with_Fa},
\begin{equation}\label{eqn_FFT_complexity}
\F(2M,k) = O\inparen{M^k\log M\cdot m\cdot \log p + \frac{M^k\log
    M}{\log m}\mr}
\end{equation}

\medskip

\section{Complexity Analysis}\label{complexity_section}

The choice of parameters should ensure that the following constraints
are satisfied:
\begin{enumerate}
\item $M^k = \Theta\inparen{\frac{N}{\log^2N}}$ and $m = O(\log
  N)$.
\item $M^L = O(N^\varepsilon)$ where $L$ is the Linnik constant
  (Theorem~\ref{linnik_theorem}) and $\varepsilon$ is any constant less
  than $1$. Recall that this makes picking the prime by brute force
  feasible (see Remark~\ref{prime_time}).
\item $p^c > M^k\cdot m\cdot 2^{2u}$ where $u = \frac{2N}{M^km}$. This
  is to prevent overflows during modular arithmetic (see
  Section~\ref{encoding_section}).
\end{enumerate}
\noindent
It is straightforward to check that $k > L+1$ and $c > 5(k+1)$ satisfy
the above constraints. Heath-Brown~\cite{Brown} showed that $L\leq
5.5$ and therefore $c = 42$ clearly suffices.\\

Let $T(N)$ denote the time complexity of multiplying two $N$ bit
integers. This consists of:

\begin{enumerate}
\item[(a)] Time required to pick a suitable prime $p$,
\item[(b)] Computing the root $\rho(\alpha)$,
\item[(c)] Encoding the input integers as polynomials,
\item[(d)] Multiplying the encoded polynomials,
\item[(e)] Evaluating the product polynomial.
\end{enumerate}

As argued before, the prime $p$ can be chosen in $o(N)$ time. To
compute $\rho(\alpha)$, we need to lift a generator of
$\mathbb{F}_p^*$ to $\Z/p^c\Z$ followed by an interpolation. Since $c$
is a constant and $p$ is a prime of $O(\log N)$ bits, the time
required for Hensel Lifting and interpolation is $o(N)$.

The encoding involves dividing bits into smaller blocks, and
expressing the exponents of $q$ in base $M$
(Section~\ref{encoding_section}) and all these take $O(N)$ time since
$M$ is a power of $2$. Similarly, evaluation of the product polynomial
takes linear time as well. Therefore, the time complexity is dominated
by the time taken for polynomial multiplication.

\subsubsection*{Time complexity of Polynomial Multiplication}

{}{}From Equation~\ref{eqn_FFT_complexity}, the complexity of Fourier
transform is given by
\[
\F(2M,k) = O\inparen{M^k\log M\cdot m\cdot \log p + \frac{M^k\log
    M}{\log m}\mr}
\]

\begin{proposition}\cite{scho_complex}
Multiplication in the ring $\R$ reduces to multiplying $O(\log^2{N})$
bit integers and therefore $\mr = T\left(O(\log^2{N})\right)$.
\end{proposition}
\begin{proof}
  Elements of $\R$ can be seen as polynomials in $\alpha$ over
  $\Z/p^c\Z$ with degree at most $m$. Given two such polynomials
  $f(\alpha)$ and $g(\alpha)$, encode them as follows: Replace $\alpha$
  by $2^d$, transforming the polynomials $f(\alpha)$ and $g(\alpha)$
  to the integers $f(2^d)$ and $g(2^d)$ respectively.  The parameter
  $d$ is chosen such that the coefficients of the product $h(\alpha) =
  f(\alpha) g(\alpha)$ can be recovered {}from the product $f(2^d)\cdot
  g(2^d)$. For this, it is sufficient to ensure that the maximum
  coefficient of $h(\alpha)$ is less than $2^d$.  Since $f$ and $g$
  are polynomials of degree $m$, we would want $2^d$ to be greater
  than $m\cdot p^{2c}$, which can be ensured by choosing $d =
  \Theta\left(\log{N}\right)$. The integers $f(2^d)$ and $g(2^d)$ are
  bounded by $2^{md}$ and hence the task of multiplying in $\R$
  reduces to $O(\log^2{N})$ bit integer multiplication.
\end{proof}

Multiplication of two polynomials involve a Fourier transform followed
by component-wise multiplications and an inverse Fourier
transform. Since the number of component-wise multiplications is only
$M^k$, the time taken is $M^k\cdot\mr$ which is clearly subsumed in
$\F(M,k)$. Therefore, the time taken for multiplying the polynomials
is $O(\F(M,k))$. Thus, the complexity of our integer multiplication
algorithm $T(N)$ is given by,
\begin{eqnarray*}
T(N) & = & O(\F(M,k))\\
& = & O\inparen{M^k\log M\cdot m\cdot \log p + \frac{M^k\log
  M}{\log m}\mr}\\
& = & O\inparen{N\log N + \frac{N}{\log N\cdot \log\log N}T(O(\log^2N))}
\end{eqnarray*}

The above recurrence leads to the following theorem.

\begin{theorem}
Given two $N$ bit integers, their product can be computed in
$O(N\cdot \log N\cdot 2^{O(\log^*N)})$ time.
\end{theorem}
\subsection{Choosing the Prime Randomly}\label{ERH_section}

To ensure that the search for a prime $p\equiv 1\pmod{2M}$ does not
affect the overall time complexity of the algorithm, we considered
multivariate polynomials to restrict the value of $M$; an alternative is
to use randomization.

\begin{proposition}
Assuming ERH, a prime $p$ such that $p\equiv 1\pmod{2M}$ can be
computed by a randomized algorithm with expected running time
$\tilde{O}(\log^3 M)$.
\end{proposition}
\begin{proof}
Titchmarsh\cite{Titchmarsh} (see also Tianxin \cite{Tianxin})
showed, assuming ERH, that the number of primes less than $x$ in the
arithmetic progression $\{ 1 + i \cdot 2M\}_{i > 0}$ is given by,
\begin{equation*}
\pi(x,2M) = \frac{Li(x)}{\varphi(2M)} + O(\sqrt{x} \log x)
\end{equation*}
for $2M \leq \sqrt{x} \cdot (\log x)^{-2}$, where $Li(x) =
\Theta(\frac{x}{\log x})$ and $\varphi$ is the Euler totient
function. In our case, since $M$ is a power of two, $\varphi(2M) = M$,
and hence for $x \geq 4M^2 \cdot \log^6 M$, we have $\pi(x, 2M) =
\Omega\inparen{\frac{x}{M\log x}}$. Therefore, for an $i$ chosen
uniformly randomly in the range $1 \leq i \leq 2M \cdot \log^6 M$, the
probability that $i\cdot 2M + 1$ is a prime is at least $\frac{d}{\log
  x}$ for a constant $d$. Furthermore, primality test of an $O(\log
M)$ bit number can be done in $\tilde{O}(\log^2 M)$ time using
Rabin-Miller primality test \cite{Miller, Rabin}. Hence, with $x = 4M^2
\cdot \log^6 M$ a suitable prime for our algorithm can be found in
expected $\tilde{O}(\log^3 M)$ time.
\end{proof}

\section{A Different Perspective } \label{Qp_section}

Our algorithm can be seen as a $p$-adic version of F\"{u}rer's integer
multiplication algorithm, where the field $\C$ is replaced by $\Q_p$,
the field of $p$-adic numbers (for a quick introduction, see Baker's
online notes\cite{Baker}). Much like $\C$, where representing a
general element (say in base $2$) takes infinitely many bits,
representing an element in $\Q_p$ takes infinitely many $p$-adic
digits. Since we cannot work with infinitely many digits, all
arithmetic has to be done with finite precision. Modular arithmetic in
the base ring $\Z[\alpha]/(p^c, \alpha^m + 1)$, can be viewed as
arithmetic in the ring $\Q_p[\alpha]/(\alpha^m + 1)$ keeping a
precision of $\varepsilon = p^{-c}$.

Arithmetic with finite precision naturally introduces some errors in
computation. However, the nature of $\Q_p$ makes the error analysis
simpler. The field $\Q_p$ comes with a norm $\abs{\ \cdot\ }_p$ called
the $p$-adic norm, which satisfies the stronger triangle inequality
$\abs{x+y}_p \leq \max\inparen{\abs{x}_p, \abs{y}_p}$\cite[Proposition
  2.6]{Baker}. As a result, unlike in $\C$, the errors in computation
do not compound.\\

Recall that the efficiency of FFT crucially depends on a special
principal $2M$-th root of unity in $\Q_p[\alpha]/(\alpha^m + 1)$. Such
a root is constructed with the help of a primitive $2M$-th root of
unity in $\Q_p$. The field $\Q_p$ has a primitive $2M$-th root of
unity if and only if $2M$ divides $p-1$\cite[Theorem
  5.12]{Baker}. Also, if $2M$ divides $p-1$, a $2M$-th root can be
obtained {}from a $(p-1)$-th root of unity by taking a suitable power. A
primitive $(p-1)$-th root of unity in $\Q_p$ can be constructed, to
sufficient precision, using Hensel Lifting starting {}from a generator
of $\mathbb{F}_p^*$.

\section{Conclusion}\label{conclusions_section}

There are two approaches for multiplying integers, one using
arithmetic over complex numbers, and the other using modular
arithmetic. Using complex numbers, Sch\"{o}nhage and
Strassen\cite{scho} gave an $O(N \cdot \log N \cdot \log\log N\ldots
2^{O(\log^* N)})$ algorithm. F\"{u}rer\cite{Furer} improved this
complexity to $O(N\cdot\log N \cdot2^{O(\log^*N)})$ using some special
roots of unity. The other approach, that is modular arithmetic, can be
seen as arithmetic in $\Q_p$ with certain precision. A direct
adaptation of the Sch\"{o}nhage-Strassen's algorithm in the modular
setting leads to an $O(N \cdot \log N \cdot \log\log N\ldots
2^{O(\log^* N)})$ algorithm. In this paper, we showed that by choosing
an appropriate prime and a special root of unity, a running time of
$O(N\cdot \log N \cdot 2^{O(\log^*N)})$ can be achieved through
modular arithmetic as well. Therefore, in a way, we have unified the
two paradigms.

\subsection*{Acknowledgement}

We thank V. Vinay, Srikanth Srinivasan and the anonymous referees for
many helpful suggestions that improved the overall presentation of
this paper.

\bibliography{references}

\end{document}


\subsection{Lava}

\subsubsection{Introduction}

Alternative to ElasticNet

Each parameter is split into

\(\theta_i=\rho_i+\phi_i\)

There is \(L_2\) loss on \(rho\) and \(L_1\) loss on \(\phi \).

This means that large coefficients can be penalised like \(L_1\) and small coefficients like \(L_2\).


\documentclass{article}
\usepackage{braket}

\begin{document}

\[\Set{\frac{A}{C}}{B}\]

\[\set{\frac{A}{C}}{B}\]

\[\Set{\frac{A}{C} | B | D}\]

\[\Set{\frac{A}{C} \| B | D}\]

\[\Set{\frac{A}{C} \rangle B | D}\]

\[\Set{\frac{A}{C} \mid B | \parallel D}\]

\[\Set{\frac{A}{C} || B | D}\]

\[\Set{\frac{A}{C} ||| B | D}\]

$\set{\frac{A}{C}}{B}$

\[\Set{ x\in\frac{A}{\mathbf{R}^2} | 0<{|x|}<5 }\]

% \ketbra{\frac{A}{C}}B

% \Ketbra{\frac{A}{C}}{B}

\newpage
\section*{BraKet}
$\Braket{\frac{A}{C}}{B}$

\[\Braket{\frac{A}{C}}{B}\]
\[\Braket{\frac{A}{C} | B | D}\]
\[\Braket{\frac{A}{C} || B | D}\]
\[\Braket{\frac{A}{C} | | B | D}\]
\[\Braket{\frac{A}{C} || B ||| D}\]

\[\Braket A|B C\]
\[\Braket{A|\sqrt[4]{B}[\sin[a|b] ||C}\]

\[\left[ \frac{1}{2}\middle|\middle| A\right ]\]
\[\left[ \frac{1}{2}\middle\| A\right ]\]
$\sin[2](\frac{x}{y})$

$\sqrt[{\sqrt[5]{a}}]{b}$
\newpage
\section*{Ket}
\[\Ket{\frac{A}{B}}\]

\[\ket{\frac{A}{B}}\]

\[\Ket{C\frac{A}{B}}\]

\[\ket{C\frac{A}{B}}\]

\[\Ket{C|\frac{A}{B}}\]

\[\ket{C|\frac{A}{B}}\]

\[\Ket{|C|\frac{A}{B}}\]

\[\ket{|C|\frac{A}{B}}\]

\[\ket{\bf a}b\]

\[\Bra{a\over b|}b
  \bra{a\over b|}b
  \]

$\braket<a|b|c>$
$\Braket<a|b|c>$

$\braket{\frac{a}{b}|c}$

$\Braket{\frac{a}{b}|c}$

$\Set{a|b|\frac{a}{c}}$

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


% To be compiled by XeLaTeX, preferably under TeX Live.
% LaTeX source for ``Yanqi Lake Lectures on Algebra'' Part III.
% Copyright 2019  李文威 (Wen-Wei Li).
% Permission is granted to copy, distribute and/or modify this
% document under the terms of the Creative Commons
% Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
% https://creativecommons.org/licenses/by-nc/4.0/

% To be included
\chapter{Going-up, going-down, gradings and filtrations}

This lecture will be less self-contained than the other ones.

\section{Going-up and going-down}
In geometry, it is often crucial to know properties of a morphism between algebraically defined geometric objects. Rephrased in terms of commutative algebra, our goal is to understand the image of $\varphi^\sharp: \Spec(B) \to \Spec(A)$ where $\varphi: A \to B$ is a given ring homomorphism.

\begin{itemize}
	\item We say the \emph{going-up} property holds for $\varphi$ if for every $\mathfrak{p} \subset \mathfrak{p}'$ in $\Spec(A)$ and $\mathfrak{q} \in \Spec(B)$ with $\varphi^\sharp(\mathfrak{q}) = \mathfrak{p}$ (and we say $\mathfrak{q}$ \emph{lies over} $\mathfrak{p}$...) there exists $\mathfrak{q}' \supset \mathfrak{q}$ lying over $\mathfrak{p}'$. \index{going-up}
	\item We say the \emph{going-down} property holds for $\varphi$ if for every $\mathfrak{p} \subset \mathfrak{p}'$ in $\Spec(A)$ and $\mathfrak{q}' \in \Spec(B)$ lying over $\mathfrak{p}'$, there exists $\mathfrak{q} \subset \mathfrak{q}'$ lying over $\mathfrak{p}$. \index{going-down}
\end{itemize}
Pictorially:
\begin{center}\begin{tikzpicture}
	\node (B) at (2.5, 2) {$B$};
	\node (P) at (0,1) {$\mathfrak{q}$};
	\node (P') at (1,2) {$\mathfrak{q}'$};
	\node (A) at (2.5, 0) {$A$};
	\node (p) at (0,-1) {$\mathfrak{p}$};
	\node (p') at (1,0) {$\mathfrak{p}'$};
	\draw (P') -- (P) -- (p) -- (p') -- (P');
\end{tikzpicture}\end{center}

\begin{lemma}[Existence of minimal over-primes]\label{prop:minimal-prime}\index{minimal prime ideal}
	Let $\mathfrak{a}$ be a proper ideal in a ring $R$. There exists a prime ideal $\mathfrak{p}$ which is minimal among all primes containing $\mathfrak{a}$. If $\mathfrak{P}$ is an ideal containing $\mathfrak{a}$, one can choose $\mathfrak{p} \subset \mathfrak{P}$.
\end{lemma}
\begin{proof}
	One easily reduces to the case $\mathfrak{a} = \{0\}$. We want to use Zorn's Lemma\index{Zorn's Lemma} to find a minimal prime. It boils down to show that any chain $(\mathfrak{p}_i)_{i \in I}$ of prime ideals ($I$: totally ordered set with $j > i \implies \mathfrak{p}_i \supset \mathfrak{p}_j$) has a lower bound; we assume $\mathfrak{p}_i \subset \mathfrak{P}$ when $\mathfrak{P}$ is prescribed. It suffices to show $\mathfrak{p} := \bigcap_{i \in I} \mathfrak{p}_i$ is prime: if $xy \in \mathfrak{p}$ but there exists $i$ with $x \notin \mathfrak{p}_i$, then $x \notin \mathfrak{p}_j$ whenever $j \geq i$; in this case $j \geq i \implies y \in \mathfrak{p}_j$. This entails $y \in \mathfrak{p}$.
\end{proof}

\begin{lemma}
	The going-down property for $\varphi$ is equivalent to the following: for every $\mathfrak{p} \in \Spec(A)$ with $\varphi(\mathfrak{p})B \neq B$ and any minimal over-prime $\mathfrak{q}$ of $\varphi(\mathfrak{p})B$, we have $\varphi^\sharp(\mathfrak{q}) = \mathfrak{p}$.
\end{lemma}
\begin{proof}
	Assuming going-down for $\varphi$, let $\mathfrak{p}, \mathfrak{q}$ be as above. Evidently $\varphi^\sharp(\mathfrak{q}) \supset \varphi^{-1}(\varphi(\mathfrak{p})B) \supset \mathfrak{p}$. If we have $\supsetneq$, then going-down guarantees the existence of $\mathfrak{q}^\flat \subsetneq \mathfrak{q}$ lying over $\mathfrak{p}$. Thus $\varphi^{-1}(\mathfrak{q}^\flat) = \mathfrak{p}$ implies $\mathfrak{q}^\flat \supset \varphi(\mathfrak{p})B$, contradicting the minimality of $\mathfrak{q}$.

	To show the converse, consider $\mathfrak{p} \subset \mathfrak{p}'$ with $\mathfrak{q}'$ lying over $\mathfrak{p}'$. We have $\varphi(\mathfrak{p})B \subset \varphi(\mathfrak{p}')B \subset \mathfrak{q}' \neq B$. Take $\mathfrak{q}$ to be a minimal over-prime of $\varphi(\mathfrak{p})B$ (which exists by Lemma \ref{prop:minimal-prime}) to verify the going-down property.
\end{proof}

\begin{theorem}\label{prop:going-down-flat}
	Going-down holds for flat $\varphi: A \to B$.
\end{theorem}
\begin{proof}
	Consider $\mathfrak{p} \subset \mathfrak{p}'$ and $\mathfrak{q}'$ lying over $\mathfrak{p}'$ in the setting of going-down. First, $B_{\mathfrak{q}'}$ is flat over $A_{\mathfrak{p}'}$ by Proposition \ref{prop:flatness-localized}. Secondly, $A_{\mathfrak{p}'} \to B_{\mathfrak{q}'}$ is faithfully flat since it is local by Theorem \ref{prop:faithfully-flat-criterion} (iii), therefore induces a surjection on spectra. Take any prime of $B_{\mathfrak{q}'}$ mapping to $\mathfrak{p}A_{\mathfrak{p}} \in \Spec(A_{\mathfrak{p}'})$ and to $\mathfrak{q} \in \Spec(B)$. In view of the commutative diagrams
	\[\begin{tikzcd}
		B \arrow[r] & B_{\mathfrak{q}'} \\
		A \arrow[u, "\varphi"] \arrow[r] & A_{\mathfrak{p}'} \arrow[u, "\varphi_{\mathfrak{p}'}"']
	\end{tikzcd} \qquad \begin{tikzcd}
		\Spec(B) \arrow[d, "\varphi^\sharp"'] & \Spec(B_{\mathfrak{q}'}) \arrow[d, "\varphi_{\mathfrak{p}'}^\sharp"] \arrow[hookrightarrow, l] \\
		\Spec(A) & \Spec(A_{\mathfrak{p}'}) \arrow[hookrightarrow, l]
	\end{tikzcd}\]
	we see $\mathfrak{q}$ is the required prime in going-down.
\end{proof}

\begin{theorem}[Krull--Cohen--Seidenberg]\label{prop:Cohen-Seidenberg}
	Suppose the ring $B$ is integral over its subring $A$. The following holds.
	\begin{enumerate}[(i)]
		\item The map $\Spec(B) \to \Spec(A)$ given by $\mathfrak{q} \mapsto \mathfrak{q} \cap A$ is surjective.
		\item There are no inclusion relations in any fiber of $\Spec(B) \to \Spec(A)$.
		\item Going-up holds for $A \hookrightarrow B$.
		\item If $A$ is a local ring and $\mathfrak{p} \in \MaxSpec(A)$, then the fiber $\{ \mathfrak{q} : \mathfrak{q} \cap A = \mathfrak{p} \}$ equals $\MaxSpec(B)$.
		\item Assume $A,B$ are domains and $A$ is normal. Then going-down holds for $A \hookrightarrow B$.
		\item Assume furthermore that $B$ is the integral closure of $A$ in a normal field extension $L \supset K := \mathrm{Frac}(A)$, then $\Gamma := \mathrm{Aut}(L/K)$ acts transitively on each fiber of $\Spec(B) \to \Spec
		(A)$.
	\end{enumerate}
\end{theorem}
The last assertion should be familiar to readers with a background in algebraic number theory.
\begin{proof}
	(iv): Let $\mathfrak{q} \in \MaxSpec(B)$ and $\mathfrak{p}_0 := \mathfrak{q} \cap A$. We know $B/\mathfrak{q}$ is a field, integral over its subring $A/\mathfrak{p}_0$. We claim that $A/\mathfrak{p}_0$ is also a field, therefore $\mathfrak{p}_0 = \mathfrak{p}$. Let $x \in A/\mathfrak{p}_0 \smallsetminus \{0\}$. Its inverse in $B/\mathfrak{q}$ satisfies an integral relation $(\frac{1}{x})^n + a_{n-1} (\frac{1}{x})^{n-1} + \cdots + a_0 = 0$ over $A/\mathfrak{p}_0$. Multiplying both sides by $x^{n-1}$ yields $\frac{1}{x} \in (A/\mathfrak{p}_0)[x]$.

	Conversely, we have to show any $\mathfrak{q} \in \Spec(B)$ with $\mathfrak{q} \cap A = \mathfrak{p}$ is maximal. Again, there is an integral extension of domains $A/\mathfrak{p} \hookrightarrow B/\mathfrak{q}$. Consider $y \in B/\mathfrak{q}$ satisfying $y^n + a_{n-1} y^{n-1} + \cdots + a_0 = 0$, with the smallest possible $n$. If $y \neq 0$ then $a_0 \neq 0$. Since $A/\mathfrak{p}$ is a field, the recipe to produce $y^{-1} \in (A/\mathfrak{p})[y]$ is well-known.

	(i), (ii): Fix $\mathfrak{p}$ and consider the inclusion $A_{\mathfrak{p}} \hookrightarrow B_{\mathfrak{p}} = B \dotimes{A} A_{\mathfrak{p}}$ which is still integral (note that $A \smallsetminus \mathfrak{p}$ is a multiplicative subset of $B$, and $B_{\mathfrak{p}}$ is nonzero). We are reduced to the case $A$ is local with maximal ideal $\mathfrak{p}$. By (iv) the fiber of $\mathfrak{p}$ in $\Spec(B)$ is nothing but $\MaxSpec(B)$. This establishes (i) and (ii) since there are no inclusions among maximal ideals.

	(iii): Consider $\mathfrak{p} \subset \mathfrak{p}'$ and $\mathfrak{q}$ over $\mathfrak{p}$ in the setting of going-up. Then (i) is applicable to $A/\mathfrak{p} \hookrightarrow B/\mathfrak{q}$ and yields the required $\mathfrak{q}' \in \Spec(B/\mathfrak{q}) \hookrightarrow \Spec(B)$.

	(vi): Observe that every $\sigma \in \Gamma$ induces an $A$-automorphism of $B$. Let $K' := L^\Gamma$. By (infinite) Galois theory we know $L/K'$ is Galois and $K'/K$ is purely inseparable. Let $A'$ be the integral closure of $A$ in $K'$. First observe that
	\[ \Spec(A') \longrightarrow \Spec(A), \quad \mathfrak{p}' \mapsto \mathfrak{p} = \mathfrak{p}' \cap A \]
	is a bijection. Indeed, $K' \neq K$ only when $p := \text{char}(K) > 0$, in which case the inverse is given by $\mathfrak{p}' = \left\{t \in A': t^{p^m} \in \mathfrak{p}, \; m \gg 0 \right\}$. Thus we assume henceforth that $L/K$ is Galois.

	Deal with the case $[L:K] < \infty$ first. Consider $\mathfrak{q}, \mathfrak{q}' \in \Spec(B)$ in the fiber over $\mathfrak{p}$. Suppose on the contrary that $\Gamma \mathfrak{q}$ does not meet $\mathfrak{q}'$, then by (ii) we have $\mathfrak{q}' \not\subset \sigma(\mathfrak{q})$ for each $\sigma \in \Gamma$. By the prime avoidance (Proposition \ref{prop:prime-avoidance}), there exists $x \in \mathfrak{q}' \smallsetminus \bigcup_\sigma \sigma(\mathfrak{q})$, since $\Gamma$ is finite. Now define the norm $y := N_{L/K}(x) \in K$, which is some positive power (namely $[L:K]_i$) of $\prod_{\sigma \in \Gamma} \sigma(x)$, hence belongs to $B$. Notice that
	\begin{compactitem}
		\item $A$ normal implies $y \in A$;
		\item $x \notin \sigma^{-1}(\mathfrak{q})$ for all $\sigma \in \Gamma$ implies $y \notin \mathfrak{p}$;
		\item however $y \in \mathfrak{q}' \cap A = \mathfrak{p}$ since $x \in \mathfrak{q}'$. Contradiction.
	\end{compactitem}

	Now suppose $[L:K]$ is infinite and $\mathfrak{q}, \mathfrak{q}'$ in the fiber over $\mathfrak{p}$. We need to use the Krull topology on $\Gamma$. For every finite, Galois subextension $E/K$ of $L/K$, define the set
	\[ \mathcal{T}(E) := \left\{ \sigma \in \Gamma: \sigma(\mathfrak{q} \cap E) = \mathfrak{q}' \cap E \right\}.  \]
	By the finite case we know $\mathcal{T}(E) \neq \emptyset$. Furthermore,
	\begin{compactitem}
		\item $\mathcal{T}(E)$ is closed in $\Gamma$ (it is the preimage of some subset of $\text{Gal}(E/K)$);
		\item $E' \subset E \implies \mathcal{T}(E') \supset \mathcal{T}(E)$;
		\item the intersection of all $\mathcal{T}(E)$ is nonempty (by the compactness of $\Gamma$ and the previous step).
	\end{compactitem}
	Taking $\sigma \in \bigcap_E \mathcal{T}(E)$ gives $\sigma(\mathfrak{q}) = \mathfrak{q}'$.

	(v): Define $L_0 := \text{Frac}(B)$ and $K := \text{Frac}(A)$. Then $L_0/K$ is algebraic and we may take a normal closure $L$ of $L_0$ over $K$. Let $C$ be the integral closure of $A$ (thus of $B$) in $L$. Consider the setting $\mathfrak{p} \subset \mathfrak{p}'$ and $\mathfrak{q} \cap A = \mathfrak{p}$ of going-down. Take any $\mathfrak{r} \in \Spec(C)$ mapping to $\mathfrak{p}$. By (iii) for $A \to C$ we obtain $\mathfrak{r}_1 \in \Spec(C)$ such that $\mathfrak{r}_1 \mapsto \mathfrak{p}'$ and $\mathfrak{r}_1 \supset \mathfrak{r}$. Next, take $\mathfrak{r}_2 \in \Spec(C)$ mapping to $\mathfrak{q}'$; by (vi) there exists $\sigma \in \text{Aut}(L/K)$ with $\sigma(\mathfrak{r}_1) = \mathfrak{r}_2$. One can check that $\mathfrak{q} := \sigma(\mathfrak{r}) \cap B$ is the required prime ideal. Explained pictorially:
	\begin{center}\begin{tikzpicture}
		\node (R) at (-2, 2) {$\mathfrak{r}$};
		\node (R1) at (-0.5, 2) {$\mathfrak{r}_1$};
		\node (R2) at (2, 2) {$\mathfrak{r}_2$};
		\node[fill=gray!80] (SR) at (0.5, 2) {};
		\node[fill=gray!40] (Q) at (-0.25, 1) {};
		\node (Q') at (1.5, 1) {$\mathfrak{q}'$};
		\node (P) at (-1, 0) {$\mathfrak{p}$};
		\node (P') at (1, 0) {$\mathfrak{p}'$};

		\node at (3, 2) {$C$}; \node at (3, 1) {$B$}; \node at (3, 0) {$A$};

		\draw (P) -- (R) -- (R1) -- (P') -- (P);
		\draw[dashed] (P) -- (SR) -- (R2) -- (Q')-- (P');
		\draw[dashed] (Q) -- (Q');

		\draw (-1, 2.5) edge[->, ultra thick, bend left=40] node[above, midway] {$\sigma$} (1, 2.5);
	\end{tikzpicture}\end{center}
	we first construct $\mathfrak{r}$ and then $\mathfrak{r}_1$ by going-up, then ``tilt'' it via some $\sigma$ to match $\mathfrak{r}_1$ with some chosen $\mathfrak{r}_2$ above $\mathfrak{q}'$, so that $\sigma(\mathfrak{r}) \cap B$ produces the required going-down:
\end{proof}

\begin{exercise}\label{exo:integral-closed}
	Let $A \subset B$ be an integral extension of rings. Show that $\Spec(B) \to \Spec(A)$ is a closed map (Cf.\ Proposition \ref{prop:going-up-closed}.) Hint: Let $\mathfrak{b} \subset B$ be a proper ideal, then $A/\mathfrak{b} \cap A \hookrightarrow B/\mathfrak{b}$ is still integral. Reduce the problem to showing that $V(\{0_B\}) = \Spec(B)$ has closed image in $\Spec(A)$.
\end{exercise}

\section{Subsets in the spectrum}
\begin{proposition}\label{prop:going-up-closed}
	Let $\varphi: A \to B$ be a ring homomorphism with going-up property and suppose $B$ is Noetherian. Then $\varphi^\sharp: \Spec(B) \to \Spec(A)$ is a closed map: it maps closed subsets to closed subsets.
\end{proposition}
\begin{proof}
	Consider a closed subset $V(\mathfrak{b})$ of $\Spec(B)$. First, every $\mathfrak{q} \in \Spec(B)$ with $\mathfrak{q} \supset \mathfrak{b}$ lies over a minimal over-prime of $\mathfrak{b}$, by Lemma \ref{prop:minimal-prime}. Secondly, $B$ is Noetherian implies $\text{Ass}(B/\mathfrak{b})$ is finite; in particular there are only finitely many minimal over-primes $\mathfrak{q}_1, \ldots, \mathfrak{q}_n$ of $\mathfrak{b}$.

	Set $\mathfrak{p}_i := \varphi^\sharp(\mathfrak{q}_i)$ for all $i$. By going-up, $V(\mathfrak{p}_i)$ is contained in $\varphi^\sharp(V(\mathfrak{b}))$. On the other hand, every $\mathfrak{p} = \varphi^\sharp(\mathfrak{q})$ with $\mathfrak{q} \in V(\mathfrak{b})$ lies over some $\mathfrak{p}_i = \varphi^\sharp(\mathfrak{q}_i)$ by the foregoing discussion. This shows $\varphi^\sharp(V(\mathfrak{b})) = \bigcup_{i=1}^n V(\mathfrak{p}_i)$ is closed.
\end{proof}

\begin{corollary}
	Suppose $B$ is Noetherian and integral over a subring $A$. Then $\Spec(B) \to \Spec(A)$ is a closed surjection with finite fibers.
\end{corollary}
\begin{proof}
	Apply Theorem \ref{prop:Cohen-Seidenberg} with Proposition \ref{prop:going-up-closed} to show that $\Spec(B) \to \Spec(A)$ is closed and surjective.

	To show the finiteness of the fiber over $\mathfrak{p} \in \Spec(A)$, note that the preimage of $V(\mathfrak{p})$ in $\Spec(B)$ equals $V(\mathfrak{p}B)$. Since there are no inclusions in the fiber over $\mathfrak{p}$, every element in that fiber must be a minimal over-prime of $\mathfrak{p}B$. We have seen in the proof of Proposition \ref{prop:going-up-closed} that there are only finitely many such minimal-over primes.
\end{proof}

Note that the ``closed surjection'' part applies to any integral extension of rings. See Exercise \ref{exo:integral-closed}.

In order to obtain further results of this type, we have to introduce more notions. Let $R$ be a ring.
\begin{definition}
	For $\mathfrak{p}, \mathfrak{p}' \in \Spec(R)$ satisfying $\mathfrak{p} \subset \mathfrak{p}'$, we say $\mathfrak{p}$ is a \emph{generalization} of $\mathfrak{p}'$, and $\mathfrak{p}'$ is a \emph{specialization} of $\mathfrak{p}$.
\end{definition}
To make geometric meaning from it, being ``specialized'' signifies that there are ``more equations'' in $\mathfrak{p}'$, therefore it corresponds a smaller embedded geometric object. For example, in $R=\CC[X,Y]$ the prime ideal $(X,Y)$ is a specialization of $(X)$, as the origin $X=Y=0$ belongs to the line $X=0$.

\begin{lemma}
	With respect to the Zariski topology, $\mathfrak{p}$ is a generalization of $\mathfrak{p}'$ if and only if $\mathfrak{p}' \in \overline{\{\mathfrak{p}\}}$.
\end{lemma}
\begin{proof}
	The condition $\mathfrak{p}' \in \overline{\{\mathfrak{p}\}}$ means that for every ideal $\mathfrak{a}$, if $\mathfrak{p} \supset \mathfrak{a}$ then $\mathfrak{p}' \supset \mathfrak{a}$. Taking $\mathfrak{a} = \mathfrak{p}$ yields $\mathfrak{p}' \supset \mathfrak{p}$, and the converse is even easier.
\end{proof}
A subset is called stable under specialization (resp. generalization) if the specialization (resp. generalization) of any member still belongs to that set. The following is straightforward.

\begin{lemma}\label{prop:stability-vs-closeness-0}
	Any closed subset is stable under specialization; any open subset is stable under generalization.
\end{lemma}

\begin{definition}\index{constructible subset}
	Suppose $R$ is Noetherian. A subset is called \emph{locally closed} if it is the intersection of an open with a closed subset, called \emph{constructible} if it is a finite union of locally closed subsets. % A possibly infinite intersection (resp. union) of constructible subsets is called \emph{pro-constructible} (resp. \emph{ind-constructible}).

	Closed subsets of the form $V(\mathfrak{p})$, where $\mathfrak{p} \in \Spec(R)$, are called \emph{irreducible}; in this case we call $\mathfrak{p}$ the \emph{generic point} of $Z$, which is uniquely characterized as the point which generalizes every member of $Z$.
\end{definition}
\begin{itemize}
	\item The foregoing definition is standard only for $R$ Noetherian. The general definition in EGA differs.
	\item These notions can be applied to any topological space $X$. In practice one usually suppose $X$ to be
		\begin{compactitem}
			\item \emph{Noetherian}: the closed subsets satisfy descending chain condition,
			\item \emph{sober}: every irreducible has a generic point,
		\end{compactitem}
		in order to get interesting results. This explains our Noetherian assumption.
	\item If $\Bbbk$ is algebraically closed, $R = \Bbbk[X_1, \ldots, X_n]/\mathfrak{a}$ corresponds to an affine algebraic variety $\mathcal{X} \subset \Bbbk^n$ and we work with $\MaxSpec(R)$ instead of $\Spec(R)$, then a subset $E \subset \mathcal{X}$ being locally closed means that it can be defined by a formula using the usual language of algebraic operations over $\CC$, with coordinate variables $X_1, \ldots, X_n$  and the symbols $=, \neq$, but \emph{without using the quantifiers $\exists, \forall$}. For example, the formula
	\[ (\neg X = 0) \vee (X = 0 \wedge Y=0) \]
	defines the constructible subset $E := \{(x,y) \in \Bbbk^2 : x \neq 0 \} \cup \{(0,0) \}$, which is neither closed nor open. Note that $E$ is the image of the polynomial map $\Bbbk^2 \to \Bbbk^2$ given by $(x,y) \mapsto (x,xy)$.
\end{itemize}

\begin{exercise}
	Show that the set of constructible subsets is stable under finite $\cup$, finite $\cap$ and taking complements.
\end{exercise}

\begin{exercise}
	Show that irreducible closed subsets $Z$ admit the following topological characterization: if $X = A \cup B$ with $A,B$ closed, then either $X=A$ or $X=B$.
\end{exercise}

Suppose $R$ is Noetherian. Given any closed subset $Z \subset \Spec(R)$, we may write $Z = Z_1 \cup \cdots \cup Z_n$ with each $Z_i$ irreducible. One way to do this is to use the primary decomposition for $\mathfrak{a}$, where we assume $Z = V(\mathfrak{a})$; then $Z_1, \ldots, Z_n$ will correspond to the minimal elements in $\text{Ass}(R/\mathfrak{a})$. One can show by purely topological means that such an irreducible decomposition is unique if we require $i \neq j \implies Z_i \not\subset Z_j$. See \cite[I.1.5]{Har77}.

\begin{lemma}\label{prop:char-constructible}
	Let $E$ be a subset of $\Spec(R)$ where $R$ is a Noetherian ring. The following are equivalent:
	\begin{enumerate}[(i)]
		\item $E$ is constructible;
		\item for every irreducible subset $Z$ of $\Spec(R)$, either $Z \cap E$ is not dense in $Z$ or $Z \cap E$ contains a nonempty open subset of $Z$.
	\end{enumerate}
\end{lemma}
\begin{proof}
	Omitted. See \cite[(6.C)]{Mat80}.
\end{proof}

\begin{theorem}[C.\ Chevalley]\label{prop:Chevalley}\index{Chevalley's theorem}
	Let $\varphi: A \to B$ be a ring homomorphism such that $A$ is Noetherian and $B$ is a finitely generated $A$-algebra. Then $\varphi^\sharp$ maps constructible subsets to constructible subsets.
\end{theorem}
\begin{proof}
	Omitted. See \cite[(6.E)]{Mat80}.
\end{proof}

Now we can give a partial converse to Lemma \ref{prop:stability-vs-closeness-0}, albeit not in the strongest form.
\begin{proposition}
	Suppose $R$ is Noetherian and $E$ is a constructible subset of $\Spec(R)$. If $E$ is stable under specialization (resp. generalization), then $E$ is closed (resp. open) in $\Spec(R)$.
\end{proposition}
\begin{proof}
	It suffices to treat the specialization-stable case by taking complements. Write the Zariski-closure $\bar{E}$ as a finite union of irreducibles components $Z$, without inclusion relations. For each irreducible component $Z$, notice that $Z \cap E$ is dense in $Z$ for all $Z$, since otherwise $\bar{E} = \overline{\bigcup_Z (Z \cap E)} = \bigcup_Z \overline{Z \cap E}$ would lead to another irreducible decomposition. Thus $Z \cap E$ contains a nonempty open of $Z$ by Lemma \ref{prop:char-constructible}. This open subset of $E$ must contain the generic point of $Z$. As $E$ is stable under specialization, we obtain $Z \subset E$. This being true for all $Z$, we deduce that $E = \bar{E}$.
\end{proof}

\begin{proposition}
	Consider a ring homomorphism $\varphi: A \to B$ satisfying going-down. Suppose $A$ is Noetherian and $B$ is a finitely generated $A$-algebra, then $\varphi^\sharp: \Spec(B) \to \Spec(A)$ is an open map.
\end{proposition}
\begin{proof}
	Let $U = \Spec(B) \smallsetminus V(\mathfrak{a})$ be an open subset. Going-down implies that $\varphi^\sharp(U)$ is stable under generalization. It suffices to show $\varphi^\sharp(U)$ is constructible, and this is the content of Chevalley's Theorem \ref{prop:Chevalley}.
\end{proof}

\section{Graded rings and modules}
Let $(\Gamma, +)$ be a commutative monoid. In most cases we consider $\Gamma = \Z_{\geq 0}$.

\begin{definition}\index{graded}
	A $\Gamma$-graded ring is a ring $R$ whose underlying additive group is endowed with a decomposition $R = \bigoplus_{\gamma \in \Gamma} R_\gamma$, such that $R_\gamma R_\eta \subset R_{\gamma + \eta}$ for all $\gamma, \eta \in \Gamma$.

	For $R$ as above, a $\Gamma$-graded $R$-module is an $R$-module $M$ whose underlying additive group decomposes as $M = \bigoplus_{\gamma \in \Gamma} M_\gamma$, such that $R_\gamma M_\eta \subset M_{\gamma + \eta}$ for all $\gamma, \eta \in \Gamma$; in particular, $R$ itself is a $\Gamma$-graded $R$-module. If $x \in M_\gamma \smallsetminus \{0\}$, we say $x$ is homogeneous of degree $\gamma$.\index{homogeneous}
\end{definition}
We will often omit $\Gamma$ when there is no worry of confusion. Note that if $0$ is allowed to be homogeneous, as people sometimes do, it will be homogeneous of any degree.

\begin{exercise}
	Show that in a graded ring $R$ we always have $1 \in R_0$, provides that $(\Gamma, +)$ satisfies the cancellation law: $\gamma+\eta=\eta \iff \gamma=0$. Hint: let $e_0$ be the component of $1_R$ in degree 0, argue that $x e_0 = x = e_0 x$ for all homogeneous $x \in R$. The condition $1 \in R_0$ is sometimes built into the definition of graded rings.
\end{exercise}

\begin{definition}
	A graded submodule of a graded $R$-module $M$ is a submodule $N$ with $N = \bigoplus_\gamma (N \cap M_\gamma)$, which gives rise to a natural grading $N_\gamma := N \cap M_\gamma$ on $N$.
\end{definition}
For graded $N \subset M$, the quotient $R$-module $M/N = \bigoplus_\gamma M_\gamma/N_\gamma$ is again graded. As a special case, we have the notion of graded ideals of $R$ (also known as \emph{homogeneous ideals}), and the quotient ring $R/\mathfrak{a}$ with respect to graded $\mathfrak{a}$ inherits the evident grading.

Let $N$ be an $R$-submodule of $M$ and suppose $M$ is graded. The following are easily seen to be equivalent:
\begin{enumerate}[(i)]
	\item $N \subset M$ is graded;
	\item $N$ is generated by homogeneous elements;
	\item if $x = \sum_\gamma x_\gamma \in N$ with each $x_\gamma$ homogeneous of degree $\gamma$, then $\forall \; x_\gamma \in N$.
\end{enumerate}

\begin{example}
	Let $A$ be a ring and $R := A[X_1, \ldots, X_n]$. Then $R$ is naturally $\Z_{\geq 0}$-graded by degrees: for each $d \in \Z_{\geq 0}$, let $R_d$ be the set of homogeneous polynomials of total degree $d$. Ideals generated by homogeneous polynomials are precisely the graded ideals. The importance of this grading comes from projective algebraic geometry.

	On the other hand, $R$ can also be graded by monomials by taking $\Gamma = \Z_{\geq 0} \times \cdots \times \Z_{\geq 0}$ ($n$ copies), and we set $R_{(d_1, \ldots, d_n)} = A \cdot X_1^{d_1} \cdots X_n^{d_n}$
\end{example}

Many constructions in commutative algebra can be generalized to the graded case. Let us illustrate what one can do in an important case, the primary decomposition (cf.\ \cite[\S 3.5 and Exercise 3.5]{Eis95}). In the $\Z$-graded context, it says that for a finitely generated graded module $M$ over a Noetherian graded ring, the associated primes of $M$ are all graded ideals, and one can write $\{0\} = N_1 \cap \cdots \cap N_m$ where $N_i \subset M$ are graded submodules with $\text{Ass}(M/N_i) = \{\mathfrak{p}_i\}$, $\mathfrak{p}_i \in \text{Ass}(M)$, etc. Most of the arguments in the ungraded case carry over verbatim, and the only new technique is the following

\begin{lemma}
	Let $M$ be a $\Z$-graded module over a $\Z$-graded ring $R$. If $x \in M$ and $\mathfrak{p} := \mathrm{ann}(x)$ is a prime ideal, then
	\begin{enumerate}[(i)]
		\item $\mathfrak{p}$ is a homogeneous ideal, and
		\item $\mathfrak{p} = \mathrm{ann}(y)$ for some homogeneous element $y \in M$.
	\end{enumerate}
\end{lemma}
\begin{proof}
	We begin with (i). Let $t \in \mathfrak{p}$ and $x \in M$ be such that $\mathfrak{p} = \text{ann}(M)$. Write
	\[ t = \sum_{\gamma \in \mathcal{A}} t_\gamma, \quad x = \sum_{\eta \in \mathcal{B}} x_\eta, \]
	where $t_\gamma \in R_\gamma \smallsetminus \{0\}$ and $x_\eta \in M_\eta \smallsetminus \{0\}$ for all $\gamma, \eta$. Denote by $\gamma_0$ and $\eta_0$ the minimal elements in $\mathcal{A}$ and $\mathcal{B}$, respectively. Homogenity amounts to $t_\gamma \in \mathfrak{p}$ for each $\gamma \in \mathcal{A}$, and this will be done by induction on $|\mathcal{B}|$. By a further induction on $|\mathcal{A}|$, for fixed $x$ and $\mathfrak{p}$, this can be reduced to showing $t_{\gamma_0} \in \mathfrak{p}$.

	First of all, considerations of degrees and $tx=0$ lead to $t_{\gamma_0} x_{\eta_0} = 0$. If $x = x_{\eta_0}$ (i.e.\ $|\mathcal{B}| = 1$), we obtain $t_{\gamma_0} \in \text{ann}(x) = \mathfrak{p}$ as required. In general:
	\begin{itemize}
		\item Suppose that $\mathfrak{p} = \text{ann}(t_{\gamma_0} x)$; since the decomposition
		\[ t_{\gamma_0} x = \sum_{\substack{\eta \in \mathcal{B} \\ \eta \neq \eta_0}} t_{\gamma_0} x_\eta \]
		involves fewer homogeneous terms, $\mathfrak{p}$ is then homogeneous by our induction hypothesis on $|\mathcal{B}|$.
		\item Suppose there exists $s \in R \smallsetminus \mathfrak{p}$ such that $s(t_{\gamma_0} x) = 0$, then $st_{\gamma_0} \in \mathfrak{p}$, hence $t_{\gamma_0} \in \mathfrak{p}$. This concludes the homogeneity (i).
	\end{itemize}

	From the homogeneity $\mathfrak{p}$ we infer that $\mathfrak{p} \subset \text{ann}(x_\eta)$ for each $\eta \in \mathcal{B}$. Now that
	\[ \mathfrak{p} = \text{ann}(x) \supset \prod_{\eta \in \mathcal{B}} \text{ann}(x_\eta), \]
	we have $\mathfrak{p} \supset \text{ann}(x_\eta)$ for some $\eta$, hence $\mathfrak{p} = \text{ann}(x_\eta)$. Take $y = x_\eta$ to obtain (ii).
\end{proof}

\section{Filtrations}
Now turn to filtrations. We only deal with decreasing filtrations indexed by $\Z_{\geq 0}$.
\begin{definition}\index{filtration}\index{gr@$\gr_F(M)$}
	A \emph{filtration} on a ring $R$ is a descending sequence
	\[ R = F^0 R \supset F^1 R \supset F^2 R \supset \cdots \]
	of ideals such that $F^i R \cdot F^j R \subset F^{i+j} R$. Define the associated $\Z_{\geq 0}$-graded ring
	\[ \gr_F(R) := \bigoplus_{n \geq 0} \underbracket{F^n R \big/ F^{n+1} R}_{=: \gr_F^n R} \]
	whose multiplication is defined as follows: if $x \in F^n R / F^{n+1} R$ and $y \in F^m R/F^{m+1} R$, choose liftings $\tilde{x} \in F^n R$ and $\tilde{y} \in F^m R$ and define
	\[ xy := \text{the image of }\; \tilde{x}\tilde{y}\; \text{ in }\; F^{n+m} R / F^{n+m+1} R; \]
	this is readily seen to be well-defined. The multiplication of arbitrarily many homogeneous elements can be obtained in the same recipe. The datum $(R, F^\bullet R)$ is called a \emph{filtered ring},

	Given a filtered ring $R$, a \emph{filtered $R$-module} $M$ is an $R$-module $M$ equipped with a descending sequence\footnote{In view of later applications, the filtration on a module is indexed by $\Z$ instead of $\Z_{\geq 0}$.} of submodules
	\[ \cdots \supset F^i M \supset F^{i+1} M \supset \cdots, \quad i \in \Z \]
	such that $F^i R \cdot F^j M \subset F^{i+j} M$. Define the associated graded module as the $\Z$-graded $\gr_F R$-module
	\[ \gr_F(M) := \bigoplus_{n \in \Z} \underbracket{F^n M \big/ F^{n+1} M}_{=: \gr_F^i M} \]
	whose scalar multiplication is defined using liftings as above.
\end{definition}

The subscript $F$ in $\gr$ will often be omitted. To guarantee that $\gr_F(R) \neq \{0\}$, we usually impose the harmless condition
\[ R = F^0 R \supsetneq F^1 R. \]

\begin{example}\index{filtration!$\mathfrak{a}$-adic}
	Let $\mathfrak{a}$ be a proper ideal of $R$, then $F^i R := \mathfrak{a}^i$ defines a filtration on $R$, called the \emph{$\mathfrak{a}$-adic filtration}.
\end{example}

\begin{definition}\label{def:a-stable}
	Equip $R$ with the $\mathfrak{a}$-adic filtration. A filtered $R$-module $M$ is called $\mathfrak{a}$-\emph{stable} if $\mathfrak{a} \cdot F^i M = F^{i+1} M$ for $i \gg 0$.
\end{definition}
Recall that $\mathfrak{a} \cdot F^i M \subset F^{i+1} M$ holds for all $M$, which is a part of our assumption.

As an easy example, set $F^i M := \mathfrak{a}^i M$ for $i \geq 1$, and $F^{\leq 0} M := M$; this is the $\mathfrak{a}$-adic filtration on $M$, which is obviously $\mathfrak{a}$-stable.

\begin{proposition}\label{prop:gr-Noetherian}
	Suppose $\mathfrak{a}$ is a proper ideal of $R$. If $R$ is Noetherian, so is $\gr(R)$ with respect to the $\mathfrak{a}$-adic filtration. In fact $\gr(R)$ is finitely generated over $\gr^0(R)$.
\end{proposition}
\begin{proof}
	Let $x_1, \ldots, x_n$ be generators of $\mathfrak{a}$, with images $\bar{x}_i \in \mathfrak{a}/\mathfrak{a}^2$. Then $\gr(R)$ is generated by $\bar{x}_1, \ldots \bar{x}_n$ over $R/\mathfrak{a} = \gr^0 R$, which is also Noetherian. Now apply Hilbert's Basissatz.
\end{proof}

\begin{proposition}\label{prop:gr-fg}
	Let $\mathfrak{a}$ be a proper ideal of $R$ and $M$ a finitely generated $R$-module. Suppose $M$ is endowed with an $\mathfrak{a}$-stable filtration such that $F^i M$ is finitely generated for each $i$, and $F^{\leq 0} M = M$. Then $\gr(M)$ is a finitely generated $\gr(R)$-module.
\end{proposition}
\begin{proof}
	Take $n$ such that $\mathfrak{a} \cdot F^i M = F^{i+1} M$ for all $i \geq n$. Then in $\gr(M) = \bigoplus_i \gr^i M$ we have
	\[ (\mathfrak{a}/\mathfrak{a}^2) \cdot \gr^i M = \gr^{i+1} M, \quad i \geq n. \]
	Therefore it suffices to take generators from $\gr^0 M, \ldots, \gr^n M$, each of whom is finitely generated over $R/\mathfrak{a} = \gr^0 R$.
\end{proof}

\section{Theorems of Artin--Rees and Krull}\label{sec:Artin-Rees}
Conserve the conventions in the previous section on filtrations, etc.

\begin{definition}[Morphisms between filtered objects]
	Let $(A, F^\bullet A)$ and $(B, F^\bullet B)$ be filtered rings. A \emph{morphism} between them means a ring homomorphism $\varphi: A \to B$ satisfying $\varphi(F^i A) \subset F^i B$ for all $i$. Similarly, suppose $A$ is filtered and let $M, N$ be filtered $A$-modules. A morphism $M \to N$ means a homomorphism $\psi: M \to N$ of $R$-modules satisfying $\psi(F^i M) \subset F^i N$ for all $i$.
\end{definition}
This makes the filtered rings and the filtered modules over a filtered ring into categories. Obviously, morphisms $\varphi$ between filtered objects induce graded morphisms $\gr \varphi$ between the associated graded objects. Therefore we obtain a functor from the category of filtered rings or modules into their graded avatars.

\begin{remark}
	Suppose $\varphi: M \to N$ is a morphism between filtered $A$-modules. The quotient $M/\Ker(\varphi)$ inherits a filtration from $M$, whereas the submodule $\Image(\varphi)$ inherits one from $N$. When the natural isomorphism $M/\Ker(\varphi) \to \Image(\varphi)$ is an isomorphism between filtered modules, or equivalently
	\[ \forall i \in \Z, \; \varphi(F^i M) = \varphi(M) \cap F^i N, \]
	we say $\varphi$ is a \emph{strict morphism}.
\end{remark}

It is often useful to relate properties of a filtered module or morphism to its graded counterpart. Propositions \ref{prop:gr-Noetherian} and \ref{prop:gr-fg} are such examples. Here is an example for the other direction. We say that a filtration on $M$ is \emph{exhaustive} if $\bigcup_i F^i M = M$, \emph{separating} (or \emph{Hausdorff}) if $\bigcap_i F^i M = \{0\}$

\begin{proposition}\label{prop:gr-injective}
	Suppose that $\varphi: M \to N$ is a morphism between filtered $R$-modules. If $M$ is exhaustive and separating, and $\gr\varphi$ is injective, then $\varphi$ is also injective.
\end{proposition}
\begin{proof}
	Let $x \in \Ker(\varphi)$. There exists $n$ such that $x \in F^n M$. Regard $x + F^{n+1} M$ as an element of $\gr^n M$. Then $\gr(\varphi)(x + F^{n+1} M) = \varphi(x) + F^{n+1} N = 0$, so $x \in F^{n+1} M$. Iterating this argument, we have $x \in \bigcap_{k \geq n} F^k M = \{0\}$.
\end{proof}
See Lemma \ref{prop:gr-surjective} for the case of surjections.

In what follows, $\mathfrak{a}$ always denotes a proper ideal of a ring $R$.

\begin{definition}[Blow-up algebras and modules]\index{blow-up algebra}
	Introduce an indeterminate $X$ and define the $\Z_{\geq 0}$-graded $R$-algebra
	\[ \text{Bl}_{\mathfrak{a}} R := \bigoplus_{n \geq 0} \mathfrak{a}^n X^n \; \subset R[X]. \]
	If an $R$-module $M$ is endowed with a filtration $(F^i M)_{i \geq 0}$ compatible with $\mathfrak{a}$, we define
	\[ \text{Bl}(M) := \bigoplus_{n \geq 0} (F^n M) \otimes X^n \subset M \dotimes{R} R[X]. \]
	Clearly, $\text{Bl}(M)$ is a graded $\text{Bl}_{\mathfrak{a}} R$-module.
\end{definition}

\begin{remark}
	The indeterminate $X$ is somehow a placeholder. Enlarge $\text{Bl}_{\mathfrak{a}} R$ to $\tilde{B}$ by setting the negative graded pieces to be $R \cdot X^{< 0}$, and set $T = X^{-1}$. We see that $\tilde{B}$ is actually an $R[T]$-algebra, sometimes called the \emph{Rees algebra} of $\mathfrak{a}$. Under the specialization $T=0$ we get \index{Rees algebra}
	\[ \frac{ \tilde{B}}{T \tilde{B}} \simeq \bigoplus_{n \geq 0} \frac{\mathfrak{a}^n}{\mathfrak{a}^{n+1}} \cdot T^{-n} \simeq \gr(R). \]
	On the other hand, inverting $T$ yields
	\[ \tilde{B}[T^{-1}] = \bigoplus_{n \in \Z} R \cdot T^{-n} = R[T^{\pm 1}]. \]
	This reflects a well-known deformation construction in geometry; $\gr(R)$ is actually the graded $R$-algebra corresponding to the \emph{normal cone} defined by $\mathfrak{a} \subset R$. We refer to \cite[\S 5.1]{Fu98} for details.
\end{remark}

\begin{lemma}\label{prop:Bl-fg}
	Consider a ring $R$ with proper ideal $\mathfrak{a}$, together with a filtered $R$-module $M$, assume furthermore that each $F^i M$ is finitely generated over $R$. The following are equivalent:
	\begin{enumerate}[(i)]
		\item $\mathrm{Bl}(M)$ is finitely generated over $\mathrm{Bl}_{\mathfrak{a}} R$;
		\item the filtration on $M$ is $\mathfrak{a}$-stable. (Definition \ref{def:a-stable})
	\end{enumerate}
\end{lemma}
\begin{proof}
	(i) $\implies$ (ii): Choose homogeneous generators $x_1, \ldots, x_n \in \text{Bl}(M)$ with degrees $d_1, \ldots, d_n$ respectively. It is then routine to see that
	\[ i \geq \max\{d_1, \ldots, d_n \} \implies (F^{i+1} M) X^{i+1} = \mathfrak{a} X \cdot (F^i M) X^i, \]
	that is, $\mathfrak{a} \cdot F^i M = F^{i+1} M$ for these $i$.

	(ii) $\implies$ (i): Suppose $\mathfrak{a} \cdot F^i M = F^{i+1} M$ for $i \geq d$, then $\text{Bl}(M)$ is generated by $\bigoplus_{j \leq d} (F^j M) X^j$, and each $F^j M$ is finitely generated over $R = (\text{Bl}_{\mathfrak{a}} R)_0$.
\end{proof}

\begin{theorem}[Artin--Rees]\label{prop:Artin-Rees}
	Let $R$ be a Noetherian ring endowed with $\mathfrak{a}$-adic filtration. Let $M$ be a finitely generated $R$-module and $N \subset M$ an $R$-submodule. Then the filtration on $N$ induced by the $\mathfrak{a}$-adic filtration of $M$, namely $F^i N := \mathfrak{a}^i M \cap N$, is $\mathfrak{a}$-stable.
\end{theorem}
\begin{proof}
	Define $\text{Bl}(N)$ using the induced filtration $F^i N := \mathfrak{a}^i M \cap N$, which is a submodule of the finitely generated $\text{Bl}_{\mathfrak{a}} R$-module $\text{Bl}(M)$ (Lemma \ref{prop:Bl-fg}). If $\mathfrak{a} = (a_1, \ldots, a_m)$ than $\text{Bl}_{\mathfrak{a}} R = R[a_1 X, \ldots, a_m X] \subset R[X]$, hence Noetherian by Hilbert's Basissatz. We deduce that $\text{Bl}(N)$ is finitely generated over $\text{Bl}_{\mathfrak{a}} R$. In turn, this implies $F^\bullet N$ is an $\mathfrak{a}$-stable filtration on $N$ by Lemma \ref{prop:Bl-fg}.
\end{proof}

\begin{theorem}\label{prop:intersection-thm}
	For $R, \mathfrak{a}, M$ as in the previous theorem, we set $N := \bigcap_{n \geq 0} \mathfrak{a}^n M$. Then $\mathfrak{a}N = N$.
\end{theorem}
\begin{proof}
	Since the induced filtration on $N$ is $\mathfrak{a}$-stable by Theorem \ref{prop:Artin-Rees}, for $n \gg 0$ we have
	\[ N = \mathfrak{a}^n M \cap N = \mathfrak{a} \cdot (\mathfrak{a}^{n-1} M \cap N) = \mathfrak{a} N. \]
	The assertion follows.
\end{proof}

\begin{corollary}[Krull]\label{prop:Krull-intersection-rad}
	If $\mathfrak{a} \subset \mathrm{rad}(R)$, then $\bigcap_{n \geq 0} \mathfrak{a}^n M = \{0\}$ for any finitely generated $R$-module $M$. In particular $\bigcap_{n \geq 0} \mathfrak{a}^n = \{0\}$ whenever $\mathfrak{a} \subset \mathrm{rad}(R)$.
\end{corollary}
\begin{proof}
	Theorem \ref{prop:intersection-thm} together with Nakayama's lemma imply $N = \{0\}$.
\end{proof}

\begin{corollary}[Krull's Intersection Theorem]\label{prop:Krull-intersection-domain}\index{Krull's intersection theorem}
	Let $R$ be a Noetherian domain and $\mathfrak{a}$ a proper ideal. Then $\bigcap_{n \geq 0} \mathfrak{a}^n = \{0\}$.
\end{corollary}
\begin{proof}
	Define $N := \bigcap_{n \geq 0} \mathfrak{a}^n \subset R$. By Theorem \ref{prop:intersection-thm} we have $\mathfrak{a}N = N$, thus there exists $r \in \mathfrak{a}$ with $1+r \in \text{ann}(N)$ by Nakayama's Lemma (Theorem \ref{prop:NAK}). As $\mathfrak{a}$ is proper, $1+r$ cannot be zero. Since $R$ is a domain containing $N$, the only possibility is $N=\{0\}$ as asserted.
\end{proof}