|Figure 1 - Enzymatic activities Obtained from How to Brew|
Step 1 - Acid Rest - 97 degrees Fahrenheit
If the pH and temperature become too high, the husks of the grain start of leech compounds that give the beer an astringent flavor. Luckily, there exists an enzyme in grain that reduces the pH of the mash that is active around 97 degrees Fahrenheit, where the first rest lies.
The modified barley is crushed up and added to a pot of water such that it has a consistency slightly more watery than grits. In antiquity, the mash would be heated to 97 degrees and let rest for up to 2 hours while the acid-producing enzymes (phytase) lower the pH. With a modern understanding of chemistry, different salts can be added to the mash to obtain the same effect. For this reason, the acid rest is rarely used in modern breweries.
Step 2 - Protein Rest - 122-133 degrees Fahrenheit
At each step of the mash a portion of the mash is pulled off, boiled, and then mixed back with the rest of the mash. This process, called a decoction mash, does two things for the to-be beer. It increases the temperature of the mash to the next rest temperature, while also breaking down the cell walls that were not broken up during the modification process. Most breweries have a steam controlled system that closely monitors the temperature in lieu of the decoction process.
So once the first decoction is complete, your mash will be between 122 and 133 degrees. At this temperature, the enzymes important in the acid rest have been denatured (become unwound) and are nonfunctioning. This rest actives three new classes of proteins: beta-glucanase, proteases, and peptidases. Now would be a good time to mention that whenever an enzyme is responsible for breaking down a different molecule, it has the suffix -ase.
Beta-glucanase and peptidases have a positive effect on the beer. Beta-glucanase breaks down a polysaccharide called beta-glucan. Beta-glucan causes the mash to have a high viscosity which can cause problems later during the brewing process. Peptidases release free amino nitrogen (FAN), an essential yeast nutrient, into the mash. The peptidases is particularly important if the malt was under-modified and has the bulk of its nitrogen bound in large proteins instead of free amino acids.
Proteases act to ruin the quality of the beer. This is responsible for breaking down the larger proteins, which are essential to a good beer. The larger proteins (along with the unconverted starch) are responsible for the perception of body. If there are to proteins in the finished beer, it will taste thin and watery. The large proteins are also responsible for the thick foamy head and its stability. A beer with low protein content will form a weak head that will dissipate quickly. It is because of this class of protein that the timing on this rest is so important: if too much time is spent on this rest the preteases will destroy all of your proteins.
Step 3 - Saccrification Rest - 145-160 degrees Fahrenheit
This is what we've been working towards. There are two enzymes responsible for breaking down the starches into sugars: Alpha- and Beta- amylase, which are together referred to as diastatic enzymes. During the protein rest, these enzymes become soluble and go into solution where they can act on dissolved starches. These two enzymes break down the starches in different ways.
For sake of this, consider starch as a very large shrub. These two enzymes attack the shrub from two different points. The alpha-amylase is able to take off entire branches, while the beta-amylase can only sever individual twigs. Chemically speaking, the beta-amylase can only liberate glucose and maltose, while the alpha-amylase is able to liberate amylopectin, which are branched chains of glucose and maltose. Once the amylopectic "branches" have been liberated, more regions are available for the beta-amylase to free glucose and maltose (maltose is just the glucose dimer). In this way, the two enzymes work together to break apart the starch molecules.
However, they aren't the perfect team. Beta-amylase denatures before alpha-amylase. Beta-amylase is most active in between 135 and 150 degrees Fahrenheit, while alpha-amylase is most active between 150 and 160 degrees F. This disparity in optimal temperatures provides an important variable in determining the fementability of the wort. If a low temperature is used where both enzymes are active, the starch will be largely converted to simple sugars. These will all be fermented out into alcohol and leave a thin, dry beer with a higher alcohol content. However if a higher temperature is used, the beta-amylase becomes denatured, and only the alpha-amylase acts on the starches, which leaves a portion of the starch unconverted. This means the beer will have more body, be sweeter, but have a lower alcohol content.
Apart from ingredients, the mash temperature at the saccrification rest is among the biggest factors in controlling the end product. The difference of 5 degrees can mean the difference between a malty beer that has 5% sugar by weight after fermentation and a dry beer that has barely 2% sugar by weight.
Mashing out and sparging
Once the saccrification rest is complete, the temperature of the mash is then increased to about 168 degrees F. This denatures all amylase proteins and prevents any additional conversation from taking place. At this point, the liquid containing all the sugar must be separated from the grain prior to boiling. This occurs in a process called lautering.
The mash is then strained and the wort collected. Because the grain particles are saturated with the sugary wort, hot water is rinsed through the grain to try to extract as much of the sugar as possible. The first runnings from the mash are typically between 16 and 25 percent sugar by weight, depending on the style. As the grain is rinsed with pure water this sugar concentration drops until about 3 percent. If you continue to run off after the sugar concentration drops below this point, you risk introducing harsh flavors from tannins.
Once the wort is isolated from the grain in the mash, the wort is boiled and hops are added. This boiling not only drives off different compounds from the malt that would normally lead to off flavors (mainly DMS), but also activates different flavors from the hops depending on how long they are exposed to the heat of the boil. As a hop is boiled, it first loses its aroma compounds, next its flavor compounds, then finally the alpha-acids are isomerized into compounds that are perceived as bitter.
Way more information on decoction mashes can be found here courtesy of homebrewtalk