Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
File size: 208,006 Bytes
afd65d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
\input{preamble}

% OK, start here.
%
\begin{document}

\title{Dualizing Complexes}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

\section{Introduction}
\label{section-introduction}

\noindent
In this chapter we discuss dualizing complexes in commutative algebra.
A reference is \cite{RD}.

\medskip\noindent
We begin with a discussion of
essential surjections and essential injections,
projective covers,
injective hulls,
duality for Artinian rings, and
study injective hulls of residue fields,
leading quickly to a proof of Matlis duality.
See Sections \ref{section-essential},
\ref{section-injective-modules},
\ref{section-projective-cover},
\ref{section-injective-hull},
\ref{section-artinian}, and
\ref{section-hull-residue-field} and
Proposition \ref{proposition-matlis}.

\medskip\noindent
This is followed by three sections discussing local cohomology in
great generality, see Sections \ref{section-bad-local-cohomology},
\ref{section-local-cohomology}, and \ref{section-local-cohomology-noetherian}.
We apply some of this to a discussion of depth in
Section \ref{section-depth}. In another application we show how,
given a finitely generated ideal $I$ of a ring $A$, the
``$I$-complete'' and ``$I$-torsion'' objects
of the derived category of $A$ are equivalent, see
Section \ref{section-torsion-and-complete}.
To learn more about local cohomology, for example the finiteness
theorem (which relies on local duality -- see below) please visit
Local Cohomology, Section \ref{local-cohomology-section-introduction}.

\medskip\noindent
The bulk of this chapter is devoted to duality for a ring map and
dualizing complexes. See
Sections \ref{section-trivial},
\ref{section-base-change-trivial-duality},
\ref{section-dualizing},
\ref{section-dualizing-local},
\ref{section-dimension-function},
\ref{section-local-duality},
\ref{section-dualizing-module},
\ref{section-CM},
\ref{section-gorenstein},
\ref{section-ubiquity-dualizing}, and
\ref{section-formal-fibres}.
The key definition is that of a dualizing complex
$\omega_A^\bullet$ over a Noetherian ring $A$ as an object
$\omega_A^\bullet \in D^{+}(A)$ whose cohomology modules
$H^i(\omega_A^\bullet)$ are finite $A$-modules, which has
finite injective dimension, and is such that the map
$$
A \longrightarrow R\Hom_A(\omega_A^\bullet, \omega_A^\bullet)
$$
is a quasi-isomorphism. After establishing some elementary properties
of dualizing complexes, we show a dualizing complex gives rise to a
dimension function. Next, we prove Grothendieck's local duality theorem.
After briefly discussing dualizing modules and Cohen-Macaulay rings,
we introduce Gorenstein rings and we show many familiar Noetherian
rings have dualizing complexes. In a last section we apply the material
to show there is a good theory of Noetherian local rings whose formal fibres
are Gorenstein or local complete intersections.

\medskip\noindent
In the last few sections, we describe an algebraic construction of
the ``upper shriek functors'' used in algebraic geometry, for example
in the book \cite{RD}. This topic is continued in the chapter on
duality for schemes. See
Duality for Schemes, Section \ref{duality-section-introduction}.







\section{Essential surjections and injections}
\label{section-essential}

\noindent
We will mostly work in categories of modules, but we may as well make
the definition in general.

\begin{definition}
\label{definition-essential}
Let $\mathcal{A}$ be an abelian category.
\begin{enumerate}
\item An injection $A \subset B$ of $\mathcal{A}$ is {\it essential},
or we say that $B$ is an {\it essential extension of} $A$,
if every nonzero subobject $B' \subset B$ has nonzero intersection with $A$.
\item A surjection $f : A \to B$ of $\mathcal{A}$ is {\it essential}
if for every proper subobject $A' \subset A$ we have $f(A') \not = B$.
\end{enumerate}
\end{definition}

\noindent
Some lemmas about this notion.

\begin{lemma}
\label{lemma-essential}
Let $\mathcal{A}$ be an abelian category.
\begin{enumerate}
\item If $A \subset B$ and $B \subset C$ are essential extensions, then
$A \subset C$ is an essential extension.
\item If $A \subset B$ is an essential extension and $C \subset B$
is a subobject, then $A \cap C \subset C$ is an essential extension.
\item If $A \to B$ and $B \to C$ are essential surjections, then
$A \to C$ is an essential surjection.
\item Given an essential surjection $f : A \to B$ and a surjection
$A \to C$ with kernel $K$, the morphism $C \to B/f(K)$ is an essential
surjection.
\end{enumerate}
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-union-essential-extensions}
Let $R$ be a ring. Let $M$ be an $R$-module. Let $E = \colim E_i$
be a filtered colimit of $R$-modules. Suppose given a compatible
system of essential injections $M \to E_i$ of $R$-modules.
Then $M \to E$ is an essential injection.
\end{lemma}

\begin{proof}
Immediate from the definitions and the fact that filtered
colimits are exact (Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}).
\end{proof}

\begin{lemma}
\label{lemma-essential-extension}
Let $R$ be a ring. Let $M \subset N$ be $R$-modules. The following
are equivalent
\begin{enumerate}
\item $M \subset N$ is an essential extension,
\item for all $x \in N$ nonzero there exists an $f \in R$ such that $fx \in M$
and $fx \not = 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1) and let $x \in N$ be a nonzero element. By (1) we have
$Rx \cap M \not = 0$. This implies (2).

\medskip\noindent
Assume (2). Let $N' \subset N$ be a nonzero submodule. Pick $x \in N'$
nonzero. By (2) we can find $f \in R$ with $fx \in M$ and $fx \not = 0$.
Thus $N' \cap M \not = 0$.
\end{proof}




\section{Injective modules}
\label{section-injective-modules}

\noindent
Some results about injective modules over rings.

\begin{lemma}
\label{lemma-product-injectives}
Let $R$ be a ring. Any product of injective $R$-modules is injective.
\end{lemma}

\begin{proof}
Special case of Homology, Lemma \ref{homology-lemma-product-injectives}.
\end{proof}

\begin{lemma}
\label{lemma-injective-flat}
Let $R \to S$ be a flat ring map. If $E$ is an injective $S$-module,
then $E$ is injective as an $R$-module.
\end{lemma}

\begin{proof}
This is true because $\Hom_R(M, E) = \Hom_S(M \otimes_R S, E)$
by Algebra, Lemma \ref{algebra-lemma-adjoint-tensor-restrict}
and the fact that tensoring with $S$ is exact.
\end{proof}

\begin{lemma}
\label{lemma-injective-epimorphism}
Let $R \to S$ be an epimorphism of rings. Let $E$ be an $S$-module.
If $E$ is injective as an $R$-module, then $E$ is an injective $S$-module.
\end{lemma}

\begin{proof}
This is true because $\Hom_R(N, E) = \Hom_S(N, E)$ for any $S$-module $N$,
see Algebra, Lemma \ref{algebra-lemma-epimorphism-modules}.
\end{proof}

\begin{lemma}
\label{lemma-hom-injective}
Let $R \to S$ be a ring map. If $E$ is an injective $R$-module,
then $\Hom_R(S, E)$ is an injective $S$-module.
\end{lemma}

\begin{proof}
This is true because $\Hom_S(N, \Hom_R(S, E)) = \Hom_R(N, E)$ by
Algebra, Lemma \ref{algebra-lemma-adjoint-hom-restrict}.
\end{proof}

\begin{lemma}
\label{lemma-essential-extensions-in-injective}
Let $R$ be a ring. Let $I$ be an injective $R$-module. Let $E \subset I$
be a submodule. The following are equivalent
\begin{enumerate}
\item $E$ is injective, and
\item for all $E \subset E' \subset I$ with $E \subset E'$ essential
we have $E = E'$.
\end{enumerate}
In particular, an $R$-module is injective if and only if every essential
extension is trivial.
\end{lemma}

\begin{proof}
The final assertion follows from the first and the fact that the
category of $R$-modules has enough injectives
(More on Algebra, Section \ref{more-algebra-section-injectives-modules}).

\medskip\noindent
Assume (1). Let $E \subset E' \subset I$ as in (2).
Then the map $\text{id}_E : E \to E$ can be extended
to a map $\alpha : E' \to E$. The kernel of $\alpha$ has to be
zero because it intersects $E$ trivially and $E'$ is an essential
extension. Hence $E = E'$.

\medskip\noindent
Assume (2). Let $M \subset N$ be $R$-modules and let $\varphi : M \to E$
be an $R$-module map. In order to prove (1) we have to show that
$\varphi$ extends to a morphism $N \to E$. Consider the set $\mathcal{S}$
of pairs
$(M', \varphi')$ where $M \subset M' \subset N$ and $\varphi' : M' \to E$
is an $R$-module map agreeing with $\varphi$ on $M$. We define an ordering
on $\mathcal{S}$ by the rule $(M', \varphi') \leq (M'', \varphi'')$
if and only if $M' \subset M''$ and $\varphi''|_{M'} = \varphi'$.
It is clear that we can take the maximum of a totally ordered subset
of $\mathcal{S}$. Hence by Zorn's lemma we may assume $(M, \varphi)$
is a maximal element.

\medskip\noindent
Choose an extension $\psi : N \to I$ of $\varphi$ composed
with the inclusion $E \to I$. This is possible as $I$ is injective.
If $\psi(N) \subset E$, then $\psi$ is the desired extension.
If $\psi(N)$ is not contained in $E$, then by (2) the inclusion
$E \subset E + \psi(N)$ is not essential. hence
we can find a nonzero submodule $K \subset E + \psi(N)$ meeting $E$ in $0$.
This means that $M' = \psi^{-1}(E + K)$ strictly contains $M$.
Thus we can extend $\varphi$ to $M'$ using
$$
M' \xrightarrow{\psi|_{M'}} E + K \to (E + K)/K = E
$$
This contradicts the maximality of $(M, \varphi)$.
\end{proof}

\begin{example}
\label{example-reduced-ring-injective}
Let $R$ be a reduced ring. Let $\mathfrak p \subset R$ be a minimal prime
so that $K = R_\mathfrak p$ is a field
(Algebra, Lemma \ref{algebra-lemma-minimal-prime-reduced-ring}).
Then $K$ is an injective $R$-module. Namely, we have
$\Hom_R(M, K) = \Hom_K(M_\mathfrak p, K)$ for any $R$-module
$M$. Since localization is an exact functor and taking duals is
an exact functor on $K$-vector spaces we conclude $\Hom_R(-, K)$
is an exact functor, i.e., $K$ is an injective $R$-module.
\end{example}

\begin{lemma}
\label{lemma-sum-injective-modules}
Let $R$ be a Noetherian ring. A direct sum of injective modules
is injective.
\end{lemma}

\begin{proof}
Let $E_i$ be a family of injective modules parametrized by a set $I$.
Set $E = \bigcup E_i$. To show that $E$ is injective we use
Injectives, Lemma \ref{injectives-lemma-criterion-baer}.
Thus let $\varphi : I \to E$ be a module map from an ideal of $R$
into $E$. As $I$ is a finite $R$-module (because $R$ is Noetherian)
we can find finitely many elements $i_1, \ldots, i_r \in I$
such that $\varphi$ maps into $\bigcup_{j = 1, \ldots, r} E_{i_j}$.
Then we can extend $\varphi$ into $\bigcup_{j = 1, \ldots, r} E_{i_j}$
using the injectivity of the modules $E_{i_j}$.
\end{proof}

\begin{lemma}
\label{lemma-localization-injective-modules}
Let $R$ be a Noetherian ring. Let $S \subset R$ be a multiplicative
subset. If $E$ is an injective $R$-module, then $S^{-1}E$ is an
injective $S^{-1}R$-module.
\end{lemma}

\begin{proof}
Since $R \to S^{-1}R$ is an epimorphism of rings, it suffices
to show that $S^{-1}E$ is injective as an $R$-module, see
Lemma \ref{lemma-injective-epimorphism}.
To show this we use Injectives, Lemma \ref{injectives-lemma-criterion-baer}.
Thus let $I \subset R$ be an ideal and let
$\varphi : I \to S^{-1} E$ be an $R$-module map.
As $I$ is a finitely presented $R$-module (because $R$ is Noetherian)
we can find an $f \in S$ and an $R$-module map $I \to E$
such that $f\varphi$ is the composition $I \to E \to S^{-1}E$
(Algebra, Lemma \ref{algebra-lemma-hom-from-finitely-presented}).
Then we can extend $I \to E$ to a homomorphism $R \to E$.
Then the composition
$$
R \to E \to S^{-1}E \xrightarrow{f^{-1}} S^{-1}E
$$
is the desired extension of $\varphi$ to $R$.
\end{proof}

\begin{lemma}
\label{lemma-injective-module-divide}
Let $R$ be a Noetherian ring. Let $I$ be an injective $R$-module.
\begin{enumerate}
\item Let $f \in R$. Then $E = \bigcup I[f^n] = I[f^\infty]$
is an injective submodule of $I$.
\item Let $J \subset R$ be an ideal. Then the $J$-power torsion
submodule $I[J^\infty]$ is an injective submodule of $I$.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use Lemma \ref{lemma-essential-extensions-in-injective}
to prove (1).
Suppose that $E \subset E' \subset I$ and that $E'$ is an essential
extension of $E$. We will show that $E' = E$. If not, then we can
find $x \in E'$ and $x \not \in E$.
Let $J = \{ a \in R \mid ax \in E\}$. Since $R$ is Noetherian,
we may write $J = (g_1, \ldots, g_t)$ for some
$g_i \in R$. By definition $E$ is the set of elements of $I$ annihilated
by powers of $f$, so we may choose integers $n_i$ so that $f^{n_i}g_ix = 0$.
Set $n = \mathrm{max}\{ n_i \}$. Then $x' = f^n x$ is an element of $E'$
not in $E$ and is annihilated by $J$. Set $J' = \{ a \in R \mid ax' \in E \}$
so $J \subset J'$. Conversely, we have $a \in J'$ if and only if $ax' \in E$
if and only if $f^m a x' = 0$ for some $m \geq 0$. But then
$f^m a x' = f^{m + n} a x$ implies $ax \in E$, i.e., $a \in J$.
Hence $J = J'$. Thus $J = J' = \text{Ann}(x')$, so $Rx' \cap E  = 0$.
Hence $E'$ is not an essential extension of $E$, a contradiction.

\medskip\noindent
To prove (2) write $J = (f_1, \ldots, f_t)$. Then
$I[J^\infty]$ is equal to
$$
(\ldots((I[f_1^\infty])[f_2^\infty])\ldots)[f_t^\infty]
$$
and the result follows from (1) and induction.
\end{proof}

\begin{lemma}
\label{lemma-injective-dimension-over-polynomial-ring}
Let $A$ be a Noetherian ring. Let $E$ be an injective $A$-module.
Then $E \otimes_A A[x]$ has injective-amplitude $[0, 1]$
as an object of $D(A[x])$. In particular, $E \otimes_A A[x]$
has finite injective dimension as an $A[x]$-module.
\end{lemma}

\begin{proof}
Let us write $E[x] = E \otimes_A A[x]$. Consider the short exact
sequence of $A[x]$-modules
$$
0 \to E[x] \to \Hom_A(A[x], E[x]) \to \Hom_A(A[x], E[x]) \to 0
$$
where the first map sends $p \in E[x]$ to $f \mapsto fp$ and the
second map sends $\varphi$ to $f \mapsto \varphi(xf) - x\varphi(f)$.
The second map is surjective because
$\Hom_A(A[x], E[x]) = \prod_{n \geq 0} E[x]$ as an abelian group and
the map sends $(e_n)$ to $(e_{n + 1} - xe_n)$ which is surjective.
As an $A$-module we have $E[x] \cong \bigoplus_{n \geq 0} E$
which is injective by Lemma \ref{lemma-sum-injective-modules}.
Hence the $A[x]$-module $\Hom_A(A[x], E[x])$ is injective by
Lemma \ref{lemma-hom-injective} and the proof is complete.
\end{proof}



\section{Projective covers}
\label{section-projective-cover}

\noindent
In this section we briefly discuss projective covers.

\begin{definition}
\label{definition-projective-cover}
Let $R$ be a ring. A surjection $P \to M$ of $R$-modules is said
to be a {\it projective cover}, or sometimes a {\it projective envelope},
if $P$ is a projective $R$-module and $P \to M$ is an essential
surjection.
\end{definition}

\noindent
Projective covers do not always exist. For example, if $k$ is a field
and $R = k[x]$ is the polynomial ring over $k$, then the module $M = R/(x)$
does not have a projective cover. Namely, for any surjection $f : P \to M$
with $P$ projective over $R$, the proper submodule $(x - 1)P$ surjects
onto $M$. Hence $f$ is not essential.

\begin{lemma}
\label{lemma-projective-cover-unique}
Let $R$ be a ring and let $M$ be an $R$-module. If a projective cover
of $M$ exists, then it is unique up to isomorphism.
\end{lemma}

\begin{proof}
Let $P \to M$ and $P' \to M$ be projective covers. Because $P$ is a
projective $R$-module and $P' \to M$ is surjective, we can find an
$R$-module map $\alpha : P \to P'$ compatible with the maps to $M$.
Since $P' \to M$ is essential, we see that $\alpha$ is surjective.
As $P'$ is a projective $R$-module we can choose a direct sum decomposition
$P = \Ker(\alpha) \oplus P'$. Since $P' \to M$ is surjective
and since $P \to M$ is essential we conclude that $\Ker(\alpha)$
is zero as desired.
\end{proof}

\noindent
Here is an example where projective covers exist.

\begin{lemma}
\label{lemma-projective-covers-local}
Let $(R, \mathfrak m, \kappa)$ be a local ring. Any finite $R$-module has
a projective cover.
\end{lemma}

\begin{proof}
Let $M$ be a finite $R$-module. Let $r = \dim_\kappa(M/\mathfrak m M)$.
Choose $x_1, \ldots, x_r \in M$ mapping to a basis of $M/\mathfrak m M$.
Consider the map $f : R^{\oplus r} \to M$. By Nakayama's lemma this is
a surjection (Algebra, Lemma \ref{algebra-lemma-NAK}). If
$N \subset R^{\oplus r}$ is a proper submodule, then
$N/\mathfrak m N \to \kappa^{\oplus r}$ is not surjective (by
Nakayama's lemma again) hence $N/\mathfrak m N \to M/\mathfrak m M$
is not surjective. Thus $f$ is an essential surjection.
\end{proof}







\section{Injective hulls}
\label{section-injective-hull}

\noindent
In this section we briefly discuss injective hulls.

\begin{definition}
\label{definition-injective-hull}
Let $R$ be a ring. A injection $M \to I$ of $R$-modules is said
to be an {\it injective hull} if $I$ is a injective $R$-module and
$M \to I$ is an essential injection.
\end{definition}

\noindent
Injective hulls always exist.

\begin{lemma}
\label{lemma-injective-hull}
Let $R$ be a ring. Any $R$-module has an injective hull.
\end{lemma}

\begin{proof}
Let $M$ be an $R$-module. By
More on Algebra, Section \ref{more-algebra-section-injectives-modules}
the category of $R$-modules has enough injectives.
Choose an injection $M \to I$ with $I$ an injective $R$-module.
Consider the set $\mathcal{S}$ of submodules $M \subset E \subset I$
such that $E$ is an essential extension of $M$. We order $\mathcal{S}$
by inclusion. If $\{E_\alpha\}$ is a totally ordered subset
of $\mathcal{S}$, then $\bigcup E_\alpha$ is an essential extension of $M$
too (Lemma \ref{lemma-union-essential-extensions}).
Thus we can apply Zorn's lemma and find a maximal element
$E \in \mathcal{S}$. We claim $M \subset E$ is an injective hull, i.e.,
$E$ is an injective $R$-module. This follows from
Lemma \ref{lemma-essential-extensions-in-injective}.
\end{proof}

\begin{lemma}
\label{lemma-injective-hull-unique}
Let $R$ be a ring. Let $M$, $N$ be $R$-modules and let $M \to E$
and $N \to E'$ be injective hulls. Then
\begin{enumerate}
\item for any $R$-module map $\varphi : M \to N$ there exists an
$R$-module map $\psi : E \to E'$ such that
$$
\xymatrix{
M \ar[r] \ar[d]_\varphi & E \ar[d]^\psi \\
N \ar[r] & E'
}
$$
commutes,
\item if $\varphi$ is injective, then $\psi$ is injective,
\item if $\varphi$ is an essential injection, then $\psi$ is an isomorphism,
\item if $\varphi$ is an isomorphism, then $\psi$ is an isomorphism,
\item if $M \to I$ is an embedding of $M$ into an injective $R$-module,
then there is an isomorphism $I \cong E \oplus I'$ compatible with
the embeddings of $M$,
\end{enumerate}
In particular, the injective hull $E$ of $M$ is unique up to isomorphism.
\end{lemma}

\begin{proof}
Part (1) follows from the fact that $E'$ is an injective $R$-module.
Part (2) follows as $\Ker(\psi) \cap M = 0$
and $E$ is an essential extension of $M$.
Assume $\varphi$ is an essential injection. Then
$E \cong \psi(E) \subset E'$ by (2) which implies
$E' = \psi(E) \oplus E''$ because $E$ is injective.
Since $E'$ is an essential extension of
$M$ (Lemma \ref{lemma-essential}) we get $E'' = 0$.
Part (4) is a special case of (3).
Assume $M \to I$ as in (5).
Choose a map $\alpha : E \to I$ extending the map $M \to I$.
Arguing as before we see that $\alpha$ is injective.
Thus as before $\alpha(E)$ splits off from $I$.
This proves (5).
\end{proof}

\begin{example}
\label{example-injective-hull-domain}
Let $R$ be a domain with fraction field $K$. Then $R \subset K$ is an
injective hull of $R$. Namely, by
Example \ref{example-reduced-ring-injective} we see that $K$ is an injective
$R$-module and by Lemma \ref{lemma-essential-extension} we see that
$R \subset K$ is an essential extension.
\end{example}

\begin{definition}
\label{definition-indecomposable}
An object $X$ of an additive category is called {\it indecomposable}
if it is nonzero and if $X = Y \oplus Z$, then either $Y = 0$ or $Z = 0$.
\end{definition}

\begin{lemma}
\label{lemma-indecomposable-injective}
Let $R$ be a ring. Let $E$ be an indecomposable injective $R$-module.
Then
\begin{enumerate}
\item $E$ is the injective hull of any nonzero submodule of $E$,
\item the intersection of any two nonzero submodules of $E$ is nonzero,
\item $\text{End}_R(E, E)$ is a noncommutative local ring with maximal
ideal those $\varphi : E \to E$ whose kernel is nonzero, and
\item the set of zerodivisors on $E$ is a prime ideal $\mathfrak p$ of $R$
and $E$ is an injective $R_\mathfrak p$-module.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) follows from Lemma \ref{lemma-injective-hull-unique}.
Part (2) follows from part (1) and the definition of injective hulls.

\medskip\noindent
Proof of (3). Set $A = \text{End}_R(E, E)$ and
$I = \{\varphi \in A \mid \Ker(f) \not = 0\}$.
The statement means that $I$ is a two sided ideal and
that any $\varphi \in A$, $\varphi \not \in I$ is invertible.
Suppose $\varphi$ and $\psi$ are not injective.
Then $\Ker(\varphi) \cap \Ker(\psi)$ is nonzero
by (2). Hence $\varphi + \psi \in I$. It follows that $I$
is a two sided ideal. If $\varphi \in A$, $\varphi \not \in I$,
then $E \cong \varphi(E) \subset E$ is an injective submodule,
hence $E = \varphi(E)$ because $E$ is indecomposable.

\medskip\noindent
Proof of (4). Consider the ring map $R \to A$ and let $\mathfrak p \subset R$
be the inverse image of the maximal ideal $I$. Then it is clear
that $\mathfrak p$ is a prime ideal and that $R \to A$ extends to
$R_\mathfrak p \to A$. Thus $E$ is an $R_\mathfrak p$-module.
It follows from Lemma \ref{lemma-injective-epimorphism} that $E$ is injective
as an $R_\mathfrak p$-module.
\end{proof}

\begin{lemma}
\label{lemma-injective-hull-indecomposable}
Let $\mathfrak p \subset R$ be a prime of a ring $R$.
Let $E$ be the injective hull of $R/\mathfrak p$. Then
\begin{enumerate}
\item $E$ is indecomposable,
\item $E$ is the injective hull of $\kappa(\mathfrak p)$,
\item $E$ is the injective hull of $\kappa(\mathfrak p)$
over the ring $R_\mathfrak p$.
\end{enumerate}
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-essential-extension} the inclusion
$R/\mathfrak p \subset \kappa(\mathfrak p)$ is an essential
extension. Then Lemma \ref{lemma-injective-hull-unique}
shows (2) holds. For $f \in R$, $f \not \in \mathfrak p$
the map $f : \kappa(\mathfrak p) \to \kappa(\mathfrak p)$ is an isomorphism
hence the map $f : E \to E$ is an isomorphism,
see Lemma \ref{lemma-injective-hull-unique}.
Thus $E$ is an $R_\mathfrak p$-module. It is injective
as an $R_\mathfrak p$-module by Lemma \ref{lemma-injective-epimorphism}.
Finally, let $E' \subset E$ be a nonzero injective $R$-submodule.
Then $J = (R/\mathfrak p) \cap E'$ is nonzero. After shrinking $E'$
we may assume that $E'$ is the injective hull of $J$ (see
Lemma \ref{lemma-injective-hull-unique} for example).
Observe that $R/\mathfrak p$ is an essential extension of $J$ for example by
Lemma \ref{lemma-essential-extension}. Hence $E' \to E$
is an isomorphism by Lemma \ref{lemma-injective-hull-unique} part (3).
Hence $E$ is indecomposable.
\end{proof}

\begin{lemma}
\label{lemma-indecomposable-injective-noetherian}
Let $R$ be a Noetherian ring. Let $E$ be an indecomposable injective
$R$-module. Then there exists a prime ideal $\mathfrak p$ of $R$ such that
$E$ is the injective hull of $\kappa(\mathfrak p)$.
\end{lemma}

\begin{proof}
Let $\mathfrak p$ be the prime ideal found in
Lemma \ref{lemma-indecomposable-injective}.
Say $\mathfrak p = (f_1, \ldots, f_r)$.
Pick a nonzero element $x \in \bigcap \Ker(f_i : E \to E)$,
see Lemma \ref{lemma-indecomposable-injective}.
Then $(R_\mathfrak p)x$ is a module isomorphic to $\kappa(\mathfrak p)$
inside $E$. We conclude by Lemma \ref{lemma-indecomposable-injective}.
\end{proof}

\begin{proposition}[Structure of injective modules over Noetherian rings]
\label{proposition-structure-injectives-noetherian}
Let $R$ be a Noetherian ring.
Every injective module is a direct sum of indecomposable injective modules.
Every indecomposable injective module is the injective hull of
the residue field at a prime.
\end{proposition}

\begin{proof}
The second statement is Lemma \ref{lemma-indecomposable-injective-noetherian}.
For the first statement, let $I$ be an injective $R$-module.
We will use transfinite recursion to construct $I_\alpha \subset I$
for ordinals $\alpha$ which are direct sums of indecomposable injective
$R$-modules $E_{\beta + 1}$ for $\beta < \alpha$.
For $\alpha = 0$ we let $I_0 = 0$. Suppose given an ordinal $\alpha$
such that $I_\alpha$ has been constructed. Then $I_\alpha$ is an
injective $R$-module by Lemma \ref{lemma-sum-injective-modules}.
Hence $I \cong I_\alpha \oplus I'$. If $I' = 0$ we are done.
If not, then $I'$ has an associated prime by
Algebra, Lemma \ref{algebra-lemma-ass-zero}.
Thus $I'$ contains a copy of $R/\mathfrak p$ for some prime $\mathfrak p$.
Hence $I'$ contains an indecomposable submodule $E$ by
Lemmas \ref{lemma-injective-hull-unique} and
\ref{lemma-injective-hull-indecomposable}. Set
$I_{\alpha + 1} = I_\alpha \oplus E_\alpha$.
If $\alpha$ is a limit ordinal and $I_\beta$ has been constructed
for $\beta < \alpha$, then we set
$I_\alpha = \bigcup_{\beta < \alpha} I_\beta$.
Observe that $I_\alpha = \bigoplus_{\beta < \alpha} E_{\beta + 1}$.
This concludes the proof.
\end{proof}



\section{Duality over Artinian local rings}
\label{section-artinian}

\noindent
Let $(R, \mathfrak m, \kappa)$ be an artinian local ring.
Recall that this implies $R$ is Noetherian and that $R$ has finite
length as an $R$-module. Moreover an $R$-module is finite if and
only if it has finite length. We will use these facts without
further mention in this section. Please see
Algebra, Sections \ref{algebra-section-length} and
\ref{algebra-section-artinian}
and
Algebra, Proposition \ref{algebra-proposition-dimension-zero-ring}
for more details.

\begin{lemma}
\label{lemma-finite}
Let $(R, \mathfrak m, \kappa)$ be an artinian local ring.
Let $E$ be an injective hull of $\kappa$. For every finite
$R$-module $M$ we have
$$
\text{length}_R(M) = \text{length}_R(\Hom_R(M, E))
$$
In particular, the injective hull $E$ of $\kappa$ is a finite $R$-module.
\end{lemma}

\begin{proof}
Because $E$ is an essential extension of $\kappa$ we have
$\kappa = E[\mathfrak m]$ where $E[\mathfrak m]$ is the
$\mathfrak m$-torsion in $E$ (notation as in More on Algebra, Section
\ref{more-algebra-section-torsion}).
Hence $\Hom_R(\kappa, E) \cong \kappa$ and the equality of lengths
holds for $M = \kappa$. We prove the displayed equality of the lemma
by induction on the length of $M$. If $M$ is nonzero there exists a surjection
$M \to \kappa$ with kernel $M'$. Since the functor $M \mapsto \Hom_R(M, E)$
is exact we obtain a short exact sequence
$$
0 \to \Hom_R(\kappa, E) \to \Hom_R(M, E) \to \Hom_R(M', E) \to 0.
$$
Additivity of length for this sequence and the sequence
$0 \to M' \to M \to \kappa \to 0$ and the equality for $M'$ (induction
hypothesis) and $\kappa$ implies the equality for $M$.
The final statement of the lemma follows as $E = \Hom_R(R, E)$.
\end{proof}

\begin{lemma}
\label{lemma-evaluate}
Let $(R, \mathfrak m, \kappa)$ be an artinian local ring.
Let $E$ be an injective hull of $\kappa$.
For any finite $R$-module $M$ the evaluation map
$$
M \longrightarrow \Hom_R(\Hom_R(M, E), E)
$$
is an isomorphism. In particular $R = \Hom_R(E, E)$.
\end{lemma}

\begin{proof}
Observe that the displayed arrow is injective. Namely, if $x \in M$ is
a nonzero element, then there is a nonzero map $Rx \to \kappa$ which
we can extend to a map $\varphi : M \to E$ that doesn't vanish on $x$.
Since the source and target of the arrow have the same length by
Lemma \ref{lemma-finite}
we conclude it is an isomorphism. The final statement follows
on taking $M = R$.
\end{proof}

\noindent
To state the next lemma, denote $\text{Mod}^{fg}_R$ the category of finite
$R$-modules over a ring $R$.

\begin{lemma}
\label{lemma-duality}
Let $(R, \mathfrak m, \kappa)$ be an artinian local ring.
Let $E$ be an injective hull of $\kappa$.
The functor $D(-) = \Hom_R(-, E)$ induces an exact anti-equivalence
$\text{Mod}^{fg}_R \to \text{Mod}^{fg}_R$ and
$D \circ D \cong \text{id}$.
\end{lemma}

\begin{proof}
We have seen that $D \circ D = \text{id}$ on $\text{Mod}^{fg}_R$
in Lemma \ref{lemma-evaluate}. It follows immediately that
$D$ is an anti-equivalence.
\end{proof}

\begin{lemma}
\label{lemma-duality-torsion-cotorsion}
Assumptions and notation as in Lemma \ref{lemma-duality}.
Let $I \subset R$ be an ideal and $M$ a finite $R$-module.
Then
$$
D(M[I]) = D(M)/ID(M) \quad\text{and}\quad D(M/IM) = D(M)[I]
$$
\end{lemma}

\begin{proof}
Say $I = (f_1, \ldots, f_t)$. Consider the map
$$
M^{\oplus t} \xrightarrow{f_1, \ldots, f_t} M
$$
with cokernel $M/IM$. Applying the exact functor $D$ we conclude that
$D(M/IM)$ is $D(M)[I]$. The other case is proved in the same way.
\end{proof}



\section{Injective hull of the residue field}
\label{section-hull-residue-field}

\noindent
Most of our results will be for Noetherian local rings in this section.

\begin{lemma}
\label{lemma-quotient}
Let $R \to S$ be a surjective map of local rings with kernel $I$.
Let $E$ be the injective hull of the residue field of $R$ over $R$.
Then $E[I]$ is the injective hull of the residue field of $S$ over $S$.
\end{lemma}

\begin{proof}
Observe that $E[I] = \Hom_R(S, E)$ as $S = R/I$. Hence $E[I]$ is an injective
$S$-module by Lemma \ref{lemma-hom-injective}. Since $E$ is an essential
extension of $\kappa = R/\mathfrak m_R$ it follows that $E[I]$ is an
essential extension of $\kappa$ as well. The result follows.
\end{proof}

\begin{lemma}
\label{lemma-torsion-submodule-sum-injective-hulls}
Let $(R, \mathfrak m, \kappa)$ be a local ring.
Let $E$ be the injective hull of $\kappa$.
Let $M$ be a $\mathfrak m$-power torsion $R$-module
with $n = \dim_\kappa(M[\mathfrak m]) < \infty$.
Then $M$ is isomorphic to a submodule of $E^{\oplus n}$.
\end{lemma}

\begin{proof}
Observe that $E^{\oplus n}$ is the injective hull of
$\kappa^{\oplus n} = M[\mathfrak m]$. Thus there is an $R$-module map
$M \to E^{\oplus n}$ which is injective on $M[\mathfrak m]$.
Since $M$ is $\mathfrak m$-power torsion the inclusion
$M[\mathfrak m] \subset M$ is an essential extension
(for example by Lemma \ref{lemma-essential-extension})
we conclude that the kernel of $M \to E^{\oplus n}$ is zero.
\end{proof}

\begin{lemma}
\label{lemma-union-artinian}
Let $(R, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $E$ be an injective hull of $\kappa$ over $R$.
Let $E_n$ be an injective hull of $\kappa$ over $R/\mathfrak m^n$.
Then $E = \bigcup E_n$ and $E_n = E[\mathfrak m^n]$.
\end{lemma}

\begin{proof}
We have $E_n = E[\mathfrak m^n]$ by Lemma \ref{lemma-quotient}.
We have $E = \bigcup E_n$ because $\bigcup E_n = E[\mathfrak m^\infty]$
is an injective $R$-submodule which contains $\kappa$, see
Lemma \ref{lemma-injective-module-divide}.
\end{proof}

\noindent
The following lemma tells us the injective hull of the residue
field of a Noetherian local ring only depends on the completion.

\begin{lemma}
\label{lemma-compare}
Let $R \to S$ be a flat local homomorphism of local Noetherian rings
such that $R/\mathfrak m_R \cong S/\mathfrak m_R S$.
Then the injective hull of the residue field
of $R$ is the injective hull of the residue field of $S$.
\end{lemma}

\begin{proof}
Note that $\mathfrak m_RS = \mathfrak m_S$ as the quotient by the former
is a field. Set $\kappa = R/\mathfrak m_R = S/\mathfrak m_S$.
Let $E_R$ be the injective hull of $\kappa$ over $R$.
Let $E_S$ be the injective hull of $\kappa$ over $S$.
Observe that $E_S$ is an injective $R$-module by
Lemma \ref{lemma-injective-flat}.
Choose an extension $E_R \to E_S$ of the identification of
residue fields. This map is an isomorphism by
Lemma \ref{lemma-union-artinian}
because $R \to S$ induces an isomorphism
$R/\mathfrak m_R^n \to S/\mathfrak m_S^n$ for all $n$.
\end{proof}

\begin{lemma}
\label{lemma-endos}
Let $(R, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $E$ be an injective hull of $\kappa$ over $R$. Then
$\Hom_R(E, E)$ is canonically isomorphic to the completion of $R$.
\end{lemma}

\begin{proof}
Write $E = \bigcup E_n$ with $E_n = E[\mathfrak m^n]$ as in
Lemma \ref{lemma-union-artinian}. Any endomorphism of $E$
preserves this filtration. Hence
$$
\Hom_R(E, E) = \lim \Hom_R(E_n, E_n)
$$
The lemma follows as
$\Hom_R(E_n, E_n) = \Hom_{R/\mathfrak m^n}(E_n, E_n) = R/\mathfrak m^n$
by Lemma \ref{lemma-evaluate}.
\end{proof}

\begin{lemma}
\label{lemma-injective-hull-has-dcc}
Let $(R, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $E$ be an injective hull of $\kappa$ over $R$. Then
$E$ satisfies the descending chain condition.
\end{lemma}

\begin{proof}
If $E \supset M_1 \supset M_2 \supset \ldots$ is a sequence of submodules, then
$$
\Hom_R(E, E) \to \Hom_R(M_1, E) \to \Hom_R(M_2, E) \to \ldots
$$
is a sequence of surjections. By Lemma \ref{lemma-endos} each of these is a
module over the completion $R^\wedge = \Hom_R(E, E)$.
Since $R^\wedge$ is Noetherian
(Algebra, Lemma \ref{algebra-lemma-completion-Noetherian-Noetherian})
the sequence stabilizes: $\Hom_R(M_n, E) = \Hom_R(M_{n + 1}, E) = \ldots$.
Since $E$ is injective, this can only happen if $\Hom_R(M_n/M_{n + 1}, E)$
is zero. However, if $M_n/M_{n + 1}$ is nonzero, then it contains a
nonzero element annihilated by $\mathfrak m$, because $E$ is
$\mathfrak m$-power torsion by Lemma \ref{lemma-union-artinian}.
In this case $M_n/M_{n + 1}$ has a nonzero map into $E$, contradicting
the assumed vanishing. This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-describe-categories}
Let $(R, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $E$ be an injective hull of $\kappa$.
\begin{enumerate}
\item For an $R$-module $M$ the following are equivalent:
\begin{enumerate}
\item $M$ satisfies the ascending chain condition,
\item $M$ is a finite $R$-module, and
\item there exist $n, m$ and an exact sequence
$R^{\oplus m} \to R^{\oplus n} \to M \to 0$.
\end{enumerate}
\item For an $R$-module $M$ the following are equivalent:
\begin{enumerate}
\item $M$ satisfies the descending chain condition,
\item $M$ is $\mathfrak m$-power torsion and
$\dim_\kappa(M[\mathfrak m]) < \infty$, and
\item there exist $n, m$ and an exact sequence
$0 \to M \to E^{\oplus n} \to E^{\oplus m}$.
\end{enumerate}
\end{enumerate}
\end{lemma}

\begin{proof}
We omit the proof of (1).

\medskip\noindent
Let $M$ be an $R$-module with the descending chain condition. Let $x \in M$.
Then $\mathfrak m^n x$ is a descending chain of submodules, hence stabilizes.
Thus $\mathfrak m^nx = \mathfrak m^{n + 1}x$ for some $n$. By Nakayama's lemma
(Algebra, Lemma \ref{algebra-lemma-NAK}) this implies $\mathfrak m^n x = 0$,
i.e., $x$ is $\mathfrak m$-power torsion. Since $M[\mathfrak m]$ is a vector
space over $\kappa$ it has to be finite dimensional in order to have the
descending chain condition.

\medskip\noindent
Assume that $M$ is $\mathfrak m$-power torsion and has a finite dimensional
$\mathfrak m$-torsion submodule $M[\mathfrak m]$. By
Lemma \ref{lemma-torsion-submodule-sum-injective-hulls}
we see that $M$ is a submodule of $E^{\oplus n}$ for some $n$.
Consider the quotient $N = E^{\oplus n}/M$. By
Lemma \ref{lemma-injective-hull-has-dcc} the module $E$ has the
descending chain condition hence so do $E^{\oplus n}$ and $N$.
Therefore $N$ satisfies (2)(a) which implies $N$ satisfies
(2)(b) by the second paragraph of the proof. Thus by
Lemma \ref{lemma-torsion-submodule-sum-injective-hulls}
again we see that $N$ is a submodule of $E^{\oplus m}$ for some $m$.
Thus we have a short exact sequence
$0 \to M \to E^{\oplus n} \to E^{\oplus m}$.

\medskip\noindent
Assume we have a short exact sequence
$0 \to M \to E^{\oplus n} \to E^{\oplus m}$.
Since $E$ satisfies the descending chain condition by
Lemma \ref{lemma-injective-hull-has-dcc}
so does $M$.
\end{proof}

\begin{proposition}[Matlis duality]
\label{proposition-matlis}
Let $(R, \mathfrak m, \kappa)$ be a complete local Noetherian ring.
Let $E$ be an injective hull of $\kappa$ over $R$. The functor
$D(-) = \Hom_R(-, E)$ induces an anti-equivalence
$$
\left\{
\begin{matrix}
R\text{-modules with the} \\
\text{descending chain condition}
\end{matrix}
\right\}
\longleftrightarrow
\left\{
\begin{matrix}
R\text{-modules with the} \\
\text{ascending chain condition}
\end{matrix}
\right\}
$$
and we have $D \circ D = \text{id}$ on either side of the equivalence.
\end{proposition}

\begin{proof}
By Lemma \ref{lemma-endos} we have $R = \Hom_R(E, E) = D(E)$.
Of course we have $E = \Hom_R(R, E) = D(R)$. Since $E$ is injective
the functor $D$ is exact. The result now follows immediately from the
description of the categories in
Lemma \ref{lemma-describe-categories}.
\end{proof}

\begin{remark}
\label{remark-matlis}
Let $(R, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $E$ be an injective hull of $\kappa$ over $R$. Here is an
addendum to Matlis duality: If $N$ is an $\mathfrak m$-power torsion module
and $M = \Hom_R(N, E)$ is a finite module over the completion of $R$,
then $N$ satisfies the descending chain condition. Namely, for any
submodules $N'' \subset N' \subset N$ with $N'' \not = N'$, we can
find an embedding $\kappa \subset N''/N'$ and hence a nonzero
map $N' \to E$ annihilating $N''$ which we can extend to a map $N \to E$
annihilating $N''$. Thus $N \supset N' \mapsto M' = \Hom_R(N/N', E) \subset M$
is an inclusion preserving map from submodules of $N$ to submodules
of $M$, whence the conclusion.
\end{remark}




















\section{Deriving torsion}
\label{section-bad-local-cohomology}

\noindent
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal
(if $I$ is not finitely generated perhaps a different definition
should be used). Let $Z = V(I) \subset \Spec(A)$. Recall that the
category $I^\infty\text{-torsion}$ of $I$-power torsion modules
only depends on the closed subset $Z$ and not on the choice of the
finitely generated ideal $I$ such that $Z = V(I)$, see
More on Algebra, Lemma \ref{more-algebra-lemma-local-cohomology-closed}.
In this section we will consider the functor
$$
H^0_{I} : \text{Mod}_A \longrightarrow I^\infty\text{-torsion},\quad
M \longmapsto M[I^\infty] = \bigcup M[I^n]
$$
which sends $M$ to the submodule of $I$-power torsion.

\medskip\noindent
Let $A$ be a ring and let $I$ be a finitely generated ideal.
Note that $I^\infty\text{-torsion}$ is a Grothendieck
abelian category (direct sums exist, filtered colimits are
exact, and $\bigoplus A/I^n$ is a generator by
More on Algebra, Lemma \ref{more-algebra-lemma-I-power-torsion-presentation}).
Hence the derived category $D(I^\infty\text{-torsion})$ exists, see
Injectives, Remark \ref{injectives-remark-existence-D}.
Our functor $H^0_I$ is left exact and has a derived extension
which we will denote
$$
R\Gamma_I : D(A) \longrightarrow D(I^\infty\text{-torsion}).
$$
{\bf Warning:} this functor does not deserve the name
local cohomology unless the ring $A$ is Noetherian.
The functors $H^0_I$, $R\Gamma_I$, and the satellites $H^p_I$
only depend on the closed subset $Z \subset \Spec(A)$ and not
on the choice of the finitely generated ideal $I$ such that
$V(I) = Z$. However, we insist on using the subscript $I$ for
the functors above as the notation $R\Gamma_Z$ is going
to be used for a different functor, see
(\ref{equation-local-cohomology}), which
agrees with the functor $R\Gamma_I$ only (as far as we know)
in case $A$ is Noetherian
(see Lemma \ref{lemma-local-cohomology-noetherian}).

\begin{lemma}
\label{lemma-adjoint}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
The functor $R\Gamma_I$ is right adjoint to the functor
$D(I^\infty\text{-torsion}) \to D(A)$.
\end{lemma}

\begin{proof}
This follows from the fact that taking $I$-power torsion submodules
is the right adjoint to the inclusion functor
$I^\infty\text{-torsion} \to \text{Mod}_A$. See
Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
\end{proof}

\begin{lemma}
\label{lemma-local-cohomology-ext}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
For any object $K$ of $D(A)$ we have
$$
R\Gamma_I(K) = \text{hocolim}\ R\Hom_A(A/I^n, K)
$$
in $D(A)$ and
$$
R^q\Gamma_I(K) = \colim_n \Ext_A^q(A/I^n, K)
$$
as modules for all $q \in \mathbf{Z}$.
\end{lemma}

\begin{proof}
Let $J^\bullet$ be a K-injective complex representing $K$. Then
$$
R\Gamma_I(K) = J^\bullet[I^\infty] = \colim J^\bullet[I^n] =
\colim \Hom_A(A/I^n, J^\bullet)
$$
where the first equality is the definition of $R\Gamma_I(K)$.
By Derived Categories, Lemma \ref{derived-lemma-colim-hocolim}
we obtain the first displayed equality in the statement of the lemma.
The second displayed equality in the statement of the lemma then
follows because $H^q(\Hom_A(A/I^n, J^\bullet)) = \Ext^q_A(A/I^n, K)$
and because filtered colimits are exact in the category of abelian
groups.
\end{proof}

\begin{lemma}
\label{lemma-bad-local-cohomology-vanishes}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
Let $K^\bullet$ be a complex of $A$-modules such that
$f : K^\bullet \to K^\bullet$ is an isomorphism for some
$f \in I$, i.e., $K^\bullet$ is a complex of $A_f$-modules. Then
$R\Gamma_I(K^\bullet) = 0$.
\end{lemma}

\begin{proof}
Namely, in this case the cohomology modules of $R\Gamma_I(K^\bullet)$
are both $f$-power torsion and $f$ acts by automorphisms. Hence the
cohomology modules are zero and hence the object is zero.
\end{proof}

\noindent
Let $A$ be a ring and $I \subset A$ a finitely generated ideal.
By More on Algebra, Lemma \ref{more-algebra-lemma-I-power-torsion}
the category of $I$-power torsion modules is a Serre subcategory
of the category of all $A$-modules, hence there is a functor
\begin{equation}
\label{equation-compare-torsion}
D(I^\infty\text{-torsion}) \to D_{I^\infty\text{-torsion}}(A)
\end{equation}
see Derived Categories, Section \ref{derived-section-triangulated-sub}.

\begin{lemma}
\label{lemma-not-equal}
Let $A$ be a ring and let $I$ be a finitely generated ideal.
Let $M$ and $N$ be $I$-power torsion modules.
\begin{enumerate}
\item $\Hom_{D(A)}(M, N) = \Hom_{D({I^\infty\text{-torsion}})}(M, N)$,
\item $\Ext^1_{D(A)}(M, N) =
\Ext^1_{D({I^\infty\text{-torsion}})}(M, N)$,
\item $\Ext^2_{D({I^\infty\text{-torsion}})}(M, N) \to
\Ext^2_{D(A)}(M, N)$ is not surjective in general,
\item (\ref{equation-compare-torsion}) is not an equivalence in general.
\end{enumerate}
\end{lemma}

\begin{proof}
Parts (1) and (2) follow immediately from the fact that $I$-power torsion
forms a Serre subcategory of $\text{Mod}_A$. Part (4) follows from
part (3).

\medskip\noindent
For part (3) let $A$ be a ring with an element $f \in A$ such that
$A[f]$ contains a nonzero element $x$ annihilated by $f$ and
$A$ contains elements $x_n$ with $f^nx_n = x$. Such a ring $A$
exists because we can take
$$
A = \mathbf{Z}[f, x, x_n]/(fx, f^nx_n - x)
$$
Given $A$ set $I = (f)$. Then the exact sequence
$$
0 \to A[f] \to A \xrightarrow{f} A \to A/fA \to 0
$$
defines an element in $\Ext^2_A(A/fA, A[f])$. We claim this
element does not come from an element of
$\Ext^2_{D(f^\infty\text{-torsion})}(A/fA, A[f])$.
Namely, if it did, then there would be an exact sequence
$$
0 \to A[f] \to M \to N \to A/fA \to 0
$$
where $M$ and $N$ are $f$-power torsion modules defining the same
$2$ extension class. Since $A \to A$ is a complex of free modules
and since the $2$ extension classes are the same
we would be able to find a map
$$
\xymatrix{
0 \ar[r] &
A[f] \ar[r] \ar[d] &
A \ar[r] \ar[d]_\varphi &
A \ar[r] \ar[d]_\psi &
A/fA \ar[r] \ar[d] & 0 \\
0 \ar[r] &
A[f] \ar[r] &
M \ar[r] &
N \ar[r] &
A/fA \ar[r] & 0
}
$$
(some details omitted). Then we could replace $M$ by the image of
$\varphi$ and $N$ by the image of $\psi$. Then $M$ would be a cyclic
module, hence $f^n M = 0$ for some $n$. Considering $\varphi(x_{n + 1})$
we get a contradiction with the fact that $f^{n + 1}x_n = x$ is
nonzero in $A[f]$.
\end{proof}









\section{Local cohomology}
\label{section-local-cohomology}

\noindent
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
Set $Z = V(I) \subset \Spec(A)$. We will construct a functor
\begin{equation}
\label{equation-local-cohomology}
R\Gamma_Z : D(A) \longrightarrow D_{I^\infty\text{-torsion}}(A).
\end{equation}
which is right adjoint to the inclusion functor. For notation
see Section \ref{section-bad-local-cohomology}. The cohomology
modules of $R\Gamma_Z(K)$ are the {\it local cohomology groups
of $K$ with respect to $Z$}.
By Lemma \ref{lemma-not-equal} this functor will in general {\bf not} be
equal to $R\Gamma_I( - )$ even viewed as functors into $D(A)$.
In Section \ref{section-local-cohomology-noetherian}
we will show that if $A$ is Noetherian, then the two agree.

\medskip\noindent
We will continue the discussion of local cohomology in
the chapter on local cohomology, see
Local Cohomology, Section \ref{local-cohomology-section-introduction}.
For example, there we will show that $R\Gamma_Z$ computes cohomology
with support in $Z$ for the associated complex of quasi-coherent sheaves
on $\Spec(A)$. See Local Cohomology, Lemma
\ref{local-cohomology-lemma-local-cohomology-is-local-cohomology}.


\begin{lemma}
\label{lemma-local-cohomology-adjoint}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
There exists a right adjoint $R\Gamma_Z$ (\ref{equation-local-cohomology})
to the inclusion functor $D_{I^\infty\text{-torsion}}(A) \to D(A)$.
In fact, if $I$ is generated by $f_1, \ldots, f_r \in A$, then we have
$$
R\Gamma_Z(K) =
(A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}}
\to \ldots \to A_{f_1\ldots f_r}) \otimes_A^\mathbf{L} K
$$
functorially in $K \in D(A)$.
\end{lemma}

\begin{proof}
Say $I = (f_1, \ldots, f_r)$ is an ideal.
Let $K^\bullet$ be a complex of $A$-modules.
There is a canonical map of complexes
$$
(A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to
\ldots \to A_{f_1\ldots f_r}) \longrightarrow A.
$$
from the extended {\v C}ech complex to $A$.
Tensoring with $K^\bullet$, taking associated total complex,
we get a map
$$
\text{Tot}\left(
K^\bullet \otimes_A
(A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to
\ldots \to A_{f_1\ldots f_r})\right)
\longrightarrow
K^\bullet
$$
in $D(A)$. We claim the cohomology modules of the complex on the left are
$I$-power torsion, i.e., the LHS is an object of
$D_{I^\infty\text{-torsion}}(A)$. Namely, we have
$$
(A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to
\ldots \to A_{f_1\ldots f_r}) = \colim K(A, f_1^n, \ldots, f_r^n)
$$
by More on Algebra, Lemma
\ref{more-algebra-lemma-extended-alternating-Cech-is-colimit-koszul}.
Moreover, multiplication by $f_i^n$ on the complex
$K(A, f_1^n, \ldots, f_r^n)$ is homotopic to zero by
More on Algebra, Lemma \ref{more-algebra-lemma-homotopy-koszul}.
Since
$$
H^q\left( LHS \right) =
\colim H^q(\text{Tot}(K^\bullet \otimes_A K(A, f_1^n, \ldots, f_r^n)))
$$
we obtain our claim. On the other hand, if $K^\bullet$ is an
object of $D_{I^\infty\text{-torsion}}(A)$, then the complexes
$K^\bullet \otimes_A A_{f_{i_0} \ldots f_{i_p}}$ have vanishing
cohomology. Hence in this case the map $LHS \to K^\bullet$
is an isomorphism in $D(A)$. The construction
$$
R\Gamma_Z(K^\bullet) =
\text{Tot}\left(
K^\bullet \otimes_A
(A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to
\ldots \to A_{f_1\ldots f_r})\right)
$$
is functorial in $K^\bullet$ and defines an exact functor
$D(A) \to D_{I^\infty\text{-torsion}}(A)$ between
triangulated categories. It follows formally from the
existence of the natural transformation $R\Gamma_Z \to \text{id}$
given above and the fact that this evaluates to an isomorphism
on $K^\bullet$ in the subcategory, that $R\Gamma_Z$ is the desired
right adjoint.
\end{proof}

\begin{lemma}
\label{lemma-local-cohomology-and-restriction}
Let $A \to B$ be a ring homomorphism and let $I \subset A$
be a finitely generated ideal. Set $J = IB$. Set $Z = V(I)$
and $Y = V(J)$. Then
$$
R\Gamma_Z(M_A) = R\Gamma_Y(M)_A
$$
functorially in $M \in D(B)$. Here $(-)_A$ denotes the restriction
functors $D(B) \to D(A)$ and
$D_{J^\infty\text{-torsion}}(B) \to D_{I^\infty\text{-torsion}}(A)$.
\end{lemma}

\begin{proof}
This follows from uniqueness of adjoint functors as both
$R\Gamma_Z((-)_A)$ and $R\Gamma_Y(-)_A$
are right adjoint to the functor $D_{I^\infty\text{-torsion}}(A) \to D(B)$,
$K \mapsto K \otimes_A^\mathbf{L} B$.
Alternatively, one can use the description of $R\Gamma_Z$ and $R\Gamma_Y$
in terms of alternating {\v C}ech complexes
(Lemma \ref{lemma-local-cohomology-adjoint}).
Namely, if $I = (f_1, \ldots, f_r)$ then $J$ is generated by the images
$g_1, \ldots, g_r \in B$ of $f_1, \ldots, f_r$.
Then the statement of the lemma follows from the existence of
a canonical isomorphism
\begin{align*}
& M_A \otimes_A (A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}}
\to \ldots \to A_{f_1\ldots f_r}) \\
& = 
M \otimes_B (B \to \prod\nolimits_{i_0} B_{g_{i_0}} \to
\prod\nolimits_{i_0 < i_1} B_{g_{i_0}g_{i_1}}
\to \ldots \to B_{g_1\ldots g_r})
\end{align*}
for any $B$-module $M$.
\end{proof}

\begin{lemma}
\label{lemma-torsion-change-rings}
Let $A \to B$ be a ring homomorphism and let $I \subset A$
be a finitely generated ideal. Set $J = IB$. Let $Z = V(I)$ and $Y = V(J)$.
Then
$$
R\Gamma_Z(K) \otimes_A^\mathbf{L} B = R\Gamma_Y(K \otimes_A^\mathbf{L} B)
$$
functorially in $K \in D(A)$.
\end{lemma}

\begin{proof}
Write $I = (f_1, \ldots, f_r)$. Then $J$ is generated by the images
$g_1, \ldots, g_r \in B$ of $f_1, \ldots, f_r$. Then we have
$$
(A \to \prod A_{f_{i_0}} \to \ldots \to A_{f_1\ldots f_r}) \otimes_A B =
(B \to \prod B_{g_{i_0}} \to \ldots \to B_{g_1\ldots g_r})
$$
as complexes of $B$-modules. Represent $K$ by a K-flat complex $K^\bullet$
of $A$-modules. Since the total complexes associated to
$$
K^\bullet \otimes_A
(A \to \prod A_{f_{i_0}} \to \ldots \to A_{f_1\ldots f_r}) \otimes_A B
$$
and
$$
K^\bullet \otimes_A B \otimes_B
(B \to \prod B_{g_{i_0}} \to \ldots \to B_{g_1\ldots g_r})
$$
represent the left and right hand side of the displayed formula of the
lemma (see Lemma \ref{lemma-local-cohomology-adjoint}) we conclude.
\end{proof}

\begin{lemma}
\label{lemma-local-cohomology-vanishes}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
Let $K^\bullet$ be a complex of $A$-modules such that
$f : K^\bullet \to K^\bullet$ is an isomorphism for some
$f \in I$, i.e., $K^\bullet$ is a complex of $A_f$-modules. Then
$R\Gamma_Z(K^\bullet) = 0$.
\end{lemma}

\begin{proof}
Namely, in this case the cohomology modules of $R\Gamma_Z(K^\bullet)$
are both $f$-power torsion and $f$ acts by automorphisms. Hence the
cohomology modules are zero and hence the object is zero.
\end{proof}

\begin{lemma}
\label{lemma-torsion-tensor-product}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
For $K, L \in D(A)$ we have
$$
R\Gamma_Z(K \otimes_A^\mathbf{L} L) =
K \otimes_A^\mathbf{L} R\Gamma_Z(L) =
R\Gamma_Z(K) \otimes_A^\mathbf{L} L =
R\Gamma_Z(K) \otimes_A^\mathbf{L} R\Gamma_Z(L)
$$
If $K$ or $L$ is in $D_{I^\infty\text{-torsion}}(A)$ then so is
$K \otimes_A^\mathbf{L} L$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-local-cohomology-adjoint} we know that
$R\Gamma_Z$ is given by $C \otimes^\mathbf{L} -$ for some $C \in D(A)$.
Hence, for $K, L \in D(A)$ general we have
$$
R\Gamma_Z(K \otimes_A^\mathbf{L} L) =
K \otimes^\mathbf{L} L \otimes_A^\mathbf{L} C =
K \otimes_A^\mathbf{L} R\Gamma_Z(L)
$$
The other equalities follow formally from this one. This also implies
the last statement of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-local-cohomology-ss}
Let $A$ be a ring and let $I, J \subset A$ be finitely generated
ideals. Set $Z = V(I)$ and $Y = V(J)$. Then $Z \cap Y = V(I + J)$
and $R\Gamma_Y \circ R\Gamma_Z = R\Gamma_{Y \cap Z}$ as functors
$D(A) \to D_{(I + J)^\infty\text{-torsion}}(A)$. For $K \in D^+(A)$
there is a spectral sequence
$$
E_2^{p, q} = H^p_Y(H^q_Z(K)) \Rightarrow H^{p + q}_{Y \cap Z}(K)
$$
as in Derived Categories, Lemma
\ref{derived-lemma-grothendieck-spectral-sequence}.
\end{lemma}

\begin{proof}
There is a bit of abuse of notation in the lemma as strictly
speaking we cannot compose $R\Gamma_Y$ and $R\Gamma_Z$. The
meaning of the statement is simply that we are composing
$R\Gamma_Z$ with the inclusion $D_{I^\infty\text{-torsion}}(A) \to D(A)$
and then with $R\Gamma_Y$. Then the equality
$R\Gamma_Y \circ R\Gamma_Z = R\Gamma_{Y \cap Z}$
follows from the fact that
$$
D_{I^\infty\text{-torsion}}(A) \to D(A) \xrightarrow{R\Gamma_Y}
D_{(I + J)^\infty\text{-torsion}}(A)
$$
is right adjoint to the inclusion
$D_{(I + J)^\infty\text{-torsion}}(A) \to D_{I^\infty\text{-torsion}}(A)$.
Alternatively one can prove the formula using
Lemma \ref{lemma-local-cohomology-adjoint}
and the fact that the tensor product of
extended {\v C}ech complexes on $f_1, \ldots, f_r$ and
$g_1, \ldots, g_m$ is the extended {\v C}ech complex on
$f_1, \ldots, f_n. g_1, \ldots, g_m$.
The final assertion follows from this and the cited lemma.
\end{proof}

\noindent
The following lemma is the analogue of
More on Algebra, Lemma
\ref{more-algebra-lemma-restriction-derived-complete-equivalence}
for complexes with torsion cohomologies.

\begin{lemma}
\label{lemma-torsion-flat-change-rings}
Let $A \to B$ be a flat ring map and let $I \subset A$ be a finitely
generated ideal such that $A/I = B/IB$. Then base change and
restriction induce quasi-inverse equivalences
$D_{I^\infty\text{-torsion}}(A) = D_{(IB)^\infty\text{-torsion}}(B)$.
\end{lemma}

\begin{proof}
More precisely the functors are $K \mapsto K \otimes_A^\mathbf{L} B$
for $K$ in $D_{I^\infty\text{-torsion}}(A)$ and $M \mapsto M_A$
for $M$ in $D_{(IB)^\infty\text{-torsion}}(B)$. The reason this works
is that $H^i(K \otimes_A^\mathbf{L} B) = H^i(K) \otimes_A B = H^i(K)$.
The first equality holds as $A \to B$ is flat and the second by
More on Algebra, Lemma \ref{more-algebra-lemma-neighbourhood-isomorphism}.
\end{proof}

\noindent
The following lemma was shown for $\Hom$ and $\Ext^1$ of modules in
More on Algebra, Lemmas \ref{more-algebra-lemma-neighbourhood-equivalence} and
\ref{more-algebra-lemma-neighbourhood-extensions}.

\begin{lemma}
\label{lemma-neighbourhood-extensions}
Let $A \to B$ be a flat ring map and let $I \subset A$ be a
finitely generated ideal such that $A/I \to B/IB$ is an isomorphism.
For $K \in D_{I^\infty\text{-torsion}}(A)$ and $L \in D(A)$
the map
$$
R\Hom_A(K, L) \longrightarrow R\Hom_B(K \otimes_A B, L \otimes_A B)
$$
is a quasi-isomorphism. In particular, if $M$, $N$ are $A$-modules and
$M$ is $I$-power torsion, then the canonical map
$$
\Ext^i_A(M, N)
\longrightarrow
\Ext^i_B(M \otimes_A B, N \otimes_A B)
$$
is an isomorphism for all $i$. 
\end{lemma}

\begin{proof}
Let $Z = V(I) \subset \Spec(A)$ and $Y = V(IB) \subset \Spec(B)$.
Since the cohomology modules of $K$ are $I$ power torsion, the
canonical map $R\Gamma_Z(L) \to L$ induces an isomorphism
$$
R\Hom_A(K, R\Gamma_Z(L)) \to R\Hom_A(K, L)
$$
in $D(A)$. Similarly, the cohomology modules of $K \otimes_A B$ are
$IB$ power torsion and we have an isomorphism
$$
R\Hom_B(K \otimes_A B, R\Gamma_Y(L \otimes_A B)) \to 
R\Hom_B(K \otimes_A B, L \otimes_A B)
$$
in $D(B)$.
By Lemma \ref{lemma-torsion-change-rings} we have
$R\Gamma_Z(L) \otimes_A B = R\Gamma_Y(L \otimes_A B)$.
Hence it suffices to show that the map
$$
R\Hom_A(K, R\Gamma_Z(L)) \to R\Hom_B(K \otimes_A B, R\Gamma_Z(L) \otimes_A B)
$$
is a quasi-isomorphism. This follows from
Lemma \ref{lemma-torsion-flat-change-rings}.
\end{proof}




\section{Local cohomology for Noetherian rings}
\label{section-local-cohomology-noetherian}

\noindent
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
Set $Z = V(I) \subset \Spec(A)$. Recall that (\ref{equation-compare-torsion})
is the functor
$$
D(I^\infty\text{-torsion}) \to D_{I^\infty\text{-torsion}}(A)
$$
In fact, there is a natural transformation of functors
\begin{equation}
\label{equation-compare-torsion-functors}
(\ref{equation-compare-torsion}) \circ R\Gamma_I(-)
\longrightarrow
R\Gamma_Z(-)
\end{equation}
Namely, given a complex of $A$-modules $K^\bullet$ the canonical map
$R\Gamma_I(K^\bullet) \to K^\bullet$ in $D(A)$ factors (uniquely)
through $R\Gamma_Z(K^\bullet)$ as $R\Gamma_I(K^\bullet)$ has
$I$-power torsion cohomology modules (see Lemma \ref{lemma-adjoint}).
In general this map is not an isomorphism (we've seen this in
Lemma \ref{lemma-not-equal}).

\begin{lemma}
\label{lemma-local-cohomology-noetherian}
Let $A$ be a Noetherian ring and let $I \subset A$ be an ideal.
\begin{enumerate}
\item the adjunction $R\Gamma_I(K) \to K$ is an isomorphism
for $K \in D_{I^\infty\text{-torsion}}(A)$,
\item the functor
(\ref{equation-compare-torsion})
$D(I^\infty\text{-torsion}) \to D_{I^\infty\text{-torsion}}(A)$
is an equivalence,
\item the transformation of functors
(\ref{equation-compare-torsion-functors}) is an isomorphism,
in other words $R\Gamma_I(K) = R\Gamma_Z(K)$ for $K \in D(A)$.
\end{enumerate}
\end{lemma}

\begin{proof}
A formal argument, which we omit, shows that it suffices to prove (1).

\medskip\noindent
Let $M$ be an $I$-power torsion $A$-module. Choose an embedding
$M \to J$ into an injective $A$-module. Then $J[I^\infty]$ is
an injective $A$-module, see Lemma \ref{lemma-injective-module-divide},
and we obtain an embedding $M \to J[I^\infty]$.
Thus every $I$-power torsion module has an injective resolution
$M \to J^\bullet$ with $J^n$ also $I$-power torsion. It follows
that $R\Gamma_I(M) = M$ (this is not a triviality and this is not
true in general if $A$ is not Noetherian). Next, suppose that
$K \in D_{I^\infty\text{-torsion}}^+(A)$. Then the spectral sequence
$$
R^q\Gamma_I(H^p(K)) \Rightarrow R^{p + q}\Gamma_I(K)
$$
(Derived Categories, Lemma \ref{derived-lemma-two-ss-complex-functor})
converges and above we have seen that only the terms with $q = 0$
are nonzero. Thus we see that $R\Gamma_I(K) \to K$ is an isomorphism.

\medskip\noindent
Suppose $K$ is an arbitrary object of $D_{I^\infty\text{-torsion}}(A)$.
We have
$$
R^q\Gamma_I(K) = \colim \Ext^q_A(A/I^n, K)
$$
by Lemma \ref{lemma-local-cohomology-ext}. Choose $f_1, \ldots, f_r \in A$
generating $I$. Let $K_n^\bullet = K(A, f_1^n, \ldots, f_r^n)$ be the
Koszul complex with terms in degrees $-r, \ldots, 0$. Since the
pro-objects $\{A/I^n\}$ and $\{K_n^\bullet\}$ in $D(A)$ are the same by
More on Algebra, Lemma \ref{more-algebra-lemma-sequence-Koszul-complexes},
we see that
$$
R^q\Gamma_I(K) = \colim \Ext^q_A(K_n^\bullet, K)
$$
Pick any complex $K^\bullet$ of $A$-modules representing $K$.
Since $K_n^\bullet$ is a finite complex of finite free modules we see
that
$$
\Ext^q_A(K_n, K) =
H^q(\text{Tot}((K_n^\bullet)^\vee \otimes_A K^\bullet))
$$
where $(K_n^\bullet)^\vee$ is the dual of the complex $K_n^\bullet$.
See More on Algebra, Lemma \ref{more-algebra-lemma-RHom-out-of-projective}.
As $(K_n^\bullet)^\vee$ is a complex of finite free $A$-modules sitting
in degrees $0, \ldots, r$ we see that the terms of the complex
$\text{Tot}((K_n^\bullet)^\vee \otimes_A K^\bullet)$ are the
same as the terms of the complex
$\text{Tot}((K_n^\bullet)^\vee \otimes_A \tau_{\geq q - r - 2} K^\bullet)$
in degrees $q - 1$ and higher. Hence we see that
$$
\Ext^q_A(K_n, K) = \text{Ext}^q_A(K_n, \tau_{\geq q - r - 2}K)
$$
for all $n$. It follows that
$$
R^q\Gamma_I(K) = R^q\Gamma_I(\tau_{\geq q - r - 2}K) =
H^q(\tau_{\geq q - r - 2}K) = H^q(K)
$$
Thus we see that the map $R\Gamma_I(K) \to K$ is an isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-compute-local-cohomology-noetherian}
Let $A$ be a Noetherian ring and let $I = (f_1, \ldots, f_r)$ be an ideal
of $A$. Set $Z = V(I) \subset \Spec(A)$. There are canonical isomorphisms
$$
R\Gamma_I(A) \to
(A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to
\ldots \to A_{f_1\ldots f_r}) \to R\Gamma_Z(A)
$$
in $D(A)$. If $M$ is an $A$-module, then we have similarly
$$
R\Gamma_I(M) \cong
(M \to \prod\nolimits_{i_0} M_{f_{i_0}} \to
\prod\nolimits_{i_0 < i_1} M_{f_{i_0}f_{i_1}} \to
\ldots \to M_{f_1\ldots f_r}) \cong R\Gamma_Z(M)
$$
in $D(A)$.
\end{lemma}

\begin{proof}
This follows from Lemma \ref{lemma-local-cohomology-noetherian}
and the computation of the functor $R\Gamma_Z$ in
Lemma \ref{lemma-local-cohomology-adjoint}.
\end{proof}

\begin{lemma}
\label{lemma-local-cohomology-change-rings}
If $A \to B$ is a homomorphism of Noetherian rings and $I \subset A$
is an ideal, then in $D(B)$ we have
$$
R\Gamma_I(A) \otimes_A^\mathbf{L} B =
R\Gamma_Z(A) \otimes_A^\mathbf{L} B =
R\Gamma_Y(B) = R\Gamma_{IB}(B)
$$
where $Y = V(IB) \subset \Spec(B)$.
\end{lemma}

\begin{proof}
Combine Lemmas \ref{lemma-compute-local-cohomology-noetherian} and
\ref{lemma-torsion-change-rings}.
\end{proof}






\section{Depth}
\label{section-depth}

\noindent
In this section we revisit the notion of depth introduced in
Algebra, Section \ref{algebra-section-depth}.

\begin{lemma}
\label{lemma-depth}
Let $A$ be a Noetherian ring, let $I \subset A$ be an ideal, and
let $M$ be a finite $A$-module such that $IM \not = M$. Then
the following integers are equal:
\begin{enumerate}
\item $\text{depth}_I(M)$,
\item the smallest integer $i$ such that $\Ext_A^i(A/I, M)$
is nonzero, and
\item the smallest integer $i$ such that $H^i_I(M)$ is nonzero.
\end{enumerate}
Moreover, we have $\Ext^i_A(N, M) = 0$ for $i < \text{depth}_I(M)$
for any finite $A$-module $N$ annihilated by a power of $I$.
\end{lemma}

\begin{proof}
We prove the equality of (1) and (2) by induction on $\text{depth}_I(M)$
which is allowed by
Algebra, Lemma \ref{algebra-lemma-depth-finite-noetherian}.

\medskip\noindent
Base case. If $\text{depth}_I(M) = 0$, then $I$ is contained in the union
of the associated primes of $M$
(Algebra, Lemma \ref{algebra-lemma-ass-zero-divisors}).
By prime avoidance (Algebra, Lemma \ref{algebra-lemma-silly})
we see that $I \subset \mathfrak p$ for some associated prime $\mathfrak p$.
Hence $\Hom_A(A/I, M)$
is nonzero. Thus equality holds in this case.

\medskip\noindent
Assume that $\text{depth}_I(M) > 0$. Let $f \in I$ be a nonzerodivisor
on $M$ such that $\text{depth}_I(M/fM) = \text{depth}_I(M) - 1$.
Consider the short exact sequence
$$
0 \to M \to M \to M/fM \to 0
$$
and the associated long exact sequence for $\Ext^*_A(A/I, -)$.
Note that $\Ext^i_A(A/I, M)$ is a finite $A/I$-module
(Algebra, Lemmas \ref{algebra-lemma-ext-noetherian} and
\ref{algebra-lemma-annihilate-ext}). Hence we obtain
$$
\Hom_A(A/I, M/fM) = \Ext^1_A(A/I, M)
$$
and short exact sequences
$$
0 \to \Ext^i_A(A/I, M) \to \text{Ext}^i_A(A/I, M/fM) \to
\Ext^{i + 1}_A(A/I, M) \to 0
$$
Thus the equality of (1) and (2) by induction.

\medskip\noindent
Observe that $\text{depth}_I(M) = \text{depth}_{I^n}(M)$ for all $n \geq 1$
for example by Algebra, Lemma \ref{algebra-lemma-regular-sequence-powers}.
Hence by the equality of (1) and (2) we see that
$\Ext^i_A(A/I^n, M) = 0$ for all $n$ and $i < \text{depth}_I(M)$.
Let $N$ be a finite $A$-module annihilated by a power of $I$.
Then we can choose a short exact sequence
$$
0 \to N' \to (A/I^n)^{\oplus m} \to N \to 0
$$
for some $n, m \geq 0$. Then
$\Hom_A(N, M) \subset \Hom_A((A/I^n)^{\oplus m}, M)$
and
$\Ext^i_A(N, M) \subset \text{Ext}^{i - 1}_A(N', M)$
for $i < \text{depth}_I(M)$. Thus a simply induction argument
shows that the final statement of the lemma holds.

\medskip\noindent
Finally, we prove that (3) is equal to (1) and (2).
We have $H^p_I(M) = \colim \Ext^p_A(A/I^n, M)$ by
Lemma \ref{lemma-local-cohomology-ext}.
Thus we see that $H^i_I(M) = 0$ for $i < \text{depth}_I(M)$.
For $i = \text{depth}_I(M)$, using the vanishing of
$\Ext_A^{i - 1}(I/I^n, M)$ we see that the map
$\Ext_A^i(A/I, M) \to H_I^i(M)$ is injective which
proves nonvanishing in the correct degree.
\end{proof}

\begin{lemma}
\label{lemma-depth-in-ses}
Let $A$ be a Noetherian ring. Let $0 \to N' \to N \to N'' \to 0$
be a short exact sequence of finite $A$-modules.
Let $I \subset A$ be an ideal.
\begin{enumerate}
\item
$\text{depth}_I(N) \geq \min\{\text{depth}_I(N'), \text{depth}_I(N'')\}$
\item
$\text{depth}_I(N'') \geq \min\{\text{depth}_I(N), \text{depth}_I(N') - 1\}$
\item
$\text{depth}_I(N') \geq \min\{\text{depth}_I(N), \text{depth}_I(N'') + 1\}$
\end{enumerate}
\end{lemma}

\begin{proof}
Assume $IN \not = N$, $IN' \not = N'$, and $IN'' \not = N''$. Then we
can use the characterization of depth using the Ext groups
$\Ext^i(A/I, N)$, see Lemma \ref{lemma-depth},
and use the long exact cohomology sequence
$$
\begin{matrix}
0
\to \Hom_A(A/I, N')
\to \Hom_A(A/I, N)
\to \Hom_A(A/I, N'')
\\
\phantom{0\ }
\to \Ext^1_A(A/I, N')
\to \Ext^1_A(A/I, N)
\to \Ext^1_A(A/I, N'')
\to \ldots
\end{matrix}
$$
from Algebra, Lemma \ref{algebra-lemma-long-exact-seq-ext}.
This argument also works if $IN = N$
because in this case $\Ext^i_A(A/I, N) = 0$ for all $i$.
Similarly in case $IN' \not = N'$ and/or $IN'' \not = N''$.
\end{proof}

\begin{lemma}
\label{lemma-depth-drops-by-one}
Let $A$ be a Noetherian ring, let $I \subset A$ be an ideal, and
let $M$ a finite $A$-module with $IM \not = M$.
\begin{enumerate}
\item If $x \in I$ is a nonzerodivisor on $M$, then
$\text{depth}_I(M/xM) = \text{depth}_I(M) - 1$.
\item Any $M$-regular sequence $x_1, \ldots, x_r$ in $I$ can be extended to an
$M$-regular sequence in $I$ of length $\text{depth}_I(M)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (2) is a formal consequence of part (1). Let $x \in I$ be as in (1).
By the short exact sequence $0 \to M \to M \to M/xM \to 0$ and
Lemma \ref{lemma-depth-in-ses} we see that
$\text{depth}_I(M/xM) \geq \text{depth}_I(M) - 1$.
On the other hand, if $x_1, \ldots, x_r \in I$
is a regular sequence for $M/xM$, then $x, x_1, \ldots, x_r$
is a regular sequence for $M$. Hence (1) holds.
\end{proof}

\begin{lemma}
\label{lemma-depth-CM}
Let $R$ be a Noetherian local ring. If $M$ is a finite Cohen-Macaulay
$R$-module and $I \subset R$ a nontrivial ideal. Then
$$
\text{depth}_I(M) = \dim(\text{Supp}(M)) - \dim(\text{Supp}(M/IM)).
$$
\end{lemma}

\begin{proof}
We will prove this by induction on $\text{depth}_I(M)$.

\medskip\noindent
If $\text{depth}_I(M) = 0$, then $I$ is contained in one
of the associated primes $\mathfrak p$ of $M$
(Algebra, Lemma \ref{algebra-lemma-ideal-nonzerodivisor}).
Then $\mathfrak p \in \text{Supp}(M/IM)$, hence
$\dim(\text{Supp}(M/IM)) \geq \dim(R/\mathfrak p) = \dim(\text{Supp}(M))$
where equality holds by
Algebra, Lemma \ref{algebra-lemma-CM-ass-minimal-support}.
Thus the lemma holds in this case.

\medskip\noindent
If $\text{depth}_I(M) > 0$, we pick $x \in I$ which is a
nonzerodivisor on $M$. Note that $(M/xM)/I(M/xM) = M/IM$.
On the other hand we have
$\text{depth}_I(M/xM) = \text{depth}_I(M) - 1$
by Lemma \ref{lemma-depth-drops-by-one}
and $\dim(\text{Supp}(M/xM)) = \dim(\text{Supp}(M)) -  1$
by Algebra, Lemma \ref{algebra-lemma-one-equation-module}.
Thus the result by induction hypothesis.
\end{proof}

\begin{lemma}
\label{lemma-depth-flat-CM}
Let $R \to S$ be a flat local ring homomorphism of Noetherian local
rings. Denote $\mathfrak m \subset R$ the maximal ideal.
Let $I \subset S$ be an ideal.
If $S/\mathfrak mS$ is Cohen-Macaulay, then
$$
\text{depth}_I(S) \geq \dim(S/\mathfrak mS) - \dim(S/\mathfrak mS + I)
$$
\end{lemma}

\begin{proof}
By Algebra, Lemma \ref{algebra-lemma-grothendieck-regular-sequence}
any sequence in $S$ which maps to a regular sequence in $S/\mathfrak mS$
is a regular sequence in $S$. Thus it suffices to prove the lemma
in case $R$ is a field. This is a special case of Lemma \ref{lemma-depth-CM}.
\end{proof}

\begin{lemma}
\label{lemma-divide-by-torsion}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
Let $M$ be an $A$-module. Let $Z = V(I)$.
Then $H^0_I(M) = H^0_Z(M)$. Let $N$ be the common value and
set $M' = M/N$. Then
\begin{enumerate}
\item $H^0_I(M') = 0$ and $H^p_I(M) = H^p_I(M')$ and $H^p_I(N) = 0$
for all $p > 0$,
\item $H^0_Z(M') = 0$ and $H^p_Z(M) = H^p_Z(M')$ and $H^p_Z(N) = 0$
for all $p > 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
By definition $H^0_I(M) = M[I^\infty]$ is $I$-power torsion.
By Lemma \ref{lemma-local-cohomology-adjoint} we see that
$$
H^0_Z(M) = \Ker(M \longrightarrow M_{f_1} \times \ldots \times M_{f_r})
$$
if $I = (f_1, \ldots, f_r)$. Thus $H^0_I(M) \subset H^0_Z(M)$ and
conversely, if $x \in H^0_Z(M)$, then it is annihilated by a $f_i^{e_i}$
for some $e_i \geq 1$ hence annihilated by some power of $I$.
This proves the first equality and moreover $N$ is $I$-power torsion.
By Lemma \ref{lemma-adjoint} we see that $R\Gamma_I(N) = N$.
By Lemma \ref{lemma-local-cohomology-adjoint} we see that $R\Gamma_Z(N) = N$.
This proves the higher vanishing of $H^p_I(N)$ and $H^p_Z(N)$ in (1) and (2).
The vanishing of $H^0_I(M')$ and $H^0_Z(M')$ follow from the preceding
remarks and the fact that $M'$ is $I$-power torsion free by
More on Algebra, Lemma \ref{more-algebra-lemma-divide-by-torsion}.
The equality of higher cohomologies for $M$ and $M'$ follow
immediately from the long exact cohomology sequence.
\end{proof}









\section{Torsion versus complete modules}
\label{section-torsion-and-complete}

\noindent
Let $A$ be a ring and let $I$ be a finitely generated ideal.
In this case we can consider the derived category
$D_{I^\infty\text{-torsion}}(A)$ of complexes
with $I$-power torsion cohomology modules
(Section \ref{section-local-cohomology})
and the derived category
$D_{comp}(A, I)$ of derived complete complexes
(More on Algebra, Section \ref{more-algebra-section-derived-completion}).
In this section we show these categories are equivalent.
A more general statement can be found in
\cite{Dwyer-Greenlees}.

\begin{lemma}
\label{lemma-complete-and-local}
\begin{slogan}
Results of this nature are sometimes referred to as Greenlees-May duality.
\end{slogan}
Let $A$ be a ring and let $I$ be a finitely generated ideal.
Let $R\Gamma_Z$ be as in Lemma \ref{lemma-local-cohomology-adjoint}.
Let ${\ }^\wedge$ denote derived completion as in
More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion}.
For an object $K$ in $D(A)$ we have
$$
R\Gamma_Z(K^\wedge) = R\Gamma_Z(K)
\quad\text{and}\quad
(R\Gamma_Z(K))^\wedge = K^\wedge
$$
in $D(A)$.
\end{lemma}

\begin{proof}
Choose $f_1, \ldots, f_r \in A$ generating $I$. Recall that
$$
K^\wedge = R\Hom_A\left((A \to \prod A_{f_{i_0}}
\to \prod A_{f_{i_0i_1}} \to \ldots \to A_{f_1 \ldots f_r}), K\right)
$$
by More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion}.
Hence the cone $C = \text{Cone}(K \to K^\wedge)$
is given by
$$
R\Hom_A\left((\prod A_{f_{i_0}}
\to \prod A_{f_{i_0i_1}} \to \ldots \to A_{f_1 \ldots f_r}), K\right)
$$
which can be represented by a complex endowed with a finite filtration
whose successive quotients are isomorphic to
$$
R\Hom_A(A_{f_{i_0} \ldots f_{i_p}}, K), \quad p > 0
$$
These complexes vanish on applying $R\Gamma_Z$, see
Lemma \ref{lemma-local-cohomology-vanishes}. Applying $R\Gamma_Z$
to the distinguished triangle $K \to K^\wedge \to C \to K[1]$
we see that the first formula of the lemma is correct.

\medskip\noindent
Recall that
$$
R\Gamma_Z(K) =
K \otimes^\mathbf{L} (A \to \prod A_{f_{i_0}}
\to \prod A_{f_{i_0i_1}} \to \ldots \to A_{f_1 \ldots f_r})
$$
by Lemma \ref{lemma-local-cohomology-adjoint}.
Hence the cone $C = \text{Cone}(R\Gamma_Z(K) \to K)$
can be represented by a complex endowed with a finite filtration
whose successive quotients are isomorphic to
$$
K \otimes_A A_{f_{i_0} \ldots f_{i_p}}, \quad p > 0
$$
These complexes vanish on applying ${\ }^\wedge$, see
More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion-vanishes}.
Applying derived completion to the distinguished triangle
$R\Gamma_Z(K) \to K \to C \to R\Gamma_Z(K)[1]$
we see that the second formula of the lemma is correct.
\end{proof}

\noindent
The following result is a special case of a very general phenomenon
concerning admissible subcategories of a triangulated category.

\begin{proposition}
\label{proposition-torsion-complete}
\begin{reference}
This is a special case of \cite[Theorem 1.1]{Porta-Liran-Yekutieli}.
\end{reference}
Let $A$ be a ring and let $I \subset A$ be a finitely generated ideal.
The functors $R\Gamma_Z$ and ${\ }^\wedge$
define quasi-inverse equivalences of categories
$$
D_{I^\infty\text{-torsion}}(A) \leftrightarrow D_{comp}(A, I)
$$
\end{proposition}

\begin{proof}
Follows immediately from Lemma \ref{lemma-complete-and-local}.
\end{proof}

\noindent
The following addendum of the proposition above makes the
correspondence on morphisms more precise.

\begin{lemma}
\label{lemma-compare-RHom}
With notation as in Lemma \ref{lemma-complete-and-local}.
For objects $K, L$ in $D(A)$ there is a canonical isomorphism
$$
R\Hom_A(K^\wedge, L^\wedge) \longrightarrow R\Hom_A(R\Gamma_Z(K), R\Gamma_Z(L))
$$
in $D(A)$.
\end{lemma}

\begin{proof}
Say $I = (f_1, \ldots, f_r)$. Denote
$C = (A \to \prod A_{f_i} \to \ldots \to A_{f_1 \ldots f_r})$ the
alternating {\v C}ech complex. Then derived completion is given by
$R\Hom_A(C, -)$ (More on Algebra, Lemma
\ref{more-algebra-lemma-derived-completion}) and local cohomology by
$C \otimes^\mathbf{L} -$ (Lemma \ref{lemma-local-cohomology-adjoint}).
Combining the isomorphism
$$
R\Hom_A(K \otimes^\mathbf{L} C, L \otimes^\mathbf{L} C) =
R\Hom_A(K, R\Hom_A(C,  L \otimes^\mathbf{L} C))
$$
(More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom})
and the map
$$
L \to R\Hom_A(C,  L \otimes^\mathbf{L} C)
$$
(More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-diagonal})
we obtain a map
$$
\gamma :
R\Hom_A(K, L)
\longrightarrow
R\Hom_A(K \otimes^\mathbf{L} C, L \otimes^\mathbf{L} C)
$$
On the other hand, the right hand side is derived complete as it is
equal to
$$
R\Hom_A(C, R\Hom_A(K, L \otimes^\mathbf{L} C)).
$$
Thus $\gamma$ factors through the derived completion of
$R\Hom_A(K, L)$ by the universal property of derived completion.
However, the derived completion goes inside the $R\Hom_A$ by
More on Algebra, Lemma \ref{more-algebra-lemma-completion-RHom}
and we obtain the desired map.

\medskip\noindent
To show that the map of the lemma is an isomorphism
we may assume that $K$ and $L$ are derived complete, i.e.,
$K = K^\wedge$ and $L = L^\wedge$. In this case we are
looking at the map
$$
\gamma : R\Hom_A(K, L) \longrightarrow R\Hom_A(R\Gamma_Z(K), R\Gamma_Z(L))
$$
By Proposition \ref{proposition-torsion-complete} we know that
the cohomology groups
of the left and the right hand side coincide. In other words,
we have to check that the map $\gamma$ sends a morphism
$\alpha : K \to L$ in $D(A)$ to the morphism
$R\Gamma_Z(\alpha) : R\Gamma_Z(K) \to R\Gamma_Z(L)$.
We omit the verification (hint: note that $R\Gamma_Z(\alpha)$
is just the map
$\alpha \otimes \text{id}_C :
K \otimes^\mathbf{L} C
\to
L \otimes^\mathbf{L} C$ which is almost the same as the
construction of the map in
More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-diagonal}).
\end{proof}

\begin{lemma}
\label{lemma-completion-local}
Let $I$ and $J$ be ideals in a Noetherian ring $A$. Let $M$ be a finite
$A$-module. Set $Z =V(J)$. Consider the derived $I$-adic completion
$R\Gamma_Z(M)^\wedge$ of local cohomology. Then
\begin{enumerate}
\item we have $R\Gamma_Z(M)^\wedge = R\lim R\Gamma_Z(M/I^nM)$, and
\item there are short exact sequences
$$
0 \to R^1\lim H^{i - 1}_Z(M/I^nM) \to H^i(R\Gamma_Z(M)^\wedge) \to
\lim H^i_Z(M/I^nM) \to 0
$$
\end{enumerate}
In particular $R\Gamma_Z(M)^\wedge$ has vanishing cohomology
in negative degrees.
\end{lemma}

\begin{proof}
Suppose that $J = (g_1, \ldots, g_m)$.
Then $R\Gamma_Z(M)$ is computed by the complex
$$
M \to \prod M_{g_{j_0}} \to \prod M_{g_{j_0}g_{j_1}} \to
\ldots \to M_{g_1g_2\ldots g_m}
$$
by Lemma \ref{lemma-local-cohomology-adjoint}.
By More on Algebra, Lemma
\ref{more-algebra-lemma-when-derived-completion-is-completion}
the derived $I$-adic completion of
this complex is given by the complex
$$
\lim M/I^nM \to \prod \lim (M/I^nM)_{g_{j_0}} \to
\ldots \to \lim (M/I^nM)_{g_1g_2\ldots g_m}
$$
of usual completions. Since $R\Gamma_Z(M/I^nM)$ is computed by
the complex $ M/I^nM \to \prod (M/I^nM)_{g_{j_0}} \to
\ldots \to (M/I^nM)_{g_1g_2\ldots g_m}$ and since the
transition maps between these complexes are surjective,
we conclude that (1) holds by
More on Algebra, Lemma \ref{more-algebra-lemma-compute-Rlim-modules}.
Part (2) then follows from More on Algebra, Lemma
\ref{more-algebra-lemma-break-long-exact-sequence-modules}.
\end{proof}

\begin{lemma}
\label{lemma-completion-local-H0}
With notation and hypotheses as in Lemma \ref{lemma-completion-local}
assume $A$ is $I$-adically complete. Then
$$
H^0(R\Gamma_Z(M)^\wedge) = \colim H^0_{V(J')}(M)
$$
where the filtered colimit is over $J' \subset J$ such that
$V(J') \cap V(I) = V(J) \cap V(I)$.
\end{lemma}

\begin{proof}
Since $M$ is a finite $A$-module, we have that $M$ is $I$-adically complete.
The proof of Lemma \ref{lemma-completion-local} shows that
$$
H^0(R\Gamma_Z(M)^\wedge) =
\Ker(M^\wedge \to \prod M_{g_j}^\wedge) =
\Ker(M \to \prod M_{g_j}^\wedge)
$$
where on the right hand side we have usual $I$-adic completion.
The kernel $K_j$ of $M_{g_j} \to M_{g_j}^\wedge$ is $\bigcap I^n M_{g_j}$.
By Algebra, Lemma \ref{algebra-lemma-intersection-powers-ideal-module}
for every $\mathfrak p \in V(IA_{g_j})$ we find an
$f \in A_{g_j}$, $f \not \in \mathfrak p$ such that $(K_j)_f = 0$.

\medskip\noindent
Let $s \in H^0(R\Gamma_Z(M)^\wedge)$.
By the above we may think of $s$ as an element of $M$.
The support $Z'$ of $s$ intersected with $D(g_j)$ is disjoint from
$D(g_j) \cap V(I)$ by the arguments above.
Thus $Z'$ is a closed subset of $\Spec(A)$ with $Z' \cap V(I) \subset V(J)$.
Then $Z' \cup V(J) = V(J')$ for some ideal $J' \subset J$ with
$V(J') \cap V(I) \subset V(J)$ and we have $s \in H^0_{V(J')}(M)$.
Conversely, any $s \in H^0_{V(J')}(M)$ with $J' \subset J$ and
$V(J') \cap V(I) \subset V(J)$ maps to zero in $M_{g_j}^\wedge$ for all $j$.
This proves the lemma.
\end{proof}









\section{Trivial duality for a ring map}
\label{section-trivial}

\noindent
Let $A \to B$ be a ring homomorphism. Consider the functor
$$
\Hom_A(B, -) : \text{Mod}_A \longrightarrow \text{Mod}_B,\quad
M \longmapsto \Hom_A(B, M)
$$
This functor is left exact and has a derived extension
$R\Hom(B, -) : D(A) \to D(B)$.

\begin{lemma}
\label{lemma-right-adjoint}
Let $A \to B$ be a ring homomorphism. The functor $R\Hom(B, -)$
constructed above is right adjoint to the restriction functor
$D(B) \to D(A)$.
\end{lemma}

\begin{proof}
This is a consequence of the fact that restriction and $\Hom_A(B, -)$ are
adjoint functors by Algebra, Lemma \ref{algebra-lemma-adjoint-hom-restrict}.
See Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
\end{proof}

\begin{lemma}
\label{lemma-composition-right-adjoints}
Let $A \to B \to C$ be ring maps. Then
$R\Hom(C, -) \circ R\Hom(B, -) : D(A) \to D(C)$
is the functor $R\Hom(C, -) : D(A) \to D(C)$.
\end{lemma}

\begin{proof}
Follows from uniqueness of right adjoints and Lemma \ref{lemma-right-adjoint}.
\end{proof}

\begin{lemma}
\label{lemma-RHom-ext}
Let $\varphi : A \to B$ be a ring homomorphism. For $K$ in $D(A)$ we have
$$
\varphi_*R\Hom(B, K) = R\Hom_A(B, K)
$$
where $\varphi_* : D(B) \to D(A)$ is restriction. In particular
$R^q\Hom(B, K) = \Ext_A^q(B, K)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $I^\bullet$ representing $K$.
Then $R\Hom(B, K)$ is represented by the complex $\Hom_A(B, I^\bullet)$
of $B$-modules. Since this complex, as a complex of $A$-modules,
represents $R\Hom_A(B, K)$ we see that the lemma is true.
\end{proof}

\noindent
Let $A$ be a Noetherian ring. We will denote
$$
D_{\textit{Coh}}(A) \subset D(A)
$$
the full subcategory consisting of those objects $K$ of $D(A)$
whose cohomology modules are all finite $A$-modules. This makes sense
by Derived Categories, Section \ref{derived-section-triangulated-sub}
because as $A$ is Noetherian, the subcategory of finite $A$-modules
is a Serre subcategory of $\text{Mod}_A$.

\begin{lemma}
\label{lemma-exact-support-coherent}
With notation as above, assume $A \to B$ is a finite ring map of
Noetherian rings. Then $R\Hom(B, -)$ maps
$D^+_{\textit{Coh}}(A)$ into $D^+_{\textit{Coh}}(B)$.
\end{lemma}

\begin{proof}
We have to show: if $K \in D^+(A)$ has finite cohomology modules, then the
complex $R\Hom(B, K)$ has finite cohomology modules too.
This follows for example from Lemma \ref{lemma-RHom-ext}
if we can show the ext modules $\Ext^i_A(B, K)$
are finite $A$-modules. Since $K$ is bounded below there is a
convergent spectral sequence
$$
\Ext^p_A(B, H^q(K)) \Rightarrow \text{Ext}^{p + q}_A(B, K)
$$
This finishes the proof as the modules $\Ext^p_A(B, H^q(K))$
are finite by
Algebra, Lemma \ref{algebra-lemma-ext-noetherian}.
\end{proof}

\begin{remark}
\label{remark-exact-support}
Let $A$ be a ring and let $I \subset A$ be an ideal. Set $B = A/I$.
In this case the functor $\Hom_A(B, -)$ is equal to the functor
$$
\text{Mod}_A \longrightarrow \text{Mod}_B,\quad M \longmapsto M[I]
$$
which sends $M$ to the submodule of $I$-torsion.
\end{remark}

\begin{situation}
\label{situation-resolution}
Let $R \to A$ be a ring map.
We will give an alternative construction of $R\Hom(A, -)$
which will stand us in good stead later in this chapter.
Namely, suppose we have a differential graded algebra $(E, d)$
over $R$ and a quasi-isomorphism $E \to A$ where we view $A$
as a differential graded algebra over $R$ with zero differential.
Then we have commutative diagrams
$$
\vcenter{
\xymatrix{
D(E, \text{d}) \ar[rd] & &  D(A) \ar[ll] \ar[ld] \\
& D(R)
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
D(E, \text{d}) \ar[rr]_{- \otimes_E^\mathbf{L} A} & &  D(A) \\
& D(R) \ar[lu]^{- \otimes_R^\mathbf{L} E} \ar[ru]_{- \otimes_R^\mathbf{L} A}
}
}
$$
where the horizontal arrows are equivalences of categories
(Differential Graded Algebra, Lemma \ref{dga-lemma-qis-equivalence}).
It is clear that the first diagram commutes.
The second diagram commutes because the first one does
and our functors are their left adjoints
(Differential Graded Algebra, Example \ref{dga-example-map-hom-tensor})
or because we have $E \otimes^\mathbf{L}_E A = E \otimes_E A$
and we can use 
Differential Graded Algebra, Lemma
\ref{dga-lemma-compose-tensor-functors-general}.
\end{situation}

\begin{lemma}
\label{lemma-RHom-dga}
In Situation \ref{situation-resolution} the functor $R\Hom(A, -)$
is equal to the composition of
$R\Hom(E, -) : D(R) \to D(E, \text{d})$
and the equivalence $- \otimes^\mathbf{L}_E A : D(E, \text{d}) \to D(A)$.
\end{lemma}

\begin{proof}
This is true because $R\Hom(E, -)$ is the right adjoint
to $- \otimes^\mathbf{L}_R E$, see
Differential Graded Algebra, Lemma \ref{dga-lemma-tensor-hom-adjoint}.
Hence this functor plays the same role as the functor
$R\Hom(A, -)$ for the map $R \to A$ (Lemma \ref{lemma-right-adjoint}),
whence these functors must correspond via the equivalence
$- \otimes^\mathbf{L}_E A : D(E, \text{d}) \to D(A)$.
\end{proof}

\begin{lemma}
\label{lemma-RHom-is-tensor}
In Situation \ref{situation-resolution} assume that
\begin{enumerate}
\item $E$ viewed as an object of $D(R)$ is compact, and
\item $N = \Hom^\bullet_R(E^\bullet, R)$ computes $R\Hom(E, R)$.
\end{enumerate}
Then $R\Hom(E, -) : D(R) \to D(E)$ is isomorphic to
$K \mapsto K \otimes_R^\mathbf{L} N$.
\end{lemma}

\begin{proof}
Special case of Differential Graded Algebra, Lemma
\ref{dga-lemma-RHom-is-tensor}.
\end{proof}

\begin{lemma}
\label{lemma-RHom-is-tensor-special}
In Situation \ref{situation-resolution} assume $A$ is a perfect $R$-module.
Then
$$
R\Hom(A, -) : D(R) \to D(A)
$$
is given by $K \mapsto K \otimes_R^\mathbf{L} M$
where $M = R\Hom(A, R) \in D(A)$.
\end{lemma}

\begin{proof}
We apply Divided Power Algebra, Lemma
\ref{dpa-lemma-tate-resoluton-pseudo-coherent-ring-map}
to choose a Tate resolution $(E, \text{d})$ of $A$ over $R$.
Note that $E^i = 0$ for $i > 0$, $E^0 = R[x_1, \ldots, x_n]$
is a polynomial algebra, and $E^i$ is a finite free $E^0$-module
for $i < 0$. It follows that $E$ viewed as a complex of $R$-modules
is a bounded above complex of free $R$-modules.
We check the assumptions of Lemma \ref{lemma-RHom-is-tensor}.
The first holds because $A$ is perfect
(hence compact by More on Algebra, Proposition
\ref{more-algebra-proposition-perfect-is-compact})
and the second by
More on Algebra, Lemma \ref{more-algebra-lemma-RHom-out-of-projective}.
From the lemma conclude that $K \mapsto R\Hom(E, K)$ is
isomorphic to $K \mapsto K \otimes_R^\mathbf{L} N$ for
some differential graded $E$-module $N$. Observe that
$$
(R \otimes_R E) \otimes_E^\mathbf{L} A = R \otimes_E E \otimes_E A
$$
in $D(A)$. Hence by Differential Graded Algebra, Lemma
\ref{dga-lemma-compose-tensor-functors-general-algebra}
we conclude that the composition of
$- \otimes_R^\mathbf{L} N$ and $- \otimes_R^\mathbf{L} A$
is of the form $- \otimes_R M$ for some $M \in D(A)$.
To finish the proof we apply Lemma \ref{lemma-RHom-dga}.
\end{proof}

\begin{lemma}
\label{lemma-compute-for-effective-Cartier-algebraic}
Let $R \to A$ be a surjective ring map whose kernel $I$
is an invertible $R$-module. The functor
$R\Hom(A, -) : D(R) \to D(A)$
is isomorphic to $K \mapsto K \otimes_R^\mathbf{L} N[-1]$
where $N$ is inverse of the invertible $A$-module $I \otimes_R A$.
\end{lemma}

\begin{proof}
Since $A$ has the finite projective resolution
$$
0 \to I \to R \to A \to 0
$$
we see that $A$ is a perfect $R$-module. By
Lemma \ref{lemma-RHom-is-tensor-special} it suffices
to prove that $R\Hom(A, R)$ is represented by $N[-1]$ in $D(A)$.
This means $R\Hom(A, R)$ has a unique nonzero
cohomology module, namely $N$ in degree $1$. As
$\text{Mod}_A \to \text{Mod}_R$ is fully faithful it suffice to prove
this after applying the restriction functor $i_* : D(A) \to D(R)$.
By Lemma \ref{lemma-RHom-ext} we have
$$
i_*R\Hom(A, R) = R\Hom_R(A, R)
$$
Using the finite projective resolution above we find that the latter
is represented by the complex $R \to I^{\otimes -1}$ with $R$
in degree $0$. The map $R \to I^{\otimes -1}$ is injective
and the cokernel is $N$.
\end{proof}





\section{Base change for trivial duality}
\label{section-base-change-trivial-duality}

\noindent
In this section we consider a cocartesian square of rings
$$
\xymatrix{
A \ar[r]_\alpha & A' \\
R \ar[u]^\varphi \ar[r]^\rho & R' \ar[u]_{\varphi'}
}
$$
In other words, we have $A' = A \otimes_R R'$. If $A$ and $R'$
are {\bf tor independent over} $R$ then there is a canonical base change map
\begin{equation}
\label{equation-base-change}
R\Hom(A, K) \otimes_A^\mathbf{L} A'
\longrightarrow
R\Hom(A', K \otimes_R^\mathbf{L} R')
\end{equation}
in $D(A')$ functorial for $K$ in $D(R)$. Namely, by the adjointness
of Lemma \ref{lemma-right-adjoint} such an arrow is the same thing as a map
$$
\varphi'_*\left(R\Hom(A, K) \otimes_A^\mathbf{L} A'\right)
\longrightarrow
K \otimes_R^\mathbf{L} R'
$$
in $D(R')$ where $\varphi'_* : D(A') \to D(R')$ is the restriction functor.
We may apply
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-comparison}
to the left hand side to get that this is the same thing as a map
$$
\varphi_*(R\Hom(A, K)) \otimes_R^\mathbf{L} R'
\longrightarrow
K \otimes_R^\mathbf{L} R'
$$
in $D(R')$ where $\varphi_* : D(A) \to D(R)$ is the restriction functor.
For this we can choose $can \otimes^\mathbf{L} \text{id}_{R'}$
where $can : \varphi_*(R\Hom(A, K)) \to K$ is the
counit of the adjunction between $R\Hom(A, -)$ and $\varphi_*$.

\begin{lemma}
\label{lemma-check-base-change-is-iso}
In the situation above, the map (\ref{equation-base-change})
is an isomorphism if and only if the map
$$
R\Hom_R(A, K) \otimes_R^\mathbf{L} R'
\longrightarrow
R\Hom_R(A, K \otimes_R^\mathbf{L} R')
$$
of More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-diagonal-better} is an isomorphism.
\end{lemma}

\begin{proof}
To see that the map is an isomorphism, it suffices to prove it
is an isomorphism after applying $\varphi'_*$.
Applying the functor $\varphi'_*$ to (\ref{equation-base-change})
and using that $A' = A \otimes_R^\mathbf{L} R'$
we obtain the base change map
$R\Hom_R(A, K) \otimes_R^\mathbf{L} R' \to
R\Hom_{R'}(A \otimes_R^\mathbf{L} R', K \otimes_R^\mathbf{L} R')$
for derived hom of
More on Algebra, Equation (\ref{more-algebra-equation-base-change-RHom}).
Unwinding the left and right hand side exactly as in the proof of
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}
and in particular using
More on Algebra, Lemma \ref{more-algebra-lemma-upgrade-adjoint-tensor-RHom}
gives the desired result.
\end{proof}

\begin{lemma}
\label{lemma-flat-bc-surjection}
Let $R \to A$ and $R \to R'$ be ring maps and $A' = A \otimes_R R'$.
Assume
\begin{enumerate}
\item $A$ is pseudo-coherent as an $R$-module,
\item $R'$ has finite tor dimension as an $R$-module (for example
$R \to R'$ is flat),
\item $A$ and $R'$ are tor independent over $R$.
\end{enumerate}
Then (\ref{equation-base-change}) is an isomorphism for $K \in D^+(R)$.
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-check-base-change-is-iso} and
More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (4).
\end{proof}

\begin{lemma}
\label{lemma-bc-surjection}
Let $R \to A$ and $R \to R'$ be ring maps and $A' = A \otimes_R R'$.
Assume
\begin{enumerate}
\item $A$ is perfect as an $R$-module,
\item $A$ and $R'$ are tor independent over $R$.
\end{enumerate}
Then (\ref{equation-base-change}) is an isomorphism for all $K \in D(R)$.
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-check-base-change-is-iso} and
More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (1).
\end{proof}







\section{Dualizing complexes}
\label{section-dualizing}

\noindent
In this section we define dualizing complexes for Noetherian rings.

\begin{definition}
\label{definition-dualizing}
Let $A$ be a Noetherian ring. A {\it dualizing complex} is a
complex of $A$-modules $\omega_A^\bullet$ such that
\begin{enumerate}
\item $\omega_A^\bullet$ has finite injective dimension,
\item $H^i(\omega_A^\bullet)$ is a finite $A$-module for all $i$, and
\item $A \to R\Hom_A(\omega_A^\bullet, \omega_A^\bullet)$
is a quasi-isomorphism.
\end{enumerate}
\end{definition}

\noindent
This definition takes some time getting used to. It is perhaps a good
idea to prove some of the following lemmas yourself without reading
the proofs.

\begin{lemma}
\label{lemma-finite-ext-into-bounded-injective}
Let $A$ be a Noetherian ring. Let $K, L \in D_{\textit{Coh}}(A)$
and assume $L$ has finite injective dimension. Then
$R\Hom_A(K, L)$ is in $D_{\textit{Coh}}(A)$.
\end{lemma}

\begin{proof}
Pick an integer $n$ and consider the distinguished triangle
$$
\tau_{\leq n}K \to K \to \tau_{\geq n + 1}K \to \tau_{\leq n}K[1]
$$
see Derived Categories, Remark
\ref{derived-remark-truncation-distinguished-triangle}.
Since $L$ has finite injective dimension we see
that $R\Hom_A(\tau_{\geq n + 1}K, L)$ has vanishing
cohomology in degrees $\geq c - n$ for some constant $c$.
Hence, given $i$, we see that
$\Ext^i_A(K, L) \to \Ext^i_A(\tau_{\leq n}K, L)$
is an isomorphism for some $n \gg - i$. By
Derived Categories of Schemes, Lemma \ref{perfect-lemma-coherent-internal-hom}
applied to $\tau_{\leq n}K$ and $L$
we see conclude that $\Ext^i_A(K, L)$ is
a finite $A$-module for all $i$. Hence $R\Hom_A(K, L)$
is indeed an object of $D_{\textit{Coh}}(A)$.
\end{proof}

\begin{lemma}
\label{lemma-dualizing}
Let $A$ be a Noetherian ring. If $\omega_A^\bullet$ is a dualizing
complex, then the functor
$$
D : K \longmapsto R\Hom_A(K, \omega_A^\bullet)
$$
is an anti-equivalence $D_{\textit{Coh}}(A) \to D_{\textit{Coh}}(A)$
which exchanges $D^+_{\textit{Coh}}(A)$ and $D^-_{\textit{Coh}}(A)$
and induces an anti-equivalence
$D^b_{\textit{Coh}}(A) \to D^b_{\textit{Coh}}(A)$.
Moreover $D \circ D$ is isomorphic to the identity functor.
\end{lemma}

\begin{proof}
Let $K$ be an object of $D_{\textit{Coh}}(A)$. From
Lemma \ref{lemma-finite-ext-into-bounded-injective}
we see $R\Hom_A(K, \omega_A^\bullet)$ is an object of $D_{\textit{Coh}}(A)$.
By More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-isomorphism-technical}
and the assumptions on the dualizing complex
we obtain a canonical isomorphism
$$
K = R\Hom_A(\omega_A^\bullet, \omega_A^\bullet) \otimes_A^\mathbf{L} K
\longrightarrow
R\Hom_A(R\Hom_A(K, \omega_A^\bullet), \omega_A^\bullet)
$$
Thus our functor has a quasi-inverse and the proof is complete.
\end{proof}

\noindent
Let $R$ be a ring. Recall that an object $L$ of $D(R)$ is
{\it invertible} if it is an invertible object for the
symmetric monoidal structure on $D(R)$ given by derived
tensor product. In
More on Algebra, Lemma \ref{more-algebra-lemma-invertible-derived}
we have seen this means $L$ is perfect, $L = \bigoplus H^n(L)[-n]$,
this is a finite sum, each $H^n(L)$ is finite projective,
and there is an open covering $\Spec(R) = \bigcup D(f_i)$ such that
$L \otimes_R R_{f_i} \cong R_{f_i}[-n_i]$ for some integers $n_i$.

\begin{lemma}
\label{lemma-equivalence-comes-from-invertible}
Let $A$ be a Noetherian ring. Let
$F : D^b_{\textit{Coh}}(A) \to D^b_{\textit{Coh}}(A)$ be an $A$-linear
equivalence of categories. Then $F(A)$ is an invertible object of $D(A)$.
\end{lemma}

\begin{proof}
Let $\mathfrak m \subset A$ be a maximal ideal with residue field $\kappa$.
Consider the object $F(\kappa)$. Since
$\kappa = \Hom_{D(A)}(\kappa, \kappa)$ we find that all
cohomology groups of $F(\kappa)$ are annihilated by $\mathfrak m$.
We also see that
$$
\Ext^i_A(\kappa, \kappa) = \text{Ext}^i_A(F(\kappa), F(\kappa))
= \Hom_{D(A)}(F(\kappa), F(\kappa)[i])
$$
is zero for $i < 0$. Say $H^a(F(\kappa)) \not = 0$ and
$H^b(F(\kappa)) \not = 0$ with $a$ minimal and $b$ maximal
(so in particular $a \leq b$). Then there is a nonzero map
$$
F(\kappa) \to H^b(F(\kappa))[-b] \to H^a(F(\kappa))[-b]
\to F(\kappa)[a - b]
$$
in $D(A)$ (nonzero because it induces a nonzero map on cohomology).
This proves that $b = a$. We conclude that $F(\kappa) = \kappa[-a]$.

\medskip\noindent
Let $G$ be a quasi-inverse to our functor $F$. Arguing as above
we find an integer $b$ such that $G(\kappa) = \kappa[-b]$.
On composing we find $a + b = 0$. Let $E$ be a finite $A$-module
wich is annihilated by a power of $\mathfrak m$. Arguing by
induction on the length of $E$ we find that $G(E) = E'[-b]$
for some finite $A$-module $E'$ annihilated by a power of
$\mathfrak m$. Then $E[-a] = F(E')$.
Next, we consider the groups
$$
\Ext^i_A(A, E') = \text{Ext}^i_A(F(A), F(E')) =
\Hom_{D(A)}(F(A), E[-a + i])
$$
The left hand side is nonzero if and only if $i = 0$ and then
we get $E'$. Applying this with $E = E' = \kappa$ and using Nakayama's
lemma this implies that $H^j(F(A))_\mathfrak m$ is zero for $j > a$ and
generated by $1$ element for $j = a$. On the other hand, if
$H^j(F(A))_\mathfrak m$ is not zero for some $j < a$, then
there is a map $F(A) \to E[-a + i]$ for some $i < 0$ and some
$E$ (More on Algebra, Lemma \ref{more-algebra-lemma-detect-cohomology})
which is a contradiction.
Thus we see that $F(A)_\mathfrak m = M[-a]$
for some $A_\mathfrak m$-module $M$ generated by $1$ element.
However, since
$$
A_\mathfrak m = \Hom_{D(A)}(A, A)_\mathfrak m =
\Hom_{D(A)}(F(A), F(A))_\mathfrak m = \Hom_{A_\mathfrak m}(M, M)
$$
we see that $M \cong A_\mathfrak m$. We conclude that there exists
an element $f \in A$, $f \not \in \mathfrak m$ such that
$F(A)_f$ is isomorphic to $A_f[-a]$. This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-unique}
Let $A$ be a Noetherian ring. If $\omega_A^\bullet$ and
$(\omega'_A)^\bullet$ are dualizing complexes, then
$(\omega'_A)^\bullet$ is quasi-isomorphic to
$\omega_A^\bullet \otimes_A^\mathbf{L} L$
for some invertible object $L$ of $D(A)$.
\end{lemma}

\begin{proof}
By Lemmas \ref{lemma-dualizing} and
\ref{lemma-equivalence-comes-from-invertible} the functor
$K \mapsto R\Hom_A(R\Hom_A(K, \omega_A^\bullet), (\omega_A')^\bullet)$
maps $A$ to an invertible object $L$. In other words, there is
an isomorphism
$$
L \longrightarrow R\Hom_A(\omega_A^\bullet, (\omega_A')^\bullet)
$$
Since $L$ has finite tor dimension, this means that we can apply
More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-isomorphism-technical}
to see that
$$
R\Hom_A(\omega_A^\bullet, (\omega'_A)^\bullet) \otimes_A^\mathbf{L} K
\longrightarrow
R\Hom_A(R\Hom_A(K, \omega_A^\bullet), (\omega_A')^\bullet)
$$
is an isomorphism for $K$ in $D^b_{\textit{Coh}}(A)$.
In particular, setting $K = \omega_A^\bullet$ finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-localize}
Let $A$ be a Noetherian ring. Let $B = S^{-1}A$ be a localization.
If $\omega_A^\bullet$ is a dualizing
complex, then $\omega_A^\bullet \otimes_A B$ is a dualizing
complex for $B$.
\end{lemma}

\begin{proof}
Let $\omega_A^\bullet \to I^\bullet$ be a quasi-isomorphism
with $I^\bullet$ a bounded complex of injectives.
Then $S^{-1}I^\bullet$ is a bounded complex of injective
$B = S^{-1}A$-modules (Lemma \ref{lemma-localization-injective-modules})
representing $\omega_A^\bullet \otimes_A B$.
Thus $\omega_A^\bullet \otimes_A B$ has finite injective dimension.
Since $H^i(\omega_A^\bullet \otimes_A B) = H^i(\omega_A^\bullet) \otimes_A B$
by flatness of $A \to B$ we see that $\omega_A^\bullet \otimes_A B$
has finite cohomology modules. Finally, the map
$$
B \longrightarrow
R\Hom_A(\omega_A^\bullet \otimes_A B, \omega_A^\bullet \otimes_A B)
$$
is a quasi-isomorphism as formation of internal hom commutes with
flat base change in this case, see
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-glue}
Let $A$ be a Noetherian ring. Let $f_1, \ldots, f_n \in A$
generate the unit ideal. If $\omega_A^\bullet$ is a complex
of $A$-modules such that $(\omega_A^\bullet)_{f_i}$ is a dualizing
complex for $A_{f_i}$ for all $i$, then $\omega_A^\bullet$ is a dualizing
complex for $A$.
\end{lemma}

\begin{proof}
Consider the double complex
$$
\prod\nolimits_{i_0} (\omega_A^\bullet)_{f_{i_0}}
\to
\prod\nolimits_{i_0 < i_1} (\omega_A^\bullet)_{f_{i_0}f_{i_1}}
\to \ldots
$$
The associated total complex is quasi-isomorphic to $\omega_A^\bullet$
for example by Descent, Remark \ref{descent-remark-standard-covering}
or by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-alternating-cech-complex-complex-computes-cohomology}.
By assumption the complexes $(\omega_A^\bullet)_{f_i}$ have
finite injective dimension as complexes of $A_{f_i}$-modules.
This implies that each of the complexes
$(\omega_A^\bullet)_{f_{i_0} \ldots f_{i_p}}$, $p > 0$ has
finite injective dimension over $A_{f_{i_0} \ldots f_{i_p}}$,
see Lemma \ref{lemma-localization-injective-modules}.
This in turn implies that each of the complexes
$(\omega_A^\bullet)_{f_{i_0} \ldots f_{i_p}}$, $p > 0$ has
finite injective dimension over $A$, see
Lemma \ref{lemma-injective-flat}. Hence $\omega_A^\bullet$
has finite injective dimension as a complex of $A$-modules
(as it can be represented by a complex endowed with
a finite filtration whose graded parts have finite injective
dimension). Since $H^n(\omega_A^\bullet)_{f_i}$ is a finite
$A_{f_i}$ module for each $i$ we see that $H^i(\omega_A^\bullet)$
is a finite $A$-module, see Algebra, Lemma \ref{algebra-lemma-cover}.
Finally, the (derived) base change of the map
$A \to R\Hom_A(\omega_A^\bullet, \omega_A^\bullet)$ to $A_{f_i}$
is the map
$A_{f_i} \to R\Hom_A((\omega_A^\bullet)_{f_i}, (\omega_A^\bullet)_{f_i})$ by
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}.
Hence we deduce that
$A \to R\Hom_A(\omega_A^\bullet, \omega_A^\bullet)$
is an isomorphism and the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-finite}
Let $A \to B$ be a finite ring map of Noetherian rings.
Let $\omega_A^\bullet$ be a dualizing complex.
Then $R\Hom(B, \omega_A^\bullet)$ is a dualizing complex for $B$.
\end{lemma}

\begin{proof}
Let $\omega_A^\bullet \to I^\bullet$ be a quasi-isomorphism
with $I^\bullet$ a bounded complex of injectives.
Then $\Hom_A(B, I^\bullet)$ is a bounded complex of injective
$B$-modules (Lemma \ref{lemma-hom-injective}) representing
$R\Hom(B, \omega_A^\bullet)$.
Thus $R\Hom(B, \omega_A^\bullet)$ has finite injective dimension.
By Lemma \ref{lemma-exact-support-coherent} it is an object of
$D_{\textit{Coh}}(B)$. Finally, we compute
$$
\Hom_{D(B)}(R\Hom(B, \omega_A^\bullet), R\Hom(B, \omega_A^\bullet)) =
\Hom_{D(A)}(R\Hom(B, \omega_A^\bullet), \omega_A^\bullet) = B
$$
and for $n \not = 0$ we compute
$$
\Hom_{D(B)}(R\Hom(B, \omega_A^\bullet), R\Hom(B, \omega_A^\bullet)[n]) =
\Hom_{D(A)}(R\Hom(B, \omega_A^\bullet), \omega_A^\bullet[n]) = 0
$$
which proves the last property of a dualizing complex.
In the displayed equations, the first
equality holds by Lemma \ref{lemma-right-adjoint}
and the second equality holds by Lemma \ref{lemma-dualizing}.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-quotient}
Let $A \to B$ be a surjective homomorphism of Noetherian rings.
Let $\omega_A^\bullet$ be a dualizing complex.
Then $R\Hom(B, \omega_A^\bullet)$ is a dualizing complex for $B$.
\end{lemma}

\begin{proof}
Special case of Lemma \ref{lemma-dualizing-finite}.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-polynomial-ring}
Let $A$ be a Noetherian ring. If $\omega_A^\bullet$ is a dualizing
complex, then $\omega_A^\bullet \otimes_A A[x]$ is a dualizing
complex for $A[x]$.
\end{lemma}

\begin{proof}
Set $B = A[x]$ and $\omega_B^\bullet = \omega_A^\bullet \otimes_A B$.
It follows from Lemma \ref{lemma-injective-dimension-over-polynomial-ring}
and More on Algebra, Lemma \ref{more-algebra-lemma-finite-injective-dimension}
that $\omega_B^\bullet$ has finite injective dimension.
Since $H^i(\omega_B^\bullet) = H^i(\omega_A^\bullet) \otimes_A B$
by flatness of $A \to B$ we see that $\omega_A^\bullet \otimes_A B$
has finite cohomology modules. Finally, the map
$$
B \longrightarrow R\Hom_B(\omega_B^\bullet, \omega_B^\bullet)
$$
is a quasi-isomorphism as formation of internal hom commutes with
flat base change in this case, see
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}.
\end{proof}

\begin{proposition}
\label{proposition-dualizing-essentially-finite-type}
Let $A$ be a Noetherian ring which has a dualizing complex.
Then any $A$-algebra essentially of finite type over $A$
has a dualizing complex.
\end{proposition}

\begin{proof}
This follows from a combination of
Lemmas \ref{lemma-dualizing-localize},
\ref{lemma-dualizing-quotient}, and \ref{lemma-dualizing-polynomial-ring}.
\end{proof}

\begin{lemma}
\label{lemma-find-function}
Let $A$ be a Noetherian ring. Let $\omega_A^\bullet$ be a dualizing
complex. Let $\mathfrak m \subset A$ be a maximal ideal and set
$\kappa = A/\mathfrak m$. Then
$R\Hom_A(\kappa, \omega_A^\bullet) \cong \kappa[n]$ for some
$n \in \mathbf{Z}$.
\end{lemma}

\begin{proof}
This is true because $R\Hom_A(\kappa, \omega_A^\bullet)$ is a dualizing
complex over $\kappa$ (Lemma \ref{lemma-dualizing-quotient}),
because dualizing complexes over $\kappa$ are unique up to shifts
(Lemma \ref{lemma-dualizing-unique}), and because $\kappa$ is a
dualizing complex over $\kappa$.
\end{proof}




\section{Dualizing complexes over local rings}
\label{section-dualizing-local}

\noindent
In this section $(A, \mathfrak m, \kappa)$ will be a Noetherian local
ring endowed with a dualizing complex $\omega_A^\bullet$ such that
the integer $n$ of Lemma \ref{lemma-find-function} is zero.
More precisely, we assume that $R\Hom_A(\kappa, \omega_A^\bullet) = \kappa[0]$.
In this case we will say that the dualizing complex is {\it normalized}.
Observe that a normalized dualizing complex is unique up to
isomorphism and that any other dualizing complex for $A$ is isomorphic
to a shift of a normalized one (Lemma \ref{lemma-dualizing-unique}).

\begin{lemma}
\label{lemma-normalized-finite}
Let $(A, \mathfrak m, \kappa) \to (B, \mathfrak m', \kappa')$
be a finite local map of Noetherian local rings. Let $\omega_A^\bullet$
be a normalized dualizing complex. Then
$\omega_B^\bullet = R\Hom(B, \omega_A^\bullet)$ is a
normalized dualizing complex for $B$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-dualizing-finite} the complex
$\omega_B^\bullet$ is dualizing for $B$. We have
$$
R\Hom_B(\kappa', \omega_B^\bullet) =
R\Hom_B(\kappa', R\Hom(B, \omega_A^\bullet)) =
R\Hom_A(\kappa', \omega_A^\bullet)
$$
by Lemma \ref{lemma-right-adjoint}. Since $\kappa'$ is isomorphic
to a finite direct sum of copies of $\kappa$ as an $A$-module
and since $\omega_A^\bullet$ is normalized, we
see that this complex only has cohomology placed in degree $0$.
Thus $\omega_B^\bullet$ is a normalized dualizing complex as well.
\end{proof}

\begin{lemma}
\label{lemma-normalized-quotient}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local
ring with normalized dualizing complex $\omega_A^\bullet$.
Let $A \to B$ be surjective. Then
$\omega_B^\bullet = R\Hom_A(B, \omega_A^\bullet)$ is a
normalized dualizing complex for $B$.
\end{lemma}

\begin{proof}
Special case of Lemma \ref{lemma-normalized-finite}.
\end{proof}

\begin{lemma}
\label{lemma-equivalence-finite-length}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local
ring. Let $F$ be an $A$-linear self-equivalence of the category of
finite length $A$-modules. Then $F$ is isomorphic to the identity functor.
\end{lemma}

\begin{proof}
Since $\kappa$ is the unique simple object of the category we have
$F(\kappa) \cong \kappa$. Since our category is abelian, we find that
$F$ is exact. Hence $F(E)$ has the same length as $E$ for all finite
length modules $E$.
Since $\Hom(E, \kappa) = \Hom(F(E), F(\kappa)) \cong \Hom(F(E), \kappa)$
we conclude from Nakayama's lemma that $E$ and $F(E)$ have the same
number of generators. Hence $F(A/\mathfrak m^n)$ is a cyclic $A$-module.
Pick a generator $e \in F(A/\mathfrak m^n)$.
Since $F$ is $A$-linear we conclude that $\mathfrak m^n e = 0$.
The map $A/\mathfrak m^n \to F(A/\mathfrak m^n)$ has to be
an isomorphism as the lengths are equal. Pick an element
$$
e \in \lim F(A/\mathfrak m^n)
$$
which maps to a generator for all $n$ (small argument omitted).
Then we obtain a system of isomorphisms
$A/\mathfrak m^n \to F(A/\mathfrak m^n)$ compatible with all
$A$-module maps $A/\mathfrak m^n \to A/\mathfrak m^{n'}$ (by $A$-linearity
of $F$ again). Since any finite length module is a cokernel
of a map between direct sums of cyclic modules, we obtain the isomorphism
of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-finite-length}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local
ring with normalized dualizing complex $\omega_A^\bullet$.
Let $E$ be an injective hull of $\kappa$. Then there exists
a functorial isomorphism
$$
R\Hom_A(N, \omega_A^\bullet) = \Hom_A(N, E)[0]
$$
for $N$ running through the finite length $A$-modules.
\end{lemma}

\begin{proof}
By induction on the length of $N$ we see that $R\Hom_A(N, \omega_A^\bullet)$
is a module of finite length sitting in degree $0$. Thus
$R\Hom_A(-, \omega_A^\bullet)$ induces an anti-equivalence
on the category of finite length modules. Since the same is true
for $\Hom_A(-, E)$ by Proposition \ref{proposition-matlis} we see that
$$
N \longmapsto \Hom_A(R\Hom_A(N, \omega_A^\bullet), E)
$$
is an equivalence as in Lemma \ref{lemma-equivalence-finite-length}.
Hence it is isomorphic to the identity functor.
Since $\Hom_A(-, E)$ applied twice is the identity
(Proposition \ref{proposition-matlis}) we obtain
the statement of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-sitting-in-degrees}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring with
normalized dualizing complex $\omega_A^\bullet$. Let $M$ be a finite
$A$-module and let $d = \dim(\text{Supp}(M))$. Then
\begin{enumerate}
\item if $\Ext^i_A(M, \omega_A^\bullet)$ is nonzero, then
$i \in \{-d, \ldots, 0\}$,
\item the dimension of the support of $\Ext^i_A(M, \omega_A^\bullet)$
is at most $-i$,
\item $\text{depth}(M)$ is the smallest integer $\delta \geq 0$ such that
$\Ext^{-\delta}_A(M, \omega_A^\bullet) \not = 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
We prove this by induction on $d$. If $d = 0$, this follows from
Lemma \ref{lemma-dualizing-finite-length} and Matlis duality
(Proposition \ref{proposition-matlis}) which guarantees that
$\Hom_A(M, E)$ is nonzero if $M$ is nonzero.

\medskip\noindent
Assume the result holds for modules with support of dimension $< d$ and that
$M$ has depth $> 0$. Choose an $f \in \mathfrak m$ which is a nonzerodivisor
on $M$ and consider the short exact sequence
$$
0 \to M \to M \to M/fM \to 0
$$
Since $\dim(\text{Supp}(M/fM)) = d - 1$
(Algebra, Lemma \ref{algebra-lemma-one-equation-module}) we
may apply the induction hypothesis.
Writing
$E^i = \Ext^i_A(M, \omega_A^\bullet)$ and
$F^i = \Ext^i_A(M/fM, \omega_A^\bullet)$
we obtain a long exact sequence
$$
\ldots \to F^i \to E^i \xrightarrow{f} E^i \to F^{i + 1} \to \ldots
$$
By induction $E^i/fE^i = 0$ for
$i + 1 \not \in \{-\dim(\text{Supp}(M/fM)), \ldots, -\text{depth}(M/fM)\}$.
By Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK})
and Algebra, Lemma \ref{algebra-lemma-depth-drops-by-one}
we conclude $E^i = 0$ for
$i \not \in \{-\dim(\text{Supp}(M)), \ldots, -\text{depth}(M)\}$.
Moreover, in the boundary case $i = - \text{depth}(M)$ we deduce that $E^i$
is nonzero as $F^{i + 1}$ is nonzero by induction.
Since $E^i/fE^i \subset F^{i + 1}$ we get
$$
\dim(\text{Supp}(F^{i + 1})) \geq \dim(\text{Supp}(E^i/fE^i))
\geq \dim(\text{Supp}(E^i)) - 1
$$
(see lemma used above) we also obtain the dimension estimate (2).

\medskip\noindent
If $M$ has depth $0$ and $d > 0$ we let $N = M[\mathfrak m^\infty]$ and set
$M' = M/N$ (compare with Lemma \ref{lemma-divide-by-torsion}).
Then $M'$ has depth $> 0$ and $\dim(\text{Supp}(M')) = d$.
Thus we know the result for $M'$ and since
$R\Hom_A(N, \omega_A^\bullet) = \Hom_A(N, E)$
(Lemma \ref{lemma-dualizing-finite-length})
the long exact cohomology sequence of $\Ext$'s implies the
result for $M$.
\end{proof}

\begin{remark}
\label{remark-vanishing-for-arbitrary-modules}
Let $(A, \mathfrak m)$ and $\omega_A^\bullet$ be as in
Lemma \ref{lemma-sitting-in-degrees}.
By More on Algebra, Lemma \ref{more-algebra-lemma-injective-amplitude}
we see that $\omega_A^\bullet$ has injective-amplitude in $[-d, 0]$
because part (3) of that lemma applies.
In particular, for any $A$-module $M$ (not necessarily finite) we have
$\Ext^i_A(M, \omega_A^\bullet) = 0$ for $i \not \in \{-d, \ldots, 0\}$.
\end{remark}

\begin{lemma}
\label{lemma-local-CM}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring
with normalized dualizing complex $\omega_A^\bullet$. Let $M$
be a finite $A$-module. The following are equivalent
\begin{enumerate}
\item $M$ is Cohen-Macaulay,
\item $\Ext^i_A(M, \omega_A^\bullet)$ is nonzero for a single $i$,
\item $\Ext^{-i}_A(M, \omega_A^\bullet)$ is zero for
$i \not = \dim(\text{Supp}(M))$.
\end{enumerate}
Denote $CM_d$ the category of finite Cohen-Macaulay $A$-modules
of depth $d$. Then $M \mapsto \Ext^{-d}_A(M, \omega_A^\bullet)$
defines an anti-auto-equivalence of $CM_d$.
\end{lemma}

\begin{proof}
We will use the results of Lemma \ref{lemma-sitting-in-degrees}
without further mention. Fix a finite module $M$.
If $M$ is Cohen-Macaulay, then only
$\Ext^{-d}_A(M, \omega_A^\bullet)$ can be nonzero,
hence (1) $\Rightarrow$ (3).
The implication (3) $\Rightarrow$ (2) is immediate.
Assume (2) and let $N = \Ext^{-\delta}_A(M, \omega_A^\bullet)$
be the nonzero $\Ext$ where $\delta = \text{depth}(M)$. Then, since
$$
M[0] = R\Hom_A(R\Hom_A(M, \omega_A^\bullet), \omega_A^\bullet) =
R\Hom_A(N[\delta], \omega_A^\bullet)
$$
(Lemma \ref{lemma-dualizing})
we conclude that $M = \Ext_A^{-\delta}(N, \omega_A^\bullet)$.
Thus $\delta \geq \dim(\text{Supp}(M))$. However,
since we also know that $\delta \leq \dim(\text{Supp}(M))$
(Algebra, Lemma \ref{algebra-lemma-bound-depth}) we conclude that $M$ is
Cohen-Macaulay.

\medskip\noindent
To prove the final statement, it suffices to show that
$N = \Ext^{-d}_A(M, \omega_A^\bullet)$ is in $CM_d$
for $M$ in $CM_d$. Above we have seen that
$M[0] = R\Hom_A(N[d], \omega_A^\bullet)$ and this proves the
desired result by the equivalence of (1) and (3).
\end{proof}

\begin{lemma}
\label{lemma-dualizing-artinian}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local
ring with normalized dualizing complex $\omega_A^\bullet$.
If $\dim(A) = 0$, then $\omega_A^\bullet \cong E[0]$
where $E$ is an injective hull of the residue field.
\end{lemma}

\begin{proof}
Immediate from Lemma \ref{lemma-dualizing-finite-length}.
\end{proof}

\begin{lemma}
\label{lemma-divide-by-finite-length-ideal}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local
ring with normalized dualizing complex. Let $I \subset \mathfrak m$ be an
ideal of finite length. Set $B = A/I$. Then there is a distinguished
triangle
$$
\omega_B^\bullet \to \omega_A^\bullet \to \Hom_A(I, E)[0] \to
\omega_B^\bullet[1]
$$
in $D(A)$ where $E$ is an injective hull of $\kappa$ and
$\omega_B^\bullet$ is a normalized dualizing complex for $B$.
\end{lemma}

\begin{proof}
Use the short exact sequence $0 \to I \to A \to B \to 0$
and Lemmas \ref{lemma-dualizing-finite-length} and
\ref{lemma-normalized-quotient}.
\end{proof}

\begin{lemma}
\label{lemma-divide-by-nonzerodivisor}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local
ring with normalized dualizing complex $\omega_A^\bullet$.
Let $f \in \mathfrak m$ be a
nonzerodivisor. Set $B = A/(f)$. Then there is a distinguished
triangle
$$
\omega_B^\bullet \to \omega_A^\bullet \to \omega_A^\bullet \to
\omega_B^\bullet[1]
$$
in $D(A)$ where $\omega_B^\bullet$ is a normalized dualizing complex
for $B$.
\end{lemma}

\begin{proof}
Use the short exact sequence $0 \to A \to A \to B \to 0$
and Lemma \ref{lemma-normalized-quotient}.
\end{proof}

\begin{lemma}
\label{lemma-nonvanishing-generically-local}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring with
normalized dualizing complex $\omega_A^\bullet$.
Let $\mathfrak p$ be a minimal prime of $A$ with
$\dim(A/\mathfrak p) = e$. Then
$H^i(\omega_A^\bullet)_\mathfrak p$ is nonzero
if and only if $i = -e$.
\end{lemma}

\begin{proof}
Since $A_\mathfrak p$ has dimension zero, there exists an integer
$n > 0$ such that $\mathfrak p^nA_\mathfrak p$ is zero.
Set $B = A/\mathfrak p^n$ and
$\omega_B^\bullet = R\Hom_A(B, \omega_A^\bullet)$.
Since $B_\mathfrak p = A_\mathfrak p$ we see that
$$
(\omega_B^\bullet)_\mathfrak p =
R\Hom_A(B, \omega_A^\bullet) \otimes_A^\mathbf{L} A_\mathfrak p =
R\Hom_{A_\mathfrak p}(B_\mathfrak p, (\omega_A^\bullet)_\mathfrak p) =
(\omega_A^\bullet)_\mathfrak p
$$
The second equality holds by
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}.
By Lemma \ref{lemma-normalized-quotient} we may replace $A$ by $B$.
After doing so, we see that $\dim(A) = e$. Then we see that
$H^i(\omega_A^\bullet)_\mathfrak p$ can only be nonzero if $i = -e$
by Lemma \ref{lemma-sitting-in-degrees} parts (1) and (2).
On the other hand, since $(\omega_A^\bullet)_\mathfrak p$
is a dualizing complex for the nonzero ring $A_\mathfrak p$
(Lemma \ref{lemma-dualizing-localize})
we see that the remaining module has to be nonzero.
\end{proof}





\section{Dualizing complexes and dimension functions}
\label{section-dimension-function}

\noindent
Our results in the local setting have the following consequence:
a Noetherian ring which has a dualizing complex is a
universally catenary ring of finite dimension.

\begin{lemma}
\label{lemma-nonvanishing-generically}
Let $A$ be a Noetherian ring. Let $\mathfrak p$ be a minimal prime
of $A$. Then $H^i(\omega_A^\bullet)_\mathfrak p$ is nonzero
for exactly one $i$.
\end{lemma}

\begin{proof}
The complex $\omega_A^\bullet \otimes_A A_\mathfrak p$
is a dualizing complex for $A_\mathfrak p$
(Lemma \ref{lemma-dualizing-localize}).
The dimension of $A_\mathfrak p$ is zero as $\mathfrak p$
is minimal. Hence the result follows from
Lemma \ref{lemma-dualizing-artinian}.
\end{proof}

\noindent
Let $A$ be a Noetherian ring and let $\omega_A^\bullet$ be a dualizing
complex. Lemma \ref{lemma-find-function} allows us to define a function
$$
\delta = \delta_{\omega_A^\bullet} : \Spec(A) \longrightarrow \mathbf{Z}
$$
by mapping $\mathfrak p$ to the integer of Lemma \ref{lemma-find-function}
for the dualizing complex $(\omega_A^\bullet)_\mathfrak p$
over $A_\mathfrak p$ (Lemma \ref{lemma-dualizing-localize})
and the residue field $\kappa(\mathfrak p)$. To be precise, we define
$\delta(\mathfrak p)$ to be the unique integer such that
$$
(\omega_A^\bullet)_\mathfrak p[-\delta(\mathfrak p)]
$$
is a normalized dualizing complex over the Noetherian local ring
$A_\mathfrak p$.

\begin{lemma}
\label{lemma-quotient-function}
Let $A$ be a Noetherian ring and let $\omega_A^\bullet$ be a dualizing
complex. Let $A \to B$ be a surjective ring map and let
$\omega_B^\bullet = R\Hom(B, \omega_A^\bullet)$ be the dualizing
complex for $B$ of Lemma \ref{lemma-dualizing-quotient}. Then we have
$$
\delta_{\omega_B^\bullet} = \delta_{\omega_A^\bullet}|_{\Spec(B)}
$$
\end{lemma}

\begin{proof}
This follows from the definition of the functions and
Lemma \ref{lemma-normalized-quotient}.
\end{proof}

\begin{lemma}
\label{lemma-dimension-function}
Let $A$ be a Noetherian ring and let $\omega_A^\bullet$ be a dualizing
complex. The function $\delta = \delta_{\omega_A^\bullet}$
defined above is a dimension function
(Topology, Definition \ref{topology-definition-dimension-function}).
\end{lemma}

\begin{proof}
Let $\mathfrak p \subset \mathfrak q$ be an immediate specialization.
We have to show that $\delta(\mathfrak p) = \delta(\mathfrak q) + 1$.
We may replace $A$ by $A/\mathfrak p$, the complex $\omega_A^\bullet$ by
$\omega_{A/\mathfrak p}^\bullet = R\Hom(A/\mathfrak p, \omega_A^\bullet)$,
the prime $\mathfrak p$ by $(0)$, and the prime $\mathfrak q$
by $\mathfrak q/\mathfrak p$,
see Lemma \ref{lemma-quotient-function}. Thus we may assume that
$A$ is a domain, $\mathfrak p = (0)$, and $\mathfrak q$ is a prime
ideal of height $1$.

\medskip\noindent
Then $H^i(\omega_A^\bullet)_{(0)}$ is nonzero
for exactly one $i$, say $i_0$, by Lemma \ref{lemma-nonvanishing-generically}.
In fact $i_0 = -\delta((0))$ because
$(\omega_A^\bullet)_{(0)}[-\delta((0))]$
is a normalized dualizing complex over the field $A_{(0)}$.

\medskip\noindent
On the other hand $(\omega_A^\bullet)_\mathfrak q[-\delta(\mathfrak q)]$
is a normalized dualizing complex for $A_\mathfrak q$. By
Lemma \ref{lemma-nonvanishing-generically-local}
we see that
$$
H^e((\omega_A^\bullet)_\mathfrak q[-\delta(\mathfrak q)])_{(0)} =
H^{e - \delta(\mathfrak q)}(\omega_A^\bullet)_{(0)}
$$
is nonzero only for $e = -\dim(A_\mathfrak q) = -1$.
We conclude
$$
-\delta((0)) = -1 - \delta(\mathfrak q)
$$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-universally-catenary}
Let $A$ be a Noetherian ring which has a dualizing
complex. Then $A$ is universally catenary of finite dimension.
\end{lemma}

\begin{proof}
Because $\Spec(A)$ has a dimension function by
Lemma \ref{lemma-dimension-function}
it is catenary, see
Topology, Lemma \ref{topology-lemma-dimension-function-catenary}.
Hence $A$ is catenary, see
Algebra, Lemma \ref{algebra-lemma-catenary}.
It follows from
Proposition \ref{proposition-dualizing-essentially-finite-type}
that $A$ is universally catenary.

\medskip\noindent
Because any dualizing complex $\omega_A^\bullet$ is
in $D^b_{\textit{Coh}}(A)$ the values of the function
$\delta_{\omega_A^\bullet}$ in minimal primes are bounded by
Lemma \ref{lemma-nonvanishing-generically}.
On the other hand, for a maximal ideal $\mathfrak m$ with
residue field $\kappa$ the integer $i = -\delta(\mathfrak m)$
is the unique integer such that
$\Ext_A^i(\kappa, \omega_A^\bullet)$ is nonzero
(Lemma \ref{lemma-find-function}).
Since $\omega_A^\bullet$ has finite injective dimension
these values are bounded too. Since the dimension of
$A$ is the maximal value of $\delta(\mathfrak p) - \delta(\mathfrak m)$
where $\mathfrak p \subset \mathfrak m$ are a pair
consisting of a minimal prime and a maximal prime we find that the
dimension of $\Spec(A)$ is bounded.
\end{proof}

\begin{lemma}
\label{lemma-depth-dualizing-module}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring with
normalized dualizing complex $\omega_A^\bullet$. Let $d = \dim(A)$
and $\omega_A = H^{-d}(\omega_A^\bullet)$. Then
\begin{enumerate}
\item the support of $\omega_A$ is the union of the irreducible components
of $\Spec(A)$ of dimension $d$,
\item $\omega_A$ satisfies $(S_2)$, see
Algebra, Definition \ref{algebra-definition-conditions}.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use Lemma \ref{lemma-sitting-in-degrees} without further mention.
By Lemma \ref{lemma-nonvanishing-generically-local} the support
of $\omega_A$ contains the irreducible components of dimension $d$.
Let $\mathfrak p \subset A$ be a prime. By Lemma \ref{lemma-dimension-function}
the complex $(\omega_A^\bullet)_{\mathfrak p}[-\dim(A/\mathfrak p)]$
is a normalized dualizing complex for $A_\mathfrak p$. Hence if
$\dim(A/\mathfrak p) + \dim(A_\mathfrak p) < d$, then
$(\omega_A)_\mathfrak p = 0$.
This proves the support of $\omega_A$ is the union of the irreducible
components of dimension $d$, because the complement of this union
is exactly the primes $\mathfrak p$ of $A$ for which
$\dim(A/\mathfrak p) + \dim(A_\mathfrak p) < d$ as $A$ is catenary
(Lemma \ref{lemma-universally-catenary}).
On the other hand, if $\dim(A/\mathfrak p) + \dim(A_\mathfrak p) = d$, then
$$
(\omega_A)_\mathfrak p =
H^{-\dim(A_\mathfrak p)}\left(
(\omega_A^\bullet)_{\mathfrak p}[-\dim(A/\mathfrak p)] \right)
$$
Hence in order to prove $\omega_A$ has $(S_2)$ it suffices to show that
the depth of $\omega_A$ is at least $\min(\dim(A), 2)$.
We prove this by induction on $\dim(A)$. The case $\dim(A) = 0$ is
trivial.

\medskip\noindent
Assume $\text{depth}(A) > 0$. Choose a nonzerodivisor $f \in \mathfrak m$
and set $B = A/fA$. Then $\dim(B) = \dim(A) - 1$ and we may apply the
induction hypothesis to $B$. By Lemma \ref{lemma-divide-by-nonzerodivisor}
we see that multiplication by $f$ is injective on $\omega_A$ and we get
$\omega_A/f\omega_A \subset \omega_B$. This proves the depth of $\omega_A$
is at least $1$. If $\dim(A) > 1$, then $\dim(B) > 0$ and $\omega_B$
has depth $ > 0$. Hence $\omega_A$ has depth $> 1$ and we conclude in
this case.

\medskip\noindent
Assume $\dim(A) > 0$ and $\text{depth}(A) = 0$. Let
$I = A[\mathfrak m^\infty]$ and set $B = A/I$. Then $B$ has
depth $\geq 1$ and $\omega_A = \omega_B$ by
Lemma \ref{lemma-divide-by-finite-length-ideal}.
Since we proved the result for $\omega_B$ above the proof is done.
\end{proof}





\section{The local duality theorem}
\label{section-local-duality}

\noindent
The main result in this section is due to Grothendieck.

\begin{lemma}
\label{lemma-local-cohomology-of-dualizing}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $\omega_A^\bullet$ be a normalized dualizing complex.
Let $Z = V(\mathfrak m) \subset \Spec(A)$.
Then $E = R^0\Gamma_Z(\omega_A^\bullet)$ is an injective hull of
$\kappa$ and $R\Gamma_Z(\omega_A^\bullet) = E[0]$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-local-cohomology-noetherian} we have
$R\Gamma_{\mathfrak m} = R\Gamma_Z$. Thus
$$
R\Gamma_Z(\omega_A^\bullet) =
R\Gamma_{\mathfrak m}(\omega_A^\bullet) =
\text{hocolim}\ R\Hom_A(A/\mathfrak m^n, \omega_A^\bullet)
$$
by Lemma \ref{lemma-local-cohomology-ext}. Let $E'$ be an injective
hull of the residue field.
By Lemma \ref{lemma-dualizing-finite-length}
we can find isomorphisms
$$
R\Hom_A(A/\mathfrak m^n, \omega_A^\bullet) \cong \Hom_A(A/\mathfrak m^n, E')[0]
$$
compatible with transition maps. Since
$E' = \bigcup E'[\mathfrak m^n] = \colim \Hom_A(A/\mathfrak m^n, E')$
by Lemma \ref{lemma-union-artinian}
we conclude that $E \cong E'$ and that all other cohomology
groups of the complex $R\Gamma_Z(\omega_A^\bullet)$ are zero.
\end{proof}

\begin{remark}
\label{remark-specific-injective-hull}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring
with a normalized dualizing complex $\omega_A^\bullet$.
By Lemma \ref{lemma-local-cohomology-of-dualizing}
above we see that $R\Gamma_Z(\omega_A^\bullet)$
is an injective hull of the residue field placed in degree $0$.
In fact, this gives a ``construction'' or ``realization''
of the injective hull which is slightly more canonical than
just picking any old injective hull. Namely, a normalized
dualizing complex is unique up to isomorphism, with group
of automorphisms the group of units of $A$, whereas an
injective hull of $\kappa$ is unique up to isomorphism, with
group of automorphisms the group of units of the completion
$A^\wedge$ of $A$ with respect to $\mathfrak m$.
\end{remark}

\noindent
Here is the main result of this section.

\begin{theorem}
\label{theorem-local-duality}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $\omega_A^\bullet$ be a normalized dualizing complex.
Let $E$ be an injective hull of the residue field.
Let $Z = V(\mathfrak m) \subset \Spec(A)$.
Denote ${}^\wedge$ derived completion with respect to $\mathfrak m$.
Then
$$
R\Hom_A(K, \omega_A^\bullet)^\wedge \cong R\Hom_A(R\Gamma_Z(K), E[0])
$$
for $K$ in $D(A)$.
\end{theorem}

\begin{proof}
Observe that $E[0] \cong R\Gamma_Z(\omega_A^\bullet)$ by
Lemma \ref{lemma-local-cohomology-of-dualizing}.
By More on Algebra, Lemma \ref{more-algebra-lemma-completion-RHom}
completion on the left hand side goes inside.
Thus we have to prove
$$
R\Hom_A(K^\wedge, (\omega_A^\bullet)^\wedge)
=
R\Hom_A(R\Gamma_Z(K), R\Gamma_Z(\omega_A^\bullet))
$$
This follows from the equivalence between
$D_{comp}(A, \mathfrak m)$ and $D_{\mathfrak m^\infty\text{-torsion}}(A)$
given in Proposition \ref{proposition-torsion-complete}.
More precisely, it is a special case of Lemma \ref{lemma-compare-RHom}.
\end{proof}

\noindent
Here is a special case of the theorem above.

\begin{lemma}
\label{lemma-special-case-local-duality}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring.
Let $\omega_A^\bullet$ be a normalized dualizing complex.
Let $E$ be an injective hull of the residue field.
Let $K \in D_{\textit{Coh}}(A)$. Then
$$
\Ext^{-i}_A(K, \omega_A^\bullet)^\wedge =
\Hom_A(H^i_{\mathfrak m}(K), E)
$$
where ${}^\wedge$ denotes $\mathfrak m$-adic completion.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-dualizing} we see that $R\Hom_A(K, \omega_A^\bullet)$
is an object of $D_{\textit{Coh}}(A)$.
It follows that the cohomology modules of the derived completion
of $R\Hom_A(K, \omega_A^\bullet)$ are equal to the usual completions
$\Ext^i_A(K, \omega_A^\bullet)^\wedge$ by
More on Algebra, Lemma
\ref{more-algebra-lemma-derived-completion-pseudo-coherent}.
On the other hand, we have $R\Gamma_{\mathfrak m} = R\Gamma_Z$
for $Z = V(\mathfrak m)$ by Lemma \ref{lemma-local-cohomology-noetherian}.
Moreover, the functor $\Hom_A(-, E)$ is exact hence
factors through cohomology.
Hence the lemma is consequence of
Theorem \ref{theorem-local-duality}.
\end{proof}





\section{Dualizing modules}
\label{section-dualizing-module}

\noindent
If $(A, \mathfrak m, \kappa)$ is a Noetherian local ring and
$\omega_A^\bullet$ is a normalized dualizing complex, then
we say the module $\omega_A = H^{-\dim(A)}(\omega_A^\bullet)$, described
in Lemma \ref{lemma-depth-dualizing-module},
is a {\it dualizing module}
for $A$. This module is a canonical module of $A$.
It seems generally agreed upon to define a {\it canonical module}
for a Noetherian local ring $(A, \mathfrak m, \kappa)$ to be
a finite $A$-module $K$ such that
$$
\Hom_A(K, E) \cong H^{\dim(A)}_\mathfrak m(A)
$$
where $E$ is an injective hull of the residue field. A dualizing
module is canonical because
$$
\Hom_A(H^{\dim(A)}_\mathfrak m(A), E) = (\omega_A)^\wedge
$$
by Lemma \ref{lemma-special-case-local-duality}
and hence applying
$\Hom_A(-, E)$ we get
\begin{align*}
\Hom_A(\omega_A, E)
& =
\Hom_A((\omega_A)^\wedge, E) \\
& =
\Hom_A(\Hom_A(H^{\dim(A)}_\mathfrak m(A), E), E) \\
& = H^{\dim(A)}_\mathfrak m(A)
\end{align*}
the first equality because $E$ is $\mathfrak m$-power torsion, the
second by the above, and the third by Matlis duality
(Proposition \ref{proposition-matlis}).
The utility of the definition
of a canonical module given above lies in the fact that it makes sense
even if $A$ does not have a dualizing complex.




\section{Cohen-Macaulay rings}
\label{section-CM}

\noindent
Cohen-Macaulay modules and rings were studied in
Algebra, Sections \ref{algebra-section-CM} and \ref{algebra-section-CM-ring}.

\begin{lemma}
\label{lemma-depth-in-terms-dualizing-complex}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring with
normalized dualizing complex $\omega_A^\bullet$.
Then $\text{depth}(A)$ is equal to the smallest integer $\delta \geq 0$
such that $H^{-\delta}(\omega_A^\bullet) \not = 0$.
\end{lemma}

\begin{proof}
This follows immediately from
Lemma \ref{lemma-sitting-in-degrees}.
Here are two other ways to see that it is true.

\medskip\noindent
First alternative. By Nakayama's lemma we see that
$\delta$ is the smallest integer such that
$\Hom_A(H^{-\delta}(\omega_A^\bullet), \kappa) \not = 0$.
In other words, it is the smallest integer such that
$\Ext_A^{-\delta}(\omega_A^\bullet, \kappa)$
is nonzero. Using Lemma \ref{lemma-dualizing} and the fact that
$\omega_A^\bullet$ is normalized this is equal to the
smallest integer such that $\Ext_A^\delta(\kappa, A)$ is
nonzero. This is equal to the depth of $A$ by
Algebra, Lemma \ref{algebra-lemma-depth-ext}.

\medskip\noindent
Second alternative. By the local duality theorem
(in the form of Lemma \ref{lemma-special-case-local-duality})
$\delta$ is the smallest integer such that $H^\delta_\mathfrak m(A)$
is nonzero. This is equal to the depth of $A$ by
Lemma \ref{lemma-depth}.
\end{proof}

\begin{lemma}
\label{lemma-apply-CM}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring
with normalized dualizing complex $\omega_A^\bullet$
and dualizing module $\omega_A = H^{-\dim(A)}(\omega_A^\bullet)$.
The following are equivalent
\begin{enumerate}
\item $A$ is Cohen-Macaulay,
\item $\omega_A^\bullet$ is concentrated in a single degree, and
\item $\omega_A^\bullet = \omega_A[\dim(A)]$.
\end{enumerate}
In this case $\omega_A$ is a maximal Cohen-Macaulay module.
\end{lemma}

\begin{proof}
Follows immediately from Lemma \ref{lemma-local-CM}.
\end{proof}

\begin{lemma}
\label{lemma-has-dualizing-module-CM}
Let $A$ be a Noetherian ring. If there exists a finite $A$-module
$\omega_A$ such that $\omega_A[0]$ is a dualizing complex, then
$A$ is Cohen-Macaulay.
\end{lemma}

\begin{proof}
We may replace $A$ by the localization at a prime
(Lemma \ref{lemma-dualizing-localize} and
Algebra, Definition \ref{algebra-definition-ring-CM}).
In this case the result follows immediately from
Lemma \ref{lemma-apply-CM}.
\end{proof}

\begin{lemma}
\label{lemma-CM-open}
Let $A$ be a Noetherian ring with dualizing complex $\omega_A^\bullet$.
Let $M$ be a finite $A$-module. Then
$$
U = \{\mathfrak p \in \Spec(A) \mid M_\mathfrak p\text{ is Cohen-Macaulay}\}
$$
is an open subset of $\Spec(A)$ whose intersection with
$\text{Supp}(M)$ is dense.
\end{lemma}

\begin{proof}
If $\mathfrak p$ is a generic point of $\text{Supp}(M)$, then
$\text{depth}(M_\mathfrak p) = \dim(M_\mathfrak p) = 0$
and hence $\mathfrak p \in U$. This proves denseness.
If $\mathfrak p \in U$, then we see that
$$
R\Hom_A(M, \omega_A^\bullet)_\mathfrak p =
R\Hom_{A_\mathfrak p}(M_\mathfrak p, (\omega_A^\bullet)_\mathfrak p)
$$
has a unique nonzero cohomology module, say in degree $i_0$, by
Lemma \ref{lemma-local-CM}.
Since $R\Hom_A(M, \omega_A^\bullet)$
has only a finite number of nonzero cohomology modules $H^i$
and since each of these is a finite $A$-module, we can
find an $f \in A$, $f \not \in \mathfrak p$ such that
$(H^i)_f = 0$ for $i \not = i_0$. Then
$R\Hom_A(M, \omega_A^\bullet)_f$ has a unique nonzero cohomology
module and reversing the arguments just given we find
that $D(f) \subset U$.
\end{proof}

\begin{lemma}
\label{lemma-CM}
Let $A$ be a Noetherian ring. If $A$ has a dualizing complex
$\omega_A^\bullet$, then
$\{\mathfrak p \in \Spec(A) \mid A_\mathfrak p\text{ is Cohen-Macaulay}\}$
is a dense open subset of $\Spec(A)$.
\end{lemma}

\begin{proof}
Immediate consequence of Lemma \ref{lemma-CM-open} and the definitions.
\end{proof}






\section{Gorenstein rings}
\label{section-gorenstein}

\noindent
So far, the only explicit dualizing complex we've seen is $\kappa$ on $\kappa$
for a field $\kappa$, see proof of Lemma \ref{lemma-find-function}.
By Proposition \ref{proposition-dualizing-essentially-finite-type}
this means that any finite type algebra over a field has a dualizing
complex. However, it turns out that there are Noetherian (local) rings
which do not have a dualizing complex. Namely, we have seen that
a ring which has a dualizing complex is universally catenary
(Lemma \ref{lemma-universally-catenary})
but there are examples of
Noetherian local rings which are not catenary, see
Examples, Section \ref{examples-section-non-catenary-Noetherian-local}.

\medskip\noindent
Nonetheless many rings in algebraic geometry have dualizing complexes
simply because they are quotients of Gorenstein rings. This condition
is in fact both necessary and sufficient. That is: a Noetherian ring
has a dualizing complex if and only if it is a quotient of a finite
dimensional Gorenstein ring. This is Sharp's conjecture (\cite{Sharp})
which can be found as \cite[Corollary 1.4]{Kawasaki} in the literature.
Returning to our current topic, here is the definition of Gorenstein rings.

\begin{definition}
\label{definition-gorenstein}
Gorenstein rings.
\begin{enumerate}
\item Let $A$ be a Noetherian local ring. We say $A$ is {\it Gorenstein}
if $A[0]$ is a dualizing complex for $A$.
\item Let $A$ be a Noetherian ring. We say $A$ is {\it Gorenstein}
if $A_\mathfrak p$ is Gorenstein for every prime $\mathfrak p$ of $A$.
\end{enumerate}
\end{definition}

\noindent
This definition makes sense, because if $A[0]$ is a dualizing complex
for $A$, then $S^{-1}A[0]$ is a dualizing complex for $S^{-1}A$ by
Lemma \ref{lemma-dualizing-localize}.
We will see later that a finite dimensional Noetherian ring is Gorenstein
if it has finite injective dimension as a module over itself.

\begin{lemma}
\label{lemma-gorenstein-CM}
A Gorenstein ring is Cohen-Macaulay.
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-apply-CM}.
\end{proof}

\noindent
An example of a Gorenstein ring is a regular ring.

\begin{lemma}
\label{lemma-regular-gorenstein}
A regular local ring is Gorenstein.
A regular ring is Gorenstein.
\end{lemma}

\begin{proof}
Let $A$ be a regular ring of finite dimension $d$. Then $A$ has finite
global dimension $d$, see
Algebra, Lemma \ref{algebra-lemma-finite-gl-dim-finite-dim-regular}.
Hence $\Ext^{d + 1}_A(M, A) = 0$ for all $A$-modules $M$, see
Algebra, Lemma \ref{algebra-lemma-projective-dimension-ext}.
Thus $A$ has finite injective dimension as an $A$-module by
More on Algebra, Lemma \ref{more-algebra-lemma-injective-amplitude}.
It follows that $A[0]$ is a dualizing complex, hence $A$ is
Gorenstein by the remark following the definition.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein}
Let $A$ be a Noetherian ring.
\begin{enumerate}
\item If $A$ has a dualizing complex $\omega_A^\bullet$, then
\begin{enumerate}
\item $A$ is Gorenstein $\Leftrightarrow$ $\omega_A^\bullet$ is an invertible
object of $D(A)$,
\item $A_\mathfrak p$ is Gorenstein $\Leftrightarrow$
$(\omega_A^\bullet)_\mathfrak p$ is an invertible object of
$D(A_\mathfrak p)$,
\item $\{\mathfrak p \in \Spec(A) \mid A_\mathfrak p\text{ is Gorenstein}\}$
is an open subset.
\end{enumerate}
\item If $A$ is Gorenstein, then $A$ has a dualizing complex if and
only if $A[0]$ is a dualizing complex.
\end{enumerate}
\end{lemma}

\begin{proof}
For invertible objects of $D(A)$, see
More on Algebra, Lemma \ref{more-algebra-lemma-invertible-derived}
and the discussion in Section \ref{section-dualizing}.

\medskip\noindent
By Lemma \ref{lemma-dualizing-localize} for every
$\mathfrak p$ the complex $(\omega_A^\bullet)_\mathfrak p$ is a
dualizing complex over $A_\mathfrak p$. By definition and uniqueness
of dualizing complexes (Lemma \ref{lemma-dualizing-unique})
we see that (1)(b) holds.

\medskip\noindent
To see (1)(c) assume that $A_\mathfrak p$ is Gorenstein.
Let $n_x$ be the unique integer such that
$H^{n_{x}}((\omega_A^\bullet)_\mathfrak p)$
is nonzero and isomorphic to $A_\mathfrak p$.
Since $\omega_A^\bullet$ is in $D^b_{\textit{Coh}}(A)$
there are finitely many nonzero finite $A$-modules
$H^i(\omega_A^\bullet)$. Thus there exists some
$f \in A$, $f \not \in \mathfrak p$
such that only $H^{n_x}((\omega_A^\bullet)_f)$
is nonzero and generated by $1$ element over $A_f$.
Since dualizing complexes are faithful (by definition)
we conclude that $A_f \cong H^{n_x}((\omega_A^\bullet)_f)$.
In this way we see that $A_\mathfrak q$ is Gorenstein
for every $\mathfrak q \in D(f)$. This proves that the set
in (1)(c) is open.

\medskip\noindent
Proof of (1)(a). The implication $\Leftarrow$ follows from (1)(b).
The implication $\Rightarrow$ follows from the discussion
in the previous paragraph, where we showed that if $A_\mathfrak p$
is Gorenstein, then for some $f \in A$, $f \not \in \mathfrak p$
the complex $(\omega_A^\bullet)_f$ has only one nonzero cohomology module
which is invertible.

\medskip\noindent
If $A[0]$ is a dualizing complex then $A$ is Gorenstein by
part (1). Conversely, we see that part (1) shows that
$\omega_A^\bullet$ is locally isomorphic to a shift of $A$.
Since being a dualizing complex is local
(Lemma \ref{lemma-dualizing-glue})
the result is clear.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-ext}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local ring.
Then $A$ is Gorenstein if and only if $\Ext^i_A(\kappa, A)$
is zero for $i \gg 0$.
\end{lemma}

\begin{proof}
Observe that $A[0]$ is a dualizing complex for $A$ if and only
if $A$ has finite injective dimension as an $A$-module
(follows immediately from Definition \ref{definition-dualizing}).
Thus the lemma follows from More on Algebra, Lemma
\ref{more-algebra-lemma-finite-injective-dimension-Noetherian-local}.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-divide-by-nonzerodivisor}
Let $(A, \mathfrak m, \kappa)$
be a Noetherian local ring. Let $f \in \mathfrak m$ be a
nonzerodivisor. Set $B = A/(f)$. Then $A$ is Gorenstein if and
only if $B$ is Gorenstein.
\end{lemma}

\begin{proof}
If $A$ is Gorenstein, then $B$ is Gorenstein by
Lemma \ref{lemma-divide-by-nonzerodivisor}.
Conversely, suppose that $B$ is Gorenstein. Then
$\Ext^i_B(\kappa, B)$ is zero for $i \gg 0$
(Lemma \ref{lemma-gorenstein-ext}).
Recall that $R\Hom(B, -) : D(A) \to D(B)$ is a right adjoint
to restriction (Lemma \ref{lemma-right-adjoint}).
Hence
$$
R\Hom_A(\kappa, A) = R\Hom_B(\kappa, R\Hom(B, A)) =
R\Hom_B(\kappa, B[1])
$$
The final equality by direct computation or by
Lemma \ref{lemma-compute-for-effective-Cartier-algebraic}.
Thus we see that $\Ext^i_A(\kappa, A)$ is zero for
$i \gg 0$ and $A$ is Gorenstein (Lemma \ref{lemma-gorenstein-ext}).
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-lci}
If $A \to B$ is a local complete intersection homomorphism of rings and
$A$ is a Noetherian Gorenstein ring, then $B$ is a Gorenstein ring.
\end{lemma}

\begin{proof}
By More on Algebra, Definition
\ref{more-algebra-definition-local-complete-intersection}
we can write $B = A[x_1, \ldots, x_n]/I$
where $I$ is a Koszul-regular ideal. Observe that a polynomial
ring over a Gorenstein ring $A$ is Gorenstein: reduce to
$A$ local and then use Lemmas \ref{lemma-dualizing-polynomial-ring} and
\ref{lemma-gorenstein}.
A Koszul-regular ideal is by definition locally generated
by a Koszul-regular sequence, see More on Algebra, Section
\ref{more-algebra-section-ideals}.
Looking at local rings of $A[x_1, \ldots, x_n]$
we see it suffices to show: if $R$ is a Noetherian local
Gorenstein ring and $f_1, \ldots, f_c \in \mathfrak m_R$
is a Koszul regular sequence, then $R/(f_1, \ldots, f_c)$ is Gorenstein.
This follows from
Lemma \ref{lemma-gorenstein-divide-by-nonzerodivisor} and
the fact that a Koszul regular sequence in $R$ is just a
regular sequence (More on Algebra, Lemma
\ref{more-algebra-lemma-noetherian-finite-all-equivalent}).
\end{proof}

\begin{lemma}
\label{lemma-flat-under-gorenstein}
Let $A \to B$ be a flat local homomorphism of Noetherian local rings.
The following are equivalent
\begin{enumerate}
\item $B$ is Gorenstein, and
\item $A$ and $B/\mathfrak m_A B$ are Gorenstein.
\end{enumerate}
\end{lemma}

\begin{proof}
Below we will use without further mention that a local Gorenstein ring
has finite injective dimension as well as Lemma \ref{lemma-gorenstein-ext}.
By More on Algebra, Lemma
\ref{more-algebra-lemma-pseudo-coherence-and-base-change-ext}
we have
$$
\Ext^i_A(\kappa_A, A) \otimes_A B =
\Ext^i_B(B/\mathfrak m_A B, B)
$$
for all $i$.

\medskip\noindent
Assume (2). Using that
$R\Hom(B/\mathfrak m_A B, -) : D(B) \to D(B/\mathfrak m_A B)$ is a
right adjoint to restriction (Lemma \ref{lemma-right-adjoint}) we obtain
$$
R\Hom_B(\kappa_B, B) =
R\Hom_{B/\mathfrak m_A B}(\kappa_B, R\Hom(B/\mathfrak m_A B, B))
$$
The cohomology modules of $R\Hom(B/\mathfrak m_A B, B)$ are the modules
$\Ext^i_B(B/\mathfrak m_A B, B) =
\Ext^i_A(\kappa_A, A) \otimes_A B$.
Since $A$ is Gorenstein, we conclude only a finite number of these are nonzero
and each is isomorphic to a direct sum of copies of $B/\mathfrak m_A B$.
Hence since $B/\mathfrak m_A B$ is Gorenstein we conclude that
$R\Hom_B(B/\mathfrak m_B, B)$ has only a finite number of nonzero
cohomology modules. Hence $B$ is Gorenstein.

\medskip\noindent
Assume (1). Since $B$ has finite injective dimension,
$\Ext^i_B(B/\mathfrak m_A B, B)$ is $0$ for $i \gg 0$.
Since $A \to B$ is faithfully flat
we conclude that $\Ext^i_A(\kappa_A, A)$ is $0$
for $i \gg 0$. We conclude that $A$ is Gorenstein. This implies that
$\Ext^i_A(\kappa_A, A)$ is nonzero for exactly one $i$,
namely for $i = \dim(A)$, and
$\Ext^{\dim(A)}_A(\kappa_A, A) \cong \kappa_A$
(see Lemmas \ref{lemma-normalized-finite}, \ref{lemma-apply-CM}, and
\ref{lemma-gorenstein-CM}).
Thus we see that
$\Ext^i_B(B/\mathfrak m_A B, B)$ is zero except for one $i$,
namely $i = \dim(A)$ and
$\Ext^{\dim(A)}_B(B/\mathfrak m_A B, B) \cong B/\mathfrak m_A B$.
Thus $B/\mathfrak m_A B$ is Gorenstein by
Lemma \ref{lemma-normalized-finite}.
\end{proof}

\begin{lemma}
\label{lemma-tor-injective-hull}
Let $(A, \mathfrak m, \kappa)$ be a Noetherian local Gorenstein ring
of dimension $d$. Let $E$ be the injective hull of $\kappa$. Then
$\text{Tor}_i^A(E, \kappa)$ is zero for $i \not = d$
and $\text{Tor}_d^A(E, \kappa) = \kappa$.
\end{lemma}

\begin{proof}
Since $A$ is Gorenstein $\omega_A^\bullet = A[d]$ is a
normalized dualizing complex for $A$.
Also $E$ is the only nonzero cohomology module of
$R\Gamma_\mathfrak m(\omega_A^\bullet)$ sitting in degree $0$, see
Lemma \ref{lemma-local-cohomology-of-dualizing}.
By Lemma \ref{lemma-torsion-tensor-product} we have
$$
E \otimes_A^\mathbf{L} \kappa =
R\Gamma_\mathfrak m(\omega_A^\bullet) \otimes_A^\mathbf{L} \kappa =
R\Gamma_\mathfrak m(\omega_A^\bullet \otimes_A^\mathbf{L} \kappa) =
R\Gamma_\mathfrak m(\kappa[d]) = \kappa[d]
$$
and the lemma follows.
\end{proof}




\section{The ubiquity of dualizing complexes}
\label{section-ubiquity-dualizing}

\noindent
Many Noetherian rings have dualizing complexes.

\begin{lemma}
\label{lemma-flat-unramified}
Let $A \to B$ be a local homomorphism of Noetherian local rings.
Let $\omega_A^\bullet$ be a normalized dualizing complex.
If $A \to B$ is flat and $\mathfrak m_A B = \mathfrak m_B$,
then $\omega_A^\bullet \otimes_A B$ is a normalized dualizing
complex for $B$.
\end{lemma}

\begin{proof}
It is clear that $\omega_A^\bullet \otimes_A B$ is in $D^b_{\textit{Coh}}(B)$.
Let $\kappa_A$ and $\kappa_B$ be the residue fields of $A$ and $B$.
By More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}
we see that
$$
R\Hom_B(\kappa_B, \omega_A^\bullet \otimes_A B) =
R\Hom_A(\kappa_A, \omega_A^\bullet) \otimes_A B =
\kappa_A[0] \otimes_A B = \kappa_B[0]
$$
Thus $\omega_A^\bullet \otimes_A B$ has finite injective dimension by
More on Algebra, Lemma
\ref{more-algebra-lemma-finite-injective-dimension-Noetherian-local}.
Finally, we can use the same arguments to see that
$$
R\Hom_B(\omega_A^\bullet \otimes_A B, \omega_A^\bullet \otimes_A B) =
R\Hom_A(\omega_A^\bullet, \omega_A^\bullet) \otimes_A B = A \otimes_A B = B
$$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-flat-iso-mod-I}
Let $A \to B$ be a flat map of Noetherian rings. Let
$I \subset A$ be an ideal such that $A/I = B/IB$ and
such that $IB$ is contained in the Jacobson radical of $B$.
Let $\omega_A^\bullet$ be a dualizing complex.
Then $\omega_A^\bullet \otimes_A B$ is a dualizing
complex for $B$.
\end{lemma}

\begin{proof}
It is clear that $\omega_A^\bullet \otimes_A B$ is in $D^b_{\textit{Coh}}(B)$.
By More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}
we see that
$$
R\Hom_B(K \otimes_A B, \omega_A^\bullet \otimes_A B) =
R\Hom_A(K, \omega_A^\bullet) \otimes_A B
$$
for any $K \in D^b_{\textit{Coh}}(A)$. For any ideal
$IB \subset J \subset B$ there is a unique ideal $I \subset J' \subset A$
such that $A/J' \otimes_A B = B/J$. Thus $\omega_A^\bullet \otimes_A B$
has finite injective dimension by
More on Algebra, Lemma
\ref{more-algebra-lemma-finite-injective-dimension-Noetherian-radical}.
Finally, we also have
$$
R\Hom_B(\omega_A^\bullet \otimes_A B, \omega_A^\bullet \otimes_A B) =
R\Hom_A(\omega_A^\bullet, \omega_A^\bullet) \otimes_A B = A \otimes_A B = B
$$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-completion-henselization-dualizing}
Let $A$ be a Noetherian ring and let $I \subset A$ be an ideal.
Let $\omega_A^\bullet$ be a dualizing complex.
\begin{enumerate}
\item $\omega_A^\bullet \otimes_A A^h$ is a dualizing complex on the
henselization $(A^h, I^h)$ of the pair $(A, I)$,
\item $\omega_A^\bullet \otimes_A A^\wedge$ is a dualizing complex on
the $I$-adic completion $A^\wedge$, and
\item if $A$ is local, then $\omega_A^\bullet \otimes_A A^h$,
resp.\ $\omega_A^\bullet \otimes_A A^{sh}$ is a dualzing complex
on the henselization, resp.\ strict henselization of $A$.
\end{enumerate}
\end{lemma}

\begin{proof}
Immediate from Lemmas \ref{lemma-flat-unramified} and
\ref{lemma-flat-iso-mod-I}.
See More on Algebra, Sections \ref{more-algebra-section-henselian-pairs},
\ref{more-algebra-section-permanence-completion}, and
\ref{more-algebra-section-permanence-henselization} and
Algebra, Sections \ref{algebra-section-completion} and
\ref{algebra-section-completion-noetherian}
for information on completions and henselizations.
\end{proof}

\begin{lemma}
\label{lemma-ubiquity-dualizing}
The following types of rings have a dualizing complex:
\begin{enumerate}
\item fields,
\item Noetherian complete local rings,
\item $\mathbf{Z}$,
\item Dedekind domains,
\item any ring which is obtained from one of the rings above by
taking an algebra essentially of finite type, or by taking an
ideal-adic completion, or by taking a henselization, 
or by taking a strict henselization.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (5) follows from Proposition
\ref{proposition-dualizing-essentially-finite-type}
and Lemma \ref{lemma-completion-henselization-dualizing}.
By Lemma \ref{lemma-regular-gorenstein} a regular local ring has a
dualizing complex.
A complete Noetherian local ring is the quotient of a regular
local ring by the Cohen structure theorem
(Algebra, Theorem \ref{algebra-theorem-cohen-structure-theorem}).
Let $A$ be a Dedekind domain. Then every ideal $I$ is a finite
projective $A$-module (follows from
Algebra, Lemma \ref{algebra-lemma-finite-projective}
and the fact that the local rings of $A$ are discrete valuation ring
and hence PIDs). Thus every $A$-module has finite injective dimension
at most $1$ by
More on Algebra, Lemma \ref{more-algebra-lemma-injective-amplitude}.
It follows easily that $A[0]$ is a dualizing complex.
\end{proof}





\section{Formal fibres}
\label{section-formal-fibres}

\noindent
This section is a continuation of
More on Algebra, Section \ref{more-algebra-section-properties-formal-fibres}.
There we saw there is a (fairly) good theory of Noetherian rings $A$
whose local rings have Cohen-Macaulay formal fibres. Namely, we proved
(1) it suffices to check the formal fibres of localizations at
maximal ideals are Cohen-Macaulay,
(2) the property is inherited by rings of finite type over $A$,
(3) the fibres of $A \to A^\wedge$ are Cohen-Macaulay for
any completion $A^\wedge$ of $A$, and
(4) the property is inherited by henselizations of $A$. See
More on Algebra, Lemma \ref{more-algebra-lemma-check-P-ring-maximal-ideals},
Proposition \ref{more-algebra-proposition-finite-type-over-P-ring},
Lemma \ref{more-algebra-lemma-map-P-ring-to-completion-P}, and
Lemma \ref{more-algebra-lemma-henselization-pair-P-ring}.
Similarly, for Noetherian rings whose local rings have formal fibres
which are geometrically reduced, geometrically normal, $(S_n)$, and
geometrically $(R_n)$.
In this section we will see that the same is true for Noetherian rings
whose local rings have formal fibres which are Gorenstein
or local complete intersections.
This is relevant to this chapter because a Noetherian ring which has a
dualizing complex is an example.

\begin{lemma}
\label{lemma-formal-fibres-gorenstein}
Properties (A), (B), (C), (D), and (E) of
More on Algebra, Section \ref{more-algebra-section-properties-formal-fibres}
hold for $P(k \to R) =$``$R$ is a Gorenstein ring''.
\end{lemma}

\begin{proof}
Since we already know the result holds for Cohen-Macaulay instead
of Gorenstein, we may in each step assume the ring we have is
Cohen-Macaulay. This is not particularly helpful for the proof, but
psychologically may be useful.

\medskip\noindent
Part (A). Let $K/k$ be a finitely generated field extension.
Let $R$ be a Gorenstein $k$-algebra.
We can find a global complete intersection
$A = k[x_1, \ldots, x_n]/(f_1, \ldots, f_c)$
over $k$ such that $K$ is isomorphic to the fraction field of $A$, see
Algebra, Lemma \ref{algebra-lemma-colimit-syntomic}.
Then $R \to R \otimes_k A$ is a relative global complete intersection.
Hence $R \otimes_k A$ is Gorenstein by Lemma \ref{lemma-gorenstein-lci}.
Thus $R \otimes_k K$ is too as a localization.

\medskip\noindent
Proof of (B). This is clear because a ring is Gorenstein
if and only if all of its local rings are Gorenstein.

\medskip\noindent
Part (C). Let $A \to B \to C$ be flat maps of Noetherian rings.
Assume the fibres of $A \to B$ are Gorenstein and $B \to C$ is regular.
We have to show the fibres of $A \to C$ are Gorenstein.
Clearly, we may assume $A = k$ is a field. Then we may assume that
$B \to C$ is a regular local homomorphism of Noetherian local rings.
Then $B$ is Gorenstein and $C/\mathfrak m_B C$ is regular, in
particular Gorenstein (Lemma \ref{lemma-regular-gorenstein}).
Then $C$ is Gorenstein by
Lemma \ref{lemma-flat-under-gorenstein}.

\medskip\noindent
Part (D). This follows from Lemma \ref{lemma-flat-under-gorenstein}.
Part (E) is immediate as the condition does not refer to the ground field.
\end{proof}

\begin{lemma}
\label{lemma-dualizing-gorenstein-formal-fibres}
Let $A$ be a Noetherian local ring. If $A$ has a dualizing complex,
then the formal fibres of $A$ are Gorenstein.
\end{lemma}

\begin{proof}
Let $\mathfrak p$ be a prime of $A$. The formal fibre of $A$ at $\mathfrak p$
is isomorphic to the formal fibre of $A/\mathfrak p$ at $(0)$. The quotient
$A/\mathfrak p$ has a dualizing complex
(Lemma \ref{lemma-dualizing-quotient}).
Thus it suffices to check the statement
when $A$ is a local domain and $\mathfrak p = (0)$.
Let $\omega_A^\bullet$ be a dualizing complex for $A$. Then
$\omega_A^\bullet \otimes_A A^\wedge$ is a dualizing complex
for the completion $A^\wedge$
(Lemma \ref{lemma-flat-unramified}).
Then $\omega_A^\bullet \otimes_A K$ is a dualizing
complex for the fraction field $K$ of $A$
(Lemma \ref{lemma-dualizing-localize}).
Hence $\omega_A^\bullet \otimes_A K$
is isomorphic ot $K[n]$ for some $n \in \mathbf{Z}$.
Similarly, we conclude a dualizing complex for the formal fibre
$A^\wedge \otimes_A K$ is
$$
\omega_A^\bullet \otimes_A A^\wedge \otimes_{A^\wedge} (A^\wedge \otimes_A K) =
(\omega_A^\bullet \otimes_A K) \otimes_K (A^\wedge \otimes_A K) \cong
(A^\wedge \otimes_A K)[n]
$$
as desired.
\end{proof}

\noindent
Here is the verification promised in
Divided Power Algebra, Remark \ref{dpa-remark-no-good-ci-map}.

\begin{lemma}
\label{lemma-formal-fibres-lci}
Properties (A), (B), (C), (D), and (E) of
More on Algebra, Section \ref{more-algebra-section-properties-formal-fibres}
hold for $P(k \to R) =$``$R$ is a local complete intersection''.
See Divided Power Algebra, Definition \ref{dpa-definition-lci}.
\end{lemma}

\begin{proof}
Part (A). Let $K/k$ be a finitely generated field extension.
Let $R$ be a $k$-algebra which is a local complete intersection.
We can find a global complete intersection
$A = k[x_1, \ldots, x_n]/(f_1, \ldots, f_c)$
over $k$ such that $K$ is isomorphic to the fraction field of $A$, see
Algebra, Lemma \ref{algebra-lemma-colimit-syntomic}.
Then $R \to R \otimes_k A$ is a relative global complete intersection.
It follows that $R \otimes_k A$ is a local complete intersection
by Divided Power Algebra, Lemma \ref{dpa-lemma-avramov}.

\medskip\noindent
Proof of (B). This is clear
because a ring is a local complete intersection if and only if all of its
local rings are complete intersections.

\medskip\noindent
Part (C). Let $A \to B \to C$ be flat maps of Noetherian rings.
Assume the fibres of $A \to B$ are local complete intersections
and $B \to C$ is regular. We have to show the fibres of $A \to C$
are local complete intersections. Clearly, we may assume $A = k$ is a field.
Then we may assume that $B \to C$ is a regular local homomorphism
of Noetherian local rings. Then $B$ is a complete intersection and
$C/\mathfrak m_B C$ is regular, in particular a complete intersection
(by definition). Then $C$ is a complete intersection by
Divided Power Algebra, Lemma \ref{dpa-lemma-avramov}.

\medskip\noindent
Part (D). This follows by the same arguments as in (C) from
the other implication in
Divided Power Algebra, Lemma \ref{dpa-lemma-avramov}.
Part (E) is immediate as the condition does not refer to the ground
field.
\end{proof}






\section{Upper shriek algebraically}
\label{section-relative-dualizing-complex-algebraic}

\noindent
For a finite type homomorphism $R \to A$ of Noetherian rings
we will construct a functor $\varphi^! : D(R) \to D(A)$
well defined up to nonunique isomorphism which
as we will see in Duality for Schemes, Remark
\ref{duality-remark-local-calculation-shriek}
agrees up to isomorphism with the upper shriek functors
one encounters in the duality theory for schemes.
To motivate the construction we mention two additional properties:
\begin{enumerate}
\item $\varphi^!$ sends a dualizing complex for $R$ (if it exists)
to a dualizing complex for $A$, and
\item $\omega_{A/R}^\bullet = \varphi^!(R)$ is a kind of
relative dualizing complex: it lies in $D^b_{\textit{Coh}}(A)$ and restricts
to a dualizing complex on the fibres provided $R \to A$ is flat.
\end{enumerate}
These statemens are Lemmas \ref{lemma-shriek-dualizing-algebraic} and
\ref{lemma-relative-dualizing-algebraic}.

\medskip\noindent
Let $\varphi : R \to A$ be a finite type homomorphism of Noetherian rings.
We will define a functor $\varphi^! : D(R) \to D(A)$ in the following way
\begin{enumerate}
\item If $\varphi : R \to A$ is surjective we set
$\varphi^!(K) = R\Hom(A, K)$. Here we use the functor
$R\Hom(A, -) : D(R) \to D(A)$ of
Section \ref{section-trivial}, and
\item in general we choose a surjection $\psi : P \to A$ with
$P = R[x_1, \ldots, x_n]$ and we set
$\varphi^!(K) = \psi^!(K \otimes_R^\mathbf{L} P)[n]$.
Here we use the functor
$- \otimes_R^\mathbf{L} P : D(R) \to D(P)$
of More on Algebra, Section \ref{more-algebra-section-derived-base-change}.
\end{enumerate}
Note the shift $[n]$ by the number of variables in the polynomial
ring. This construction is {\bf not} canonical and the functor
$\varphi^!$ will only be well defined up to a (nonunique) isomorphism of
functors\footnote{It is possible to make the construction canonical:
use $\Omega^n_{P/R}[n]$ instead of $P[n]$ in the
construction and use this in Lemma \ref{lemma-well-defined}.
The material in this section becomes a lot more involved
if one wants to do this.}.

\begin{lemma}
\label{lemma-well-defined}
Let $\varphi : R \to A$ be a finite type homomorphism of
Noetherian rings. The functor $\varphi^!$ is well defined
up to isomorphism.
\end{lemma}

\begin{proof}
Suppose that $\psi_1 : P_1 = R[x_1, \ldots, x_n] \to A$ and
$\psi_2 : P_2 = R[y_1, \ldots, y_m] \to A$ are two
surjections from polynomial rings onto $A$. Then we get a
commutative diagram
$$
\xymatrix{
R[x_1, \ldots, x_n, y_1, \ldots, y_m]
\ar[d]^{x_i \mapsto g_i} \ar[rr]_-{y_j \mapsto f_j} & &
R[x_1, \ldots, x_n] \ar[d] \\
R[y_1, \ldots, y_m] \ar[rr] & & A
}
$$
where $f_j$ and $g_i$ are chosen such that $\psi_1(f_j) = \psi_2(y_j)$
and $\psi_2(g_i) = \psi_1(x_i)$. By symmetry it suffices to prove
the functors defined using $P \to A$ and $P[y_1, \ldots, y_m] \to A$
are isomorphic. By induction we may assume $m = 1$. This reduces
us to the case discussed in the next paragraph.

\medskip\noindent
Here $\psi : P \to A$ is given and $\chi : P[y] \to A$ induces
$\psi$ on $P$. Write $Q = P[y]$.
Choose $g \in P$ with $\psi(g) = \chi(y)$.
Denote $\pi : Q \to P$ the $P$-algebra map
with $\pi(y) = g$. Then $\chi = \psi \circ \pi$ and hence
$\chi^! = \psi^! \circ \pi^!$ as both are
adjoint to the restriction functor $D(A) \to D(Q)$ by the material
in Section \ref{section-trivial}. Thus
$$
\chi^!\left(K \otimes_R^\mathbf{L} Q\right)[n + 1] =
\psi^!\left(\pi^!\left(K \otimes_R^\mathbf{L} Q\right)[1]\right)[n]
$$
Hence it suffices to show that
$\pi^!(K \otimes_R^\mathbf{L} Q[1]) = K \otimes_R^\mathbf{L} P$
Thus it suffices to show that the functor
$\pi^!(-) : D(Q) \to D(P)$
is isomorphic to $K \mapsto K \otimes_Q^\mathbf{L} P[-1]$.
This follows from Lemma \ref{lemma-compute-for-effective-Cartier-algebraic}.
\end{proof}

\begin{lemma}
\label{lemma-shriek-boundedness}
Let $\varphi : R \to A$ be a finite type homomorphism of Noetherian rings.
\begin{enumerate}
\item $\varphi^!$ maps $D^+(R)$ into $D^+(A)$ and
$D^+_{\textit{Coh}}(R)$ into $D^+_{\textit{Coh}}(A)$.
\item if $\varphi$ is perfect, then $\varphi^!$ maps
$D^-(R)$ into $D^-(A)$,
$D^-_{\textit{Coh}}(R)$ into $D^-_{\textit{Coh}}(A)$, and
$D^b_{\textit{Coh}}(R)$ into $D^b_{\textit{Coh}}(A)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Choose a factorization $R \to P \to A$ as in the definition of $\varphi^!$.
The functor $- \otimes_R^\mathbf{L} : D(R) \to D(P)$ preserves
the subcategories
$D^+, D^+_{\textit{Coh}}, D^-, D^-_{\textit{Coh}}, D^b_{\textit{Coh}}$.
The functor $R\Hom(A, -) : D(P) \to D(A)$
preserves $D^+$ and $D^+_{\textit{Coh}}$ by
Lemma \ref{lemma-exact-support-coherent}.
If $R \to A$ is perfect, then $A$ is perfect as a $P$-module, see
More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}.
Recall that the restriction of $R\Hom(A, K)$ to $D(P)$ is
$R\Hom_P(A, K)$. By More on Algebra, Lemma
\ref{more-algebra-lemma-dual-perfect-complex}
we have $R\Hom_P(A, K) = E \otimes_P^\mathbf{L} K$ for
some perfect $E \in D(P)$. Since we can represent $E$ by
a finite complex of finite projective $P$-modules
it is clear that $R\Hom_P(A, K)$ is in
$D^-(P), D^-_{\textit{Coh}}(P), D^b_{\textit{Coh}}(P)$
as soon as $K$ is. Since the restriction functor
$D(A) \to D(P)$ reflects these subcategories, the
proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-shriek-dualizing-algebraic}
Let $\varphi$ be a finite type homomorphism of Noetherian rings.
If $\omega_R^\bullet$ is a dualizing complex for $R$, then
$\varphi^!(\omega_R^\bullet)$ is a dualizing complex for $A$.
\end{lemma}

\begin{proof}
Follows from Lemmas
\ref{lemma-dualizing-polynomial-ring} and
\ref{lemma-dualizing-quotient},
\end{proof}

\begin{lemma}
\label{lemma-flat-bc}
Let $R \to R'$ be a flat homomorphism of Noetherian rings.
Let $\varphi : R \to A$ be a finite type ring map.
Let $\varphi' : R' \to A' = A \otimes_R R'$ be the map induced by $\varphi$.
Then we have a functorial maps
$$
\varphi^!(K) \otimes_A^\mathbf{L} A' \longrightarrow
(\varphi')^!(K \otimes_R^\mathbf{L} R')
$$
for $K$ in $D(R)$ which are isomorphisms for $K \in D^+(R)$.
\end{lemma}

\begin{proof}
Choose a factorization $R \to P \to A$ where $P$ is a polynomial ring over $R$.
This gives a corresponding factorization $R' \to P' \to A'$ by base change.
Since we have $(K \otimes_R^\mathbf{L} P) \otimes_P^\mathbf{L} P' =
(K \otimes_R^\mathbf{L} R') \otimes_{R'}^\mathbf{L} P'$
by More on Algebra, Lemma \ref{more-algebra-lemma-double-base-change}
it suffices to construct maps
$$
R\Hom(A, K \otimes_R^\mathbf{L} P[n]) \otimes_A^\mathbf{L} A'
\longrightarrow
R\Hom(A', (K \otimes_R^\mathbf{L} P[n]) \otimes_P^\mathbf{L} P')
$$
functorial in $K$. For this we use the map (\ref{equation-base-change})
constructed in Section \ref{section-base-change-trivial-duality}
for $P, A, P', A'$.
The map is an isomorphism for $K \in D^+(R)$ by
Lemma \ref{lemma-flat-bc-surjection}.
\end{proof}

\begin{lemma}
\label{lemma-bc}
Let $R \to R'$ be a homomorphism of Noetherian rings.
Let $\varphi : R \to A$ be a perfect ring map
(More on Algebra, Definition
\ref{more-algebra-definition-pseudo-coherent-perfect})
such that $R'$ and $A$ are tor independent over $R$.
Let $\varphi' : R' \to A' = A \otimes_R R'$ be the map induced by $\varphi$.
Then we have a functorial isomorphism
$$
\varphi^!(K) \otimes_A^\mathbf{L} A' =
(\varphi')^!(K \otimes_R^\mathbf{L} R')
$$
for $K$ in $D(R)$.
\end{lemma}

\begin{proof}
We may choose a factorization $R \to P \to A$ where $P$
is a polynomial ring over $R$ such that $A$ is a perfect $P$-module, see
More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}.
This gives a corresponding factorization $R' \to P' \to A'$ by base change.
Since we have $(K \otimes_R^\mathbf{L} P) \otimes_P^\mathbf{L} P' =
(K \otimes_R^\mathbf{L} R') \otimes_{R'}^\mathbf{L} P'$
by More on Algebra, Lemma \ref{more-algebra-lemma-double-base-change}
it suffices to construct maps
$$
R\Hom(A, K \otimes_R^\mathbf{L} P[n]) \otimes_A^\mathbf{L} A'
\longrightarrow
R\Hom(A', (K \otimes_R^\mathbf{L} P[n]) \otimes_P^\mathbf{L} P')
$$
functorial in $K$. We have
$$
A \otimes_P^\mathbf{L} P' = A \otimes_R^\mathbf{L} R' = A'
$$
The first equality by
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-comparison}
applied to $R, R', P, P'$. The second equality because
$A$ and $R'$ are tor independent over $R$. Hence $A$ and $P'$ are
tor independent over $P$ and we can use the map (\ref{equation-base-change})
constructed in Section \ref{section-base-change-trivial-duality} for
$P, A, P', A'$
get the desired arrow. By Lemma \ref{lemma-bc-surjection}
to finish the proof it suffices to prove that $A$ is a perfect $P$-module
which we saw above.
\end{proof}

\begin{lemma}
\label{lemma-bc-flat}
Let $R \to R'$ be a homomorphism of Noetherian rings.
Let $\varphi : R \to A$ be flat of finite type.
Let $\varphi' : R' \to A' = A \otimes_R R'$ be the map induced by $\varphi$.
Then we have a functorial isomorphism
$$
\varphi^!(K) \otimes_A^\mathbf{L} A' =
(\varphi')^!(K \otimes_R^\mathbf{L} R')
$$
for $K$ in $D(R)$.
\end{lemma}

\begin{proof}
Special case of Lemma \ref{lemma-bc} by
More on Algebra, Lemma
\ref{more-algebra-lemma-flat-finite-presentation-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-composition-shriek-algebraic}
Let $A \xrightarrow{a} B \xrightarrow{b} C$ be finite type homomorphisms of
Noetherian rings. Then there is a transformation of functors
$b^! \circ a^! \to (b \circ a)^!$ which is an isomorphism on $D^+(A)$.
\end{lemma}

\begin{proof}
Choose a polynomial ring $P = A[x_1, \ldots, x_n]$ over $A$
and a surjection $P \to B$. Choose elements $c_1, \ldots, c_m \in C$
generating $C$ over $B$. Set $Q = P[y_1, \ldots, y_m]$ and
denote $Q' = Q \otimes_P B = B[y_1, \ldots, y_m]$.
Let $\chi : Q' \to C$ be the surjection sending $y_j$ to $c_j$.
Picture
$$
\xymatrix{
& Q \ar[r]_{\psi'} & Q' \ar[r]_\chi & C \\
A \ar[r] & P \ar[r]^\psi \ar[u] & B \ar[u]
}
$$
By Lemma \ref{lemma-flat-bc-surjection} for $M \in D(P)$ we have an arrow
$\psi^!(M) \otimes_B^\mathbf{L} Q' \to (\psi')^!(M \otimes_P^\mathbf{L} Q)$
which is an isomorphism whenever $M$ is bounded below. Also
we have $\chi^! \circ (\psi')^! = (\chi \circ \psi')^!$ as both
functors are adjoint to the restriction functor $D(C) \to D(Q)$
by Section \ref{section-trivial}. Then we see
\begin{align*}
b^!(a^!(K))
& =
\chi^!(\psi^!(K \otimes_A^\mathbf{L} P)[n] \otimes_B^\mathbf{L} Q)[m] \\
& \to
\chi^!((\psi')^!(K \otimes_A^\mathbf{L} P \otimes_P^\mathbf{L} Q))[n + m] \\
& =
(\chi \circ \psi')^!(K\otimes_A^\mathbf{L} Q)[n + m] \\
& =
(b \circ a)^!(K)
\end{align*}
where we have used in addition to the above
More on Algebra, Lemma \ref{more-algebra-lemma-double-base-change}.
\end{proof}

\begin{lemma}
\label{lemma-upper-shriek-finite}
Let $\varphi : R \to A$ be a finite map of Noetherian rings.
Then $\varphi^!$ is isomorphic to the functor
$R\Hom(A, -) : D(R) \to D(A)$ from
Section \ref{section-trivial}.
\end{lemma}

\begin{proof}
Suppose that $A$ is generated by $n > 1$ elements over $R$.
Then can factor $R \to A$ as a composition of two finite ring maps
where in both steps the number of generators is $< n$.
Since we have Lemma \ref{lemma-composition-shriek-algebraic} and
Lemma \ref{lemma-composition-right-adjoints}
we conclude that it suffices
to prove the lemma when $A$ is generated by one element over $R$.
Since $A$ is finite over $R$, it follows that $A$ is a quotient
of $B = R[x]/(f)$ where $f$ is a monic polynomial in $x$
(Algebra, Lemma \ref{algebra-lemma-finite-is-integral}).
Again using the lemmas on composition and the fact that we
have agreement for surjections by definition, we conclude that
it suffices to prove the lemma for $R \to B = R[x]/(f)$.
In this case, the functor $\varphi^!$ is isomorphic to
$K \mapsto K \otimes_R^\mathbf{L} B$; you prove this by
using Lemma \ref{lemma-compute-for-effective-Cartier-algebraic}
for the map $R[x] \to B$ (note that the shift in the definition
of $\varphi^!$ and in the lemma add up to zero).
For the functor $R\Hom(B, -) : D(R) \to D(B)$ we can use
Lemma \ref{lemma-RHom-is-tensor-special}
to see that it suffices to show $\Hom_R(B, R) \cong B$
as $B$-modules. Suppose that $f$ has degree $d$.
Then an $R$-basis for $B$ is given by $1, x, \ldots, x^{d - 1}$.
Let $\delta_i : B \to R$, $i = 0, \ldots, d - 1$
be the $R$-linear map which picks off the coefficient
of $x^i$ with respect to the given basis. Then
$\delta_0, \ldots, \delta_{d - 1}$ is a basis for $\Hom_R(B, R)$.
Finally, for $0 \leq i \leq d - 1$ a computation shows that
$$
x^i \delta_{d - 1} =
\delta_{d - 1 - i} + b_1 \delta_{d - i} + \ldots + b_i \delta_{d - 1}
$$
for some $c_1, \ldots, c_d \in R$\footnote{If
$f = x^d + a_1 x^{d - 1} + \ldots + a_d$, then
$c_1 = -a_1$, $c_2 = a_1^2 - a_2$, $c_3 = -a_1^3 + 2a_1a_2 -a_3$, etc.}.
Hence $\Hom_R(B, R)$ is a principal $B$-module with generator
$\delta_{d - 1}$. By looking
at ranks we conclude that it is a rank $1$ free $B$-module.
\end{proof}

\begin{lemma}
\label{lemma-upper-shriek-localize}
Let $R$ be a Noetherian ring and let $f \in R$.
If $\varphi$ denotes the map $R \to R_f$, then $\varphi^!$
is isomorphic to $- \otimes_R^\mathbf{L} R_f$.
More generally, if $\varphi : R \to R'$ is a map such that
$\Spec(R') \to \Spec(R)$ is an open immersion, then
$\varphi^!$ is isomorphic to $- \otimes_R^\mathbf{L} R'$.
\end{lemma}

\begin{proof}
Choose the presentation $R \to R[x] \to R[x]/(fx - 1) = R_f$ and observe
that $fx - 1$ is a nonzerodivisor in $R[x]$. Thus we can apply
using Lemma \ref{lemma-compute-for-effective-Cartier-algebraic}
to compute the functor $\varphi^!$. Details omitted;
note that the shift in the definition
of $\varphi^!$ and in the lemma add up to zero.

\medskip\noindent
In the general case note that $R' \otimes_R R' = R'$.
Hence the result follows from the base change results
above. Either Lemma \ref{lemma-flat-bc} or
Lemma \ref{lemma-bc} will do.
\end{proof}

\begin{lemma}
\label{lemma-upper-shriek-is-tensor-functor}
Let $\varphi : R \to A$ be a perfect homomorphism of Noetherian rings
(for example $\varphi$ is flat of finite type).
Then $\varphi^!(K) = K \otimes_R^\mathbf{L} \varphi^!(R)$
for $K \in D(R)$.
\end{lemma}

\begin{proof}
(The parenthetical statement follows from
More on Algebra, Lemma
\ref{more-algebra-lemma-flat-finite-presentation-perfect}.)
We can choose a factorization $R \to P \to A$ where $P$ is a polynomial
ring in $n$ variables over $R$ and then $A$ is a perfect $P$-module, see
More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}.
Recall that $\varphi^!(K) = R\Hom(A, K \otimes_R^\mathbf{L} P[n])$.
Thus the result follows from
Lemma \ref{lemma-RHom-is-tensor-special}
and More on Algebra, Lemma \ref{more-algebra-lemma-double-base-change}.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-if-have-omega}
Let $\varphi : A \to B$ be a finite type homomorphism of Noetherian rings.
Let $\omega_A^\bullet$ be a dualizing complex for $A$. Set
$\omega_B^\bullet = \varphi^!(\omega_A^\bullet)$. Denote
$D_A(K) = R\Hom_A(K, \omega_A^\bullet)$ for $K \in D_{\textit{Coh}}(A)$
and
$D_B(L) = R\Hom_B(L, \omega_B^\bullet)$ for $L \in D_{\textit{Coh}}(B)$.
Then there is a functorial isomorphism
$$
\varphi^!(K) = D_B(D_A(K) \otimes_A^\mathbf{L} B)
$$
for $K \in D_{\textit{Coh}}(A)$.
\end{lemma}

\begin{proof}
Observe that $\omega_B^\bullet$ is a dualizing complex for $B$ by
Lemma \ref{lemma-shriek-dualizing-algebraic}.
Let $A \to B \to C$ be finite type homomorphisms of Noetherian rings.
If the lemma holds for $A \to B$ and $B \to C$, then the lemma holds for
$A \to C$. This follows from
Lemma \ref{lemma-composition-shriek-algebraic}
and the fact that $D_B \circ D_B \cong \text{id}$ by
Lemma \ref{lemma-dualizing}.
Thus it suffices to prove the lemma in case $A \to B$ is
a surjection and in the case where $B$ is a
polynomial ring over $A$.

\medskip\noindent
Assume $B = A[x_1, \ldots, x_n]$. Since $D_A \circ D_A \cong \text{id}$,
it suffices to prove
$D_B(K \otimes_A B) \cong D_A(K) \otimes_A B[n]$ for $K$
in $D_{\textit{Coh}}(A)$.
Choose a bounded complex $I^\bullet$ of injectives representing
$\omega_A^\bullet$. Choose a quasi-isomorphism
$I^\bullet \otimes_A B \to J^\bullet$ where $J^\bullet$
is a bounded complex of $B$-modules. Given a complex
$K^\bullet$ of $A$-modules, consider the obvious
map of complexes
$$
\Hom^\bullet(K^\bullet, I^\bullet) \otimes_A B[n]
\longrightarrow
\Hom^\bullet(K^\bullet \otimes_A B, J^\bullet[n])
$$
The left hand side represents $D_A(K) \otimes_A B[n]$ and the right hand
side represents $D_B(K \otimes_A B)$. Thus it suffices to prove this
map is a quasi-isomorphism if the cohomology modules
of $K^\bullet$ are finite $A$-modules. Observe that the
cohomology of the complex in degree $r$ (on either side)
only depends on finitely many of the $K^i$. Thus we may
replace $K^\bullet$ by a truncation, i.e., we may assume
$K^\bullet$ represents an object of $D^-_{\textit{Coh}}(A)$.
Then $K^\bullet$ is quasi-isomorphic to a bounded
above complex of finite free $A$-modules.
Therefore we may assume $K^\bullet$ is a bounded
above complex of finite free $A$-modules.
In this case it is easy to that the
displayed map is an isomorphism of complexes which finishes
the proof in this case.

\medskip\noindent
Assume that $A \to B$ is surjective. Denote $i_* : D(B) \to D(A)$
the restriction functor and recall that $\varphi^!(-) = R\Hom(A, -)$
is a right adjoint to $i_*$ (Lemma \ref{lemma-right-adjoint}).
For $F \in D(B)$ we have
\begin{align*}
\Hom_B(F, D_B(D_A(K) \otimes_A^\mathbf{L} B))
& =
\Hom_B((D_A(K) \otimes_A^\mathbf{L} B) \otimes_B^\mathbf{L} F,
\omega_B^\bullet) \\
& =
\Hom_A(D_A(K) \otimes_A^\mathbf{L} i_*F, \omega_A^\bullet) \\
& =
\Hom_A(i_*F, D_A(D_A(K))) \\
& =
\Hom_A(i_*F, K) \\
& =
\Hom_B(F, \varphi^!(K))
\end{align*}
The first equality follows from More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom} and the definition
of $D_B$. The second equality by the adjointness mentioned
above and the equality
$i_*((D_A(K) \otimes_A^\mathbf{L} B) \otimes_B^\mathbf{L} F) =
D_A(K) \otimes_A^\mathbf{L} i_*F$
(More on Algebra, Lemma \ref{more-algebra-lemma-derived-base-change}).
The third equality follows from More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom}. The fourth because
$D_A \circ D_A = \text{id}$. The final equality by adjointness again.
Thus the result holds by the Yoneda lemma.
\end{proof}






\section{Relative dualizing complexes in the Noetherian case}
\label{section-relative-dualizing-complexes-Noetherian}

\noindent
Let $\varphi : R \to A$ be a finite type homomorphism of
Noetherian rings. Then we define the {\it relative dualizing
complex of $A$ over $R$} as the object
$$
\omega_{A/R}^\bullet = \varphi^!(R)
$$
of $D(A)$. Here $\varphi^!$ is as in
Section \ref{section-relative-dualizing-complex-algebraic}.
From the material in that section we see that
$\omega_{A/R}^\bullet$ is well defined up to (non-unique) isomorphism.

\begin{lemma}
\label{lemma-base-change-relative-algebraic}
Let $R \to R'$ be a homomorphism of Noetherian rings.
Let $R \to A$ be of finite type. Set $A' = A \otimes_R R'$. If
\begin{enumerate}
\item $R \to R'$ is flat, or
\item $R \to A$ is flat, or
\item $R \to A$ is perfect
and $R'$ and $A$ are tor independent over $R$,
\end{enumerate}
then there is an isomorphism
$\omega_{A/R}^\bullet \otimes_A^\mathbf{L} A' \to \omega^\bullet_{A'/R'}$
in $D(A')$.
\end{lemma}

\begin{proof}
Follows from Lemmas \ref{lemma-flat-bc}, \ref{lemma-bc-flat}, and
\ref{lemma-bc} and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-algebraic}
Let $\varphi : R \to A$ be a flat finite type map of Noetherian rings.
Then
\begin{enumerate}
\item $\omega_{A/R}^\bullet$ is in $D^b_{\textit{Coh}}(A)$
and $R$-perfect (More on Algebra,
Definition \ref{more-algebra-definition-relatively-perfect}),
\item $A \to R\Hom_A(\omega_{A/R}^\bullet, \omega_{A/R}^\bullet)$
is an isomorphism, and
\item for every map $R \to k$ to a field the base change
$\omega_{A/R}^\bullet \otimes_A^\mathbf{L} (A \otimes_R k)$
is a dualizing complex for $A \otimes_R k$.
\end{enumerate}
\end{lemma}

\begin{proof}
Choose $R \to P \to A$ as in the definition of $\varphi^!$.
Recall that $R \to A$ is a perfect ring map
(More on Algebra, Lemma
\ref{more-algebra-lemma-flat-finite-presentation-perfect}) and
hence $A$ is perfect as a $P$-modue
(More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}).
This shows that $\omega_{A/R}^\bullet$ is in $D^b_{\textit{Coh}}(A)$
by Lemma \ref{lemma-shriek-boundedness}.
To show $\omega_{A/R}^\bullet$ is $R$-perfect it suffices to
show it has finite tor dimension as a complex of $R$-modules.
This is true because
$\omega_{A/R}^\bullet = \varphi^!(R) = R\Hom(A, P)[n]$
maps to $R\Hom_P(A, P)[n]$ in $D(P)$, which is perfect in $D(P)$
(More on Algebra, Lemma \ref{more-algebra-lemma-dual-perfect-complex}),
hence has finite tor dimension in $D(R)$
as $R \to P$ is flat. This proves (1).

\medskip\noindent
Proof of (2). The object
$R\Hom_A(\omega_{A/R}^\bullet, \omega_{A/R}^\bullet)$
of $D(A)$ maps in $D(P)$ to
\begin{align*}
R\Hom_P(\omega_{A/R}^\bullet, R\Hom(A, P)[n])
& =
R\Hom_P(R\Hom_P(A, P)[n], P)[n] \\
& =
R\Hom_P(R\Hom_P(A, P), P)
\end{align*}
This is equal to $A$ by the already used
More on Algebra, Lemma \ref{more-algebra-lemma-dual-perfect-complex}.

\medskip\noindent
Proof of (3). By Lemma \ref{lemma-base-change-relative-algebraic}
there is an isomorphism
$$
\omega_{A/R}^\bullet \otimes_A^\mathbf{L} (A \otimes_R k) \cong
\omega^\bullet_{A \otimes_R k/k}
$$
and the right hand side is a dualizing complex by
Lemma \ref{lemma-shriek-dualizing-algebraic}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-dualizing-over-field}
Let $K/k$ be an extension of fields. Let $A$ be a finite type
$k$-algebra. Let $A_K = A \otimes_k K$. If
$\omega_A^\bullet$ is a dualizing complex for $A$, then
$\omega_A^\bullet \otimes_A A_K$ is a dualizing complex for $A_K$.
\end{lemma}

\begin{proof}
By the uniqueness of dualizing complexes, it doesn't matter which
dualizing complex we pick for $A$; we omit the detailed proof.
Denote $\varphi : k \to A$ the algebra structure.
We may take $\omega_A^\bullet = \varphi^!(k[0])$ by
Lemma \ref{lemma-shriek-dualizing-algebraic}.
We conclude by
Lemma \ref{lemma-relative-dualizing-algebraic}.
\end{proof}

\begin{lemma}
\label{lemma-lci-shriek}
Let $\varphi : R \to A$ be a local complete intersection homomorphism of
Noetherian rings. Then $\omega_{A/R}^\bullet$ is an invertible object of
$D(A)$ and $\varphi^!(K) = K \otimes_R^\mathbf{L} \omega_{A/R}^\bullet$
for all $K \in D(R)$.
\end{lemma}

\begin{proof}
Recall that a local complete intersection homomorphism is a perfect
ring map by More on Algebra, Lemma \ref{more-algebra-lemma-lci-perfect}.
Hence the final statement holds by
Lemma \ref{lemma-upper-shriek-is-tensor-functor}.
By More on Algebra, Definition
\ref{more-algebra-definition-local-complete-intersection}
we can write $A = R[x_1, \ldots, x_n]/I$ where $I$ is a
Koszul-regular ideal.
The construction of $\varphi^!$ in
Section \ref{section-relative-dualizing-complex-algebraic}
shows that it suffices to show the lemma in case
$A = R/I$ where $I \subset R$ is a Koszul-regular ideal.
Checking $\omega_{A/R}^\bullet$ is invertible in $D(A)$
is local on $\Spec(A)$ by More on Algebra, Lemma
\ref{more-algebra-lemma-invertible-derived}.
Moreover, formation of $\omega_{A/R}^\bullet$ commutes with
localization on $R$ by Lemma \ref{lemma-flat-bc}.
Combining
More on Algebra, Definition \ref{more-algebra-definition-regular-ideal} and
Lemma \ref{more-algebra-lemma-noetherian-finite-all-equivalent} and
Algebra, Lemma \ref{algebra-lemma-regular-sequence-in-neighbourhood}
we can find $g_1, \ldots, g_r \in R$ generating the unit ideal in $A$
such that $I_{g_j} \subset R_{g_j}$ is generated by a regular sequence.
Thus we may assume $A = R/(f_1, \ldots, f_c)$ where $f_1, \ldots, f_c$
is a regular sequence in $R$. Then we consider the ring maps
$$
R \to R/(f_1) \to R/(f_1, f_2) \to \ldots \to R/(f_1, \ldots, f_c) = A
$$
and we use Lemma \ref{lemma-composition-shriek-algebraic}
(and the final statement already proven)
to see that it suffices to prove the lemma for each step.
Finally, in case $A = R/(f)$ for some nonzerodivisor $f$
we see that the lemma is true since $\varphi^!(R) = R\Hom(A, R)$
is invertible by Lemma \ref{lemma-compute-for-effective-Cartier-algebraic}.
\end{proof}

\begin{lemma}
\label{lemma-gorenstein-shriek}
Let $\varphi : R \to A$ be a flat finite type homomorphism of Noetherian rings.
The following are equivalent
\begin{enumerate}
\item the fibres $A \otimes_R \kappa(\mathfrak p)$ are Gorenstein
for all primes $\mathfrak p \subset R$, and
\item $\omega_{A/R}^\bullet$ is an invertible object of $D(A)$, see
More on Algebra, Lemma \ref{more-algebra-lemma-invertible-derived}.
\end{enumerate}
\end{lemma}

\begin{proof}
If (2) holds, then the fibre rings $A \otimes_R \kappa(\mathfrak p)$
have invertible dualizing complexes, and hence are Gorenstein.
See Lemmas \ref{lemma-relative-dualizing-algebraic} and \ref{lemma-gorenstein}.

\medskip\noindent
For the converse, assume (1).
Observe that $\omega_{A/R}^\bullet$ is in $D^b_{\textit{Coh}}(A)$
by Lemma \ref{lemma-shriek-boundedness} (since flat finite type homomorphisms
of Noetherian rings are perfect, see 
More on Algebra, Lemma
\ref{more-algebra-lemma-flat-finite-presentation-perfect}).
Take a prime $\mathfrak q \subset A$ lying over $\mathfrak p \subset R$.
Then
$$
\omega_{A/R}^\bullet \otimes_A^\mathbf{L} \kappa(\mathfrak q) =
\omega_{A/R}^\bullet \otimes_A^\mathbf{L}
(A \otimes_R \kappa(\mathfrak p))
\otimes_{(A \otimes_R \kappa(\mathfrak p))}^\mathbf{L}
\kappa(\mathfrak q)
$$
Applying Lemmas \ref{lemma-relative-dualizing-algebraic} and
\ref{lemma-gorenstein} and assumption (1) we find that this complex has $1$
nonzero cohomology group which is a $1$-dimensional
$\kappa(\mathfrak q)$-vector space. By
More on Algebra, Lemma
\ref{more-algebra-lemma-lift-bounded-pseudo-coherent-to-perfect}
we conclude that $(\omega_{A/R}^\bullet)_f$ is an invertible
object of $D(A_f)$ for some $f \in A$, $f \not \in \mathfrak q$.
This proves (2) holds.
\end{proof}

\noindent
The following lemma is useful to see how dimension functions change
when passing to a finite type algebra over a Noetherian ring.

\begin{lemma}
\label{lemma-shriek-normalized}
Let $\varphi : R \to A$ be a finite type homomorphism of Noetherian rings.
Assume $R$ local and let $\mathfrak m \subset A$ be a maximal
ideal lying over the maximal ideal of $R$. If $\omega_R^\bullet$
is a normalized dualizing complex for $R$, then
$\varphi^!(\omega_R^\bullet)_\mathfrak m$ is a normalized
dualizing complex for $A_\mathfrak m$.
\end{lemma}

\begin{proof}
We already know that $\varphi^!(\omega_R^\bullet)$ is a dualizing
complex for $A$, see Lemma \ref{lemma-shriek-dualizing-algebraic}.
Choose a factorization $R \to P \to A$ with $P = R[x_1, \ldots, x_n]$
as in the construction of $\varphi^!$. If we can prove the
lemma for $R \to P$ and the maximal ideal $\mathfrak m'$ of $P$ corresponding to
$\mathfrak m$, then we obtain the result for $R \to A$ by
applying Lemma \ref{lemma-normalized-quotient} to
$P_{\mathfrak m'} \to A_\mathfrak m$ or by applying
Lemma \ref{lemma-quotient-function} to $P \to A$.
In the case $A = R[x_1, \ldots, x_n]$ we see that
$\dim(A_\mathfrak m) = \dim(R) + n$ for example by
Algebra, Lemma \ref{algebra-lemma-dimension-base-fibre-equals-total}
(combined with Algebra, Lemma \ref{algebra-lemma-dim-affine-space}
to compute the dimension of the fibre).
The fact that $\omega_R^\bullet$ is normalized means
that $i = -\dim(R)$ is the smallest index such that
$H^i(\omega_R^\bullet)$ is nonzero (follows from
Lemmas \ref{lemma-sitting-in-degrees} and
\ref{lemma-nonvanishing-generically-local}).
Then $\varphi^!(\omega_R^\bullet)_\mathfrak m =
\omega_R^\bullet \otimes_R A_\mathfrak m[n]$
has its first nonzero cohomology module in degree $-\dim(R) - n$
and therefore is the normalized dualizing complex for $A_\mathfrak m$.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-trivial-vanishing}
Let $R \to A$ be a finite type homomorphism of Noetherian rings.
Let $\mathfrak q \subset A$ be a prime ideal lying over
$\mathfrak p \subset R$. Then
$$
H^i(\omega_{A/R}^\bullet)_\mathfrak q \not = 0
\Rightarrow - d \leq i
$$
where $d$ is the dimension of the fibre of $\Spec(A) \to \Spec(R)$
over $\mathfrak p$ at the point $\mathfrak q$.
\end{lemma}

\begin{proof}
Choose a factorization $R \to P \to A$ with $P = R[x_1, \ldots, x_n]$
as in Section \ref{section-relative-dualizing-complex-algebraic}
so that $\omega_{A/R}^\bullet = R\Hom(A, P)[n]$.
We have to show that $R\Hom(A, P)_\mathfrak q$
has vanishing cohomology in degrees $< n - d$.
By Lemma \ref{lemma-RHom-ext} this means we have to
show that $\Ext_P^i(P/I, P)_{\mathfrak r} = 0$ for $i < n - d$
where $\mathfrak r \subset P$ is the prime corresponding to $\mathfrak q$
and $I$ is the kernel of $P \to A$.
We may rewrite this as
$\Ext_{P_\mathfrak r}^i(P_\mathfrak r/IP_\mathfrak r, P_\mathfrak r)$
by More on Algebra, Lemma
\ref{more-algebra-lemma-pseudo-coherence-and-base-change-ext}.
Thus we have to show
$$
\text{depth}_{IP_\mathfrak r}(P_\mathfrak r) \geq n - d
$$
by Lemma \ref{lemma-depth}.
By Lemma \ref{lemma-depth-flat-CM} we have
$$
\text{depth}_{IP_\mathfrak r}(P_\mathfrak r) \geq
\dim((P \otimes_R \kappa(\mathfrak p))_\mathfrak r) -
\dim((P/I \otimes_R \kappa(\mathfrak p))_\mathfrak r)
$$
The two expressions on the right hand side agree by
Algebra, Lemma \ref{algebra-lemma-codimension}.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-flat-vanishing}
Let $R \to A$ be a flat finite type homomorphism of Noetherian rings.
Let $\mathfrak q \subset A$ be a prime ideal lying over
$\mathfrak p \subset R$. Then
$$
H^i(\omega_{A/R}^\bullet)_\mathfrak q \not = 0
\Rightarrow - d \leq i \leq 0
$$
where $d$ is the dimension of the fibre of $\Spec(A) \to \Spec(R)$
over $\mathfrak p$ at the point $\mathfrak q$. If all fibres of
$\Spec(A) \to \Spec(R)$ have dimension $\leq d$, then
$\omega_{A/R}^\bullet$ has tor amplitude in $[-d, 0]$
as a complex of $R$-modules.
\end{lemma}

\begin{proof}
The lower bound has been shown in
Lemma \ref{lemma-relative-dualizing-trivial-vanishing}.
Choose a factorization $R \to P \to A$ with $P = R[x_1, \ldots, x_n]$
as in Section \ref{section-relative-dualizing-complex-algebraic}
so that $\omega_{A/R}^\bullet = R\Hom(A, P)[n]$.
The upper bound means that $\Ext^i_P(A, P)$ is zero for $i > n$.
This follows from
More on Algebra, Lemma \ref{more-algebra-lemma-perfect-over-polynomial-ring}
which shows that $A$ is a perfect $P$-module with
tor amplitude in $[-n, 0]$.

\medskip\noindent
Proof of the final statement. Let $R \to R'$ be a ring homomorphism
of Noetherian rings. Set $A' = A \otimes_R R'$. Then
$$
\omega_{A'/R'}^\bullet =
\omega_{A/R}^\bullet \otimes_A^\mathbf{L} A' =
\omega_{A/R}^\bullet \otimes_R^\mathbf{L} R'
$$
The first isomorphism by Lemma \ref{lemma-base-change-relative-algebraic}
and the second, which takes place in $D(R')$, by
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-comparison}.
By the first part of the proof
(note that the fibres of $\Spec(A') \to \Spec(R')$ have dimension $\leq d$)
we conclude that $\omega_{A/R}^\bullet \otimes_R^\mathbf{L} R'$
has cohomology only in degrees $[-d, 0]$. Taking $R' = R \oplus M$
to be the square zero thickening of $R$ by a finite $R$-module $M$,
we see that $R\Hom(A, P) \otimes_R^\mathbf{L} M$
has cohomology only in the interval $[-d, 0]$ for any finite $R$-module $M$.
Since any $R$-module is a filtered colimit of finite $R$-modules
and since tensor products commute with colimits we conclude.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-CM-vanishing}
Let $R \to A$ be a finite type homomorphism of Noetherian rings.
Let $\mathfrak p \subset R$ be a prime ideal. Assume
\begin{enumerate}
\item $R_\mathfrak p$ is Cohen-Macaulay, and
\item for any minimal prime $\mathfrak q \subset A$ we have
$\text{trdeg}_{\kappa(R \cap \mathfrak q)} \kappa(\mathfrak q) \leq r$.
\end{enumerate}
Then
$$
H^i(\omega_{A/R}^\bullet)_\mathfrak p \not = 0 \Rightarrow - r \leq i
$$
and $H^{-r}(\omega_{A/R}^\bullet)_\mathfrak p$ is $(S_2)$
as an $A_\mathfrak p$-module.
\end{lemma}

\begin{proof}
We may replace $R$ by $R_\mathfrak p$ by
Lemma \ref{lemma-base-change-relative-algebraic}.
Thus we may assume $R$ is a Cohen-Macaulay local ring
and we have to show the assertions of the lemma
for the $A$-modules $H^i(\omega_{A/R}^\bullet)$.

\medskip\noindent
Let $R^\wedge$ be the completion of $R$.
The map $R \to R^\wedge$ is flat and $R^\wedge$ is Cohen-Macaulay
(More on Algebra, Lemma \ref{more-algebra-lemma-completion-CM}).
Observe that the minimal primes of $A \otimes_R R^\wedge$
lie over minimal primes of $A$ by the flatness of
$A \to A \otimes_R R^\wedge$ (and going down for flatness, see
Algebra, Lemma \ref{algebra-lemma-flat-going-down}).
Thus condition (2) holds for the finite type ring map
$R^\wedge \to A \otimes_R R^\wedge$ by
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change}.
Appealing to Lemma \ref{lemma-base-change-relative-algebraic}
once again it suffices to prove the lemma for
$R^\wedge \to A \otimes_R R^\wedge$. In this way, using
Lemma \ref{lemma-ubiquity-dualizing},
we may assume $R$ is a Noetherian local
Cohen-Macaulay ring which has a dualizing complex $\omega_R^\bullet$.

\medskip\noindent
Let $\mathfrak m \subset A$ be a maximal ideal.
It suffices to show that the assertions of
the lemma hold for $H^i(\omega_{A/R}^\bullet)_\mathfrak m$.
If $\mathfrak m$ does not lie over the maximal ideal of $R$,
then we replace $R$ by a localization to reduce to this case
(small detail omitted). 

\medskip\noindent
We may assume $\omega_R^\bullet$ is normalized.
Setting $d = \dim(R)$ we see that $\omega_R^\bullet = \omega_R[d]$
for some $R$-module $\omega_R$, see
Lemma \ref{lemma-apply-CM}. Set
$\omega_A^\bullet = \varphi^!(\omega_R^\bullet)$.
By Lemma \ref{lemma-relative-dualizing-if-have-omega} we have
$$
\omega_{A/R}^\bullet =
R\Hom_A(\omega_R[d] \otimes_R^\mathbf{L} A, \omega_A^\bullet)
$$
By the dimension formula we have $\dim(A_\mathfrak m) \leq d + r$, see
Morphisms, Lemma \ref{morphisms-lemma-dimension-formula-general}
and use that $\kappa(\mathfrak m)$ is finite over the residue field of $R$
by the Hilbert Nullstellensatz.
By Lemma \ref{lemma-shriek-normalized}
we see that $(\omega_A^\bullet)_\mathfrak m$
is a normalized dualizing complex for $A_\mathfrak m$.
Hence $H^i((\omega_A^\bullet)_\mathfrak m)$ is nonzero
only for $-d - r \leq i \leq 0$, see
Lemma \ref{lemma-sitting-in-degrees}.
Since $\omega_R[d] \otimes_R^\mathbf{L} A$ lives in
degrees $\leq -d$ we conclude the vanishing holds.
Finally, we also see that
$$
H^{-r}(\omega_{A/R}^\bullet)_\mathfrak m =
\Hom_A(\omega_R \otimes_R A, H^{-d - r}(\omega_A^\bullet))_\mathfrak m
$$
Since $H^{-d - r}(\omega_A^\bullet)_\mathfrak m$ is $(S_2)$ by
Lemma \ref{lemma-depth-dualizing-module}
we find that the final statement is true by
More on Algebra, Lemma \ref{more-algebra-lemma-hom-into-S2}.
\end{proof}



\section{More on dualizing complexes}
\label{section-more-dualizing}

\noindent
Some lemmas which don't fit anywhere else very well.

\begin{lemma}
\label{lemma-descent}
Let $A \to B$ be a faithfully flat map of Noetherian rings.
If $K \in D(A)$ and $K \otimes_A^\mathbf{L} B$
is a dualizing complex for $B$, then $K$ is a dualizing complex
for $A$.
\end{lemma}

\begin{proof}
Since $A \to B$ is flat we have
$H^i(K) \otimes_A B = H^i(K \otimes_A^\mathbf{L} B)$.
Since $K \otimes_A^\mathbf{L} B$ is in $D^b_{\textit{Coh}}(B)$
we first find that $K$ is in $D^b(A)$ and then we see that
$H^i(K)$ is a finite $A$-module by
Algebra, Lemma \ref{algebra-lemma-descend-properties-modules}.
Let $M$ be a finite $A$-module. Then
$$
R\Hom_A(M, K) \otimes_A B = R\Hom_B(M \otimes_A B, K \otimes_A^\mathbf{L} B)
$$
by More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}.
Since $K \otimes_A^\mathbf{L} B$ has finite injective dimension,
say injective-amplitude in $[a, b]$, we see that the right hand side
has vanishing cohomology in degrees $> b$.
Since $A \to B$ is faithfully flat, we find
that $R\Hom_A(M, K)$ has vanishing cohomology in degrees $> b$.
Thus $K$ has finite injective dimension by
More on Algebra, Lemma \ref{more-algebra-lemma-injective-amplitude}.
To finish the proof we have to show that the map
$A \to R\Hom_A(K, K)$ is an isomorphism.
For this we again use
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}
and the fact that
$B \to R\Hom_B(K \otimes_A^\mathbf{L} B, K \otimes_A^\mathbf{L} B)$
is an isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-descent-ascent}
Let $\varphi : A \to B$ be a homomorphism of Noetherian rings. Assume
\begin{enumerate}
\item $A \to B$ is syntomic and induces a surjective map on spectra, or
\item $A \to B$ is a faithfully flat local complete intersection, or
\item $A \to B$ is faithfully flat of finite type with Gorenstein fibres.
\end{enumerate}
Then $K \in D(A)$ is a dualizing complex for $A$ if and only if
$K \otimes_A^\mathbf{L} B$ is a dualizing complex for $B$.
\end{lemma}

\begin{proof}
Observe that $A \to B$ satisfies (1) if and only if $A \to B$
satisfies (2) by  More on Algebra, Lemma \ref{more-algebra-lemma-syntomic-lci}.
Observe that in both (2) and (3) the relative dualzing
complex $\varphi^!(A) = \omega_{B/A}^\bullet$ is an invertible
object of $D(B)$, see
Lemmas \ref{lemma-lci-shriek} and \ref{lemma-gorenstein-shriek}.
Moreover we have
$\varphi^!(K) = K \otimes_A^\mathbf{L} \omega_{B/A}^\bullet$
in both cases, see Lemma \ref{lemma-upper-shriek-is-tensor-functor}
for case (3).
Thus $\varphi^!(K)$ is the same as $K \otimes_A^\mathbf{L} B$
up to tensoring with an invertible object of $D(B)$.
Hence $\varphi^!(K)$ is a dualizing complex for $B$
if and only if $K \otimes_A^\mathbf{L} B$ is
(as being a dualizing complex is local and invariant under shifts).
Thus we see that if $K$ is dualizing for $A$, then
$K \otimes_A^\mathbf{L} B$ is dualizing for $B$ by
Lemma \ref{lemma-shriek-dualizing-algebraic}.
To descend the property, see
Lemma \ref{lemma-descent}.
\end{proof}

\begin{lemma}
\label{lemma-injective-hull-goes-up}
Let $(A, \mathfrak m, \kappa) \to (B, \mathfrak n, l)$
be a flat local homorphism of Noetherian rings such that
$\mathfrak n = \mathfrak m B$. If $E$ is the injective
hull of $\kappa$, then $E \otimes_A B$ is the injective
hull of $l$.
\end{lemma}

\begin{proof}
Write $E = \bigcup E_n$ as in Lemma \ref{lemma-union-artinian}.
It suffices to show that $E_n \otimes_{A/\mathfrak m^n} B/\mathfrak n^n$
is the injective hull of $l$ over $B/\mathfrak n$.
This reduces us to the case where $A$ and $B$ are Artinian local.
Observe that $\text{length}_A(A) = \text{length}_B(B)$ and
$\text{length}_A(E) = \text{length}_B(E \otimes_A B)$
by Algebra, Lemma \ref{algebra-lemma-pullback-module}.
By Lemma \ref{lemma-finite} we have
$\text{length}_A(E) = \text{length}_A(A)$ and
$\text{length}_B(E') = \text{length}_B(B)$
where $E'$ is the injective hull of $l$ over $B$.
We conclude $\text{length}_B(E') = \text{length}_B(E \otimes_A B)$.
Observe that
$$
\dim_l((E \otimes_A B)[\mathfrak n]) =
\dim_l(E[\mathfrak m] \otimes_A B) =
\dim_\kappa(E[\mathfrak m]) = 1
$$
where we have used flatness of $A \to B$ and $\mathfrak n = \mathfrak mB$.
Thus there is an injective $B$-module map $E \otimes_A B \to E'$
by Lemma \ref{lemma-torsion-submodule-sum-injective-hulls}.
By equality of lengths shown above this is an isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-injective-goes-up}
Let $\varphi : A \to B$ be a flat homorphism of Noetherian rings such
that for all primes $\mathfrak q \subset B$ we have
$\mathfrak p B_\mathfrak q = \mathfrak qB_\mathfrak q$
where $\mathfrak p = \varphi^{-1}(\mathfrak q)$, for example
if $\varphi$ is \'etale.
If $I$ is an injective $A$-module, then $I \otimes_A B$ is
an injective $B$-module.
\end{lemma}

\begin{proof}
\'Etale maps satisfy the assumption by
Algebra, Lemma \ref{algebra-lemma-etale-at-prime}.
By Lemma \ref{lemma-sum-injective-modules} and
Proposition \ref{proposition-structure-injectives-noetherian}
we may assume $I$ is the injective hull of $\kappa(\mathfrak p)$
for some prime $\mathfrak p \subset A$.
Then $I$ is a module over $A_\mathfrak p$.
It suffices to prove $I \otimes_A B = I \otimes_{A_\mathfrak p} B_\mathfrak p$
is injective as a $B_\mathfrak p$-module, see
Lemma \ref{lemma-injective-flat}.
Thus we may assume $(A, \mathfrak m, \kappa)$ is local Noetherian
and $I = E$ is the injective hull of the residue field $\kappa$.
Our assumption implies that the Noetherian ring $B/\mathfrak m B$
is a product of fields (details omitted).
Thus there are finitely many prime ideals
$\mathfrak m_1, \ldots, \mathfrak m_n$ in $B$
lying over $\mathfrak m$ and they are all maximal ideals.
Write $E = \bigcup E_n$ as in Lemma \ref{lemma-union-artinian}.
Then $E \otimes_A B = \bigcup E_n \otimes_A B$
and $E_n \otimes_A B$ is a finite $B$-module with support
$\{\mathfrak m_1, \ldots, \mathfrak m_n\}$ hence decomposes
as a product over the localizations at $\mathfrak m_i$.
Thus $E \otimes_A B = \prod (E \otimes_A B)_{\mathfrak m_i}$.
Since $(E \otimes_A B)_{\mathfrak m_i} = E \otimes_A B_{\mathfrak m_i}$
is the injective hull of the residue field of $\mathfrak m_i$
by Lemma \ref{lemma-injective-hull-goes-up} we conclude.
\end{proof}






\section{Relative dualizing complexes}
\label{section-relative-dualizing-complexes}

\noindent
For a finite type ring map $\varphi : R \to A$ of Noetherian rings
we have the relative dualizing complex $\omega_{A/R}^\bullet = \varphi^!(R)$
considered in Section \ref{section-relative-dualizing-complexes-Noetherian}.
If $R$ is not Noetherian, a similarly constructed complex will
in general not have good properties. In this section, we give a
definition of a relative dualizing complex for a flat and finitely presented
ring maps $R \to A$ of non-Noetherian rings. The definition is
chosen to globalize to flat and finitely presented morphisms
of schemes, see Duality for Schemes, Section
\ref{duality-section-relative-dualizing-complexes}. We will
show that relative dualizing complexes exist (when the definition
applies), are unique up to (noncanonical) isomorphism,
and that in the Noetherian case we recover the complex of
Section \ref{section-relative-dualizing-complexes-Noetherian}.

\medskip\noindent
The Noetherian reader may safely skip this section!

\begin{definition}
\label{definition-relative-dualizing-complex}
Let $R \to A$ be a flat ring map of finite presentation.
A {\it relative dualizing complex} is an object $K \in D(A)$ such that
\begin{enumerate}
\item $K$ is $R$-perfect (More on Algebra, Definition
\ref{more-algebra-definition-relatively-perfect}), and
\item $R\Hom_{A \otimes_R A}(A, K \otimes_A^\mathbf{L} (A \otimes_R A))$
is isomorphic to $A$.
\end{enumerate}
\end{definition}

\noindent
To understand this definition you may have to read and understand some
of the following lemmas. Lemmas \ref{lemma-relative-dualizing-noetherian} and
\ref{lemma-uniqueness-relative-dualizing} show this definition
does not clash with the definition in
Section \ref{section-relative-dualizing-complexes-Noetherian}.

\begin{lemma}
\label{lemma-uniqueness-relative-dualizing}
Let $R \to A$ be a flat ring map of finite presentation.
Any two relative dualizing complexes for $R \to A$ are isomorphic.
\end{lemma}

\begin{proof}
Let $K$ and $L$ be two relative dualizing complexes for $R \to A$.
Denote $K_1 = K \otimes_A^\mathbf{L} (A \otimes_R A)$
and $L_2 = (A \otimes_R A) \otimes_A^\mathbf{L} L$ the
derived base changes via the first and second coprojections
$A \to A \otimes_R A$. By symmetry the assumption on $L_2$
implies that $R\Hom_{A \otimes_R A}(A, L_2)$ is isomorphic to $A$.
By More on Algebra, Lemma
\ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (3)
applied twice we have
$$
A \otimes_{A \otimes_R A}^\mathbf{L} L_2 \cong
R\Hom_{A \otimes_R A}(A, K_1 \otimes_{A \otimes_R A}^\mathbf{L} L_2) \cong
A \otimes_{A \otimes_R A}^\mathbf{L} K_1
$$
Applying the restriction functor $D(A \otimes_R A) \to D(A)$
for either coprojection we obtain the desired result.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-noetherian}
Let $\varphi : R \to A$ be a flat finite type ring map of Noetherian rings.
Then the relative dualizing complex $\omega_{A/R}^\bullet = \varphi^!(R)$
of Section \ref{section-relative-dualizing-complexes-Noetherian}
is a relative dualizing complex in the sense of
Definition \ref{definition-relative-dualizing-complex}.
\end{lemma}

\begin{proof}
From Lemma \ref{lemma-relative-dualizing-algebraic} we see that
$\varphi^!(R)$ is $R$-perfect.
Denote $\delta : A \otimes_R A \to A$ the multiplication map
and $p_1, p_2 : A \to A \otimes_R A$ the coprojections.
Then
$$
\varphi^!(R) \otimes_A^\mathbf{L} (A \otimes_R A) =
\varphi^!(R) \otimes_{A, p_1}^\mathbf{L} (A \otimes_R A) =
p_2^!(A)
$$
by Lemma \ref{lemma-flat-bc}. Recall that
$
R\Hom_{A \otimes_R A}(A, \varphi^!(R) \otimes_A^\mathbf{L} (A \otimes_R A))
$
is the image of $\delta^!(\varphi^!(R) \otimes_A^\mathbf{L} (A \otimes_R A))$
under the restriction map $\delta_* : D(A) \to D(A \otimes_R A)$.
Use the definition of $\delta^!$ from
Section \ref{section-relative-dualizing-complex-algebraic}
and Lemma \ref{lemma-RHom-ext}.
Since $\delta^!(p_2^!(A)) \cong A$ by
Lemma \ref{lemma-composition-shriek-algebraic}
we conclude.
\end{proof}

\begin{lemma}
\label{lemma-base-change-relative-dualizing}
Let $R \to A$ be a flat ring map of finite presentation. Then
\begin{enumerate}
\item there exists a relative dualizing complex $K$ in $D(A)$, and
\item for any ring map $R \to R'$ setting $A' = A \otimes_R R'$
and $K' = K \otimes_A^\mathbf{L} A'$, then $K'$ is a
relative dualizing complex for $R' \to A'$.
\end{enumerate}
Moreover, if
$$
\xi : A \longrightarrow K \otimes_A^\mathbf{L} (A \otimes_R A)
$$
is a generator for the cyclic module
$\Hom_{D(A \otimes_R A)}(A, K \otimes_A^\mathbf{L} (A \otimes_R A))$
then in (2) the derived base change of $\xi$ by
$A \otimes_R A \to A' \otimes_{R'} A'$ is a generator for
the cyclic module
$\Hom_{D(A' \otimes_{R'} A')}(A',
K' \otimes_{A'}^\mathbf{L} (A' \otimes_{R'} A'))$
\end{lemma}

\begin{proof}
We first reduce to the Noetherian case. By
Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}
there exists a finite type $\mathbf{Z}$ subalgebra $R_0 \subset R$
and a flat finite type ring map $R_0 \to A_0$ such that
$A = A_0 \otimes_{R_0} R$. By Lemma \ref{lemma-relative-dualizing-noetherian}
there exists a relative
dualizing complex $K_0 \in D(A_0)$.
Thus if we show (2) for $K_0$, then we find that
$K_0 \otimes_{A_0}^\mathbf{L} A$ is
a dualizing complex for $R \to A$ and that it also satisfies (2)
by transitivity of derived base change.
The uniqueness of relative dualizing complexes
(Lemma \ref{lemma-uniqueness-relative-dualizing})
then shows that this holds for
any relative dualizing complex.

\medskip\noindent
Assume $R$ Noetherian and let $K$ be a relative dualizing complex
for $R \to A$. Given a ring map $R \to R'$ set $A' = A \otimes_R R'$
and $K' = K \otimes_A^\mathbf{L} A'$. To finish the proof we have
to show that $K'$ is a relative dualizing complex for $R' \to A'$.
By More on Algebra, Lemma
\ref{more-algebra-lemma-base-change-relatively-perfect}
we see that $K'$ is $R'$-perfect in all cases.
By Lemmas \ref{lemma-base-change-relative-algebraic} and
\ref{lemma-relative-dualizing-noetherian}
if $R'$ is Noetherian, then $K'$ is a relative dualizing complex
for $R' \to A'$ (in either sense).
Transitivity of derived tensor product shows that
$K \otimes_A^\mathbf{L} (A \otimes_R A)
\otimes_{A \otimes_R A}^\mathbf{L} (A' \otimes_{R'} A') =
K' \otimes_{A'}^\mathbf{L} (A' \otimes_{R'} A')$.
Flatness of $R \to A$ guarantees that
$A \otimes_{A \otimes_R A}^\mathbf{L} (A' \otimes_{R'} A') = A'$;
namely $A \otimes_R A$ and $R'$ are tor independent over $R$
so we can apply More on Algebra, Lemma
\ref{more-algebra-lemma-base-change-comparison}.
Finally, $A$ is pseudo-coherent as an $A \otimes_R A$-module
by More on Algebra, Lemma
\ref{more-algebra-lemma-more-relative-pseudo-coherent-is-moot}. Thus
we have checked all the assumptions of
More on Algebra, Lemma
\ref{more-algebra-lemma-compute-RHom-relatively-perfect}.
We find there exists a bounded below complex
$E^\bullet$ of $R$-flat finitely presented $A \otimes_R A$-modules
such that $E^\bullet \otimes_R R'$ represents
$R\Hom_{A' \otimes_{R'} A'}(A',
K' \otimes_{A'}^\mathbf{L} (A' \otimes_{R'} A'))$
and these identifications are compatible with derived base change.
Let $n \in \mathbf{Z}$, $n \not = 0$.
Define $Q^n$ by the sequence
$$
E^{n - 1} \to E^n \to Q^n \to 0
$$
Since $\kappa(\mathfrak p)$ is a Noetherian ring, we know that
$H^n(E^\bullet \otimes_R \kappa(\mathfrak p)) = 0$, see remarks above.
Chasing diagrams this means that
$$
Q^n \otimes_R \kappa(\mathfrak p) \to E^{n + 1} \otimes_R \kappa(\mathfrak p)
$$
is injective. Hence for a prime $\mathfrak q$ of $A \otimes_R A$
lying over $\mathfrak p$ we have $Q^n_\mathfrak q$ is $R_\mathfrak p$-flat
and $Q^n_\mathfrak p \to E^{n + 1}_\mathfrak q$ is
$R_\mathfrak p$-universally injective, see
Algebra, Lemma \ref{algebra-lemma-mod-injective}.
Since this holds for all primes,
we conclude that $Q^n$ is $R$-flat
and $Q^n \to E^{n + 1}$ is $R$-universally injective. In particular
$H^n(E^\bullet \otimes_R R') = 0$ for any ring map $R \to R'$.
Let $Z^0 = \Ker(E^0 \to E^1)$. Since there is an exact sequence
$0 \to Z^0 \to E^0 \to E^1 \to Q^1 \to 0$ we see that $Z^0$
is $R$-flat and that
$Z^0 \otimes_R R' = \Ker(E^0 \otimes_R R' \to E^1 \otimes_R R')$
for all $R \to R'$. Then the short exact sequence
$0 \to Q^{-1} \to Z^0 \to H^0(E^\bullet) \to 0$
shows that
$$
H^0(E^\bullet \otimes_R R') = H^0(E^\bullet) \otimes_R R'
= A \otimes_R R' = A'
$$
as desired. This equality furthermore gives the final assertion
of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-RHom}
Let $R \to A$ be a flat ring map of finite presentation.
Let $K$ be a relative dualizing complex.
Then $A \to R\Hom_A(K, K)$ is an isomorphism.
\end{lemma}

\begin{proof}
By
Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}
there exists a finite type $\mathbf{Z}$ subalgebra $R_0 \subset R$
and a flat finite type ring map $R_0 \to A_0$ such that
$A = A_0 \otimes_{R_0} R$. By Lemmas
\ref{lemma-uniqueness-relative-dualizing},
\ref{lemma-relative-dualizing-noetherian}, and
\ref{lemma-base-change-relative-dualizing}
there exists a relative dualizing complex $K_0 \in D(A_0)$
and its derived base change is $K$.
This reduces us to the situation discussed in the next paragraph.

\medskip\noindent
Assume $R$ Noetherian and let $K$ be a relative dualizing complex
for $R \to A$. Given a ring map $R \to R'$ set $A' = A \otimes_R R'$
and $K' = K \otimes_A^\mathbf{L} A'$. To finish the proof we show
$R\Hom_{A'}(K', K') = A'$. By Lemma \ref{lemma-relative-dualizing-algebraic}
we know this is true whenever $R'$ is Noetherian.
Since a general $R'$ is a filtered colimit of Noetherian
$R$-algebras, we find the result holds by
More on Algebra, Lemma \ref{more-algebra-lemma-colimit-relatively-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-relative-dualizing-composition}
Let $R \to A \to B$ be a ring maps which are flat and of finite presentation.
Let $K_{A/R}$ and $K_{B/A}$ be relative dualizing complexes for $R \to A$
and $A \to B$. Then $K = K_{A/R} \otimes_A^\mathbf{L} K_{B/A}$
is a relative dualizing complex for $R \to B$.
\end{lemma}

\begin{proof}
We will use reduction to the Noetherian case.
Namely, by Algebra, Lemma
\ref{algebra-lemma-flat-finite-presentation-limit-flat}
there exists a finite type $\mathbf{Z}$ subalgebra $R_0 \subset R$
and a flat finite type ring map $R_0 \to A_0$ such that
$A = A_0 \otimes_{R_0} R$. After increasing $R_0$ and correspondingly
replacing $A_0$ we may assume there is a flat
finite type ring map $A_0 \to B_0$ such that $B = B_0 \otimes_{R_0} R$
(use the same lemma). If we prove the lemma for $R_0 \to A_0 \to B_0$,
then the lemma follows by Lemmas
\ref{lemma-uniqueness-relative-dualizing},
\ref{lemma-relative-dualizing-noetherian}, and
\ref{lemma-base-change-relative-dualizing}.
This reduces us to the situation discussed in the next paragraph.

\medskip\noindent
Assume $R$ is Noetherian and denote $\varphi : R \to A$ and
$\psi : A \to B$ the given ring maps. Then $K_{A/R} \cong \varphi^!(R)$ and
$K_{B/A} \cong \psi^!(A)$, see references given above.
Then
$$
K = K_{A/R} \otimes_A^\mathbf{L} K_{B/A} \cong
\varphi^!(R) \otimes_A^\mathbf{L} \psi^!(A) \cong
\psi^!(\varphi^!(R)) \cong (\psi \circ \varphi)^!(R)
$$
by Lemmas \ref{lemma-upper-shriek-is-tensor-functor} and
\ref{lemma-composition-shriek-algebraic}. Thus $K$ is a relative
dualizing complex for $R \to B$.
\end{proof}





\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}