system
Given the following post, respond as if you're commenting on Reddit:
human
What's the difference between fermented and rotted foods? And how can you know when fermented food is unsafe to eat?
gpt
Fermentation and "rotting" are assessments of value. Technically speaking, any microbial process on food can be construed as fermentation. If it isn't the kind of fermentation you want, you would call it rotten.

Fermentation is a three way war between yeast, bacteria, and mold, the three major decomposers contending over our food. The following is slightly simplified, but roughly speaking:

* Yeast produce alcohol, which kills bacteria and mold.
* Bacteria produce acids, which kill mold and yeast.
* Mold produces digestive enzymes and antibiotics, which kill yeast and bacteria.

(To be sure, some exception exist.)

The operating principle of fermentation is summarized by this saying:

*One form of filth kills another form of filth.*

Humanity intervenes to pick which combatant we want to win for each particular food because we desire some effect from the fermentation-- usually flavor and preservation against decay by the others. For sweet fruit, we want yeast, not mold nor bacteria. For cucumber pickles, sauerkraut, kimchee, and kombucha, we want bacteria and yeast that support them. For salami and soft cheese, we prefer mold, and sometimes bacteria. If anything other than the desired microbe takes hold of our food, even if it is technically edible and nontoxic, we would call it rotten. Moldy fruit, for example, is generally considered rotten. Our intervention usually comes in the form of innoculating the food or controlling the environment or saltiness or other factors to favor one of these over the others.

Some products, like rice wine vinegar, go through all three. Rice starch is converted into fermentable sugars using koji mold; yeast turn the sugars into alcohol; acetobactet then turns the alcohol into acetic acid, the main acid in vinegar.