File size: 252,170 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
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
\input{preamble}

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

\title{Differential Graded Algebra}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

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

\noindent
In this chapter we talk about differential graded algebras, modules,
categories, etc. A basic reference is \cite{Keller-Deriving}.
A survey paper is \cite{Keller-survey}.

\medskip\noindent
Since we do not worry about length of exposition in the Stacks project
we first develop the material in the setting of categories of differential
graded modules. After that we redo the constructions in the setting of
differential graded modules over differential graded categories.



\section{Conventions}
\label{section-conventions}

\noindent
In this chapter we hold on to the convention that {\it ring} means
commutative ring with $1$. If $R$ is a ring, then an {\it $R$-algebra $A$}
will be an $R$-module $A$ endowed with an $R$-bilinear map $A \times A \to A$
(multiplication) such that multiplication is associative and has a unit.
In other words, these are unital associative $R$-algebras
such that the structure map $R \to A$ maps into the center of $A$.

\medskip\noindent
{\bf Sign rules.} In this chapter we will work with graded algebras
and graded modules often equipped with differentials. The sign rules on
underlying complexes will always be (compatible with) those introduced in
More on Algebra, Section \ref{more-algebra-section-sign-rules}.
This will occasionally cause the multiplicative structure to be
twisted in unexpected ways especially when considering left modules
or the relationship between left and right modules.





\section{Differential graded algebras}
\label{section-dga}


\noindent
Just the definitions.

\begin{definition}
\label{definition-dga}
Let $R$ be a commutative ring. A {\it differential graded algebra over $R$}
is either
\begin{enumerate}
\item a chain complex $A_\bullet$ of $R$-modules endowed with
$R$-bilinear maps $A_n \times A_m \to A_{n + m}$,
$(a, b) \mapsto ab$ such that
$$
\text{d}_{n + m}(ab) = \text{d}_n(a)b + (-1)^n a\text{d}_m(b)
$$
and such that $\bigoplus A_n$ becomes an associative and unital
$R$-algebra, or
\item a cochain complex $A^\bullet$ of $R$-modules endowed with
$R$-bilinear maps $A^n \times A^m \to A^{n + m}$, $(a, b) \mapsto ab$
such that
$$
\text{d}^{n + m}(ab) = \text{d}^n(a)b + (-1)^n a\text{d}^m(b)
$$
and such that $\bigoplus A^n$ becomes an associative and unital $R$-algebra.
\end{enumerate}
\end{definition}

\noindent
We often just write $A = \bigoplus A_n$ or $A = \bigoplus A^n$ and
think of this as an associative unital $R$-algebra endowed with a
$\mathbf{Z}$-grading and an $R$-linear operator $\text{d}$ whose square
is zero and which satisfies the Leibniz rule as explained above. In this case
we often say ``Let $(A, \text{d})$ be a differential graded algebra''.

\medskip\noindent
The Leibniz rule relating differentials and multiplication on a differential
graded $R$-algebra $A$ exactly means that the multiplication map defines
a map of cochain complexes
$$
\text{Tot}(A^\bullet \otimes_R A^\bullet) \to A^\bullet
$$
Here $A^\bullet$ denote the underlying cochain complex of $A$.

\begin{definition}
\label{definition-homomorphism-dga}
A {\it homomorphism of differential graded algebras}
$f : (A, \text{d}) \to (B, \text{d})$ is an algebra map $f : A \to B$
compatible with the gradings and $\text{d}$.
\end{definition}

\begin{definition}
\label{definition-cdga}
A differential graded algebra $(A, \text{d})$ is {\it commutative} if
$ab = (-1)^{nm}ba$ for $a$ in degree $n$ and $b$ in degree $m$.
We say $A$ is {\it strictly commutative} if in addition $a^2 = 0$
for $\deg(a)$ odd.
\end{definition}

\noindent
The following definition makes sense in general but is perhaps
``correct'' only when tensoring commutative differential graded
algebras.

\begin{definition}
\label{definition-tensor-product}
Let $R$ be a ring.
Let $(A, \text{d})$, $(B, \text{d})$ be differential graded algebras over $R$.
The {\it tensor product differential graded algebra} of $A$ and $B$
is the algebra $A \otimes_R B$ with multiplication defined by
$$
(a \otimes b)(a' \otimes b') = (-1)^{\deg(a')\deg(b)} aa' \otimes bb'
$$
endowed with differential $\text{d}$ defined by the rule
$\text{d}(a \otimes b) = \text{d}(a) \otimes b + (-1)^m a \otimes \text{d}(b)$
where $m = \deg(a)$.
\end{definition}

\begin{lemma}
\label{lemma-total-complex-tensor-product}
Let $R$ be a ring.
Let $(A, \text{d})$, $(B, \text{d})$ be differential graded algebras over $R$.
Denote $A^\bullet$, $B^\bullet$ the underlying cochain complexes.
As cochain complexes of $R$-modules we have
$$
(A \otimes_R B)^\bullet = \text{Tot}(A^\bullet \otimes_R B^\bullet).
$$
\end{lemma}

\begin{proof}
Recall that the differential of the total complex is given by
$\text{d}_1^{p, q} + (-1)^p \text{d}_2^{p, q}$ on $A^p \otimes_R B^q$.
And this is exactly the same as the rule for the differential
on $A \otimes_R B$ in
Definition \ref{definition-tensor-product}.
\end{proof}






\section{Differential graded modules}
\label{section-modules}

\noindent
Our default in this chapter is right modules;
we discuss left modules in Section \ref{section-left-modules}.

\begin{definition}
\label{definition-dgm}
Let $R$ be a ring.
Let $(A, \text{d})$ be a differential graded algebra over $R$.
A (right) {\it differential graded module} $M$ over $A$ is a right $A$-module
$M$ which has a grading $M = \bigoplus M^n$ and a differential $\text{d}$
such that $M^n A^m \subset M^{n + m}$, such that
$\text{d}(M^n) \subset M^{n + 1}$, and such that
$$
\text{d}(ma) = \text{d}(m)a + (-1)^n m\text{d}(a)
$$
for $a \in A$ and $m \in M^n$. A
{\it homomorphism of differential graded modules} $f : M \to N$
is an $A$-module map compatible with gradings and differentials.
The category of (right) differential graded $A$-modules is denoted
$\text{Mod}_{(A, \text{d})}$.
\end{definition}

\noindent
Note that we can think of $M$ as a cochain complex $M^\bullet$
of (right) $R$-modules. Namely, for $r \in R$ we have $\text{d}(r) = 0$
and $r$ maps to a degree $0$ element of $A$, hence
$\text{d}(mr) = \text{d}(m)r$.

\medskip\noindent
The Leibniz rule relating differentials and multiplication on a differential
graded $R$-module $M$ over a differential graded $R$-algebra $A$
exactly means that the multiplication map defines a map of cochain complexes
$$
\text{Tot}(M^\bullet \otimes_R A^\bullet) \to M^\bullet
$$
Here $A^\bullet$ and $M^\bullet$ denote the underlying cochain complexes
of $A$ and $M$.

\begin{lemma}
\label{lemma-dgm-abelian}
Let $(A, d)$ be a differential graded algebra. The category
$\text{Mod}_{(A, \text{d})}$ is abelian and has arbitrary limits and colimits.
\end{lemma}

\begin{proof}
Kernels and cokernels commute with taking underlying $A$-modules.
Similarly for direct sums and colimits. In other words, these operations
in $\text{Mod}_{(A, \text{d})}$ commute with the forgetful functor to the
category of $A$-modules. This is not the case for products and limits.
Namely, if $N_i$, $i \in I$ is a family of
differential graded $A$-modules, then the product $\prod N_i$ in
$\text{Mod}_{(A, \text{d})}$ is given by setting $(\prod N_i)^n = \prod N_i^n$
and $\prod N_i = \bigoplus_n (\prod N_i)^n$. Thus we see that the product
does commute with the forgetful functor to the category of graded $A$-modules.
A category with products and equalizers has limits, see
Categories, Lemma \ref{categories-lemma-limits-products-equalizers}.
\end{proof}

\noindent
Thus, if $(A, \text{d})$ is a differential graded
algebra over $R$, then there is an exact functor
$$
\text{Mod}_{(A, \text{d})} \longrightarrow \text{Comp}(R)
$$
of abelian categories. For a differential graded module $M$ the
cohomology groups $H^n(M)$ are defined as the cohomology of the
corresponding complex of $R$-modules. Therefore, a short exact
sequence $0 \to K \to L \to M \to 0$ of differential graded modules
gives rise to a long exact sequence
\begin{equation}
\label{equation-les}
H^n(K) \to H^n(L) \to H^n(M) \to H^{n + 1}(K)
\end{equation}
of cohomology modules, see
Homology, Lemma \ref{homology-lemma-long-exact-sequence-cochain}.

\medskip\noindent
Moreover, from now on we borrow all the terminology used for
complexes of modules. For example, we say that a differential
graded $A$-module $M$ is {\it acyclic} if $H^k(M) = 0$ for
all $k \in \mathbf{Z}$. We say that a homomorphism $M \to N$
of differential graded $A$-modules is a {\it quasi-isomorphism}
if it induces isomorphisms $H^k(M) \to H^k(N)$ for all $k \in \mathbf{Z}$.
And so on and so forth.

\begin{definition}
\label{definition-shift}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded module whose underlying complex
of $R$-modules is $M^\bullet$. For any $k \in \mathbf{Z}$
we define the {\it $k$-shifted module} $M[k]$ as follows
\begin{enumerate}
\item the underlying complex of $R$-modules of $M[k]$ is $M^\bullet[k]$,
i.e., we have $M[k]^n = M^{n + k}$ and
$\text{d}_{M[k]} = (-1)^k\text{d}_M$ and
\item as $A$-module the multiplication
$$
(M[k])^n \times A^m \longrightarrow (M[k])^{n + m}
$$
is equal to the given multiplication $M^{n + k} \times A^m \to M^{n + k + m}$.
\end{enumerate}
For a morphism $f : M \to N$ of differential graded $A$-modules
we let $f[k] : M[k] \to N[k]$ be the map equal to $f$ on underlying
$A$-modules. This defines a functor
$[k] : \text{Mod}_{(A, \text{d})} \to \text{Mod}_{(A, \text{d})}$.
\end{definition}

\noindent
Let us check that with this choice the Leibniz rule is satisfied.
Let $x \in M[k]^n = M^{n + k}$ and $a \in A^m$ and denoting
$\cdot_{M[k]}$ the product in $M[k]$ then we see
\begin{align*}
\text{d}_{M[k]}(x \cdot_{M[k]} a)
& =
(-1)^k \text{d}_M(xa) \\
& =
(-1)^k \text{d}_M(x) a + (-1)^{k + n + k} x \text{d}(a) \\
& =
\text{d}_{M[k]}(x) a + (-1)^n x \text{d}(a) \\
& =
\text{d}_{M[k]}(x) \cdot_{M[k]} a + (-1)^n x \cdot_{M[k]} \text{d}(a)
\end{align*}
This is what we want as $x$ has degree $n$ as a homogeneous element of $M[k]$.
We also observe that with these choices we may think of
the multiplication map as the map of complexes
$$
\text{Tot}(M^\bullet[k] \otimes _R A^\bullet) \to
\text{Tot}(M^\bullet \otimes _R A^\bullet)[k] \to
M^\bullet[k]
$$
where the first arrow is
More on Algebra, Section \ref{more-algebra-section-sign-rules}
(\ref{more-algebra-item-shift-tensor}) which in this
case does not involve a sign. (In fact, we could have deduced
that the Liebniz rule holds from this observation.)

\medskip\noindent
The remarks in Homology, Section \ref{homology-section-homotopy-shift} apply.
In particular, we will identify the cohomology groups of all shifts
$M[k]$ without the intervention of signs.

\medskip\noindent
At this point we have enough structure to talk about {\it triangles},
see Derived Categories, Definition \ref{derived-definition-triangle}.
In fact, our next goal is to develop enough theory to be able to
state and prove that the homotopy category of differential graded
modules is a triangulated category. First we define the homotopy category.






\section{The homotopy category}
\label{section-homotopy}

\noindent
Our homotopies take into account the $A$-module structure and the
grading, but not the differential (of course).

\begin{definition}
\label{definition-homotopy}
Let $(A, \text{d})$ be a differential graded algebra. Let
$f, g : M \to N$ be homomorphisms of differential graded $A$-modules.
A {\it homotopy between $f$ and $g$} is an $A$-module map $h : M \to N$
such that
\begin{enumerate}
\item $h(M^n) \subset N^{n - 1}$ for all $n$, and
\item $f(x) - g(x) = \text{d}_N(h(x)) + h(\text{d}_M(x))$ for
all $x \in M$.
\end{enumerate}
If a homotopy exists, then we say $f$ and $g$ are {\it homotopic}.
\end{definition}

\noindent
Thus $h$ is compatible with the $A$-module structure and the grading
but not with the differential. If $f = g$ and $h$ is a homotopy
as in the definition, then $h$ defines a morphism $h : M \to N[-1]$
in $\text{Mod}_{(A, \text{d})}$.

\begin{lemma}
\label{lemma-compose-homotopy}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f, g : L \to M$ be homomorphisms of differential graded $A$-modules.
Suppose given further homomorphisms $a : K \to L$, and $c : M \to N$.
If $h : L \to M$ is an $A$-module map which defines a homotopy between
$f$ and $g$, then $c \circ h \circ a$ defines a homotopy between
$c \circ f \circ a$ and $c \circ g \circ a$.
\end{lemma}

\begin{proof}
Immediate from Homology, Lemma \ref{homology-lemma-compose-homotopy-cochain}.
\end{proof}

\noindent
This lemma allows us to define the homotopy category as follows.

\begin{definition}
\label{definition-complexes-notation}
Let $(A, \text{d})$ be a differential graded algebra.
The {\it homotopy category}, denoted $K(\text{Mod}_{(A, \text{d})})$, is
the category whose objects are the objects of
$\text{Mod}_{(A, \text{d})}$ and whose morphisms are homotopy classes
of homomorphisms of differential graded $A$-modules.
\end{definition}

\noindent
The notation $K(\text{Mod}_{(A, \text{d})})$ is not standard but at least is
consistent with the use of $K(-)$ in other places of the Stacks project.

\begin{lemma}
\label{lemma-homotopy-direct-sums}
Let $(A, \text{d})$ be a differential graded algebra.
The homotopy category $K(\text{Mod}_{(A, \text{d})})$
has direct sums and products.
\end{lemma}

\begin{proof}
Omitted. Hint: Just use the direct sums and products as in
Lemma \ref{lemma-dgm-abelian}. This works because we saw that
these functors commute with the forgetful functor to the category
of graded $A$-modules and because $\prod$ is an exact functor
on the category of families of abelian groups.
\end{proof}







\section{Cones}
\label{section-cones}

\noindent
We introduce cones for the category of differential graded modules.

\begin{definition}
\label{definition-cone}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f : K \to L$ be a homomorphism of differential graded $A$-modules.
The {\it cone} of $f$ is the differential graded $A$-module
$C(f)$ given by $C(f) = L \oplus K$ with grading
$C(f)^n = L^n \oplus K^{n + 1}$ and
differential
$$
d_{C(f)} =
\left(
\begin{matrix}
\text{d}_L & f \\
0 & -\text{d}_K
\end{matrix}
\right)
$$
It comes equipped with canonical morphisms of complexes $i : L \to C(f)$
and $p : C(f) \to K[1]$ induced by the obvious maps $L \to C(f)$
and $C(f) \to K$.
\end{definition}

\noindent
The formation of the cone triangle is functorial in the following sense.

\begin{lemma}
\label{lemma-functorial-cone}
Let $(A, \text{d})$ be a differential graded algebra.
Suppose that
$$
\xymatrix{
K_1 \ar[r]_{f_1} \ar[d]_a & L_1 \ar[d]^b \\
K_2 \ar[r]^{f_2} & L_2
}
$$
is a diagram of homomorphisms of differential graded $A$-modules which is
commutative up to homotopy.
Then there exists a morphism $c : C(f_1) \to C(f_2)$ which gives rise to
a morphism of triangles
$$
(a, b, c) : (K_1, L_1, C(f_1), f_1, i_1, p_1) \to
(K_1, L_1, C(f_1), f_2, i_2, p_2)
$$
in $K(\text{Mod}_{(A, \text{d})})$.
\end{lemma}

\begin{proof}
Let $h : K_1 \to L_2$ be a homotopy between $f_2 \circ a$ and $b \circ f_1$.
Define $c$ by the matrix
$$
c =
\left(
\begin{matrix}
b & h \\
0 & a
\end{matrix}
\right) :
L_1 \oplus K_1 \to L_2 \oplus K_2
$$
A matrix computation show that $c$ is a morphism of differential
graded modules. It is trivial that $c \circ i_1 = i_2 \circ b$, and it is
trivial also to check that $p_2 \circ c = a \circ p_1$.
\end{proof}











\section{Admissible short exact sequences}
\label{section-admissible}

\noindent
An admissible short exact sequence is the analogue of termwise split exact
sequences in the setting of differential graded modules.

\begin{definition}
\label{definition-admissible-ses}
Let $(A, \text{d})$ be a differential graded algebra.
\begin{enumerate}
\item A homomorphism $K \to L$ of differential graded $A$-modules
is an {\it admissible monomorphism} if there exists a graded $A$-module
map $L \to K$ which is left inverse to $K \to L$.
\item A homomorphism $L \to M$ of differential graded $A$-modules
is an {\it admissible epimorphism} if there exists a graded $A$-module
map $M \to L$ which is right inverse to $L \to M$.
\item A short exact sequence $0 \to K \to L \to M \to 0$ of differential
graded $A$-modules is an {\it admissible short exact sequence}
if it is split as a sequence of graded $A$-modules.
\end{enumerate}
\end{definition}

\noindent
Thus the splittings are compatible with all the data except for
the differentials. Given an admissible short exact sequence we
obtain a triangle; this is the reason that we require our splittings
to be compatible with the $A$-module structure.

\begin{lemma}
\label{lemma-admissible-ses}
Let $(A, \text{d})$ be a differential graded algebra.
Let $0 \to K \to L \to M \to 0$ be an admissible short exact sequence
of differential graded $A$-modules. Let $s : M \to L$ and $\pi : L \to K$
be splittings such that $\Ker(\pi) = \Im(s)$.
Then we obtain a morphism
$$
\delta = \pi \circ \text{d}_L \circ s : M \to K[1]
$$
of $\text{Mod}_{(A, \text{d})}$ which induces the boundary maps
in the long exact sequence of cohomology (\ref{equation-les}).
\end{lemma}

\begin{proof}
The map $\pi \circ \text{d}_L \circ s$ is compatible with the $A$-module
structure and the gradings by construction. It is compatible with
differentials by Homology, Lemmas
\ref{homology-lemma-ses-termwise-split-cochain}.
Let $R$ be the ring that $A$ is a differential graded algebra over.
The equality of maps is a statement about $R$-modules. Hence this
follows from Homology, Lemmas
\ref{homology-lemma-ses-termwise-split-cochain} and
\ref{homology-lemma-ses-termwise-split-long-cochain}.
\end{proof}

\begin{lemma}
\label{lemma-make-commute-map}
Let $(A, \text{d})$ be a differential graded algebra. Let
$$
\xymatrix{
K \ar[r]_f \ar[d]_a & L \ar[d]^b \\
M \ar[r]^g & N
}
$$
be a diagram of homomorphisms of differential graded $A$-modules
commuting up to homotopy.
\begin{enumerate}
\item If $f$ is an admissible monomorphism, then $b$ is homotopic to a
homomorphism which makes the diagram commute.
\item If $g$ is an admissible epimorphism, then $a$ is homotopic to a
morphism which makes the diagram commute.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $h : K \to N$ be a homotopy between $bf$ and $ga$, i.e.,
$bf - ga = \text{d}h + h\text{d}$. Suppose that $\pi : L \to K$
is a graded $A$-module map left inverse to $f$. Take
$b' = b - \text{d}h\pi - h\pi \text{d}$.
Suppose $s : N \to M$ is a graded $A$-module map right inverse to $g$.
Take $a' = a + \text{d}sh + sh\text{d}$.
Computations omitted.
\end{proof}

\begin{lemma}
\label{lemma-make-injective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $\alpha : K \to L$ be a homomorphism of differential graded
$A$-modules. There exists a factorization
$$
\xymatrix{
K \ar[r]^{\tilde \alpha} \ar@/_1pc/[rr]_\alpha &
\tilde L \ar[r]^\pi & L
}
$$
in $\text{Mod}_{(A, \text{d})}$ such that
\begin{enumerate}
\item $\tilde \alpha$ is an admissible monomorphism (see
Definition \ref{definition-admissible-ses}),
\item there is a morphism $s : L \to \tilde L$
such that $\pi \circ s = \text{id}_L$ and such that
$s \circ \pi$ is homotopic to $\text{id}_{\tilde L}$.
\end{enumerate}
\end{lemma}

\begin{proof}
The proof is identical to the proof of
Derived Categories, Lemma \ref{derived-lemma-make-injective}.
Namely, we set $\tilde L = L \oplus C(1_K)$ and we use elementary
properties of the cone construction.
\end{proof}

\begin{lemma}
\label{lemma-sequence-maps-split}
Let $(A, \text{d})$ be a differential graded algebra.
Let $L_1 \to L_2 \to \ldots \to L_n$
be a sequence of composable homomorphisms of
differential graded $A$-modules.
There exists a commutative diagram
$$
\xymatrix{
L_1 \ar[r] &
L_2 \ar[r] &
\ldots \ar[r] &
L_n \\
M_1 \ar[r] \ar[u] &
M_2 \ar[r] \ar[u] &
\ldots \ar[r] &
M_n \ar[u]
}
$$
in $\text{Mod}_{(A, \text{d})}$ such that each $M_i \to M_{i + 1}$
is an admissible monomorphism and each $M_i \to L_i$
is a homotopy equivalence.
\end{lemma}

\begin{proof}
The case $n = 1$ is without content.
Lemma \ref{lemma-make-injective} is the case $n = 2$.
Suppose we have constructed the diagram
except for $M_n$. Apply Lemma \ref{lemma-make-injective} to
the composition $M_{n - 1} \to L_{n - 1} \to L_n$.
The result is a factorization $M_{n - 1} \to M_n \to L_n$
as desired.
\end{proof}



\begin{lemma}
\label{lemma-nilpotent}
Let $(A, \text{d})$ be a differential graded algebra.
Let $0 \to K_i \to L_i \to M_i \to 0$, $i = 1, 2, 3$
be admissible short exact sequence of differential graded $A$-modules.
Let $b : L_1 \to L_2$ and $b' : L_2 \to L_3$
be homomorphisms of differential graded modules such that
$$
\vcenter{
\xymatrix{
K_1 \ar[d]_0 \ar[r] &
L_1 \ar[r] \ar[d]_b &
M_1 \ar[d]_0 \\
K_2 \ar[r] & L_2 \ar[r] & M_2
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
K_2 \ar[d]^0 \ar[r] &
L_2 \ar[r] \ar[d]^{b'} &
M_2 \ar[d]^0 \\
K_3 \ar[r] & L_3 \ar[r] & M_3
}
}
$$
commute up to homotopy. Then $b' \circ b$ is homotopic to $0$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-make-commute-map} we can replace $b$ and $b'$ by
homotopic maps such that the right square of the left diagram commutes
and the left square of the right diagram commutes. In other words, we have
$\Im(b) \subset \Im(K_2 \to L_2)$ and
$\Ker((b')^n) \supset \Im(K_2 \to L_2)$.
Then $b \circ b' = 0$ as a map of modules.
\end{proof}
















\section{Distinguished triangles}
\label{section-distinguished}

\noindent
The following lemma produces our distinguished triangles.

\begin{lemma}
\label{lemma-triangle-independent-splittings}
Let $(A, \text{d})$ be a differential graded algebra. Let
$0 \to K \to L \to M \to 0$ be an admissible short exact sequence
of differential graded $A$-modules. The triangle
\begin{equation}
\label{equation-triangle-associated-to-admissible-ses}
K \to L \to M \xrightarrow{\delta} K[1]
\end{equation}
with $\delta$ as in Lemma \ref{lemma-admissible-ses} is, up to canonical
isomorphism in $K(\text{Mod}_{(A, \text{d})})$, independent of the choices
made in Lemma \ref{lemma-admissible-ses}.
\end{lemma}

\begin{proof}
Namely, let $(s', \pi')$ be a second choice of splittings as in
Lemma \ref{lemma-admissible-ses}. Then we claim that $\delta$ and $\delta'$
are homotopic. Namely, write $s' = s + \alpha \circ h$ and
$\pi' = \pi + g \circ \beta$ for some unique homomorphisms
of $A$-modules $h : M \to K$ and $g : M \to K$ of degree $-1$.
Then $g = -h$ and $g$ is a homotopy between $\delta$ and $\delta'$.
The computations are done in the proof of
Homology, Lemma \ref{homology-lemma-ses-termwise-split-homotopy-cochain}.
\end{proof}

\begin{definition}
\label{definition-distinguished-triangle}
Let $(A, \text{d})$ be a differential graded algebra.
\begin{enumerate}
\item If $0 \to K \to L \to M \to 0$ is an admissible short exact sequence
of differential graded $A$-modules, then the {\it triangle associated
to $0 \to K \to L \to M \to 0$} is the triangle 
(\ref{equation-triangle-associated-to-admissible-ses})
of $K(\text{Mod}_{(A, \text{d})})$.
\item A triangle of $K(\text{Mod}_{(A, \text{d})})$ is called a
{\it distinguished triangle} if it is isomorphic to a triangle
associated to an admissible short exact sequence
of differential graded $A$-modules.
\end{enumerate}
\end{definition}









\section{Cones and distinguished triangles}
\label{section-cones-and-triangles}

\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Let $f : K \to L$ be a homomorphism of differential graded $A$-modules.
Then $(K, L, C(f), f, i, p)$ forms a triangle:
$$
K \to L \to C(f) \to K[1]
$$
in $\text{Mod}_{(A, \text{d})}$ and hence in $K(\text{Mod}_{(A, \text{d})})$.
Cones are {\bf not} distinguished triangles in general, but the difference
is a sign or a rotation (your choice). Here are two precise statements.

\begin{lemma}
\label{lemma-rotate-cone}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f : K \to L$ be a homomorphism of differential graded modules.
The triangle $(L, C(f), K[1], i, p, f[1])$ is
the triangle associated to the admissible short exact sequence
$$
0 \to L \to C(f) \to K[1] \to 0
$$
coming from the definition of the cone of $f$.
\end{lemma}

\begin{proof}
Immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-rotate-triangle}
Let $(A, \text{d})$ be a differential graded algebra.
Let $\alpha : K \to L$ and $\beta : L \to M$
define an admissible short exact sequence
$$
0 \to K \to L \to M \to 0
$$
of differential graded $A$-modules.
Let $(K, L, M, \alpha, \beta, \delta)$
be the associated triangle. Then the triangles
$$
(M[-1], K, L, \delta[-1], \alpha, \beta)
\quad\text{and}\quad
(M[-1], K, C(\delta[-1]), \delta[-1], i, p)
$$
are isomorphic.
\end{lemma}

\begin{proof}
Using a choice of splittings we write $L = K \oplus M$ and we identify
$\alpha$ and $\beta$ with the natural inclusion and projection maps.
By construction of $\delta$ we have
$$
d_B =
\left(
\begin{matrix}
d_K & \delta \\
0 & d_M
\end{matrix}
\right)
$$
On the other hand the cone of $\delta[-1] : M[-1] \to K$
is given as $C(\delta[-1]) = K \oplus M$ with differential identical
with the matrix above! Whence the lemma.
\end{proof}

\begin{lemma}
\label{lemma-third-isomorphism}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f_1 : K_1 \to L_1$ and $f_2 : K_2 \to L_2$ be homomorphisms of
differential graded $A$-modules. Let
$$
(a, b, c) :
(K_1, L_1, C(f_1), f_1, i_1, p_1)
\longrightarrow
(K_1, L_1, C(f_1), f_2, i_2, p_2)
$$
be any morphism of triangles of $K(\text{Mod}_{(A, \text{d})})$.
If $a$ and $b$ are homotopy equivalences then so is $c$.
\end{lemma}

\begin{proof}
Let $a^{-1} : K_2 \to K_1$ be a homomorphism of differential graded $A$-modules
which is inverse to $a$ in $K(\text{Mod}_{(A, \text{d})})$.
Let $b^{-1} : L_2 \to L_1$ be a homomorphism of differential graded $A$-modules
which is inverse to $b$ in $K(\text{Mod}_{(A, \text{d})})$.
Let $c' : C(f_2) \to C(f_1)$ be the morphism from
Lemma \ref{lemma-functorial-cone} applied to
$f_1 \circ a^{-1} = b^{-1} \circ f_2$.
If we can show that $c \circ c'$ and $c' \circ c$ are isomorphisms in
$K(\text{Mod}_{(A, \text{d})})$
then we win. Hence it suffices to prove the following: Given
a morphism of triangles
$(1, 1, c) : (K, L, C(f), f, i, p)$
in $K(\text{Mod}_{(A, \text{d})})$ the morphism $c$ is an isomorphism
in $K(\text{Mod}_{(A, \text{d})})$.
By assumption the two squares in the diagram
$$
\xymatrix{
L \ar[r] \ar[d]_1 &
C(f) \ar[r] \ar[d]_c &
K[1] \ar[d]_1 \\
L \ar[r] &
C(f) \ar[r] &
K[1]
}
$$
commute up to homotopy. By construction of $C(f)$ the rows
form admissible short exact sequences. Thus we see that
$(c - 1)^2 = 0$ in $K(\text{Mod}_{(A, \text{d})})$ by
Lemma \ref{lemma-nilpotent}.
Hence $c$ is an isomorphism in $K(\text{Mod}_{(A, \text{d})})$
with inverse $2 - c$.
\end{proof}

\noindent
The following lemma shows that the collection of triangles of the homotopy
category given by cones and the distinguished triangles are the same
up to isomorphisms, at least up to sign!

\begin{lemma}
\label{lemma-the-same-up-to-isomorphisms}
Let $(A, \text{d})$ be a differential graded algebra.
\begin{enumerate}
\item Given an admissible short exact sequence
$0 \to K \xrightarrow{\alpha} L \to M \to 0$
of differential graded $A$-modules there exists a homotopy equivalence
$C(\alpha) \to M$ such that the diagram
$$
\xymatrix{
K \ar[r] \ar[d] & L \ar[d] \ar[r] &
C(\alpha) \ar[r]_{-p} \ar[d] & K[1] \ar[d] \\
K \ar[r]^\alpha & L \ar[r]^\beta &
M \ar[r]^\delta & K[1]
}
$$
defines an isomorphism of triangles in $K(\text{Mod}_{(A, \text{d})})$.
\item Given a morphism of complexes $f : K \to L$
there exists an isomorphism of triangles
$$
\xymatrix{
K \ar[r] \ar[d] & \tilde L \ar[d] \ar[r] &
M \ar[r]_{\delta} \ar[d] & K[1] \ar[d] \\
K \ar[r] & L \ar[r] &
C(f) \ar[r]^{-p} & K[1]
}
$$
where the upper triangle is the triangle associated to a
admissible short exact sequence $K \to \tilde L \to M$.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). We have $C(\alpha) = L \oplus K$ and we simply define
$C(\alpha) \to M$ via the projection onto $L$ followed by $\beta$.
This defines a morphism of differential graded modules because the
compositions $K^{n + 1} \to L^{n + 1} \to M^{n + 1}$ are zero.
Choose splittings $s : M \to L$ and $\pi : L \to K$ with
$\Ker(\pi) = \Im(s)$ and set
$\delta = \pi \circ \text{d}_L \circ s$ as usual.
To get a homotopy inverse we take
$M \to C(\alpha)$ given by $(s , -\delta)$. This is compatible with
differentials because $\delta^n$ can be characterized as the
unique map $M^n \to K^{n + 1}$ such that
$\text{d} \circ s^n - s^{n + 1} \circ \text{d} = \alpha \circ \delta^n$,
see proof of
Homology, Lemma \ref{homology-lemma-ses-termwise-split-cochain}.
The composition $M \to C(f) \to M$ is the identity.
The composition $C(f) \to M \to C(f)$ is equal to the morphism
$$
\left(
\begin{matrix}
s \circ \beta & 0 \\
-\delta \circ \beta & 0
\end{matrix}
\right)
$$
To see that this is homotopic to the identity map
use the homotopy $h : C(\alpha) \to C(\alpha)$
given by the matrix
$$
\left(
\begin{matrix}
0 & 0 \\
\pi & 0
\end{matrix}
\right) :
C(\alpha) = L \oplus K
\to
L \oplus K = C(\alpha)
$$
It is trivial to verify that
$$
\left(
\begin{matrix}
1 & 0 \\
0 & 1
\end{matrix}
\right)
-
\left(
\begin{matrix}
s \\
-\delta
\end{matrix}
\right)
\left(
\begin{matrix}
\beta & 0
\end{matrix}
\right)
=
\left(
\begin{matrix}
\text{d} & \alpha \\
0 & -\text{d}
\end{matrix}
\right)
\left(
\begin{matrix}
0 & 0 \\
\pi & 0
\end{matrix}
\right)
+
\left(
\begin{matrix}
0 & 0 \\
\pi & 0
\end{matrix}
\right)
\left(
\begin{matrix}
\text{d} & \alpha \\
0 & -\text{d}
\end{matrix}
\right)
$$
To finish the proof of (1) we have to show that the morphisms
$-p : C(\alpha) \to K[1]$ (see
Definition \ref{definition-cone})
and $C(\alpha) \to M \to K[1]$ agree up
to homotopy. This is clear from the above. Namely, we can use the homotopy
inverse $(s, -\delta) : M \to C(\alpha)$
and check instead that the two maps
$M \to K[1]$ agree. And note that
$p \circ (s, -\delta) = -\delta$ as desired.

\medskip\noindent
Proof of (2). We let $\tilde f : K \to \tilde L$,
$s : L \to \tilde L$
and $\pi : L \to L$ be as in
Lemma \ref{lemma-make-injective}. By
Lemmas \ref{lemma-functorial-cone} and \ref{lemma-third-isomorphism}
the triangles $(K, L, C(f), i, p)$ and
$(K, \tilde L, C(\tilde f), \tilde i, \tilde p)$
are isomorphic. Note that we can compose isomorphisms of
triangles. Thus we may replace $L$ by
$\tilde L$ and $f$ by $\tilde f$. In other words
we may assume that $f$ is an admissible monomorphism.
In this case the result follows from part (1).
\end{proof}







\section{The homotopy category is triangulated}
\label{section-homotopy-triangulated}

\noindent
We first prove that it is pre-triangulated.

\begin{lemma}
\label{lemma-homotopy-category-pre-triangulated}
Let $(A, \text{d})$ be a differential graded algebra.
The homotopy category $K(\text{Mod}_{(A, \text{d})})$
with its natural translation functors and distinguished triangles
is a pre-triangulated category.
\end{lemma}

\begin{proof}
Proof of TR1. By definition every triangle isomorphic to a distinguished
one is distinguished. Also, any triangle $(K, K, 0, 1, 0, 0)$
is distinguished since $0 \to K \to K \to 0 \to 0$ is
an admissible short exact sequence. Finally, given any homomorphism
$f : K \to L$ of differential graded $A$-modules the triangle
$(K, L, C(f), f, i, -p)$ is distinguished by
Lemma \ref{lemma-the-same-up-to-isomorphisms}.

\medskip\noindent
Proof of TR2. Let $(X, Y, Z, f, g, h)$ be a triangle.
Assume $(Y, Z, X[1], g, h, -f[1])$ is distinguished.
Then there exists an admissible short exact sequence
$0 \to K \to L \to M \to 0$ such that the associated
triangle $(K, L, M, \alpha, \beta, \delta)$
is isomorphic to $(Y, Z, X[1], g, h, -f[1])$. Rotating back we see
that $(X, Y, Z, f, g, h)$ is isomorphic to
$(M[-1], K, L, -\delta[-1], \alpha, \beta)$.
It follows from Lemma \ref{lemma-rotate-triangle} that the triangle
$(M[-1], K, L, \delta[-1], \alpha, \beta)$
is isomorphic to
$(M[-1], K, C(\delta[-1]), \delta[-1], i, p)$.
Precomposing the previous isomorphism of triangles with $-1$ on $Y$
it follows that $(X, Y, Z, f, g, h)$ is isomorphic to
$(M[-1], K, C(\delta[-1]), \delta[-1], i, -p)$.
Hence it is distinguished by
Lemma \ref{lemma-the-same-up-to-isomorphisms}.
On the other hand, suppose that $(X, Y, Z, f, g, h)$ is distinguished.
By Lemma \ref{lemma-the-same-up-to-isomorphisms} this means that it is
isomorphic to a triangle of the form
$(K, L, C(f), f, i, -p)$ for some morphism $f$ of
$\text{Mod}_{(A, \text{d})}$. Then the rotated triangle
$(Y, Z, X[1], g, h, -f[1])$ is
isomorphic to $(L, C(f), K[1], i, -p, -f[1])$ which is
isomorphic to the triangle
$(L, C(f), K[1], i, p, f[1])$.
By Lemma \ref{lemma-rotate-cone} this triangle is distinguished.
Hence $(Y, Z, X[1], g, h, -f[1])$ is distinguished as desired.

\medskip\noindent
Proof of TR3. Let $(X, Y, Z, f, g, h)$ and $(X', Y', Z', f', g', h')$
be distinguished triangles of $K(\mathcal{A})$ and let $a : X \to X'$
and $b : Y \to Y'$ be morphisms such that $f' \circ a = b \circ f$. By
Lemma \ref{lemma-the-same-up-to-isomorphisms} we may assume that
$(X, Y, Z, f, g, h) = (X, Y, C(f), f, i, -p)$ and
$(X', Y', Z', f', g', h') = (X', Y', C(f'), f', i', -p')$.
At this point we simply apply Lemma \ref{lemma-functorial-cone}
to the commutative diagram given by $f, f', a, b$.
\end{proof}

\noindent
Before we prove TR4 in general we prove it in a special case.

\begin{lemma}
\label{lemma-two-split-injections}
Let $(A, \text{d})$ be a differential graded algebra. Suppose that
$\alpha : K \to L$ and $\beta : L \to M$ are admissible monomorphisms
of differential graded $A$-modules. Then there exist distinguished triangles
$(K, L, Q_1, \alpha, p_1, d_1)$, $(K, M, Q_2, \beta \circ \alpha, p_2, d_2)$
and $(L, M, Q_3, \beta, p_3, d_3)$ for which TR4 holds.
\end{lemma}

\begin{proof}
Say $\pi_1 : L \to K$ and $\pi_3 : M \to L$ are homomorphisms
of graded $A$-modules which are left inverse to $\alpha$ and $\beta$.
Then also $K \to M$ is an admissible monomorphism with left
inverse $\pi_2 = \pi_1 \circ \pi_3$. Let us write $Q_1$, $Q_2$
and $Q_3$ for the cokernels of $K \to L$, $K \to M$, and $L \to M$.
Then we obtain identifications (as graded $A$-modules)
$Q_1 = \Ker(\pi_1)$, $Q_3 = \Ker(\pi_3)$ and
$Q_2 = \Ker(\pi_2)$. Then $L = K \oplus Q_1$ and
$M = L \oplus Q_3$ as graded $A$-modules. This implies
$M = K \oplus Q_1 \oplus Q_3$. Note that $\pi_2 = \pi_1 \circ \pi_3$
is zero on both $Q_1$ and $Q_3$. Hence $Q_2 = Q_1 \oplus Q_3$.
Consider the commutative diagram
$$
\begin{matrix}
0 & \to & K & \to & L & \to & Q_1 & \to & 0 \\
  &     & \downarrow &     & \downarrow &     & \downarrow  & \\
0 & \to & K & \to & M & \to & Q_2 & \to & 0 \\
  &     & \downarrow &     & \downarrow &     & \downarrow  & \\
0 & \to & L & \to & M & \to & Q_3 & \to & 0
\end{matrix}
$$
The rows of this diagram are admissible short exact sequences, and
hence determine distinguished triangles by definition. Moreover
downward arrows in the diagram above are compatible with the chosen
splittings and hence define morphisms of triangles
$$
(K \to L \to Q_1 \to K[1])
\longrightarrow
(K \to M \to Q_2 \to K[1])
$$
and
$$
(K \to M \to Q_2 \to K[1])
\longrightarrow
(L \to M \to Q_3 \to L[1]).
$$
Note that the splittings $Q_3 \to M$ of the bottom sequence in the
diagram provides a splitting for the split sequence
$0 \to Q_1 \to Q_2 \to Q_3 \to 0$ upon composing with $M \to Q_2$.
It follows easily from this that the morphism $\delta : Q_3 \to Q_1[1]$
in the corresponding distinguished triangle
$$
(Q_1 \to Q_2 \to Q_3 \to Q_1[1])
$$
is equal to the composition $Q_3 \to L[1] \to Q_1[1]$.
Hence we get a structure as in the conclusion of axiom TR4.
\end{proof}

\noindent
Here is the final result.

\begin{proposition}
\label{proposition-homotopy-category-triangulated}
Let $(A, \text{d})$ be a differential graded algebra. The homotopy category
$K(\text{Mod}_{(A, \text{d})})$ of differential graded $A$-modules with its
natural translation functors and distinguished triangles is a triangulated
category.
\end{proposition}

\begin{proof}
We know that $K(\text{Mod}_{(A, \text{d})})$ is a pre-triangulated category.
Hence it suffices to prove TR4 and to prove it we can use
Derived Categories, Lemma \ref{derived-lemma-easier-axiom-four}.
Let $K \to L$ and $L \to M$ be composable morphisms of
$K(\text{Mod}_{(A, \text{d})})$. By
Lemma \ref{lemma-sequence-maps-split} we may assume that
$K \to L$ and $L \to M$ are admissible monomorphisms.
In this case the result follows from
Lemma \ref{lemma-two-split-injections}.
\end{proof}











\section{Left modules}
\label{section-left-modules}

\noindent
Everything we have said sofar has an analogue in the setting
of left differential graded modules, except that one has to
take care with some sign rules.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded $R$-algebra.
Exactly analogous to right modules, we define a
{\it left differential graded $A$-module} $M$ as a left
$A$-module $M$ which has a grading $M = \bigoplus M^n$
and a differential $\text{d}$, such that $A^n M^m \subset M^{n + m}$,
such that $\text{d}(M^n) \subset M^{n + 1}$, and such that
$$
\text{d}(am) = \text{d}(a) m + (-1)^{\deg(a)}a \text{d}(m)
$$
for homogeneous elements $a \in A$ and $m \in M$. As before this
Leibniz rule exactly signifies that the multiplication defines
a map of complexes
$$
\text{Tot}(A^\bullet \otimes_R M^\bullet) \to M^\bullet
$$
Here $A^\bullet$ and $M^\bullet$ denote the complexes of $R$-modules
underlying $A$ and $M$.

\begin{definition}
\label{definition-opposite-dga}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded algebra
over $R$. The {\it opposite differential graded algebra} is the differential
graded algebra $(A^{opp}, \text{d})$ over $R$ where $A^{opp} = A$
as a graded $R$-module, $\text{d} = \text{d}$, and multiplication is
given by
$$
a \cdot_{opp} b = (-1)^{\deg(a)\deg(b)} b a
$$
for homogeneous elements $a, b \in A$.
\end{definition}

\noindent
This makes sense because
\begin{align*}
\text{d}(a \cdot_{opp} b)
& =
(-1)^{\deg(a)\deg(b)} \text{d}(b a) \\
& =
(-1)^{\deg(a)\deg(b)} \text{d}(b) a +
(-1)^{\deg(a)\deg(b) + \deg(b)}b\text{d}(a) \\
& =
(-1)^{\deg(a)}a \cdot_{opp} \text{d}(b) + \text{d}(a) \cdot_{opp} b
\end{align*}
as desired. In terms of underlying complexes of $R$-modules
this means that the diagram
$$
\xymatrix{
\text{Tot}(A^\bullet \otimes_R A^\bullet)
\ar[rrr]_-{\text{multiplication of }A^{opp}}
\ar[d]_{\text{commutativity constraint}} & & &
A^\bullet \ar[d]^{\text{id}} \\
\text{Tot}(A^\bullet \otimes_R A^\bullet)
\ar[rrr]^-{\text{multiplication of }A} & & &
A^\bullet
}
$$
commutes. Here the commutativity constraint on the symmetric monoidal
category of complexes of $R$-modules is given in
More on Algebra, Section \ref{more-algebra-section-sign-rules}.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded algebra over $R$.
Let $M$ be a left differential graded $A$-module. We will denote
$M^{opp}$ the module $M$ viewed as a right $A^{opp}$-module with
multiplication $\cdot_{opp}$ defined by the rule
$$
m \cdot_{opp} a = (-1)^{\deg(a)\deg(m)} a m
$$
for $a$ and $m$ homogeneous. This is compatible with differentials
because we could have used the diagram
$$
\xymatrix{
\text{Tot}(M^\bullet \otimes_R A^\bullet)
\ar[rrr]_-{\text{multiplication on }M^{opp}}
\ar[d]_{\text{commutativity constraint}} & & &
M^\bullet \ar[d]^{\text{id}} \\
\text{Tot}(A^\bullet \otimes_R M^\bullet)
\ar[rrr]^-{\text{multiplication on }M} & & &
M^\bullet
}
$$
to define the multiplication $\cdot_{opp}$ on $M^{opp}$.
To see that it is an associative multiplication we compute for
homogeneous elements $a, b \in A$ and $m \in M$ that
\begin{align*}
m \cdot_{opp} (a \cdot_{opp} b)
& =
(-1)^{\deg(a)\deg(b)} m \cdot_{opp} (ba) \\
& =
(-1)^{\deg(a)\deg(b) + \deg(ab)\deg(m)} bam \\
& =
(-1)^{\deg(a)\deg(b) + \deg(ab)\deg(m) + \deg(b)\deg(am)}
(am) \cdot_{opp} b \\
& =
(-1)^{\deg(a)\deg(b) + \deg(ab)\deg(m) + \deg(b)\deg(am) + \deg(a)\deg(m)}
(m \cdot_{opp} a) \cdot_{opp} b \\
& =
(m \cdot_{opp} a) \cdot_{opp} b
\end{align*}
Of course, we could have been shown this using the compatibility between
the associativity and commutativity constraint on the symmetric monoidal
category of complexes of $R$-modules as well.

\begin{lemma}
\label{lemma-left-right}
Let $(A, \text{d})$ be a differential graded $R$-algebra.
The functor $M \mapsto M^{opp}$ from the category of
left differential graded $A$-modules to the category of right
differential graded $A^{opp}$-modules is an equivalence.
\end{lemma}

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

\noindent
Mext, we come to shifts. Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a left differential graded $A$-module whose underlying complex
of $R$-modules is denoted $M^\bullet$.
For any $k \in \mathbf{Z}$ we define the {\it $k$-shifted module}
$M[k]$ as follows
\begin{enumerate}
\item the underlying complex of $R$-modules of $M[k]$ is $M^\bullet[k]$
\item as $A$-module the multiplication
$$
A^n \times (M[k])^m \longrightarrow (M[k])^{n + m}
$$
is equal to $(-1)^{nk}$ times the given multiplication
$A^n \times M^{m + k} \to M^{n + m + k}$.
\end{enumerate}
Let us check that with this choice the Leibniz rule is satisfied.
Let $a \in A^n$ and $x \in M[k]^m = M^{m + k}$ and denoting
$\cdot_{M[k]}$ the product in $M[k]$ then we see
\begin{align*}
\text{d}_{M[k]}(a \cdot_{M[k]} x)
& =
(-1)^{k + nk} \text{d}_M(ax) \\
& =
(-1)^{k + nk} \text{d}(a) x + (-1)^{k + nk + n} a \text{d}_M(x) \\
& =
\text{d}(a) \cdot_{M[k]} x + (-1)^{nk + n} a \text{d}_{M[k]}(x) \\
& =
\text{d}(a) \cdot_{M[k]} x + (-1)^n a \cdot_{M[k]} \text{d}_{M[k]}(x)
\end{align*}
This is what we want as $a$ has degree $n$ as a homogeneous element of $A$.
We also observe that with these choices we may think of
the multiplication map as the map of complexes
$$
\text{Tot}(A^\bullet \otimes_R M^\bullet[k]) \to
\text{Tot}(A^\bullet \otimes_R M^\bullet)[k] \to
M^\bullet[k]
$$
where the first arrow is
More on Algebra, Section \ref{more-algebra-section-sign-rules}
(\ref{more-algebra-item-shift-tensor}) which in this
case involves exactly the sign we chose above. (In fact, we could have deduced
that the Liebniz rule holds from this observation.)

\medskip\noindent
With the rule above we have canonical identifications
$$
(M[k])^{opp} = M^{opp}[k]
$$
of right differential graded $A^{opp}$-modules
defined without the intervention of signs, in other words, the equivalence
of Lemma \ref{lemma-left-right} is compatible with shift functors.

\medskip\noindent
Our choice above necessitates the following definition.

\begin{definition}
\label{definition-shift-graded-module}
Let $R$ be a ring. Let $A$ be a $\mathbf{Z}$-graded $R$-algebra.
\begin{enumerate}
\item Given a right graded $A$-module $M$ we define the
{\it $k$th shifted $A$-module} $M[k]$ as the same as
a right $A$-module but with grading $(M[k])^n = M^{n + k}$.
\item Given a left graded $A$-module $M$ we define the
{\it $k$th shifted $A$-module} $M[k]$ as the module
with grading $(M[k])^n = M^{n + k}$ and multiplication
$A^n \times (M[k])^m \to (M[k])^{n + m}$
equal to $(-1)^{nk}$ times the given multiplication
$A^n \times M^{m + k} \to M^{n + m + k}$.
\end{enumerate}
\end{definition}

\noindent
Let $(A, \text{d})$ be a differential graded algebra. Let
$f, g : M \to N$ be homomorphisms of left differential graded $A$-modules.
A {\it homotopy between $f$ and $g$} is a graded $A$-module map
$h : M \to N[-1]$ (observe the shift!) such that
$$
f(x) - g(x) = \text{d}_N(h(x)) + h(\text{d}_M(x))
$$
for all $x \in M$. If a homotopy exists, then we say $f$ and $g$ are
{\it homotopic}. Thus $h$ is compatible with the $A$-module structure
(with the shifted one on $N$) and the grading (with shifted grading on $N$)
but not with the differential. If $f = g$ and $h$ is a homotopy, then
$h$ defines a morphism $h : M \to N[-1]$ of left differential
graded $A$-modules.

\medskip\noindent
With the rule above we find that $f, g : M \to N$ are homotopic if
and only if the induced morphisms
$f^{opp}, g^{opp} : M^{opp} \to N^{opp}$
are homotopic as right differential graded $A^{opp}$-module homomorphisms
(with the same homotopy).

\medskip\noindent
The homotopy category, cones, admissible short exact sequences,
distinguished triangles are all defined in exactly the same manner
as for right differential graded modules (and everything agrees
on underlying complexes of $R$-modules with the constructions for
complexes of $R$-modules). In this manner we obtain the analogue of
Proposition \ref{proposition-homotopy-category-triangulated}
for left modules as well, or we can deduce it by working
with right modules over the opposite algebra.



\section{Tensor product}
\label{section-tensor-product}

\noindent
Let $R$ be a ring. Let $A$ be an $R$-algebra (see
Section \ref{section-conventions}). Given a right $A$-module $M$
and a left $A$-module $N$ there is a {\it tensor product}
$$
M \otimes_A N
$$
This tensor product is a module over $R$. As an $R$-module $M \otimes_A N$
is generated by symbols $x \otimes y$ with $x \in M$ and $y \in N$ subject
to the relations
$$
\begin{matrix}
(x_1 + x_2) \otimes y - x_1 \otimes y - x_2 \otimes y, \\
x \otimes (y_1 + y_2) - x \otimes y_1 - x \otimes y_2, \\
xa \otimes y - x \otimes ay
\end{matrix}
$$
for $a \in A$, $x, x_1, x_2 \in M$ and $y, y_1, y_2 \in N$.
We list some properties of the tensor product

\medskip\noindent
In each variable the tensor product is right exact, in fact commutes
with direct sums and arbitrary colimits.

\medskip\noindent
The tensor product $M \otimes_A N$ is the receptacle of the universal
$A$-bilinear map $M \times N \to M \otimes_A N$, $(x, y) \mapsto x \otimes y$.
In a formula
$$
\text{Bilinear}_A(M \times N, Q) = \Hom_R(M \otimes_A N, Q)
$$
for any $R$-module $Q$.

\medskip\noindent
If $A$ is a $\mathbf{Z}$-graded algebra and $M$, $N$ are graded
$A$-modules then $M \otimes_A N$ is a graded $R$-module.
Then $n$th graded piece $(M \otimes_A N)^n$ of $M \otimes_A N$
is equal to
$$
\Coker\left(
\bigoplus\nolimits_{r + t + s = n}
M^r \otimes_R A^t \otimes_R N^s \to
\bigoplus\nolimits_{p + q = n} M^p \otimes_R N^q
\right)
$$
where the map sends $x \otimes a \otimes y$ to
$x \otimes ay - xa \otimes y$ for
$x \in M^r$, $y \in N^s$, and $a \in A^t$ with $r + s + t = n$.
In this case the map $M \times N \to M \otimes_A N$ is $A$-bilinear
and compatible with gradings and universal in the sense that
$$
\text{GradedBilinear}_A(M \times N, Q) =
\Hom_{\text{graded }R\text{-modules}}(M \otimes_A N, Q)
$$
for any graded $R$-module $Q$ with an obvious notion of graded
bilinar map.

\medskip\noindent
If $(A, \text{d})$ is a differential graded algebra and
$M$ and $N$ are left and right differential graded $A$-modules, then
$M \otimes_A N$ is a differential graded $R$-module with differential
$$
\text{d}(x \otimes y) =
\text{d}(x) \otimes y + (-1)^{\deg(x)}x \otimes \text{d}(y)
$$
for $x \in M$ and $y \in N$ homogeneous. In this case the map
$M \times N \to M \otimes_A N$ is $A$-bilinear, compatible with gradings,
and compatible with differentials and universal in the sense that
$$
\text{DifferentialGradedBilinear}_A(M \times N, Q) =
\Hom_{\text{Comp}(R)}(M \otimes_A N, Q)
$$
for any differential graded $R$-module $Q$ with an obvious notion of
differential graded bilinar map.






\section{Hom complexes and differential graded modules}
\label{section-hom-complexes}

\noindent
We urge the reader to skip this section.

\medskip\noindent
Let $R$ be a ring and let $M^\bullet$ be a complex of $R$-modules.
Consider the complex of $R$-modules
$$
E^\bullet = \Hom^\bullet(M^\bullet, M^\bullet)
$$
introduced in
More on Algebra, Section \ref{more-algebra-section-hom-complexes}.
By More on Algebra, Lemma \ref{more-algebra-lemma-composition}
there is a canonical composition law
$$
\text{Tot}(E^\bullet \otimes_R E^\bullet) \to E^\bullet
$$
which is a map of complexes. Thus we see that $E^\bullet$ with this
multiplication is a differential graded $R$-algebra which we will
denote $(E, \text{d})$. Moreover, viewing $M^\bullet$ as
$\Hom^\bullet(R, M^\bullet)$ we see that composition defines a multiplication
$$
\text{Tot}(E^\bullet \otimes_R M^\bullet) \to M^\bullet
$$
which turns $M^\bullet$ into a {\bf left} differential graded $E$-module
which we will denote $M$.

\begin{lemma}
\label{lemma-left-module-structure}
In the situation above, let $A$ be a differential graded $R$-algebra.
To give a left $A$-module structure on $M$ is the same thing as
giving a homomorphism $A \to E$ of differential graded $R$-algebras.
\end{lemma}

\begin{proof}
Proof omitted. Observe that no signs intervene in this correspondence.
\end{proof}

\noindent
We continue with the discussion above and we assume given another
complex $N^\bullet$ of $R$-modules. Consider the complex
of $R$-modules $\Hom^\bullet(M^\bullet, N^\bullet)$ introduced in
More on Algebra, Section \ref{more-algebra-section-hom-complexes}.
As above we see that composition
$$
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet) \otimes_R E^\bullet)
\to \Hom^\bullet(M^\bullet, N^\bullet)
$$
defines a multiplication which turns $\Hom^\bullet(M^\bullet, N^\bullet)$
into a {\bf right} differential graded $E$-module. Using
Lemma \ref{lemma-left-module-structure} we
conclude that given a left differential graded $A$-module $M$ and
a complex of $R$-modules $N^\bullet$ there is a canonical
right differential graded $A$-module whose underlying complex
of $R$-modules is $\Hom^\bullet(M^\bullet, N^\bullet)$ and
where multiplication
$$
\Hom^n(M^\bullet, N^\bullet) \times A^m \longrightarrow
\Hom^{n + m}(M^\bullet, N^\bullet)
$$
sends $f = (f_{p, q})_{p + q = n}$ with $f_{p, q} \in \Hom(M^{-q}, N^p)$
and $a \in A^m$ to the element $f \cdot a = (f_{p, q} \circ a)$ where
$f_{p, q} \circ a$ is the map
$$
M^{-q - m} \xrightarrow{a} M^{-q} \xrightarrow{f_{p, q}} N^p, \quad
x \longmapsto f_{p, q}(ax)
$$
without the intervention of signs. Let us use the notation
$\Hom(M, N^\bullet)$ to denote this right differential graded $A$-module.

\begin{lemma}
\label{lemma-characterize-hom}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded $R$-algebra.
Let $M'$ be a right differential graded $A$-module and let
$M$ be a left differential graded $A$-module.
Let $N^\bullet$ be a complex of $R$-modules. Then we have
$$
\Hom_{\text{Mod}_{(A, d)}}(M', \Hom(M, N^\bullet)) =
\Hom_{\text{Comp}(R)}(M' \otimes_A M, N^\bullet)
$$
where $M \otimes_A M$ is viewed as a complex of $R$-modules
as in Section \ref{section-tensor-product}.
\end{lemma}

\begin{proof}
Let us show that both sides correspond to graded $A$-bilinear maps
$$
M' \times M \longrightarrow N^\bullet
$$
compatible with differentials. We have seen this is true for the right
hand side in Section \ref{section-tensor-product}. Given an element
$g$ of the left hand side, the equality of
More on Algebra, Lemma \ref{more-algebra-lemma-compose}
determines a map of complexes of $R$-modules
$g' : \text{Tot}(M' \otimes_R M) \to N^\bullet$.
In other words, we obtain a graded $R$-bilinear
map $g'' : M' \times M \to N^\bullet$ compatible with differentials.
The $A$-linearity of $g$ translates immediately
into $A$-bilinarity of $g''$.
\end{proof}

\noindent
Let $R$, $M^\bullet$, $E^\bullet$, $E$, and $M$ be as above.
However, now suppose given a differential graded $R$-algebra $A$
and a {\bf right} differential graded $A$-module structure on $M$.
Then we can consider the map
$$
\text{Tot}(A^\bullet \otimes_R M^\bullet)
\xrightarrow{\psi}
\text{Tot}(A^\bullet \otimes_R M^\bullet)
\to
M^\bullet
$$
where the first arrow is the commutativity constraint on the
differential graded category of complexes of $R$-modules.
This corresponds to a map
$$
\tau : A^\bullet \longrightarrow E^\bullet
$$
of complexes of $R$-modules. Recall that
$E^n = \prod_{p + q = n} \Hom_R(M^{-q}, M^p)$
and write $\tau(a) = (\tau_{p, q}(a))_{p + q = n}$ for $a \in A^n$.
Then we see
$$
\tau_{p, q}(a) : M^{-q} \longrightarrow M^p,\quad
x \longmapsto (-1)^{\deg(a)\deg(x)}x a = (-1)^{-nq}xa
$$
This is not compatible with the product on $A$ as the readed should
expect from the discussion in Section \ref{section-left-modules}.
Namely, we have
$$
\tau(a a') = (-1)^{\deg(a)\deg(a')}\tau(a') \tau(a)
$$
We conclude the following lemma is true

\begin{lemma}
\label{lemma-right-module-structure}
In the situation above, let $A$ be a differential graded $R$-algebra.
To give a right $A$-module structure on $M$ is the same thing as
giving a homomorphism $\tau : A \to E^{opp}$
of differential graded $R$-algebras.
\end{lemma}

\begin{proof}
See discussion above and note that the construction of $\tau$
from the multiplication map $M^n \times A^m \to M^{n + m}$
uses signs.
\end{proof}

\noindent
Let $R$, $M^\bullet$, $E^\bullet$, $E$, $A$ and $M$ be as above
and let a right differential graded $A$-module structure on $M$
be given as in the lemma. In this case there is a canonical left
differential graded $A$-module whose underlying complex of $R$-modules is
$\Hom^\bullet(M^\bullet, N^\bullet)$. Namely, for multiplication
we can use
\begin{align*}
\text{Tot}(A^\bullet \otimes_R \Hom^\bullet(M^\bullet, N^\bullet))
& \xrightarrow{\psi}
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet) \otimes_R A^\bullet) \\
& \xrightarrow{\tau}
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet) \otimes_R
\Hom^\bullet(M^\bullet, M^\bullet)) \\
& \to
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet)
\end{align*}
The first arrow uses the commutativity constraint on the category
of complexes of $R$-modules, the second arrow is described above, and
the third arrow is the composition law for the Hom complex.
Each map is a map of complexes, hence the result is a map of complexes.
In fact, this construction turns $\Hom^\bullet(M^\bullet, N^\bullet)$
into a left differential graded $A$-module (associativity of the multiplication
can be shown using the symmetric monoidal structure or by a direct calculation
using the formulae below). Let us explicate the multiplication
$$
A^n \times \Hom^m(M^\bullet, N^\bullet) \longrightarrow
\Hom^{n + m}(M^\bullet, N^\bullet)
$$
It sends $a \in A^n$ and
$f = (f_{p, q})_{p + q = m}$ with $f_{p, q} \in \Hom(M^{-q}, N^p)$
to the element $a \cdot f$ with constituents
$$
(-1)^{nm}f_{p, q} \circ \tau_{-q, q + n}(a) =
(-1)^{nm - n(q + n)}f_{p, q} \circ a =
(-1)^{np + n} f_{p, q} \circ a
$$
in $\Hom_R(M^{-q - n}, N^p)$ where $f_{p, q} \circ a$ is the map
$$
M^{-q - n} \xrightarrow{a} M^{-q} \xrightarrow{f_{p, q}} N^p,\quad
x \longmapsto f_{p, q}(xa)
$$
Here a sign of $(-1)^{np + n}$ does intervene.  Let us use the notation
$\Hom(M, N^\bullet)$ to denote this left differential graded $A$-module.

\begin{lemma}
\label{lemma-characterize-hom-other-side}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded $R$-algebra.
Let $M$ be a right differential graded $A$-module and let
$M'$ be a left differential graded $A$-module.
Let $N^\bullet$ be a complex of $R$-modules. Then we have
$$
\Hom_{\text{left diff graded }A\text{-modules}}(M', \Hom(M, N^\bullet)) =
\Hom_{\text{Comp}(R)}(M \otimes_A M', N^\bullet)
$$
where $M \otimes_A M'$ is viewed as a complex of $R$-modules
as in Section \ref{section-tensor-product}.
\end{lemma}

\begin{proof}
Let us show that both sides correspond to graded $A$-bilinear maps
$$
M \times M' \longrightarrow N^\bullet
$$
compatible with differentials. We have seen this is true for the right
hand side in Section \ref{section-tensor-product}. Given an element
$g$ of the left hand side, the equality of
More on Algebra, Lemma \ref{more-algebra-lemma-compose}
determines a map of complexes
$g' : \text{Tot}(M' \otimes_R M) \to N^\bullet$.
We precompose with the commutativity constraint to get
$$
\text{Tot}(M \otimes_R M') \xrightarrow{\psi}
\text{Tot}(M' \otimes_R M) \xrightarrow{g'}
N^\bullet
$$
which corresponds to a graded $R$-bilinear
map $g'' : M \times M' \to N^\bullet$ compatible with differentials.
The $A$-linearity of $g$ translates immediately into $A$-bilinarity of $g''$.
Namely, say $x \in M^e$ and $x' \in (M')^{e'}$ and $a \in A^n$. Then
on the one hand we have
\begin{align*}
g''(x, ax')
& =
(-1)^{e(n + e')} g'(ax' \otimes x) \\
& =
(-1)^{e(n + e')} g(ax')(x) \\
& =
(-1)^{e(n + e')} (a \cdot g(x'))(x) \\
& =
(-1)^{e(n + e') + n(n + e + e') + n} g(x')(xa)
\end{align*}
and on the other hand we have
$$
g''(xa, x') = (-1)^{(e + n)e'} g'(x' \otimes xa) =
(-1)^{(e + n)e'} g(x')(xa) 
$$
which is the same thing by a trivial mod $2$ calculation of the exponents.
\end{proof}

\begin{remark}
\label{remark-evaluation-map-left}
Let $R$ be a ring. Let $A$ be a differential graded $R$-algebra.
Let $M$ be a left differential graded $A$-module. Let
$N^\bullet$ be a complex of $R$-modules. The constructions above
produce a right differential graded $A$-module $\Hom(M, N^\bullet)$
and then a leftt differential graded $A$-module
$\Hom(\Hom(M, N^\bullet), N^\bullet)$. We claim there is an
evaluation map
$$
ev : M \longrightarrow \Hom(\Hom(M, N^\bullet), N^\bullet)
$$
in the category of left differential graded $A$-modules. To define it, by
Lemma \ref{lemma-characterize-hom} it suffices to construct an
$A$-bilinear pairing
$$
\Hom(M, N^\bullet) \times M \longrightarrow N^\bullet
$$
compatible with grading and differentials. For this we take
$$
(f, x) \longmapsto f(x)
$$
We leave it to the reader to verify this is compatible with grading,
differentials, and $A$-bilinear. The map $ev$ on underlying complexes
of $R$-modules is More on Algebra, Item (\ref{more-algebra-item-evaluation}).
\end{remark}

\begin{remark}
\label{remark-evaluation-map-right}
Let $R$ be a ring. Let $A$ be a differential graded $R$-algebra.
Let $M$ be a right differential graded $A$-module. Let
$N^\bullet$ be a complex of $R$-modules. The constructions above
produce a left differential graded $A$-module $\Hom(M, N^\bullet)$
and then a right differential graded $A$-module
$\Hom(\Hom(M, N^\bullet), N^\bullet)$. We claim there is an evaluation map
$$
ev : M \longrightarrow \Hom(\Hom(M, N^\bullet), N^\bullet)
$$
in the category of right differential graded $A$-modules. To define it, by
Lemma \ref{lemma-characterize-hom} it suffices to construct an
$A$-bilinear pairing
$$
M \times \Hom(M, N^\bullet) \longrightarrow N^\bullet
$$
compatible with grading and differentials. For this we take
$$
(x, f) \longmapsto (-1)^{\deg(x)\deg(f)}f(x)
$$
We leave it to the reader to verify this is compatible with grading,
differentials, and $A$-bilinear. The map $ev$ on underlying complexes
of $R$-modules is More on Algebra, Item (\ref{more-algebra-item-evaluation}).
\end{remark}

\begin{remark}
\label{remark-shift-dual}
Let $R$ be a ring. Let $A$ be a differential graded $R$-algebra.
Let $M^\bullet$ and $N^\bullet$ be complexes of $R$-modules.
Let $k \in \mathbf{Z}$ and consider the isomorphism
$$
\Hom^\bullet(M^\bullet, N^\bullet)[-k]
\longrightarrow
\Hom^\bullet(M^\bullet[k], N^\bullet)
$$
of complexes of $R$-modules defined in
More on Algebra, Item (\ref{more-algebra-item-shift-hom}).
If $M^\bullet$ has the structure of a left, resp.\ right
differential graded $A$-module, then this is a map of
right, resp.\ left differential graded $A$-modules (with the
module structures as defined in this section).
We omit the verification; we warn the reader that the
$A$-module structure on the shift of a left graded $A$-module
is defined using a sign, see
Definition \ref{definition-shift-graded-module}.
\end{remark}






\section{Projective modules over algebras}
\label{section-projectives-over-algebras}

\noindent
In this section we discuss projective modules over algebras analogous to
Algebra, Section \ref{algebra-section-projective}.
This section should probably be moved somewhere else.

\medskip\noindent
Let $R$ be a ring and let $A$ be an $R$-algebra, see
Section \ref{section-conventions} for our conventions.
It is clear that $A$ is a projective right $A$-module since
$\Hom_A(A, M) = M$ for any right $A$-module $M$ (and thus $\Hom_A(A, -)$
is exact). Conversely, let $P$ be a projective right $A$-module. Then
we can choose a surjection
$\bigoplus_{i \in I} A \to P$ by choosing a set $\{p_i\}_{i \in I}$
of generators of $P$ over $A$. Since $P$ is projective there is a
left inverse to the surjection, and we find that $P$ is isomorphic
to a direct summand of a free module, exactly as in the commutative case
(Algebra, Lemma \ref{algebra-lemma-characterize-projective}).

\medskip\noindent
We conclude
\begin{enumerate}
\item the category of $A$-modules has enough projectives,
\item $A$ is a projective $A$-module,
\item every $A$-module is a quotient of a direct sum of copies of $A$,
\item every projective $A$-module is a direct summand of a direct
sum of copies of $A$.
\end{enumerate}



\section{Projective modules over graded algebras}
\label{section-projectives-over-graded-algebras}

\noindent
In this section we discuss projective graded modules over graded algebras
analogous to Algebra, Section \ref{algebra-section-projective}.

\medskip\noindent
Let $R$ be a ring. Let $A$ be a $\mathbf{Z}$-graded algebra over $R$.
Section \ref{section-conventions} for our conventions.
Let $\text{Mod}_A$ denote the category of graded right $A$-modules.
For an integer $k$ let $A[k]$ denote the shift of $A$.
For a graded right $A$-module we have
$$
\Hom_{\text{Mod}_A}(A[k], M) = M^{-k}
$$
As the functor $M \mapsto M^{-k}$ is exact on $\text{Mod}_A$ we
conclude that $A[k]$ is a projective object of $\text{Mod}_A$.
Conversely, suppose that $P$ is a projective object of $\text{Mod}_A$.
By choosing a set of homogeneous generators of $P$ as an $A$-module,
we can find a surjection
$$
\bigoplus\nolimits_{i \in I} A[k_i] \longrightarrow P
$$
Thus we conclude that a projective object of $\text{Mod}_A$ is
a direct summand of a direct sum of the shifts $A[k]$.

\medskip\noindent
We conclude
\begin{enumerate}
\item the category of graded $A$-modules has enough projectives,
\item $A[k]$ is a projective $A$-module for every $k \in \mathbf{Z}$,
\item every graded $A$-module is a quotient of a direct sum of
copies of the modules $A[k]$ for varying $k$,
\item every projective $A$-module is a direct summand of a direct
sum of copies of the modules $A[k]$ for varying $k$.
\end{enumerate}




\section{Projective modules and differential graded algebras}
\label{section-projective-over-differential-graded}

\noindent
If $(A, \text{d})$ is a differential graded algebra and $P$ is
an object of $\text{Mod}_{(A, \text{d})}$ then we say
{\it $P$ is projective as a graded $A$-module} or sometimes
{\it $P$ is graded projective} to mean that $P$
is a projective object of the abelian category $\text{Mod}_A$
of graded $A$-modules as in
Section \ref{section-projectives-over-graded-algebras}.

\begin{lemma}
\label{lemma-target-graded-projective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M \to P$ be a surjective homomorphism of differential graded
$A$-modules. If $P$ is projective as a graded $A$-module, then
$M \to P$ is an admissible epimorphism.
\end{lemma}

\begin{proof}
This is immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-hom-from-shift-free}
Let $(A, d)$ be a differential graded algebra. Then we have
$$
\Hom_{\text{Mod}_{(A, \text{d})}}(A[k], M) =
\Ker(\text{d} : M^{-k} \to M^{-k + 1})
$$
and
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(A[k], M) = H^{-k}(M)
$$
for any differential graded $A$-module $M$.
\end{lemma}

\begin{proof}
Immediate from the definitions.
\end{proof}







\section{Injective modules over algebras}
\label{section-modules-noncommutative}

\noindent
In this section we discuss injective modules over algebras
analogous to
More on Algebra, Section \ref{more-algebra-section-injectives-modules}.
This section should probably be moved somewhere else.

\medskip\noindent
Let $R$ be a ring and let $A$ be an
$R$-algebra, see Section \ref{section-conventions} for our conventions.
For a right $A$-module $M$ we set
$$
M^\vee = \Hom_\mathbf{Z}(M, \mathbf{Q}/\mathbf{Z})
$$
which we think of as a left $A$-module by the multiplication
$(a f)(x) = f(xa)$. Namely, $((ab)f)(x) = f(xab) = (bf)(xa) = (a(bf))(x)$.
Conversely, if $M$ is a left $A$-module, then $M^\vee$ is a right
$A$-module. Since $\mathbf{Q}/\mathbf{Z}$ is an injective abelian
group (More on Algebra, Lemma \ref{more-algebra-lemma-injective-abelian}), the
functor $M \mapsto M^\vee$ is exact
(More on Algebra, Lemma \ref{more-algebra-lemma-vee-exact}).
Moreover, the evaluation map $M \to (M^\vee)^\vee$ is
injective for all modules $M$
(More on Algebra, Lemma \ref{more-algebra-lemma-ev-injective}).

\medskip\noindent
We claim that $A^\vee$ is an injective right $A$-module. Namely, given
a right $A$-module $N$ we have
$$
\Hom_A(N, A^\vee) =
\Hom_A(N, \Hom_\mathbf{Z}(A, \mathbf{Q}/\mathbf{Z})) = N^\vee
$$
and we conclude because the functor $N \mapsto N^\vee$ is exact.
The second equality holds because
$$
\Hom_\mathbf{Z}(N, \Hom_\mathbf{Z}(A, \mathbf{Q}/\mathbf{Z})) =
\Hom_\mathbf{Z}(N \otimes_\mathbf{Z} A, \mathbf{Q}/\mathbf{Z})
$$
by Algebra, Lemma \ref{algebra-lemma-hom-from-tensor-product}.
Inside this module $A$-linearity exactly picks out the bilinear maps
$\varphi : N \times A \to \mathbf{Q}/\mathbf{Z}$ which
have the same value on $x \otimes a$ and $xa \otimes 1$, i.e.,
come from elements of $N^\vee$.

\medskip\noindent
Finally, for every right $A$-module $M$ we can choose a surjection
$\bigoplus_{i \in I} A \to M^\vee$ to get an injection
$M \to (M^\vee)^\vee \to \prod_{i \in I} A^\vee$.

\medskip\noindent
We conclude
\begin{enumerate}
\item the category of $A$-modules has enough injectives,
\item $A^\vee$ is an injective $A$-module, and
\item every $A$-module injects into a product of copies of $A^\vee$.
\end{enumerate}





\section{Injective modules over graded algebras}
\label{section-modules-noncommutative-graded}

\noindent
In this section we discuss injective graded modules over graded algebras
analogous to
More on Algebra, Section \ref{more-algebra-section-injectives-modules}.

\medskip\noindent
Let $R$ be a ring. Let $A$ be a $\mathbf{Z}$-graded algebra over $R$.
Section \ref{section-conventions} for our conventions.
If $M$ is a graded $R$-module we set
$$
M^\vee =
\bigoplus\nolimits_{n \in \mathbf{Z}}
\Hom_\mathbf{Z}(M^{-n}, \mathbf{Q}/\mathbf{Z}) =
\bigoplus\nolimits_{n \in \mathbf{Z}} (M^{-n})^\vee
$$
as a graded $R$-module (no signs in the actions of $R$ on the
homogeneous parts). If $M$ has the structure of a left graded
$A$-module, then we define a right graded $A$-module structure
on $M^\vee$ by letting $a \in A^m$ act by
$$
(M^{-n})^\vee \to (M^{-n - m})^\vee, \quad
f \mapsto f \circ a
$$
as in Section \ref{section-hom-complexes}.
If $M$ has the structure of a right graded
$A$-module, then we define a left graded $A$-module structure
on $M^\vee$ by letting $a \in A^n$ act by
$$
(M^{-m})^\vee \to (M^{-m - n})^\vee, \quad
f \mapsto (-1)^{nm}f \circ a
$$
as in Section \ref{section-hom-complexes} (the sign is forced on
us because we want to use the same formula for the case
when working with differential graded modules --- if you only
care about graded modules, then you can omit the sign here).
On the category of (left or right) graded $A$-modules the
functor $M \mapsto M^\vee$ is exact (check on graded pieces).
Moreover, there is an injective evaluation map
$$
ev : M \longrightarrow (M^\vee)^\vee, \quad
ev^n = (-1)^n \text{ the evaluation map }M^n \to ((M^n)^\vee)^\vee
$$
of graded $R$-modules, see
More on Algebra, Item (\ref{more-algebra-item-evaluation}).
This evaluation map is a left, resp.\ right $A$-module homomorphism
if $M$ is a left, resp.\ right $A$-module, see
Remarks \ref{remark-evaluation-map-left} and \ref{remark-evaluation-map-right}.
Finally, given $k \in \mathbf{Z}$ there is a canonical isomorphism
$$
M^\vee[-k] \longrightarrow (M[k])^\vee
$$
of graded $R$-modules which uses a sign and which, if
$M$ is a left, resp.\ right $A$-module, is an isomorphism
of right, resp.\ left $A$-modules. See Remark \ref{remark-shift-dual}.

\medskip\noindent
We claim that $A^\vee$ is an injective object of the category
$\text{Mod}_A$ of graded right $A$-modules. Namely, given a graded
right $A$-module $N$ we have
$$
\Hom_{\text{Mod}_A}(N, A^\vee) =
\Hom_{\text{Comp}(\mathbf{Z})}(N \otimes_A A, \mathbf{Q}/\mathbf{Z})) =
(N^0)^\vee
$$
by Lemma \ref{lemma-characterize-hom}
(applied to the case where all the differentials are zero).
We conclude because the functor $N \mapsto (N^0)^\vee = (N^\vee)^0$
is exact.

\medskip\noindent
Finally, for every graded right $A$-module $M$ we can choose a surjection
of graded left $A$-modules
$$
\bigoplus\nolimits_{i \in I} A[k_i] \to M^\vee
$$
where $A[k_i]$ denotes the shift of $A$ by $k_i \in \mathbf{Z}$.
We do this by choosing homogeneous generators for $M^\vee$.
In this way we get an injection
$$
M \to (M^\vee)^\vee \to \prod A[k_i]^\vee = \prod A^\vee[-k_i]
$$
Observe that the products in the formula above are products in the
category of graded modules (in other words, take products in each degree
and then take the direct sum of the pieces).

\medskip\noindent
We conclude that
\begin{enumerate}
\item the category of graded $A$-modules has enough injectives,
\item for every $k \in \mathbf{Z}$ the module $A^\vee[k]$ is injective, and
\item every $A$-module injects into a product in the category of graded
modules of copies of shifts $A^\vee[k]$.
\end{enumerate}





\section{Injective modules and differential graded algebras}
\label{section-modules-noncommutative-differential-graded}

\noindent
If $(A, \text{d})$ is a differential graded algebra and $I$ is
an object of $\text{Mod}_{(A, \text{d})}$ then we say
{\it $I$ is injective as a graded $A$-module} or sometimes
{\it $I$ is graded injective} to mean
that $I$ is a injective object of the abelian category $\text{Mod}_A$
of graded $A$-modules.

\begin{lemma}
\label{lemma-source-graded-injective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $I \to M$ be an injective homomorphism of differential graded
$A$-modules. If $I$ is graded injective, then
$I \to M$ is an admissible monomorphism.
\end{lemma}

\begin{proof}
This is immediate from the definitions.
\end{proof}

\noindent
Let $(A, \text{d})$ be a differential graded algebra. If $M$ is a
left, resp.\ right differential graded $A$-module, then
$$
M^\vee = \Hom^\bullet(M^\bullet, \mathbf{Q}/\mathbf{Z})
$$
with $A$-module structure constructed in
Section \ref{section-modules-noncommutative-graded} is a
right, resp.\ left differential graded $A$-module by the
discussion in Section \ref{section-hom-complexes}.
By Remarks
\ref{remark-evaluation-map-left} and \ref{remark-evaluation-map-right}
there evaluation map of Section \ref{section-modules-noncommutative-graded}
$$
M \longrightarrow (M^\vee)^\vee
$$
is a homomorphism of left, resp.\ right differential graded $A$-modules

\begin{lemma}
\label{lemma-map-into-dual}
Let $(A, \text{d})$ be a differential graded algebra. If
$M$ is a left differential graded $A$-module and $N$ is a
right differential graded $A$-module, then
\begin{align*}
\Hom_{\text{Mod}_{(A, \text{d})}}(N, M^\vee)
& =
\Hom_{\text{Comp}(\mathbf{Z})}(N \otimes_A M, \mathbf{Q}/\mathbf{Z}) \\
& =
\text{DifferentialGradedBilinear}_A(N \times M, \mathbf{Q}/\mathbf{Z})
\end{align*}
\end{lemma}

\begin{proof}
The first equality is Lemma \ref{lemma-characterize-hom}
and the second equality was shown in Section \ref{section-tensor-product}.
\end{proof}

\begin{lemma}
\label{lemma-hom-into-shift-dual-free}
Let $(A, \text{d})$ be a differential graded algebra. Then we have
$$
\Hom_{\text{Mod}_{(A, \text{d})}}(M, A^\vee[k]) =
\Ker(\text{d} : (M^\vee)^k \to (M^\vee)^{k + 1})
$$
and
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(M, A^\vee[k]) = H^k(M^\vee)
$$
as functors in the differential graded $A$-module $M$.
\end{lemma}

\begin{proof}
This is clear from the discussion above.
\end{proof}















\section{P-resolutions}
\label{section-P-resolutions}

\noindent
This section is the analogue of
Derived Categories, Section \ref{derived-section-unbounded}.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Let $P$ be a differential graded $A$-module. We say $P$
{\it has property (P)} if it there exists a filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset P
$$
by differential graded submodules such that
\begin{enumerate}
\item $P = \bigcup F_pP$,
\item the inclusions $F_iP \to F_{i + 1}P$ are admissible
monomorphisms,
\item the quotients $F_{i + 1}P/F_iP$ are isomorphic as differential
graded $A$-modules to a direct sum of $A[k]$.
\end{enumerate}
In fact, condition (2) is a consequence of condition (3), see
Lemma \ref{lemma-target-graded-projective}. Moreover, the reader
can verify that as a graded $A$-module $P$ will be isomorphic to a
direct sum of shifts of $A$.

\begin{lemma}
\label{lemma-property-P-sequence}
Let $(A, \text{d})$ be a differential graded algebra.
Let $P$ be a differential graded $A$-module. If $F_\bullet$
is a filtration as in property (P), then we obtain an
admissible short exact sequence
$$
0 \to
\bigoplus\nolimits F_iP \to
\bigoplus\nolimits F_iP \to P \to 0
$$
of differential graded $A$-modules.
\end{lemma}

\begin{proof}
The second map is the direct sum of the inclusion maps.
The first map on the summand $F_iP$ of the source is the sum
of the identity $F_iP \to F_iP$ and the negative of the inclusion
map $F_iP \to F_{i + 1}P$. Choose homomorphisms $s_i : F_{i + 1}P \to F_iP$
of graded $A$-modules which are left inverse to the inclusion maps.
Composing gives maps $s_{j, i} : F_jP \to F_iP$ for all $j > i$.
Then a left inverse of the first arrow maps $x \in F_jP$ to
$(s_{j, 0}(x), s_{j, 1}(x), \ldots, s_{j, j - 1}(x), 0, \ldots)$
in $\bigoplus F_iP$.
\end{proof}

\noindent
The following lemma shows that differential graded modules with
property (P) are the dual notion to K-injective modules
(i.e., they are K-projective in some sense). See
Derived Categories, Definition \ref{derived-definition-K-injective}.

\begin{lemma}
\label{lemma-property-P-K-projective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $P$ be a differential graded $A$-module with property (P).
Then
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, N) = 0
$$
for all acyclic differential graded $A$-modules $N$.
\end{lemma}

\begin{proof}
We will use that $K(\text{Mod}_{(A, \text{d})})$ is a triangulated
category (Proposition \ref{proposition-homotopy-category-triangulated}).
Let $F_\bullet$ be a filtration on $P$ as in property (P).
The short exact sequence of Lemma \ref{lemma-property-P-sequence}
produces a distinguished triangle. Hence by
Derived Categories, Lemma \ref{derived-lemma-representable-homological}
it suffices to show that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(F_iP, N) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $i$.
Each of the differential graded modules $F_iP$ has a finite filtration
by admissible monomorphisms, whose graded pieces are direct sums
of shifts $A[k]$. Thus it suffices to prove that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(A[k], N) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $k$.
This follows from Lemma \ref{lemma-hom-from-shift-free}.
\end{proof}

\begin{lemma}
\label{lemma-good-quotient}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$P \to M$ of differential graded $A$-modules with the following
properties
\begin{enumerate}
\item $P \to M$ is surjective,
\item $\Ker(\text{d}_P) \to \Ker(\text{d}_M)$ is surjective, and
\item $P$ sits in an admissible short exact sequence
$0 \to P' \to P \to P'' \to 0$ where $P'$, $P''$ are direct sums
of shifts of $A$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $P_k$ be the free $A$-module with generators $x, y$ in degrees
$k$ and $k + 1$. Define the structure of a differential graded
$A$-module on $P_k$ by setting $\text{d}(x) = y$ and $\text{d}(y) = 0$.
For every element $m \in M^k$ there is a homomorphism
$P_k \to M$ sending $x$ to $m$ and $y$ to $\text{d}(m)$.
Thus we see that there is a surjection from a direct sum
of copies of $P_k$ to $M$. This clearly produces $P \to M$
having properties (1) and (3). To obtain property (2) note
that if $m \in \Ker(\text{d}_M)$ has degree $k$, then there is a map
$A[k] \to M$ mapping $1$ to $m$. Hence we can achieve (2) by adding
a direct sum of copies of shifts of $A$.
\end{proof}

\begin{lemma}
\label{lemma-resolve}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$P \to M$ of differential graded $A$-modules such that
\begin{enumerate}
\item $P \to M$ is a quasi-isomorphism, and
\item $P$ has property (P).
\end{enumerate}
\end{lemma}

\begin{proof}
Set $M = M_0$. We inductively choose short exact sequences
$$
0 \to M_{i + 1} \to P_i \to M_i \to 0
$$
where the maps $P_i \to M_i$ are chosen as in Lemma \ref{lemma-good-quotient}.
This gives a ``resolution''
$$
\ldots \to P_2 \xrightarrow{f_2} P_1 \xrightarrow{f_1} P_0 \to M \to 0
$$
Then we set
$$
P = \bigoplus\nolimits_{i \geq 0} P_i
$$
as an $A$-module with grading given by
$P^n = \bigoplus_{a + b = n} P_{-a}^b$ and
differential (as in the construction of the total complex associated
to a double complex) by
$$
\text{d}_P(x) = f_{-a}(x) + (-1)^a \text{d}_{P_{-a}}(x)
$$
for $x \in P_{-a}^b$. With these conventions $P$ is indeed a differential
graded $A$-module. Recalling that each $P_i$ has a two step filtration
$0 \to P_i' \to P_i \to P_i'' \to 0$ we set
$$
F_{2i}P = \bigoplus\nolimits_{i \geq j \geq 0} P_j
\subset
\bigoplus\nolimits_{i \geq 0} P_i = P
$$
and we add $P'_{i + 1}$ to $F_{2i}P$ to get $F_{2i + 1}$.
These are differential graded submodules and the successive quotients
are direct sums of shifts of $A$. By
Lemma \ref{lemma-target-graded-projective} we see that
the inclusions $F_iP \to F_{i + 1}P$ are admissible monomorphisms.
Finally, we have to show that the map $P \to M$ (given by the
augmentation $P_0 \to M$) is a quasi-isomorphism. This follows from
Homology, Lemma \ref{homology-lemma-good-resolution-gives-qis}.
\end{proof}





\section{I-resolutions}
\label{section-I-resolutions}

\noindent
This section is the dual of the section on P-resolutions.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Let $I$ be a differential graded $A$-module. We say $I$
{\it has property (I)} if it there exists a filtration
$$
I = F_0I \supset F_1I \supset F_2I \supset \ldots \supset 0
$$
by differential graded submodules such that
\begin{enumerate}
\item $I = \lim I/F_pI$,
\item the maps $I/F_{i + 1}I \to I/F_iI$ are admissible epimorphisms,
\item the quotients $F_iI/F_{i + 1}I$ are isomorphic as differential
graded $A$-modules to products of the modules $A^\vee[k]$ constructed
in Section \ref{section-modules-noncommutative-differential-graded}.
\end{enumerate}
In fact, condition (2) is a consequence of condition (3), see
Lemma \ref{lemma-source-graded-injective}. The reader can verify that as
a graded module $I$ will be isomorphic to a product of $A^\vee[k]$.

\begin{lemma}
\label{lemma-property-I-sequence}
Let $(A, \text{d})$ be a differential graded algebra.
Let $I$ be a differential graded $A$-module. If $F_\bullet$
is a filtration as in property (I), then we obtain an
admissible short exact sequence
$$
0 \to I \to
\prod\nolimits I/F_iI \to
\prod\nolimits I/F_iI \to 0
$$
of differential graded $A$-modules.
\end{lemma}

\begin{proof}
Omitted. Hint: This is dual to Lemma \ref{lemma-property-P-sequence}.
\end{proof}

\noindent
The following lemma shows that differential graded modules with
property (I) are the analogue of K-injective modules. See
Derived Categories, Definition \ref{derived-definition-K-injective}.

\begin{lemma}
\label{lemma-property-I-K-injective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $I$ be a differential graded $A$-module with property (I).
Then
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(N, I) = 0
$$
for all acyclic differential graded $A$-modules $N$.
\end{lemma}

\begin{proof}
We will use that $K(\text{Mod}_{(A, \text{d})})$ is a triangulated
category (Proposition \ref{proposition-homotopy-category-triangulated}).
Let $F_\bullet$ be a filtration on $I$ as in property (I).
The short exact sequence of Lemma \ref{lemma-property-I-sequence}
produces a distinguished triangle. Hence by
Derived Categories, Lemma \ref{derived-lemma-representable-homological}
it suffices to show that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(N, I/F_iI) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $i$.
Each of the differential graded modules $I/F_iI$ has a finite filtration
by admissible monomorphisms, whose graded pieces are
products of $A^\vee[k]$. Thus it suffices to prove that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(N, A^\vee[k]) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $k$.
This follows from Lemma \ref{lemma-hom-into-shift-dual-free}
and the fact that $(-)^\vee$ is an exact functor.
\end{proof}

\begin{lemma}
\label{lemma-good-sub}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$M \to I$ of differential graded $A$-modules with the following
properties
\begin{enumerate}
\item $M \to I$ is injective,
\item $\Coker(\text{d}_M) \to \Coker(\text{d}_I)$ is injective,
and
\item $I$ sits in an admissible short exact sequence
$0 \to I' \to I \to I'' \to 0$ where $I'$, $I''$ are products
of shifts of $A^\vee$.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use the functors $N \mapsto N^\vee$ (from left to right
differential graded modules and from right to left differential
graded modules) constructed in
Section \ref{section-modules-noncommutative-differential-graded}
and all of their properties.
For every $k \in \mathbf{Z}$ let $Q_k$ be the free left $A$-module with
generators $x, y$ in degrees $k$ and $k + 1$. Define the structure of a
left differential graded $A$-module on $Q_k$ by setting $\text{d}(x) = y$
and $\text{d}(y) = 0$. Arguing exactly as in the proof of
Lemma \ref{lemma-good-quotient} we find a surjection
$$
\bigoplus\nolimits_{i \in I} Q_{k_i} \longrightarrow M^\vee
$$
of left differential graded $A$-modules. Then we can consider the injection
$$
M \to (M^\vee)^\vee \to (\bigoplus\nolimits_{i \in I} Q_{k_i})^\vee =
\prod\nolimits_{i \in I} I_{k_i}
$$
where $I_k = Q_{-k}^\vee$ is the ``dual'' right differential graded $A$-module.
Further, the short exact sequence $0 \to A[-k - 1] \to Q_k \to A[-k] \to 0$
produces a short exact sequence
$0 \to A^\vee[k] \to I_k \to A^\vee[k + 1] \to 0$.

\medskip\noindent
The result of the previous paragraph produces $M \to I$
having properties (1) and (3). To obtain property (2), suppose
$\overline{m} \in \Coker(\text{d}_M)$ is a nonzero element of
degree $k$. Pick a map $\lambda : M^k \to \mathbf{Q}/\mathbf{Z}$
which vanishes on $\Im(M^{k - 1} \to M^k)$ but not on $m$. By
Lemma \ref{lemma-hom-into-shift-dual-free}
this corresponds to a homomorphism $M \to A^\vee[k]$ of
differential graded $A$-modules which does not vanish on $m$.
Hence we can achieve (2) by adding
a product of copies of shifts of $A^\vee$.
\end{proof}

\begin{lemma}
\label{lemma-right-resolution}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$M \to I$ of differential graded $A$-modules such that
\begin{enumerate}
\item $M \to I$ is a quasi-isomorphism, and
\item $I$ has property (I).
\end{enumerate}
\end{lemma}

\begin{proof}
Set $M = M_0$. We inductively choose short exact sequences
$$
0 \to M_i \to I_i \to M_{i + 1} \to 0
$$
where the maps $M_i \to I_i$ are chosen as in Lemma \ref{lemma-good-sub}.
This gives a ``resolution''
$$
0 \to M \to I_0 \xrightarrow{f_0} I_1 \xrightarrow{f_1} I_1 \to \ldots
$$
Denote $I$ the differential graded $A$-module with graded parts
$$
I^n = \prod\nolimits_{i \geq 0} I^{n - i}_i
$$
and differential defined by
$$
\text{d}_I(x) = f_i(x) + (-1)^i \text{d}_{I_i}(x)
$$
for $x \in I_i^{n - i}$. With these conventions $I$ is indeed a differential
graded $A$-module. Recalling that each $I_i$ has a two step filtration
$0 \to I_i' \to I_i \to I_i'' \to 0$ we set
$$
F_{2i}I^n = \prod\nolimits_{j \geq i} I^{n - j}_j
\subset
\prod\nolimits_{i \geq 0} I^{n - i}_i = I^n
$$
and we add a factor $I'_{i + 1}$ to $F_{2i}I$ to get $F_{2i + 1}I$.
These are differential graded submodules and the successive quotients
are products of shifts of $A^\vee$. By
Lemma \ref{lemma-source-graded-injective} we see that
the inclusions $F_{i + 1}I \to F_iI$ are admissible monomorphisms.
Finally, we have to show that the map $M \to I$ (given by the
augmentation $M \to I_0$) is a quasi-isomorphism. This follows from
Homology, Lemma \ref{homology-lemma-good-right-resolution-gives-qis}.
\end{proof}






\section{The derived category}
\label{section-derived}

\noindent
Recall that the notions of acyclic differential graded modules
and quasi-isomorphism of differential graded modules make sense
(see Section \ref{section-modules}).

\begin{lemma}
\label{lemma-acyclic}
Let $(A, \text{d})$ be a differential graded algebra.
The full subcategory $\text{Ac}$ of $K(\text{Mod}_{(A, \text{d})})$
consisting of acyclic modules is a strictly full saturated triangulated
subcategory of $K(\text{Mod}_{(A, \text{d})})$.
The corresponding saturated multiplicative system
(see Derived Categories, Lemma \ref{derived-lemma-operations})
of $K(\text{Mod}_{(A, \text{d})})$ is the class $\text{Qis}$
of quasi-isomorphisms. In particular, the kernel of the localization
functor
$$
Q : K(\text{Mod}_{(A, \text{d})}) \to
\text{Qis}^{-1}K(\text{Mod}_{(A, \text{d})})
$$
is $\text{Ac}$. Moreover, the functor $H^0$ factors through $Q$.
\end{lemma}

\begin{proof}
We know that $H^0$ is a homological functor by the long exact
sequence of homology (\ref{equation-les}).
The kernel of $H^0$ is the subcategory of acyclic objects and
the arrows with induce isomorphisms on all $H^i$ are the
quasi-isomorphisms. Thus this lemma is a special case of
Derived Categories, Lemma \ref{derived-lemma-acyclic-general}.

\medskip\noindent
Set theoretical remark. The construction of the localization in
Derived Categories, Proposition
\ref{derived-proposition-construct-localization}
assumes the given triangulated category is ``small'', i.e., that the
underlying collection of objects forms a set. Let $V_\alpha$ be a
partial universe (as in Sets, Section \ref{sets-section-sets-hierarchy})
containing $(A, \text{d})$ and where the cofinality of $\alpha$
is bigger than $\aleph_0$
(see Sets, Proposition \ref{sets-proposition-exist-ordinals-large-cofinality}).
Then we can consider the category $\text{Mod}_{(A, \text{d}), \alpha}$
of differential graded $A$-modules contained in $V_\alpha$.
A straightforward check shows that all the constructions used in
the proof of Proposition \ref{proposition-homotopy-category-triangulated}
work inside of $\text{Mod}_{(A, \text{d}), \alpha}$
(because at worst we take finite direct sums of differential graded modules).
Thus we obtain a triangulated category
$\text{Qis}_\alpha^{-1}K(\text{Mod}_{(A, \text{d}), \alpha})$.
We will see below that if $\beta > \alpha$, then the transition functors
$$
\text{Qis}_\alpha^{-1}K(\text{Mod}_{(A, \text{d}), \alpha})
\longrightarrow
\text{Qis}_\beta^{-1}K(\text{Mod}_{(A, \text{d}), \beta})
$$
are fully faithful as the morphism sets in the quotient categories
are computed by maps in the homotopy categories from P-resolutions
(the construction of a P-resolution in the proof of Lemma \ref{lemma-resolve}
takes countable direct sums as well as direct sums indexed over subsets
of the given module). The reader should therefore think of the category
of the lemma as the union of these subcategories.
\end{proof}

\noindent
Taking into account the set theoretical remark at the end of the
proof of the preceding lemma we define the derived category as follows.

\begin{definition}
\label{definition-unbounded-derived-category}
Let $(A, \text{d})$ be a differential graded algebra.
Let $\text{Ac}$ and $\text{Qis}$ be as in Lemma \ref{lemma-acyclic}.
The {\it derived category of $(A, \text{d})$} is the triangulated
category
$$
D(A, \text{d}) =
K(\text{Mod}_{(A, \text{d})})/\text{Ac} =
\text{Qis}^{-1}K(\text{Mod}_{(A, \text{d})}).
$$
We denote $H^0 : D(A, \text{d}) \to \text{Mod}_R$ the unique functor
whose composition with the quotient functor gives back the functor
$H^0$ defined above.
\end{definition}

\noindent
Here is the promised lemma computing morphism sets in the
derived category.

\begin{lemma}
\label{lemma-hom-derived}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ and $N$ be differential graded $A$-modules.
\begin{enumerate}
\item Let $P \to M$ be a P-resolution as in
Lemma \ref{lemma-resolve}. Then
$$
\Hom_{D(A, \text{d})}(M, N) =
\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, N)
$$
\item Let $N \to I$ be an I-resolution as in
Lemma \ref{lemma-right-resolution}. Then
$$
\Hom_{D(A, \text{d})}(M, N) =
\Hom_{K(\text{Mod}_{(A, \text{d})})}(M, I)
$$
\end{enumerate}
\end{lemma}

\begin{proof}
Let $P \to M$ be as in (1). Since $P \to M$ is a quasi-isomorphism we see that
$$
\Hom_{D(A, \text{d})}(P, N) = \Hom_{D(A, \text{d})}(M, N)
$$
by definition of the derived category. A morphism
$f : P \to N$ in $D(A, \text{d})$ is equal to
$s^{-1}f'$ where $f' : P \to N'$ is a morphism and
$s : N \to N'$ is a quasi-isomorphism. Choose a distinguished triangle
$$
N \to N' \to Q \to N[1]
$$
As $s$ is a quasi-isomorphism, we see that $Q$ is acyclic. Thus
$\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, Q[k]) = 0$ for all $k$ by
Lemma \ref{lemma-property-P-K-projective}. Since
$\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, -)$
is cohomological, we conclude that we can lift $f' : P \to N'$
uniquely to a morphism $f : P \to N$. This finishes the proof.

\medskip\noindent
The proof of (2) is dual to that of (1) using
Lemma \ref{lemma-property-I-K-injective} in stead of
Lemma \ref{lemma-property-P-K-projective}.
\end{proof}

\begin{lemma}
\label{lemma-derived-products}
Let $(A, \text{d})$ be a differential graded algebra. Then
\begin{enumerate}
\item $D(A, \text{d})$ has both direct sums and products,
\item direct sums are obtained by taking direct sums of differential graded
modules,
\item products are obtained by taking products of differential
graded modules.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use that $\text{Mod}_{(A, \text{d})}$ is an abelian category
with arbitrary direct sums and products, and that these give rise
to direct sums and products in $K(\text{Mod}_{(A, \text{d})})$.
See Lemmas \ref{lemma-dgm-abelian} and \ref{lemma-homotopy-direct-sums}.

\medskip\noindent
Let $M_j$ be a family of differential graded $A$-modules.
Consider the graded direct sum $M = \bigoplus M_j$ which is a
differential graded $A$-module with the obvious.
For a differential graded $A$-module $N$ choose a quasi-isomorphism
$N \to I$ where $I$ is a differential graded $A$-module with property (I).
See Lemma \ref{lemma-right-resolution}.
Using Lemma \ref{lemma-hom-derived} we have
\begin{align*}
\Hom_{D(A, \text{d})}(M, N)
& =
\Hom_{K(A, \text{d})}(M, I) \\
& =
\prod \Hom_{K(A, \text{d})}(M_j, I) \\
& =
\prod \Hom_{D(A, \text{d})}(M_j, N)
\end{align*}
whence the existence of direct sums in $D(A, \text{d})$ as given in
part (2) of the lemma.

\medskip\noindent
Let $M_j$ be a family of differential graded $A$-modules.
Consider the product $M = \prod M_j$ of differential graded $A$-modules.
For a differential graded $A$-module $N$ choose a quasi-isomorphism
$P \to N$ where $P$ is a differential graded $A$-module with property (P).
See Lemma \ref{lemma-resolve}.
Using Lemma \ref{lemma-hom-derived} we have
\begin{align*}
\Hom_{D(A, \text{d})}(N, M)
& =
\Hom_{K(A, \text{d})}(P, M) \\
& =
\prod \Hom_{K(A, \text{d})}(P, M_j) \\
& =
\prod \Hom_{D(A, \text{d})}(N, M_j)
\end{align*}
whence the existence of direct sums in $D(A, \text{d})$ as given in
part (3) of the lemma.
\end{proof}

\begin{remark}
\label{remark-P-resolution}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded $R$-algebra.
Using P-resolutions we can sometimes reduce statements about general
objects of $D(A, \text{d})$ to statements about $A[k]$. Namely, let
$T$ be a property of objects of $D(A, \text{d})$ and assume that
\begin{enumerate}
\item if $K_i$, $i \in I$ is a family of objects of $D(A, \text{d})$
and $T(K_i)$ holds for all $i \in I$, then $T(\bigoplus K_i)$,
\item if $K \to L \to M \to K[1]$ is a distinguished triangle of
$D(A, \text{d})$ and $T$ holds for two, then $T$
holds for the third object, and
\item $T(A[k])$ holds for all $k \in \mathbf{Z}$.
\end{enumerate}
Then $T$ holds for all objects of $D(A, \text{d})$. This is clear from
Lemmas \ref{lemma-property-P-sequence} and \ref{lemma-resolve}.
\end{remark}







\section{The canonical delta-functor}
\label{section-canonical-delta-functor}

\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Consider the functor
$\text{Mod}_{(A, \text{d})} \to K(\text{Mod}_{(A, \text{d})})$.
This functor is {\bf not} a $\delta$-functor in general.
However, it turns out that the functor
$\text{Mod}_{(A, \text{d})} \to D(A, \text{d})$ is a
$\delta$-functor. In order to see this we have to define
the morphisms $\delta$ associated to a short exact sequence
$$
0 \to K \xrightarrow{a} L \xrightarrow{b} M \to 0
$$
in the abelian category $\text{Mod}_{(A, \text{d})}$.
Consider the cone $C(a)$ of the morphism $a$. We have $C(a) = L \oplus K$
and we define $q : C(a) \to M$ via the projection to $L$ followed
by $b$. Hence a homomorphism of differential graded $A$-modules
$$
q : C(a) \longrightarrow M.
$$
It is clear that $q \circ i = b$ where $i$ is as in
Definition \ref{definition-cone}.
Note that, as $a$ is injective, the kernel of $q$ is identified with the
cone of $\text{id}_K$ which is acyclic. Hence we see that
$q$ is a quasi-isomorphism. According to
Lemma \ref{lemma-the-same-up-to-isomorphisms}
the triangle
$$
(K, L, C(a), a, i, -p)
$$
is a distinguished triangle in $K(\text{Mod}_{(A, \text{d})})$.
As the localization functor
$K(\text{Mod}_{(A, \text{d})}) \to D(A, \text{d})$ is
exact we see that $(K, L, C(a), a, i, -p)$ is a distinguished
triangle in $D(A, \text{d})$. Since $q$ is a quasi-isomorphism
we see that $q$ is an isomorphism in $D(A, \text{d})$.
Hence we deduce that
$$
(K, L, M, a, b, -p \circ q^{-1})
$$
is a distinguished triangle of $D(A, \text{d})$.
This suggests the following lemma.

\begin{lemma}
\label{lemma-derived-canonical-delta-functor}
Let $(A, \text{d})$ be a differential graded algebra. The functor
$\text{Mod}_{(A, \text{d})} \to D(A, \text{d})$
defined has the natural structure of a $\delta$-functor, with
$$
\delta_{K \to L \to M} = - p \circ q^{-1}
$$
with $p$ and $q$ as explained above.
\end{lemma}

\begin{proof}
We have already seen that this choice leads to a distinguished
triangle whenever given a short exact sequence of complexes.
We have to show functoriality of this construction, see
Derived Categories, Definition \ref{derived-definition-delta-functor}.
This follows from Lemma \ref{lemma-functorial-cone} with a bit of
work. Compare with
Derived Categories, Lemma \ref{derived-lemma-derived-canonical-delta-functor}.
\end{proof}

\begin{lemma}
\label{lemma-homotopy-colimit}
Let $(A, \text{d})$ be a differential graded algebra. Let
$M_n$ be a system of differential graded modules. Then the derived
colimit $\text{hocolim} M_n$ in $D(A, \text{d})$ is represented
by the differential graded module $\colim M_n$.
\end{lemma}

\begin{proof}
Set $M = \colim M_n$. We have an exact sequence of differential graded modules
$$
0 \to \bigoplus M_n \to \bigoplus M_n \to M \to 0
$$
by Derived Categories, Lemma \ref{derived-lemma-compute-colimit}
(applied the underlying complexes of abelian groups).
The direct sums are direct sums in $D(\mathcal{A})$ by
Lemma \ref{lemma-derived-products}.
Thus the result follows from the definition
of derived colimits in Derived Categories,
Definition \ref{derived-definition-derived-colimit}
and the fact that a short exact sequence of complexes
gives a distinguished triangle
(Lemma \ref{lemma-derived-canonical-delta-functor}).
\end{proof}








\section{Linear categories}
\label{section-linear}

\noindent
Just the definitions.

\begin{definition}
\label{definition-linear-category}
Let $R$ be a ring. An {\it $R$-linear category $\mathcal{A}$} is a category
where every morphism set is given the structure of an $R$-module
and where for $x, y, z \in \Ob(\mathcal{A})$ composition law
$$
\Hom_\mathcal{A}(y, z) \times \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
is $R$-bilinear.
\end{definition}

\noindent
Thus composition determines an $R$-linear map
$$
\Hom_\mathcal{A}(y, z) \otimes_R \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
of $R$-modules. Note that we do not assume $R$-linear categories to be
additive.

\begin{definition}
\label{definition-functor-linear-categories}
Let $R$ be a ring. A {\it functor of $R$-linear categories}, or an
{\it $R$-linear functor} is a functor $F : \mathcal{A} \to \mathcal{B}$
where for all objects $x, y$ of $\mathcal{A}$ the map
$F : \Hom_\mathcal{A}(x, y) \to \Hom_\mathcal{B}(F(x), F(y))$
is a homomorphism of $R$-modules.
\end{definition}







\section{Graded categories}
\label{section-graded}

\noindent
Just some definitions.

\begin{definition}
\label{definition-graded-category}
Let $R$ be a ring. A {\it graded category $\mathcal{A}$
over $R$} is a category where every morphism set is given the structure
of a graded $R$-module and where for
$x, y, z \in \Ob(\mathcal{A})$ composition is $R$-bilinear and induces
a homomorphism
$$
\Hom_\mathcal{A}(y, z) \otimes_R \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
of graded $R$-modules (i.e., preserving degrees).
\end{definition}

\noindent
In this situation we denote $\Hom_\mathcal{A}^i(x, y)$ the degree $i$
part of the graded object $\Hom_\mathcal{A}(x, y)$, so that
$$
\Hom_\mathcal{A}(x, y) =
\bigoplus\nolimits_{i \in \mathbf{Z}} \Hom_\mathcal{A}^i(x, y)
$$
is the direct sum decomposition into graded parts.

\begin{definition}
\label{definition-functor-graded-categories}
Let $R$ be a ring. A {\it functor of graded categories over $R$}, or a
{\it graded functor}
is a functor $F : \mathcal{A} \to \mathcal{B}$ where for all objects
$x, y$ of $\mathcal{A}$ the map
$F : \Hom_\mathcal{A}(x, y) \to \Hom_\mathcal{A}(F(x), F(y))$
is a homomorphism of graded $R$-modules.
\end{definition}

\noindent
Given a graded category we are often interested in the
corresponding ``usual'' category of maps of degree $0$.
Here is a formal definition.

\begin{definition}
\label{definition-H0-of-graded-category}
Let $R$ be a ring. Let $\mathcal{A}$ be a graded category
over $R$. We let {\it $\mathcal{A}^0$} be the category with the
same objects as $\mathcal{A}$ and with
$$
\Hom_{\mathcal{A}^0}(x, y) = \Hom^0_\mathcal{A}(x, y)
$$
the degree $0$ graded piece of the graded module of morphisms of
$\mathcal{A}$.
\end{definition}

\begin{definition}
\label{definition-graded-direct-sum}
Let $R$ be a ring. Let $\mathcal{A}$ be a graded category over $R$.
A direct sum $(x, y, z, i, j, p, q)$ in $\mathcal{A}$ (notation as in
Homology, Remark \ref{homology-remark-direct-sum})
is a {\it graded direct sum} if $i, j, p, q$ are homogeneous
of degree $0$.
\end{definition}

\begin{example}[Graded category of graded objects]
\label{example-graded-category-graded-objects}
Let $\mathcal{B}$ be an additive category. Recall that we have defined
the category $\text{Gr}(\mathcal{B})$ of graded objects of $\mathcal{B}$ in
Homology, Definition \ref{homology-definition-graded}.
In this example, we will construct a graded category
$\text{Gr}^{gr}(\mathcal{B})$ over $R = \mathbf{Z}$
whose associated category $\text{Gr}^{gr}(\mathcal{B})^0$
recovers $\text{Gr}(\mathcal{B})$.
As objects of $\text{Gr}^{gr}(\mathcal{B})$
we take graded objects of $\mathcal{B}$. Then, given graded objects
$A = (A^i)$ and $B = (B^i)$ of $\mathcal{B}$ we set
$$
\Hom_{\text{Gr}^{gr}(\mathcal{B})}(A, B) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom^n(A, B)
$$
where the graded piece of degree $n$ is the abelian group of homogeneous
maps of degree $n$ from $A$ to $B$. Explicitly we have
$$
\Hom^n(A, B) = \prod\nolimits_{p + q = n} \Hom_\mathcal{B}(A^{-q}, B^p)
$$
(observe reversal of indices and observe that we have a product here and
not a direct sum). In other words, a degree $n$ morphism $f$
from $A$ to $B$ can be seen as a system $f = (f_{p, q})$ where
$p, q \in \mathbf{Z}$, $p + q = n$ with
$f_{p, q} : A^{-q} \to B^p$ a morphism of $\mathcal{B}$.
Given graded objects $A$, $B$, $C$ of $\mathcal{B}$
composition of morphisms in $\text{Gr}^{gr}(\mathcal{B})$ is defined
via the maps
$$
\Hom^m(B, C) \times \Hom^n(A, B) \longrightarrow \Hom^{n + m}(A, C)
$$
by simple composition $(g, f) \mapsto g \circ f$ of homogeneous
maps of graded objects. In terms of components we have
$$
(g \circ f)_{p, r} = g_{p, q} \circ f_{-q, r}
$$
where $q$ is such that $p + q = m$ and $-q + r = n$.
\end{example}

\begin{example}[Graded category of graded modules]
\label{example-gm-gr-cat}
Let $A$ be a $\mathbf{Z}$-graded algebra over a ring $R$. We will construct
a graded category $\text{Mod}^{gr}_A$ over $R$ whose associated category
$(\text{Mod}^{gr}_A)^0$ is the category of graded $A$-modules. As objects
of $\text{Mod}^{gr}_A$ we take right graded $A$-modules (see
Section \ref{section-projectives-over-algebras}). Given graded
$A$-modules $L$ and $M$ we set
$$
\Hom_{\text{Mod}^{gr}_A}(L, M) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom^n(L, M)
$$
where $\Hom^n(L, M)$ is the set of right $A$-module maps $L \to M$ which
are homogeneous of degree $n$, i.e., $f(L^i) \subset M^{i + n}$ for
all $i \in \mathbf{Z}$. In terms of components, we have that
$$
\Hom^n(L, M) \subset \prod\nolimits_{p + q = n} \Hom_R(L^{-q}, M^p)
$$
(observe reversal of indices) is the subset consisting of those
$f = (f_{p, q})$ such that
$$
f_{p, q}(m a) = f_{p - i, q + i}(m)a
$$
for $a \in A^i$ and $m \in L^{-q - i}$. For graded $A$-modules
$K$, $L$, $M$ we define composition in $\text{Mod}^{gr}_A$ via
the maps
$$
\Hom^m(L, M) \times \Hom^n(K, L) \longrightarrow \Hom^{n + m}(K, M)
$$
by simple composition of right $A$-module maps: $(g, f) \mapsto g \circ f$.
\end{example}

\begin{remark}
\label{remark-graded-shift-functors}
Let $R$ be a ring. Let $\mathcal{D}$ be an $R$-linear category endowed with a
collection of $R$-linear functors $[n] : \mathcal{D} \to \mathcal{D}$,
$x \mapsto x[n]$ indexed by $n \in \mathbf{Z}$ such that
$[n] \circ [m] = [n + m]$ and $[0] = \text{id}_\mathcal{D}$ (equality as
functors). This allows us to construct a graded category $\mathcal{D}^{gr}$
over $R$ with the same objects of $\mathcal{D}$ setting
$$
\Hom_{\mathcal{D}^{gr}}(x, y) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom_\mathcal{D}(x, y[n])
$$
for $x, y$ in $\mathcal{D}$. Observe that $(\mathcal{D}^{gr})^0 = \mathcal{D}$
(see Definition \ref{definition-H0-of-graded-category}). Moreover, the graded
category $\mathcal{D}^{gr}$ inherits $R$-linear graded functors $[n]$
satisfying $[n] \circ [m] = [n + m]$ and $[0] = \text{id}_{\mathcal{D}^{gr}}$
with the property that
$$
\Hom_{\mathcal{D}^{gr}}(x, y[n]) = \Hom_{\mathcal{D}^{gr}}(x, y)[n]
$$
as graded $R$-modules compatible with composition of morphisms.

\medskip\noindent
Conversely, suppose given a graded category $\mathcal{A}$ over $R$ endowed
with a collection of $R$-linear graded functors $[n]$
satisfying $[n] \circ [m] = [n + m]$ and $[0] = \text{id}_\mathcal{A}$
which are moreover equipped with isomorphisms
$$
\Hom_\mathcal{A}(x, y[n]) = \Hom_\mathcal{A}(x, y)[n]
$$
as graded $R$-modules compatible with composition of morphisms. Then
the reader easily shows that $\mathcal{A} = (\mathcal{A}^0)^{gr}$.

\medskip\noindent
Here are two examples of the relationship
$\mathcal{D} \leftrightarrow \mathcal{A}$ we established above:
\begin{enumerate}
\item Let $\mathcal{B}$ be an additive category. If
$\mathcal{D} = \text{Gr}(\mathcal{B})$, then
$\mathcal{A} = \text{Gr}^{gr}(\mathcal{B})$ as in
Example \ref{example-graded-category-graded-objects}.
\item If $A$ is a graded ring and $\mathcal{D} = \text{Mod}_A$
is the category of graded right $A$-modules, then
$\mathcal{A} = \text{Mod}^{gr}_A$, see Example \ref{example-gm-gr-cat}.
\end{enumerate}
\end{remark}






\section{Differential graded categories}
\label{section-dga-categories}

\noindent
Note that if $R$ is a ring, then $R$ is a differential graded algebra
over itself (with $R = R^0$ of course). In this case a differential
graded $R$-module is the same thing as a complex of $R$-modules.
In particular, given two differential graded $R$-modules $M$ and $N$
we denote $M \otimes_R N$ the differential graded $R$-module
corresponding to the total complex associated to the double
complex obtained by the tensor product of the complexes of $R$-modules
associated to $M$ and $N$.

\begin{definition}
\label{definition-dga-category}
Let $R$ be a ring. A {\it differential graded category $\mathcal{A}$
over $R$} is a category where every morphism set is given the structure
of a differential graded $R$-module and where for
$x, y, z \in \Ob(\mathcal{A})$ composition is $R$-bilinear and induces
a homomorphism
$$
\Hom_\mathcal{A}(y, z) \otimes_R \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
of differential graded $R$-modules.
\end{definition}

\noindent
The final condition of the definition signifies the following:
if $f \in \Hom_\mathcal{A}^n(x, y)$ and
$g \in \Hom_\mathcal{A}^m(y, z)$ are homogeneous
of degrees $n$ and $m$, then
$$
\text{d}(g \circ f) = \text{d}(g) \circ f + (-1)^mg \circ \text{d}(f)
$$
in $\Hom_\mathcal{A}^{n + m + 1}(x, z)$. This follows from the sign
rule for the differential on the total complex of a double complex, see
Homology, Definition \ref{homology-definition-associated-simple-complex}.

\begin{definition}
\label{definition-functor-dga-categories}
Let $R$ be a ring. A {\it functor of differential graded categories over $R$}
is a functor $F : \mathcal{A} \to \mathcal{B}$ where for all objects
$x, y$ of $\mathcal{A}$ the map
$F : \Hom_\mathcal{A}(x, y) \to \Hom_\mathcal{A}(F(x), F(y))$
is a homomorphism of differential graded $R$-modules.
\end{definition}

\noindent
Given a differential graded category we are often interested in the
corresponding categories of complexes and homotopy category.
Here is a formal definition.

\begin{definition}
\label{definition-homotopy-category-of-dga-category}
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category
over $R$. Then we let
\begin{enumerate}
\item the {\it category of complexes of $\mathcal{A}$}\footnote{This may
be nonstandard terminology.} be the category
$\text{Comp}(\mathcal{A})$ whose objects are the same as the objects
of $\mathcal{A}$ and with
$$
\Hom_{\text{Comp}(\mathcal{A})}(x, y) =
\Ker(d : \Hom^0_\mathcal{A}(x, y) \to \Hom^1_\mathcal{A}(x, y))
$$
\item the {\it homotopy category of $\mathcal{A}$} be the category
$K(\mathcal{A})$ whose objects are the same as the objects
of $\mathcal{A}$ and with
$$
\Hom_{K(\mathcal{A})}(x, y) = H^0(\Hom_\mathcal{A}(x, y))
$$
\end{enumerate}
\end{definition}

\noindent
Our use of the symbol $K(\mathcal{A})$ is nonstandard, but at least
is compatible with the use of $K(-)$ in other chapters of the Stacks project.

\begin{definition}
\label{definition-dg-direct-sum}
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category over
$R$. A direct sum $(x, y, z, i, j, p, q)$ in $\mathcal{A}$ (notation as in
Homology, Remark \ref{homology-remark-direct-sum})
is a {\it differential graded direct sum} if $i, j, p, q$ are homogeneous
of degree $0$ and closed, i.e., $\text{d}(i) = 0$, etc.
\end{definition}

\begin{lemma}
\label{lemma-functorial}
Let $R$ be a ring. A functor $F : \mathcal{A} \to \mathcal{B}$
of differential graded categories over $R$ induces functors
$\text{Comp}(\mathcal{A}) \to \text{Comp}(\mathcal{B})$
and $K(\mathcal{A}) \to K(\mathcal{B})$.
\end{lemma}

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

\begin{example}[Differential graded category of complexes]
\label{example-category-complexes}
Let $\mathcal{B}$ be an additive category. We will construct
a differential graded category $\text{Comp}^{dg}(\mathcal{B})$
over $R = \mathbf{Z}$ whose associated category of complexes
is $\text{Comp}(\mathcal{B})$ and whose associated homotopy
category is $K(\mathcal{B})$. As objects of $\text{Comp}^{dg}(\mathcal{B})$
we take complexes of $\mathcal{B}$. Given complexes
$A^\bullet$ and $B^\bullet$ of $\mathcal{B}$, we sometimes also
denote $A^\bullet$ and $B^\bullet$ the corresponding graded objects
of $\mathcal{B}$ (i.e., forget about the differential).
Using this abuse of notation, we set
$$
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, B^\bullet) =
\Hom_{\text{Gr}^{gr}(\mathcal{B})}(A^\bullet, B^\bullet) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom^n(A, B)
$$
as a graded $\mathbf{Z}$-module with notation and definitions as
in Example \ref{example-graded-category-graded-objects}.
In other words, the $n$th graded piece is
the abelian group of homogeneous morphism of degree $n$ of graded objects
$$
\Hom^n(A^\bullet, B^\bullet) =
\prod\nolimits_{p + q = n} \Hom_\mathcal{B}(A^{-q}, B^p)
$$
Observe reversal of indices and observe we have a direct product
and not a direct sum. For an element
$f \in \Hom^n(A^\bullet, B^\bullet)$ of degree $n$ we set
$$
\text{d}(f) = \text{d}_B \circ f - (-1)^n f \circ \text{d}_A
$$
The sign is exactly as in
More on Algebra, Section \ref{more-algebra-section-sign-rules}.
To make sense of this we think of $\text{d}_B$ and $\text{d}_A$
as maps of graded objects of $\mathcal{B}$ homogeneous of degree $1$
and we use composition in the category $\text{Gr}^{gr}(\mathcal{B})$
on the right hand side. In terms of components, if $f = (f_{p, q})$ with
$f_{p, q} : A^{-q} \to B^p$ we have
\begin{equation}
\label{equation-differential-hom-complex}
\text{d}(f_{p, q}) =
\text{d}_B \circ f_{p, q} - (-1)^{p + q} f_{p, q} \circ \text{d}_A 
\end{equation}
Note that the first term of this expression is in
$\Hom_\mathcal{B}(A^{-q}, B^{p + 1})$ and the second term is in
$\Hom_\mathcal{B}(A^{-q - 1}, B^p)$. The reader checks that
\begin{enumerate}
\item $\text{d}$ has square zero,
\item an element $f$ in $\Hom^n(A^\bullet, B^\bullet)$
has $\text{d}(f) = 0$ if and only if the morphism
$f : A^\bullet \to B^\bullet[n]$ of graded objects of $\mathcal{B}$
is actually a map of complexes,
\item in particular, the category of complexes of
$\text{Comp}^{dg}(\mathcal{B})$ is equal to $\text{Comp}(\mathcal{B})$,
\item the morphism of complexes defined by $f$ as in (2)
is homotopy equivalent to zero if and only if $f = \text{d}(g)$
for some $g \in \Hom^{n - 1}(A^\bullet, B^\bullet)$.
\item in particular, we obtain a canonical isomorphism
$$
\Hom_{K(\mathcal{B})}(A^\bullet, B^\bullet)
\longrightarrow
H^0(\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, B^\bullet))
$$
and the homotopy category of $\text{Comp}^{dg}(\mathcal{B})$ is equal to
$K(\mathcal{B})$.
\end{enumerate}
Given complexes $A^\bullet$, $B^\bullet$, $C^\bullet$ we define
composition
$$
\Hom^m(B^\bullet, C^\bullet) \times \Hom^n(A^\bullet, B^\bullet)
\longrightarrow
\Hom^{n + m}(A^\bullet, C^\bullet)
$$
by composition $(g, f) \mapsto g \circ f$ in the graded category
$\text{Gr}^{gr}(\mathcal{B})$, see
Example \ref{example-graded-category-graded-objects}.
This defines a map of differential graded modules
$$
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(B^\bullet, C^\bullet)
\otimes_R
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, B^\bullet)
\longrightarrow
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, C^\bullet)
$$
as required in Definition \ref{definition-dga-category}
because
\begin{align*}
\text{d}(g \circ f) & =
\text{d}_C \circ g \circ f - (-1)^{n + m} g \circ f \circ \text{d}_A \\
& =
\left(\text{d}_C \circ g - (-1)^m g \circ \text{d}_B\right) \circ f +
(-1)^m g \circ \left(\text{d}_B \circ f - (-1)^n f \circ \text{d}_A\right) \\
& =
\text{d}(g) \circ f + (-1)^m g \circ \text{d}(f)
\end{align*}
as desired.
\end{example}

\begin{lemma}
\label{lemma-additive-functor-induces-dga-functor}
Let $F : \mathcal{B} \to \mathcal{B}'$ be an additive functor between
additive categories. Then $F$ induces a functor of differential
graded categories
$$
F : \text{Comp}^{dg}(\mathcal{B}) \to \text{Comp}^{dg}(\mathcal{B}')
$$
of Example \ref{example-category-complexes}
inducing the usual functors on the category of complexes and the
homotopy categories.
\end{lemma}

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

\begin{example}[Differential graded category of differential graded modules]
\label{example-dgm-dg-cat}
Let $(A, \text{d})$ be a differential graded algebra over a ring $R$. We will
construct a differential graded category $\text{Mod}^{dg}_{(A, \text{d})}$
over $R$ whose category of complexes is $\text{Mod}_{(A, \text{d})}$ and
whose homotopy category is $K(\text{Mod}_{(A, \text{d})})$.
As objects of $\text{Mod}^{dg}_{(A, \text{d})}$
we take the differential graded $A$-modules. Given differential
graded $A$-modules $L$ and $M$ we set
$$
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(L, M) =
\Hom_{\text{Mod}^{gr}_A}(L, M) = \bigoplus \Hom^n(L, M)
$$
as a graded $R$-module where the right hand side is defined as in
Example \ref{example-gm-gr-cat}. In other words, the $n$th graded piece
$\Hom^n(L, M)$ is the $R$-module of right $A$-module maps homogeneous
of degree $n$. For an element $f \in \Hom^n(L, M)$ we set
$$
\text{d}(f) = \text{d}_M \circ f - (-1)^n f \circ \text{d}_L
$$
To make sense of this we think of $\text{d}_M$ and $\text{d}_L$
as graded $R$-module maps and we use composition of graded
$R$-module maps. It is clear that $\text{d}(f)$ is homogeneous of
degree $n + 1$ as a graded $R$-module map, and it is $A$-linear
because
\begin{align*}
\text{d}(f)(xa)
& =
\text{d}_M(f(x) a) - (-1)^n f (\text{d}_L(xa)) \\
& =
\text{d}_M(f(x)) a + (-1)^{\deg(x) + n} f(x) \text{d}(a) 
- (-1)^n f(\text{d}_L(x)) a - (-1)^{n + \deg(x)} f(x) \text{d}(a) \\
& = \text{d}(f)(x) a
\end{align*}
as desired (observe that this calculation would not work without the
sign in the definition of our differential on $\Hom$). Similar formulae
to those of Example \ref{example-category-complexes} hold for the
differential of $f$ in terms of components.
The reader checks (in the same way as in
Example \ref{example-category-complexes}) that
\begin{enumerate}
\item $\text{d}$ has square zero,
\item an element $f$ in $\Hom^n(L, M)$ has $\text{d}(f) = 0$ if and only if
$f : L \to M[n]$ is a homomorphism of differential graded $A$-modules,
\item in particular, the category of complexes of
$\text{Mod}^{dg}_{(A, \text{d})}$ is $\text{Mod}_{(A, \text{d})}$,
\item the homomorphism defined by $f$ as in (2) is homotopy equivalent
to zero if and only if $f = \text{d}(g)$ for some
$g \in \Hom^{n - 1}(L, M)$.
\item in particular, we obtain a canonical isomorphism
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(L, M)
\longrightarrow
H^0(\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(L, M))
$$
and the homotopy category of $\text{Mod}^{dg}_{(A, \text{d})}$ is
$K(\text{Mod}_{(A, \text{d})})$.
\end{enumerate}
Given differential graded $A$-modules $K$, $L$, $M$ we define
composition
$$
\Hom^m(L, M) \times \Hom^n(K, L) \longrightarrow \Hom^{n + m}(K, M)
$$
by composition of homogeneous right $A$-module maps $(g, f) \mapsto g \circ f$.
This defines a map of differential graded modules
$$
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(L, M) \otimes_R
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(K, L) \longrightarrow
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(K, M)
$$
as required in
Definition \ref{definition-dga-category}
because
\begin{align*}
\text{d}(g \circ f) & =
\text{d}_M \circ g \circ f - (-1)^{n + m} g \circ f \circ \text{d}_K \\
& =
\left(\text{d}_M \circ g - (-1)^m g \circ \text{d}_L\right) \circ f +
(-1)^m g \circ \left(\text{d}_L \circ f - (-1)^n f \circ \text{d}_K\right) \\
& =
\text{d}(g) \circ f + (-1)^m g \circ \text{d}(f)
\end{align*}
as desired.
\end{example}

\begin{lemma}
\label{lemma-homomorphism-induces-dga-functor}
Let $\varphi : (A, \text{d}) \to (E, \text{d})$ be a homomorphism of
differential graded algebras. Then $\varphi$ induces a functor of differential
graded categories
$$
F :
\text{Mod}^{dg}_{(E, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(A, \text{d})}
$$
of Example \ref{example-dgm-dg-cat} inducing obvious restriction functors
on the categories of differential graded modules and homotopy categories.
\end{lemma}

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

\begin{lemma}
\label{lemma-construction}
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category
over $R$. Let $x$ be an object of $\mathcal{A}$. Let
$$
(E, \text{d}) = \Hom_\mathcal{A}(x, x)
$$
be the differential graded $R$-algebra of endomorphisms of $x$.
We obtain a functor
$$
\mathcal{A} \longrightarrow \text{Mod}^{dg}_{(E, \text{d})},\quad
y \longmapsto \Hom_\mathcal{A}(x, y)
$$
of differential graded categories by letting $E$ act on
$\Hom_\mathcal{A}(x, y)$ via composition in $\mathcal{A}$.
This functor induces functors
$$
\text{Comp}(\mathcal{A}) \to \text{Mod}_{(A, \text{d})}
\quad\text{and}\quad
K(\mathcal{A}) \to K(\text{Mod}_{(A, \text{d})})
$$
by an application of Lemma \ref{lemma-functorial}.
\end{lemma}

\begin{proof}
This lemma proves itself.
\end{proof}









\section{Obtaining triangulated categories}
\label{section-review}

\noindent
In this section we discuss the most general setup to which the arguments
proving Derived Categories, Proposition
\ref{derived-proposition-homotopy-category-triangulated} and
Proposition \ref{proposition-homotopy-category-triangulated} apply.

\medskip\noindent
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category
over $R$. To make our argument work, we impose some axioms on $\mathcal{A}$:
\begin{enumerate}
\item[(A)] $\mathcal{A}$ has a zero object and differential
graded direct sums of two objects
(as in Definition \ref{definition-dg-direct-sum}).
\item[(B)] there are functors $[n] : \mathcal{A} \longrightarrow \mathcal{A}$
of differential graded categories such that
$[0] = \text{id}_\mathcal{A}$ and $[n + m] = [n] \circ [m]$
and given isomorphisms
$$
\Hom_\mathcal{A}(x, y[n]) = \Hom_\mathcal{A}(x, y)[n]
$$
of differential graded $R$-modules compatible with composition.
\end{enumerate}

\noindent
Given our differential graded category $\mathcal{A}$ we say
\begin{enumerate}
\item a sequence $x \to y \to z$ of morphisms of $\text{Comp}(\mathcal{A})$
is an {\it admissible short exact sequence} if there exists
an isomorphism $y \cong x \oplus z$ in the underlying graded category
such that $x \to z$ and $y \to z$ are (co)projections.
\item a morphism $x\to y$ of $\text{Comp}(\mathcal{A})$ is an
{\it admissible monomorphism} if it extends to an
admissible short exact sequence $x\to y\to z$.
\item a morphism $y\to z$ of $\text{Comp}(\mathcal{A})$ is an
{\it admissible epimorphism} if it extends to an
admissible short exact sequence $x\to y\to z$.
\end{enumerate}
The next lemma tells us an admissible short exact sequence gives a
triangle, provided we have axioms (A) and (B).

\begin{lemma}
\label{lemma-get-triangle}
Let $\mathcal{A}$ be a differential graded category satisfying
axioms (A) and (B). Given an admissible short exact sequence
$x \to y \to z$ we obtain (see proof) a triangle
$$
x \to y \to z \to x[1]
$$
in $\text{Comp}(\mathcal{A})$ with the property that any two compositions
in $z[-1] \to x \to y \to z \to x[1]$ are zero in $K(\mathcal{A})$.
\end{lemma}

\begin{proof}
Choose a diagram
$$
\xymatrix{
x \ar[rr]_1 \ar[rd]_a & & x \\
& y \ar[ru]_\pi \ar[rd]^b & \\
z \ar[rr]^1 \ar[ru]^s & & z
}
$$
giving the isomorphism of graded objects $y \cong x \oplus z$ as in the
definition of an admissible short exact sequence. Here are some equations
that hold in this situation
\begin{enumerate}
\item $1 = \pi a$ and hence $\text{d}(\pi) a = 0$,
\item $1 = b s$ and hence $b \text{d}(s) = 0$,
\item $1 = a \pi + s b$ and hence $a \text{d}(\pi) + \text{d}(s) b = 0$,
\item $\pi s = 0$ and hence $\text{d}(\pi)s + \pi \text{d}(s) = 0$,
\item $\text{d}(s) = a \pi \text{d}(s)$ because
$\text{d}(s) = (a \pi + s b)\text{d}(s)$ and $b\text{d}(s) = 0$,
\item $\text{d}(\pi) = \text{d}(\pi) s b$ because
$\text{d}(\pi) = \text{d}(\pi)(a \pi + s b)$ and $\text{d}(\pi)a = 0$,
\item $\text{d}(\pi \text{d}(s)) = 0$ because if we postcompose it
with the monomorphism $a$ we get
$\text{d}(a\pi \text{d}(s)) = \text{d}(\text{d}(s)) = 0$, and
\item $\text{d}(\text{d}(\pi)s) = 0$ as by (4) it is the negative
of $\text{d}(\pi\text{d}(s))$ which is $0$ by (7).
\end{enumerate}
We've used repeatedly that $\text{d}(a) = 0$, $\text{d}(b) = 0$,
and that $\text{d}(1) = 0$. By (7) we see that
$$
\delta = \pi \text{d}(s) = - \text{d}(\pi) s : z \to x[1]
$$
is a morphism in $\text{Comp}(\mathcal{A})$. By (5) we see that
the composition $a \delta = a \pi \text{d}(s) = \text{d}(s)$
is homotopic to zero. By (6) we see that the composition
$\delta b = - \text{d}(\pi)sb = \text{d}(-\pi)$ is homotopic to zero.
\end{proof}

\noindent
Besides axioms (A) and (B) we need an axiom concerning the existence of
cones. We formalize everything as follows.

\begin{situation}
\label{situation-ABC}
Here $R$ is a ring and $\mathcal{A}$ is a differential graded category
over $R$ having axioms (A), (B), and
\begin{enumerate}
\item[(C)] given an arrow $f : x \to y$ of degree $0$ with
$\text{d}(f) = 0$ there exists an admissible short exact sequence
$y \to c(f) \to x[1]$ in $\text{Comp}(\mathcal{A})$ such that the map
$x[1] \to y[1]$ of Lemma \ref{lemma-get-triangle} is equal to $f[1]$.
\end{enumerate}
\end{situation}

\noindent
We will call $c(f)$ a {\it cone} of the morphism $f$.
If (A), (B), and (C) hold, then
cones are functorial in a weak sense.

\begin{lemma}
\label{lemma-cone}
\begin{slogan}
The homotopy category is a triangulated category.
This lemma proves a part of the axioms of a triangulated category.
\end{slogan}
In Situation \ref{situation-ABC} suppose that
$$
\xymatrix{
x_1 \ar[r]_{f_1} \ar[d]_a & y_1 \ar[d]^b \\
x_2 \ar[r]^{f_2} & y_2
}
$$
is a diagram of $\text{Comp}(\mathcal{A})$ commutative up to homotopy.
Then there exists a morphism $c : c(f_1) \to c(f_2)$ which gives rise to
a morphism of triangles
$$
(a, b, c) : (x_1, y_1, c(f_1)) \to (x_1, y_1, c(f_1))
$$
in $K(\mathcal{A})$.
\end{lemma}

\begin{proof}
The assumption means there exists a morphism $h : x_1 \to y_2$ of degree
$-1$ such that $\text{d}(h) = b f_1 - f_2 a$. Choose isomorphisms
$c(f_i) = y_i \oplus x_i[1]$ of graded objects compatible with the
morphisms $y_i \to c(f_i) \to x_i[1]$. Let's denote
$a_i : y_i \to c(f_i)$, $b_i : c(f_i) \to x_i[1]$, $s_i : x_i[1] \to c(f_i)$,
and $\pi_i : c(f_i) \to y_i$ the given morphisms. Recall that
$x_i[1] \to y_i[1]$ is given by $\pi_i \text{d}(s_i)$. By axiom (C)
this means that
$$
f_i = \pi_i \text{d}(s_i) = - \text{d}(\pi_i) s_i
$$
(we identify $\Hom(x_i, y_i)$ with $\Hom(x_i[1], y_i[1])$
using the shift functor $[1]$).
Set $c = a_2 b \pi_1 + s_2 a b_1 + a_2hb$. Then, using the
equalities found in the proof of Lemma \ref{lemma-get-triangle}
we obtain
\begin{align*}
\text{d}(c)
& =
a_2 b \text{d}(\pi_1) + \text{d}(s_2) a b_1 + a_2 \text{d}(h) b_1 \\
& =
- a_2 b f_1 b_1 + a_2 f_2 a b_1 + a_2 (b f_1 - f_2 a) b_1 \\
& = 0
\end{align*}
(where we have used in particular that
$\text{d}(\pi_1) = \text{d}(\pi_1) s_1 b_1 = f_1 b_1$ and
$\text{d}(s_2) = a_2 \pi_2 \text{d}(s_2) = a_2 f_2$).
Thus $c$ is a degree $0$ morphism $c : c(f_1) \to c(f_2)$ of $\mathcal{A}$
compatible with the given morphisms $y_i \to c(f_i) \to x_i[1]$.
\end{proof}

\noindent
In Situation \ref{situation-ABC} we say that a triangle
$(x, y, z, f, g, h)$ in $K(\mathcal{A})$ is a
{\it distinguished triangle} if there exists an admissible
short exact sequence $x' \to y' \to z'$ such that
$(x, y, z, f, g, h)$ is isomorphic as a triangle in $K(\mathcal{A})$
to the triangle $(x', y', z', x' \to y', y' \to z', \delta)$
constructed in Lemma \ref{lemma-get-triangle}. We will show below that
$$
\boxed{
K(\mathcal{A})\text{ is a triangulated category}
}
$$
This result, although not as general as one might think, applies to a
number of natural generalizations of the cases covered so far in the
Stacks project. Here are some examples:
\begin{enumerate}
\item Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(A, d)$ be a
sheaf of differential graded $\mathcal{O}_X$-algebras. Let
$\mathcal{A}$ be the differential graded category of differential
graded $A$-modules. Then $K(\mathcal{A})$ is a triangulated category.
\item Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $(A, d)$ be a
sheaf of differential graded $\mathcal{O}$-algebras. Let
$\mathcal{A}$ be the differential graded category of differential
graded $A$-modules. Then $K(\mathcal{A})$ is a triangulated category.
See Differential Graded Sheaves, Proposition
\ref{sdga-proposition-homotopy-category-triangulated}.
\item Two examples with a different flavor may be found in Examples, Section
\ref{examples-section-nongraded-differential-graded}.
\end{enumerate}

\noindent
The following simple lemma is a key to the construction.

\begin{lemma}
\label{lemma-id-cone-null}
In Situation \ref{situation-ABC}
given any object $x$ of $\mathcal{A}$, and the cone $C(1_x)$ of the
identity morphism $1_x : x \to x$, the identity morphism on
$C(1_x)$ is homotopic to zero.
\end{lemma}

\begin{proof}
Consider the admissible short exact sequence given by axiom (C).
$$
\xymatrix{
x \ar@<0.5ex>[r]^a  &
C(1_x) \ar@<0.5ex>[l]^{\pi} \ar@<0.5ex>[r]^b &
x[1]\ar@<0.5ex>[l]^s
}
$$
Then by Lemma \ref{lemma-get-triangle}, identifying hom-sets under
shifting, we have $1_x=\pi d(s)=-d(\pi)s$ where $s$ is regarded as
a morphism in $\Hom_{\mathcal{A}}^{-1}(x,C(1_x))$. Therefore
$a=a\pi d(s)=d(s)$ using formula (5) of Lemma \ref{lemma-get-triangle},
and $b=-d(\pi)sb=-d(\pi)$ by formula (6) of Lemma \ref{lemma-get-triangle}.
Hence
$$
1_{C(1_x)} = a\pi + sb = d(s)\pi - sd(\pi) = d(s\pi)
$$
since $s$ is of degree $-1$.
\end{proof}

\noindent
A more general version of the above lemma will appear in
Lemma \ref{lemma-cone-homotopy}. The following lemma is the
analogue of Lemma \ref{lemma-make-commute-map}.

\begin{lemma}
\label{lemma-homo-change}
In Situation \ref{situation-ABC} given a diagram
$$
\xymatrix{x\ar[r]^f\ar[d]_a & y\ar[d]^b\\
z\ar[r]^g & w}
$$
in $\text{Comp}(\mathcal{A})$ commuting up to homotopy. Then
\begin{enumerate}
\item If $f$ is an admissible monomorphism, then $b$ is homotopic
to a morphism $b'$ which makes the diagram commute.
\item If $g$ is an admissible epimorphism, then $a$ is homotopic
to a morphism $a'$ which makes the diagram commute.
\end{enumerate}
\end{lemma}

\begin{proof}
To prove (1), observe that the hypothesis implies that there is some
$h\in\Hom_{\mathcal{A}}(x,w)$ of degree $-1$ such that $bf-ga=d(h)$.
Since $f$ is an admissible monomorphism, there is a morphism
$\pi : y \to x$ in the category $\mathcal{A}$ of degree $0$.
Let $b' = b - d(h\pi)$. Then
\begin{align*}
b'f = bf - d(h\pi)f
= &
bf - d(h\pi f) \quad (\text{since }d(f) = 0) \\
= &
bf-d(h) \\
= &
ga
\end{align*}
as desired. The proof for (2) is omitted.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-make-injective}.

\begin{lemma}
\label{lemma-factor}
In Situation \ref{situation-ABC} let $\alpha : x \to y$
be a morphism in $\text{Comp}(\mathcal{A})$. Then there exists
a factorization in $\text{Comp}(\mathcal{A})$:
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}}  &
\tilde{y} \ar@<0.5ex>[r]^{\pi} &
y\ar@<0.5ex>[l]^s
}
$$
such that
\begin{enumerate}
\item $\tilde{\alpha}$ is an admissible monomorphism, and
$\pi\tilde{\alpha}=\alpha$.
\item There exists a morphism
$s:y\to\tilde{y}$ in $\text{Comp}(\mathcal{A})$
such that $\pi s=1_y$ and $s\pi$ is homotopic to $1_{\tilde{y}}$. 
\end{enumerate}
\end{lemma}

\begin{proof}
By axiom (A), we may let $\tilde{y}$ be the differential graded direct
sum of $y$ and $C(1_x)$, i.e., there exists a diagram
$$
\xymatrix@C=3pc{
y \ar@<0.5ex>[r]^s  &
y\oplus C(1_x) \ar@<0.5ex>[l]^{\pi} \ar@<0.5ex>[r]^{p} &
C(1_x)\ar@<0.5ex>[l]^t
}
$$
where all morphisms are of degree zero, and in
$\text{Comp}(\mathcal{A})$. Let $\tilde{y} = y \oplus C(1_x)$.
Then $1_{\tilde{y}} = s\pi + tp$. Consider now the diagram
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}}  &
\tilde{y} \ar@<0.5ex>[r]^{\pi} &
y\ar@<0.5ex>[l]^s
}
$$
where $\tilde{\alpha}$ is induced by the morphism $x\xrightarrow{\alpha}y$
and the natural morphism $x\to C(1_x)$ fitting in the admissible
short exact sequence
$$
\xymatrix{
x \ar@<0.5ex>[r]  &
C(1_x) \ar@<0.5ex>[l] \ar@<0.5ex>[r] &
x[1]\ar@<0.5ex>[l]
}
$$
So the morphism $C(1_x)\to x$ of degree 0 in this diagram,
together with the zero morphism $y\to x$, induces a degree-0
morphism $\beta : \tilde{y} \to x$. Then $\tilde{\alpha}$ is an
admissible monomorphism since it fits into the admissible short
exact sequence
$$
\xymatrix{
x\ar[r]^{\tilde{\alpha}} &
\tilde{y} \ar[r] &
x[1]
}
$$
Furthermore, $\pi\tilde{\alpha} = \alpha$ by the construction of
$\tilde{\alpha}$, and $\pi s = 1_y$ by the first diagram. It
remains to show that $s\pi$ is homotopic to $1_{\tilde{y}}$.
Write $1_x$ as $d(h)$ for some degree $-1$ map. Then, our
last statement follows from
\begin{align*}
1_{\tilde{y}} - s\pi
= &
tp \\
= &
t(dh)p\quad\text{(by Lemma \ref{lemma-id-cone-null})} \\
= &
d(thp)
\end{align*}
since $dt = dp = 0$, and $t$ is of degree zero. 
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-sequence-maps-split}.

\begin{lemma}
\label{lemma-analogue-sequence-maps-split}
In Situation \ref{situation-ABC}
let $x_1 \to x_2 \to \ldots \to x_n$
be a sequence of composable morphisms in $\text{Comp}(\mathcal{A})$.
Then there exists a commutative diagram in $\text{Comp}(\mathcal{A})$:
$$
\xymatrix{x_1\ar[r] & x_2\ar[r] & \ldots\ar[r] & x_n\\
y_1\ar[r]\ar[u] & y_2\ar[r]\ar[u] & \ldots\ar[r] & y_n\ar[u]}
$$
such that each $y_i\to y_{i+1}$ is an admissible monomorphism
and each $y_i\to x_i$ is a homotopy equivalence.
\end{lemma}

\begin{proof}
The case for $n=1$ is trivial: one simply takes $y_1 = x_1$ and the
identity morphism on $x_1$ is in particular a homotopy equivalence.
The case $n = 2$ is given by Lemma \ref{lemma-factor}. Suppose we have
constructed the diagram up to $x_{n - 1}$. We apply
Lemma \ref{lemma-factor} to the composition
$y_{n - 1} \to x_{n-1} \to x_n$ to obtain $y_n$. Then
$y_{n - 1} \to y_n$ will be an admissible monomorphism, and
$y_n \to x_n$ a homotopy equivalence.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-nilpotent}.

\begin{lemma}
\label{lemma-triseq}
In Situation \ref{situation-ABC} let $x_i \to y_i \to z_i$
be morphisms in $\mathcal{A}$ ($i=1,2,3$) such that
$x_2 \to y_2\to z_2$ is an admissible short exact sequence.
Let $b : y_1 \to y_2$ and $b' : y_2\to y_3$ be morphisms
in $\text{Comp}(\mathcal{A})$ such that
$$
\vcenter{
\xymatrix{
x_1 \ar[d]_0 \ar[r] &
y_1 \ar[r] \ar[d]_b &
z_1 \ar[d]_0 \\
x_2 \ar[r] & y_2 \ar[r] & z_2
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
x_2 \ar[d]^0 \ar[r] &
y_2 \ar[r] \ar[d]^{b'} &
z_2 \ar[d]^0 \\
x_3 \ar[r] & y_3 \ar[r] & z_3
}
}
$$
commute up to homotopy. Then $b'\circ b$ is homotopic to $0$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-homo-change}, we can replace $b$ and $b'$
by homotopic maps $\tilde{b}$ and $\tilde{b}'$, such that the right
square of the left diagram commutes and the left square of the right
diagram commutes. Say $b = \tilde{b} + d(h)$ and $b'=\tilde{b}'+d(h')$
for degree $-1$ morphisms $h$ and $h'$ in $\mathcal{A}$. Hence
$$
b'b = \tilde{b}'\tilde{b} + d(\tilde{b}'h + h'\tilde{b} + h'd(h))
$$
since $d(\tilde{b})=d(\tilde{b}')=0$, i.e. $b'b$ is homotopic to
$\tilde{b}'\tilde{b}$. We now want to show that $\tilde{b}'\tilde{b}=0$.
Because $x_2\xrightarrow{f} y_2\xrightarrow{g} z_2$ is an admissible
short exact sequence, there exist degree $0$ morphisms
$\pi : y_2 \to x_2$ and $s : z_2 \to y_2$ such that
$\text{id}_{y_2} = f\pi + sg$. Therefore
$$
\tilde{b}'\tilde{b} = \tilde{b}'(f\pi + sg)\tilde{b} = 0
$$
since $g\tilde{b} = 0$ and $\tilde{b}'f = 0$ as consequences
of the two commuting squares.
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-triangle-independent-splittings}.

\begin{lemma}
\label{lemma-analogue-triangle-independent-splittings}
In Situation \ref{situation-ABC}
let $0 \to x \to y \to z \to 0$ be an admissible short
exact sequence in $\text{Comp}(\mathcal{A})$. The triangle
$$
\xymatrix{x\ar[r] & y\ar[r] & z\ar[r]^{\delta} & x[1]}
$$
with $\delta : z \to x[1]$ as defined in Lemma \ref{lemma-get-triangle}
is up to canonical isomorphism in $K(\mathcal{A})$, independent of the
choices made in Lemma \ref{lemma-get-triangle}.
\end{lemma}

\begin{proof}
Suppose $\delta$ is defined by the splitting
$$
\xymatrix{
x \ar@<0.5ex>[r]^{a} &
y \ar@<0.5ex>[r]^b\ar@<0.5ex>[l]^{\pi} &
z \ar@<0.5ex>[l]^s
}
$$
and $\delta'$ is defined by the splitting with $\pi',s'$
in place of $\pi,s$. Then
$$
s'-s = (a\pi + sb)(s'-s) = a\pi s'
$$
since $bs' = bs = 1_z$ and $\pi s = 0$. Similarly,
$$
\pi' - \pi = (\pi' - \pi)(a\pi + sb) = \pi'sb
$$
Since $\delta = \pi d(s)$ and $\delta' = \pi'd(s')$
as constructed in Lemma \ref{lemma-get-triangle}, we may compute
$$
\delta' = \pi'd(s') = (\pi + \pi'sb)d(s + a\pi s') = \delta + d(\pi s')
$$
using $\pi a = 1_x$, $ba = 0$, and $\pi'sbd(s') = \pi'sba\pi d(s') = 0$
by formula (5) in Lemma \ref{lemma-get-triangle}.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-rotate-cone}.

\begin{lemma}
\label{lemma-restate-axiom-c}
In Situation \ref{situation-ABC}
let $f: x \to y$ be a morphism in $\text{Comp}(\mathcal{A})$.
The triangle $(y, c(f), x[1], i, p, f[1])$ is the triangle associated
to the admissible short exact sequence 
$$
\xymatrix{y\ar[r] & c(f) \ar[r] & x[1]}
$$
where the cone $c(f)$ is defined as in Lemma \ref{lemma-get-triangle}.
\end{lemma}

\begin{proof}
This follows from axiom (C).
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-rotate-triangle}.

\begin{lemma}
\label{lemma-cone-rotate-isom}
In Situation \ref{situation-ABC} let $\alpha : x \to y$ and $\beta : y \to z$
define an admissible short exact sequence
$$
\xymatrix{
x \ar[r] &
y\ar[r] &
z
}
$$
in $\text{Comp}(\mathcal{A})$. Let $(x, y, z, \alpha, \beta, \delta)$
be the associated triangle in $K(\mathcal{A})$. Then, the triangles
$$
(z[-1], x, y, \delta[-1], \alpha, \beta)
\quad\text{and}\quad
(z[-1], x, c(\delta[-1]), \delta[-1], i, p)
$$
are isomorphic. 
\end{lemma}

\begin{proof}
We have a diagram of the form
$$
\xymatrix{
z[-1]\ar[r]^{\delta[-1]}\ar[d]^1 &
x\ar@<0.5ex>[r]^{\alpha}\ar[d]^1 &
y\ar@<0.5ex>[r]^{\beta}\ar@{.>}[d]\ar@<0.5ex>[l]^{\tilde{\alpha}} &
z\ar[d]^1\ar@<0.5ex>[l]^{\tilde\beta} \\
z[-1] \ar[r]^{\delta[-1]} &
x\ar@<0.5ex>[r]^i &
c(\delta[-1]) \ar@<0.5ex>[r]^p\ar@<0.5ex>[l]^{\tilde i} &
z\ar@<0.5ex>[l]^{\tilde p}
}
$$
with splittings to $\alpha, \beta, i$, and $p$ given by
$\tilde{\alpha}, \tilde{\beta}, \tilde{i},$ and $\tilde{p}$ respectively.
Define a morphism $y \to c(\delta[-1])$ by
$i\tilde{\alpha} + \tilde{p}\beta$ and a morphism
$c(\delta[-1]) \to y$ by $\alpha \tilde{i} + \tilde{\beta} p$.
Let us first check that these define morphisms in $\text{Comp}(\mathcal{A})$.
We remark that by identities from Lemma \ref{lemma-get-triangle},
we have the relation
$\delta[-1] = \tilde{\alpha}d(\tilde{\beta}) = -d(\tilde{\alpha})\tilde{\beta}$
and the relation $\delta[-1] = \tilde{i}d(\tilde{p})$. Then
\begin{align*}
d(\tilde{\alpha})
& =
d(\tilde{\alpha})\tilde{\beta}\beta \\
& =
-\delta[-1]\beta
\end{align*}
where we have used equation (6) of
Lemma \ref{lemma-get-triangle} for the first equality and
the preceeding remark for the second. Similarly, we obtain
$d(\tilde{p}) = i\delta[-1]$. Hence
\begin{align*}
d(i\tilde{\alpha} + \tilde{p}\beta)
& =
d(i)\tilde{\alpha} + id(\tilde{\alpha}) +
d(\tilde{p})\beta + \tilde{p}d(\beta) \\
& =
id(\tilde{\alpha}) + d(\tilde{p})\beta \\
& =
-i\delta[-1]\beta + i\delta[-1]\beta \\
& =
0
\end{align*}
so $i\tilde{\alpha} + \tilde{p}\beta$ is indeed a morphism of
$\text{Comp}(\mathcal{A})$. By a similar calculation,
$\alpha \tilde{i} + \tilde{\beta} p$ is also a morphism of
$\text{Comp}(\mathcal{A})$. It is immediate that these morphisms
fit in the commutative diagram. We compute:
\begin{align*}
(i\tilde{\alpha} + \tilde{p}\beta)(\alpha \tilde{i} + \tilde{\beta} p)
& =
i\tilde{\alpha}\alpha\tilde{i} + i\tilde{\alpha}\tilde{\beta}p
+ \tilde{p}\beta\alpha\tilde{i} + \tilde{p}\beta\tilde{\beta}p \\
& =
i\tilde{i} + \tilde{p}p \\
& =
1_{c(\delta[-1])}
\end{align*}
where we have freely used the identities of
Lemma \ref{lemma-get-triangle}. Similarly, we compute
$(\alpha \tilde{i} + \tilde{\beta} p)(i\tilde{\alpha} + \tilde{p}\beta) = 1_y$,
so we conclude $y \cong c(\delta[-1])$. Hence, the two triangles in question
are isomorphic.
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-third-isomorphism}.

\begin{lemma}
\label{lemma-analogue-third-isomorphism}
In Situation \ref{situation-ABC} let $f_1 : x_1 \to y_1$ and
$f_2 : x_2 \to y_2$ be morphisms in $\text{Comp}(\mathcal{A})$. Let 
$$
(a,b,c): (x_1,y_1,c(f_1), f_1, i_1, p_1) \to (x_2,y_2, c(f_2), f_2, i_1, p_1)
$$
be any morphism of triangles in $K(\mathcal{A})$.
If $a$ and $b$ are homotopy equivalences, then so is $c$. 
\end{lemma}

\begin{proof}
Since $a$ and $b$ are homotopy equivalences, they are invertible in
$K(\mathcal{A})$ so let $a^{-1}$ and $b^{-1}$ denote their inverses
in $K(\mathcal{A})$, giving us a commutative diagram 
$$
\xymatrix{
x_2\ar[d]^{a^{-1}}\ar[r]^{f_2} &
y_2\ar[d]^{b^{-1}}\ar[r]^{i_2} &
c(f_2)\ar[d]^{c'} \\
x_1\ar[r]^{f_1} &
y_1 \ar[r]^{i_1} &
c(f_1)
}
$$
where the map $c'$ is defined via Lemma \ref{lemma-cone} applied to the left
commutative box of the above diagram. Since the diagram commutes
in $K(\mathcal{A})$, it suffices by Lemma \ref{lemma-triseq} to
prove the following: given a morphism of triangle
$(1,1,c): (x,y,c(f),f,i,p)\to (x,y,c(f),f,i,p)$
in $K(\mathcal{A})$, the map $c$ is an isomorphism in
$K(\mathcal{A})$. We have the commutative diagrams in $K(\mathcal{A})$:
$$
\vcenter{
\xymatrix{
y\ar[d]^{1}\ar[r] &
c(f)\ar[d]^{c}\ar[r] &
x[1]\ar[d]^{1} \\
y\ar[r] &
c(f) \ar[r] &
x[1]
}
}
\quad\Rightarrow\quad
\vcenter{
\xymatrix{
y\ar[d]^{0}\ar[r] &
c(f)\ar[d]^{c-1}\ar[r] &
x[1]\ar[d]^{0} \\
y\ar[r] &
c(f) \ar[r] &
x[1]
}
}
$$
Since the rows are admissible short exact sequences, we obtain
the identity $(c-1)^2 = 0$ by Lemma \ref{lemma-triseq}, from
which we conclude that $2-c$ is inverse to $c$ in $K(\mathcal{A})$
so that $c$ is an isomorphism. 
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-the-same-up-to-isomorphisms}.

\begin{lemma}
\label{lemma-cone-homotopy}
In Situation \ref{situation-ABC}.
\begin{enumerate}
\item Given an admissible short exact sequence
$x\xrightarrow{\alpha} y\xrightarrow{\beta} z$.
Then there exists a homotopy equivalence
$e:C(\alpha)\to z$ such that the diagram
\begin{equation}
\label{equation-cone-isom-triangle}
\vcenter{
\xymatrix{
x\ar[r]^{\alpha}\ar[d] &
y\ar[r]^{b}\ar[d] &
C(\alpha)\ar[r]^{-c}\ar@{.>}[d]^{e} &
x[1]\ar[d] \\
x\ar[r]^{\alpha} &
y\ar[r]^{\beta} &
z\ar[r]^{\delta} & x[1]
}
}
\end{equation}
defines an isomorphism of triangles in $K(\mathcal{A})$. Here
$y\xrightarrow{b}C(\alpha)\xrightarrow{c}x[1]$
is the admissible short exact sequence given as in axiom (C).
\item Given a morphism
$\alpha : x \to y$ in $\text{Comp}(\mathcal{A})$, let
$x \xrightarrow{\tilde{\alpha}} \tilde{y} \to y$ be the
factorization given as in Lemma \ref{lemma-factor}, where the admissible
monomorphism $x \xrightarrow{\tilde{\alpha}} y$ extends to the
admissible short exact sequence
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}} &
\tilde{y} \ar[r] & z
}
$$
Then there exists an isomorphism of triangles
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}} \ar[d] &
\tilde{y} \ar[r] \ar[d] &
z \ar[r]^{\delta} \ar@{.>}[d]^{e} &
x[1] \ar[d] \\
x \ar[r]^{\alpha} &
y \ar[r] &
C(\alpha) \ar[r]^{-c} &
x[1]
}
$$
where the upper triangle is the triangle
associated to the sequence
$x \xrightarrow{\tilde{\alpha}} \tilde{y} \to z$.
\end{enumerate}
\end{lemma}

\begin{proof}
For (1), we consider the more complete diagram, \emph{without} the
sign change on $c$:
$$
\xymatrix{
x\ar@<0.5ex>[r]^{\alpha} \ar[d] &
y\ar@<0.5ex>[l]^{\pi} \ar@<0.5ex>[r]^{b}\ar[d] &
C(\alpha)\ar@<0.5ex>[l]^{p} \ar@<0.5ex>[r]^{c}\ar@{.>}@<0.5ex>[d]^{e} &
x[1]\ar@<0.5ex>[l]^{\sigma} \ar[d]\ar@<0.5ex>[r]^{\alpha} &
y[1]\ar@<0.5ex>[l]^{\pi} \\
x\ar@<0.5ex>[r]^{\alpha} &
y\ar@<0.5ex>[r]^{\beta} \ar@<0.5ex>[l]^{\pi} &
z\ar[r]^{\delta}\ar@<0.5ex>[l]^{s} \ar@{.>}@<0.5ex>[u]^{f} &
x[1]
}
$$
where the admissible short exact sequence
$x\xrightarrow{\alpha} y\xrightarrow{\beta} z$
is given the splitting $\pi$, $s$, and the admissible short exact sequence
$y\xrightarrow{b}C(\alpha)\xrightarrow{c}x[1]$ is given the splitting
$p$, $\sigma$. Note that (identifying hom-sets under shifting)
$$
\alpha = pd(\sigma) = -d(p)\sigma,\quad
\delta = \pi d(s) = -d(\pi)s
$$
by the construction in Lemma \ref{lemma-get-triangle}.

\medskip\noindent
We define $e=\beta p$ and $f=bs-\sigma\delta$. We first check that they are
morphisms in $\text{Comp}(\mathcal{A})$. To show that $d(e)=\beta d(p)$
vanishes, it suffices to show that $\beta d(p)b$ and $\beta d(p)\sigma$
both vanish, whereas
$$
\beta d(p)b = \beta d(pb) = \beta d(1_y) = 0,\quad
\beta d(p)\sigma = -\beta\alpha = 0
$$
Similarly, to check that $d(f)=bd(s)-d(\sigma)\delta$ vanishes,
it suffices to check the post-compositions by $p$ and $c$ both vanish,
whereas
\begin{align*}
pbd(s) - pd(\sigma)\delta
= &
d(s)-\alpha\delta = d(s)-\alpha\pi d(s) = 0 \\
cbd(s)-cd(\sigma)\delta
= &
-cd(\sigma)\delta = -d(c\sigma)\delta = 0
\end{align*}
The commutativity of left two squares of the
diagram \ref{equation-cone-isom-triangle} follows directly from definition.
Before we prove the commutativity of the right square (up to homotopy),
we first check that $e$ is a homotopy equivalence. Clearly,
$$
ef=\beta p (bs-\sigma\delta)=\beta s=1_z
$$
To check that $fe$ is homotopic to $1_{C(\alpha)}$, we first observe
$$
b\alpha = bpd(\alpha) = d(\sigma),\quad
\alpha c = -d(p)\sigma c = -d(p),\quad
d(\pi)p = d(\pi)s\beta p = -\delta\beta p
$$
Using these identities, we compute
\begin{align*}
1_{C(\alpha)} = &
bp + \sigma c
\quad (\text{from }y \xrightarrow{b} C(\alpha) \xrightarrow{c} x[1]) \\
= &
b(\alpha\pi + s\beta)p + \sigma(\pi\alpha)c
\quad (\text{from }x \xrightarrow{\alpha} y \xrightarrow{\beta} z) \\
= &
d(\sigma)\pi p + bs\beta p - \sigma\pi d(p)
\quad (\text{by the first two identities above}) \\
= &
d(\sigma)\pi p + bs\beta p - \sigma\delta\beta p
+ \sigma\delta\beta p - \sigma\pi d(p) \\
= &
(bs - \sigma\delta)\beta p + d(\sigma)\pi p
- \sigma d(\pi)p - \sigma\pi d(p)\quad
(\text{by the third identity above}) \\
= &
fe + d(\sigma \pi p)
\end{align*}
since $\sigma \in \Hom^{-1}(x, C(\alpha))$
(cf. proof of Lemma \ref{lemma-id-cone-null}).
Hence $e$ and $f$ are homotopy inverses.
Finally, to check that the right square of
diagram \ref{equation-cone-isom-triangle} commutes up to homotopy,
it suffices to check that $-cf=\delta$. This follows from
$$
-cf = -c(bs-\sigma\delta) = c\sigma\delta = \delta
$$
since $cb=0$.

\medskip\noindent
For (2), consider the factorization
$x\xrightarrow{\tilde{\alpha}}\tilde{y}\to y$
given as in Lemma \ref{lemma-factor}, so the second morphism
is a homotopy equivalence. By Lemmas \ref{lemma-cone} and
\ref{lemma-analogue-third-isomorphism}, there
exists an isomorphism of triangles between
$$
x \xrightarrow{\alpha} y \to C(\alpha) \to x[1]
\quad\text{and}\quad
x \xrightarrow{\tilde{\alpha}} \tilde{y} \to C(\tilde{\alpha}) \to x[1]
$$
Since we can compose isomorphisms of triangles, by replacing
$\alpha$ by $\tilde{\alpha}$, $y$ by $\tilde{y}$, and $C(\alpha)$ by
$C(\tilde{\alpha})$, we may assume $\alpha$ is an admissible monomorphism.
In this case, the result follows from (1).
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-homotopy-category-pre-triangulated}.

\begin{lemma}
\label{lemma-analogue-homotopy-category-pre-triangulated}
In Situation \ref{situation-ABC} the homotopy category $K(\mathcal{A})$
with its natural translation functors and distinguished triangles
is a pre-triangulated category.
\end{lemma}

\begin{proof}
We will verify each of TR1, TR2, and TR3. 

\medskip\noindent
Proof of TR1. By definition every triangle isomorphic to a distinguished
one is distinguished. Since
$$
\xymatrix{x\ar[r]^{1_x} & x\ar[r] & 0}
$$
is an admissible short exact sequence, $(x, x, 0, 1_x, 0, 0)$
is a distinguished triangle. Moreover, given a morphism
$\alpha : x \to y$ in $\text{Comp}(\mathcal{A})$, the triangle
given by $(x, y, c(\alpha), \alpha, i, -p)$ is distinguished by
Lemma \ref{lemma-cone-homotopy}.

\medskip\noindent
Proof of TR2. Let $(x,y,z,\alpha,\beta,\gamma)$ be a triangle and
suppose $(y,z,x[1],\beta,\gamma,-\alpha[1])$ is distinguished.
Then there exists an admissible short exact sequence
$0 \to x' \to y' \to z' \to 0$ such that the associated triangle
$(x',y',z',\alpha',\beta',\gamma')$ is isomorphic to
$(y,z,x[1],\beta,\gamma,-\alpha[1])$. After rotating, we conclude
that $(x,y,z,\alpha,\beta,\gamma)$ is isomorphic to
$(z'[-1],x',y', \gamma'[-1], \alpha',\beta')$. By
Lemma \ref{lemma-cone-rotate-isom},
we deduce that $(z'[-1],x',y', \gamma'[-1], \alpha',\beta')$ is
isomorphic to $(z'[-1],x',c(\gamma'[-1]), \gamma'[-1], i, p)$.
Composing the two isomorphisms with sign changes as indicated in
the following diagram:
$$
\xymatrix@C=3pc{
x\ar[r]^{\alpha}\ar[d] &
y\ar[r]^{\beta}\ar[d] &
z\ar[r]^{\gamma}\ar[d] &
x[1]\ar[d] \\
z'[-1]\ar[r]^{-\gamma'[-1]}\ar[d]_{-1_{z'[-1]}} &
x \ar[r]^{\alpha'}\ar@{=}[d] &
y' \ar[r]^{\beta'} \ar[d] &
z'\ar[d]^{-1_{z'}} \\
z'[-1]\ar[r]^{\gamma'[-1]} &
x \ar[r]^{\alpha'} &
c(\gamma'[-1]) \ar[r]^{-p} &
z'
}
$$
We conclude that $(x,y,z,\alpha,\beta,\gamma)$ is distinguished by
Lemma \ref{lemma-cone-homotopy} (2). Conversely, suppose that
$(x,y,z,\alpha,\beta,\gamma)$ is distinguished, so that by
Lemma \ref{lemma-cone-homotopy} (1), it is isomorphic to a
triangle of the form $(x',y', c(\alpha'), \alpha', i, -p)$
for some morphism $\alpha': x' \to y'$ in $\text{Comp}(\mathcal{A})$.
The rotated triangle $(y,z,x[1],\beta,\gamma, -\alpha[1])$ is
isomorphic to the triangle $(y',c(\alpha'), x'[1], i, -p, -\alpha[1])$
which is isomorphic to $(y',c(\alpha'), x'[1], i, p, \alpha[1])$.
By Lemma \ref{lemma-restate-axiom-c}, this triangle is distinguished,
from which it follows that $(y,z,x[1], \beta,\gamma, -\alpha[1])$
is distinguished.

\medskip\noindent
Proof of TR3: Suppose $(x,y,z, \alpha,\beta,\gamma)$ and
$(x',y',z',\alpha',\beta',\gamma')$ are distinguished triangles
of $\text{Comp}(\mathcal{A})$ and let $f: x \to x'$ and
$g: y \to y'$ be morphisms such that
$\alpha' \circ f = g \circ \alpha$. By
Lemma \ref{lemma-cone-homotopy}, we may assume that
$(x,y,z,\alpha,\beta,\gamma)= (x,y,c(\alpha),\alpha, i, -p)$
and $(x',y',z', \alpha',\beta',\gamma')= (x',y',c(\alpha'), \alpha',i',-p')$.
Now apply Lemma \ref{lemma-cone}
and we are done.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-two-split-injections}.

\begin{lemma}
\label{lemma-dgc-analogue-tr4}
In Situation \ref{situation-ABC} given admissible monomorphisms
$x \xrightarrow{\alpha} y$, $y \xrightarrow{\beta} z$ in $\mathcal{A}$,
there exist distinguished triangles
$(x,y,q_1,\alpha,p_1,\delta_1)$, $(x,z,q_2,\beta\alpha,p_2,\delta_2)$
and $(y,z,q_3,\beta,p_3,\delta_3)$ for which TR4 holds.
\end{lemma}

\begin{proof}
Given admissible monomorphisms $x\xrightarrow{\alpha} y$ and
$y\xrightarrow{\beta}z$, we can find distinguished triangles,
via their extensions to admissible short exact sequences,
$$
\xymatrix{
x\ar@<0.5ex>[r]^{\alpha} &
y\ar@<0.5ex>[l]^{\pi_1} \ar@<0.5ex>[r]^{p_1} &
q_1 \ar[r]^{\delta_1} \ar@<0.5ex>[l]^{s_1} &
x[1]
}
$$
$$
\xymatrix{
x\ar@<0.5ex>[r]^{\beta\alpha} &
z\ar@<0.5ex>[l]^{\pi_1\pi_3} \ar@<0.5ex>[r]^{p_2} &
q_2 \ar[r]^{\delta_2} \ar@<0.5ex>[l]^{s_2} &
x[1]
}
$$
$$
\xymatrix{
y\ar@<0.5ex>[r]^{\beta} &
z\ar@<0.5ex>[l]^{\pi_3} \ar@<0.5ex>[r]^{p_3} &
q_3 \ar[r]^{\delta_3} \ar@<0.5ex>[l]^{s_3} &
x[1]
}
$$
In these diagrams, the maps $\delta_i$ are defined as
$\delta_i = \pi_i d(s_i)$ analagous to the maps defined in
Lemma \ref{lemma-get-triangle}.
They fit in the following solid commutative diagram
$$
\xymatrix@C=5pc@R=3pc{
x\ar@<0.5ex>[r]^{\alpha} \ar@<0.5ex>[dr]^{\beta\alpha} &
y\ar@<0.5ex>[d]^{\beta} \ar@<0.5ex>[l]^{\pi_1} \ar@<0.5ex>[r]^{p_1} &
q_1 \ar[r]^{\delta_1} \ar@<0.5ex>[l]^{s_1} \ar@{.>}[dd]^{p_2\beta s_1} &
x[1] \\
 &
z \ar@<0.5ex>[u]^{\pi_3}\ar@<0.5ex>[d]^{p_3}
\ar@<0.5ex>[dr]^{p_2} \ar@<0.5ex>[ul]^{\pi_1\pi_3} & & \\
 &
q_3\ar@<0.5ex>[u]^{s_3} \ar[d]^{\delta_3} &
q_2 \ar@{.>}[l]^{p_3s_2} \ar@<0.5ex>[ul]^{s_2} \ar[dr]^{\delta_2} \\
 &
y[1] & & x[1]}
$$
where we have defined the dashed arrows as indicated.
Clearly, their composition $p_3s_2p_2\beta s_1 = 0$
since $s_2p_2 = 0$. We claim that they both are morphisms of
$\text{Comp}(\mathcal{A})$. We can check this using equations in
Lemma \ref{lemma-get-triangle}:
$$
d(p_2\beta s_1) = p_2\beta d(s_1) = p_2\beta\alpha\pi_1 d(s_1) = 0
$$
since $p_2\beta\alpha = 0$, and
$$
d(p_3s_2) = p_3d(s_2) = p_3\beta\alpha\pi_1\pi_3 d(s_2) = 0
$$
since $p_3\beta = 0$. To check that $q_1\to q_2\to q_3$
is an admissible short exact sequence, it remains to show
that in the underlying graded category, $q_2 = q_1\oplus q_3$
with the above two morphisms as coprojection and projection.
To do this, observe that in the underlying graded category
$\mathcal{C}$, there hold
$$
y = x\oplus q_1,\quad
z = y\oplus q_3 = x\oplus q_1\oplus q_3
$$
where $\pi_1\pi_3$ gives the projection morphism onto the first
factor: $x\oplus q_1\oplus q_3\to z$. By axiom (A) on
$\mathcal{A}$, $\mathcal{C}$ is an additive category, hence
we may apply
Homology, Lemma \ref{homology-lemma-additive-cat-biproduct-kernel}
and conclude that
$$
\Ker(\pi_1\pi_3) = q_1\oplus q_3
$$
in $\mathcal{C}$. Another application of
Homology, Lemma \ref{homology-lemma-additive-cat-biproduct-kernel}
to $z = x\oplus q_2$ gives $\Ker(\pi_1\pi_3) = q_2$.
Hence $q_2\cong q_1\oplus q_3$ in $\mathcal{C}$.
It is clear that the dashed morphisms defined above give
coprojection and projection.

\medskip\noindent
Finally, we have to check that the morphism
$\delta : q_3 \to q_1[1]$ induced by the admissible
short exact sequence $q_1\to q_2\to q_3$ agrees with
$p_1\delta_3$. By the construction in
Lemma \ref{lemma-get-triangle}, the morphism $\delta$ is given by
\begin{align*}
p_1\pi_3s_2d(p_2s_3)
= &
p_1\pi_3s_2p_2d(s_3) \\
= &
p_1\pi_3(1-\beta\alpha\pi_1\pi_3)d(s_3) \\
= &
p_1\pi_3d(s_3)\quad (\text{since }\pi_3\beta = 0) \\
= &
p_1\delta_3
\end{align*}
as desired. The proof is complete.
\end{proof}

\noindent
Putting everything together we finally obtain the analogue
of Proposition \ref{proposition-homotopy-category-triangulated}.

\begin{proposition}
\label{proposition-ABC-homotopy-category-triangulated}
In Situation \ref{situation-ABC} the homotopy category $K(\mathcal{A})$
with its natural translation functors and distinguished triangles is a
triangulated category.
\end{proposition}

\begin{proof}
By Lemma \ref{lemma-analogue-homotopy-category-pre-triangulated} we know that
$K(\mathcal{A})$ is pre-triangulated. Combining
Lemmas \ref{lemma-analogue-sequence-maps-split} and
\ref{lemma-dgc-analogue-tr4} with
Derived Categories, Lemma \ref{derived-lemma-easier-axiom-four},
we conclude that $K(\mathcal{A})$ is a triangulated category.
\end{proof}

\begin{lemma}
\label{lemma-functor-between-ABC}
Let $R$ be a ring. Let $F : \mathcal{A} \to \mathcal{B}$ be a functor
between differential graded categories over $R$ satisfying axioms
(A), (B), and (C) such that $F(x[1]) = F(x)[1]$.
Then $F$ induces an exact functor
$K(\mathcal{A}) \to K(\mathcal{B})$ of triangulated categories.
\end{lemma}

\begin{proof}
Namely, if $x \to y \to z$ is an admissible short exact sequence
in $\text{Comp}(\mathcal{A})$, then $F(x) \to F(y) \to F(z)$
is an admissible short exact sequence in $\text{Comp}(\mathcal{B})$.
Moreover, the ``boundary'' morphism $\delta = \pi\text{d}(s) : z \to x[1]$
constructed in Lemma \ref{lemma-get-triangle} produces the morphism
$F(\delta) : F(z) \to F(x[1]) = F(x)[1]$ which is equal to the boundary
map $F(\pi) \text{d}(F(s))$ for the admissible short exact sequence
$F(x) \to F(y) \to F(z)$.
\end{proof}





\section{Bimodules}
\label{section-bimodules}

\noindent
We continue the discussion started in Section \ref{section-tensor-product}.

\begin{definition}
\label{definition-bimodule}
Bimodules. Let $R$ be a ring.
\begin{enumerate}
\item Let $A$ and $B$ be $R$-algebras. An {\it $(A, B)$-bimodule}
is an $R$-module $M$ equippend with $R$-bilinear maps
$$
A \times M \to M, (a, x) \mapsto ax
\quad\text{and}\quad
M \times B \to M, (x, b) \mapsto xb
$$
such that the following hold
\begin{enumerate}
\item $a'(ax) = (a'a)x$ and $(xb)b' = x(bb')$,
\item $a(xb) = (ax)b$, and
\item $1 x = x = x 1$.
\end{enumerate}
\item Let $A$ and $B$ be $\mathbf{Z}$-graded $R$-algebras. A
{\it graded $(A, B)$-bimodule} is an $(A, B)$-bimodule $M$ which
has a grading $M = \bigoplus M^n$ such that
$A^n M^m \subset M^{n + m}$ and $M^n B^m \subset M^{n + m}$.
\item Let $A$ and $B$ be differential graded $R$-algebras. A
{\it differential graded $(A, B)$-bimodule} is a graded $(A, B)$-bimodule
which comes equipped with a differential
$\text{d} : M \to M$ homogeneous of degree $1$
such that $\text{d}(ax) = \text{d}(a)x + (-1)^{\deg(a)}a\text{d}(x)$ and
$\text{d}(xb) = \text{d}(x)b + (-1)^{\deg(x)}x\text{d}(b)$
for homogeneous elements $a \in A$, $x \in M$, $b \in B$.
\end{enumerate}
\end{definition}

\noindent
Observe that a differential graded $(A, B)$-bimodule
$M$ is the same thing as a right differential graded
$B$-module which is also a left differential graded
$A$-module such that the grading and differentials agree
and such that the $A$-module structure commutes with
the $B$-module structure. Here is a precise statement.

\begin{lemma}
\label{lemma-what-makes-a-bimodule-dg}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded algebras over $R$. Let $M$ be a right differential
graded $B$-module. There is a $1$-to-$1$ correspondence
between $(A, B)$-bimodule structures on $M$ compatible with the given
differential graded $B$-module structure and homomorphisms
$$
A
\longrightarrow
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, M)
$$
of differential graded $R$-algebras.
\end{lemma}

\begin{proof}
Let $\mu : A \times M \to M$ define a left differential graded $A$-module
structure on the underlying complex of $R$-modules $M^\bullet$ of $M$.
By Lemma \ref{lemma-left-module-structure} the structure $\mu$ corresponds
to a map $\gamma : A \to \Hom^\bullet(M^\bullet, M^\bullet)$
of differential graded $R$-algebras. The assertion of the lemma is simply
that $\mu$ commutes with the $B$-action, if and only if $\gamma$ ends
up inside
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, M) \subset
\Hom^\bullet(M^\bullet, M^\bullet)
$$
We omit the detailed calculation.
\end{proof}

\noindent
Let $M$ be a differential graded $(A, B)$-bimodule. Recall from
Section \ref{section-left-modules} that the left differential graded
$A$-module structure corresponds to a right differential graded
$A^{opp}$-module structure. Since the $A$ and $B$ module structures
commute this gives $M$ the structure of a differential graded
$A^{opp} \otimes_R B$-module:
$$
x \cdot (a \otimes b) = (-1)^{\deg(a)\deg(x)} axb
$$
Conversely, if we have a differential graded $A^{opp} \otimes_R B$-module
$M$, then we can use the formula above to get a differential graded
$(A, B)$-bimodule.

\begin{lemma}
\label{lemma-bimodule-over-tensor}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. The construction above
defines an equivalence of categories
$$
\begin{matrix}
\text{differential graded}\\
(A, B)\text{-bimodules}
\end{matrix}
\longleftrightarrow
\begin{matrix}
\text{right differential graded }\\
A^{opp} \otimes_R B\text{-modules}
\end{matrix}
$$
\end{lemma}

\begin{proof}
Immediate from discussion the above.
\end{proof}

\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras.
Let $P$ be a differential graded $(A, B)$-bimodule. We say $P$
{\it has property (P)} if it there exists a filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset P
$$
by differential graded $(A, B)$-bimodules such that
\begin{enumerate}
\item $P = \bigcup F_pP$,
\item the inclusions $F_iP \to F_{i + 1}P$ are split as graded
$(A, B)$-bimodule maps,
\item the quotients $F_{i + 1}P/F_iP$ are isomorphic as differential
graded $(A, B)$-bimodules to a direct sum of $(A \otimes_R B)[k]$.
\end{enumerate}

\begin{lemma}
\label{lemma-bimodule-resolve}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $M$ be a differential graded
$(A, B)$-bimodule. There exists a homomorphism $P \to M$
of differential graded $(A, B)$-bimodules which is a quasi-isomorphism
such that $P$ has property (P) as defined above.
\end{lemma}

\begin{proof}
Immediate from Lemmas \ref{lemma-bimodule-over-tensor} and
\ref{lemma-resolve}.
\end{proof}

\begin{lemma}
\label{lemma-bimodule-property-P-sequence}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $P$ be a
differential graded $(A, B)$-bimodule having property (P)
with corresponding filtration $F_\bullet$, then we obtain a
short exact sequence
$$
0 \to
\bigoplus\nolimits F_iP \to
\bigoplus\nolimits F_iP \to P \to 0
$$
of differential graded $(A, B)$-bimodules which is split as a sequence
of graded $(A, B)$-bimodules.
\end{lemma}

\begin{proof}
Immediate from Lemmas \ref{lemma-bimodule-over-tensor} and
\ref{lemma-property-P-sequence}.
\end{proof}















\section{Bimodules and tensor product}
\label{section-bimodules-tensor}

\noindent
Let $R$ be a ring. Let $A$ and $B$ be $R$-algebras. Let $M$ be a right
$A$-module. Let $N$ be a $(A, B)$-bimodule. Then
$M \otimes_A N$ is a right $B$-module.

\medskip\noindent
If in the situation of the previous paragraph
$A$ and $B$ are $\mathbf{Z}$-graded algebras,
$M$ is a graded $A$-module, and $N$ is a graded $(A, B)$-bimodule,
then $M \otimes_A N$ is a right graded $B$-module. The construction
is functorial in $M$ and defines a functor
$$
- \otimes_A N :
\text{Mod}^{gr}_A
\longrightarrow
\text{Mod}^{gr}_B
$$
of graded categories as in Example \ref{example-gm-gr-cat}. Namely, if
$M$ and $M'$ are graded $A$-modules and $f : M \to M'$ is an $A$-module
homomorphism homogeneous of degree $n$, then
$f \otimes \text{id}_N : M \otimes_A N \to M' \otimes_A N$
is a $B$-module homomorphism homogeneous of degree $n$.

\medskip\noindent
If in the situation of the previous paragraph
$(A, \text{d})$ and $(B, \text{d})$ are differential graded algebras,
$M$ is a differential graded $A$-module, and $N$ is a differential
graded $(A, B)$-bimodule, then $M \otimes_A N$ is a right
differential graded $B$-module.

\begin{lemma}
\label{lemma-tensor}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Then
$M \mapsto M \otimes_A N$ defines a functor
$$
- \otimes_A N :
\text{Mod}^{dg}_{(A, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(B, \text{d})}
$$
of differential graded categories. This functor induces functors
$$
\text{Mod}_{(A, \text{d})} \to \text{Mod}_{(B, \text{d})}
\quad\text{and}\quad
K(\text{Mod}_{(A, \text{d})}) \to K(\text{Mod}_{(B, \text{d})})
$$
by an application of Lemma \ref{lemma-functorial}.
\end{lemma}

\begin{proof}
Above we have seen how the construction defines a functor of underlying
graded categories. Thus it suffices to show that the construction is
compatible with differentials. Let $M$ and $M'$ be differential
graded $A$-modules and let $f : M \to M'$ be an $A$-module homomorphism
which is homogeneous of degree $n$. Then we have
$$
\text{d}(f) = \text{d}_{M'} \circ f - (-1)^n f \circ \text{d}_M
$$
On the other hand, we have
$$
\text{d}(f \otimes \text{id}_N) =
\text{d}_{M' \otimes_A N} \circ
(f \otimes \text{id}_N)
- (-1)^n
(f \otimes \text{id}_N) \circ \text{d}_{M \otimes_A N}
$$
Applying this to an element $x \otimes y$ with $x \in M$ and
$y \in N$ homogeneous we get
\begin{align*}
\text{d}(f \otimes \text{id}_N)(x \otimes y)
= &
\text{d}_{M'}(f(x)) \otimes y + (-1)^{n + \deg(x)}f(x) \otimes \text{d}_N(y) \\
& - (-1)^n f(\text{d}_M(x)) \otimes y
- (-1)^{n + \deg(x)}f(x) \otimes \text{d}_N(y) \\
= &
\text{d}(f) (x \otimes y)
\end{align*}
Thus we see that $\text{d}(f) \otimes \text{id}_N =
\text{d}(f \otimes \text{id}_N)$ and the proof is complete.
\end{proof}

\begin{remark}
\label{remark-shift-tensor-no-sign}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Let $M$ be a right differential
graded $A$-module. Then for every $k \in \mathbf{Z}$ there
is an isomorphism
$$
(M \otimes_A N)[k] \longrightarrow
M[k] \otimes_A N
$$
of right differential graded $B$-modules defined without the intervention
of signs, see More on Algebra, Section \ref{more-algebra-section-sign-rules}.
\end{remark}

\noindent
If we have a ring $R$ and $R$-algebras $A$, $B$, and $C$,
a right $A$-module $M$, an $(A, B)$-bimodule $N$, and a
$(B, C)$-bimodule $N'$, then
$N \otimes_B N'$ is a $(A, C)$-bimodule and we have
$$
(M \otimes_A N) \otimes_B N' = M \otimes_A (N \otimes_B N')
$$
This equality continuous to hold in the graded and in the differential
graded case. See More on Algebra, Section \ref{more-algebra-section-sign-rules}
for sign rules.






\section{Bimodules and internal hom}
\label{section-bimodules-hom}

\noindent
Let $R$ be a ring. If $A$ is an $R$-algebra (see our conventions
in Section \ref{section-conventions}) and $M$, $M'$ are right
$A$-modules, then we define
$$
\Hom_A(M, M') = \{f : M \to M' \mid f \text{ is }A\text{-linear}\}
$$
as usual.

\medskip\noindent
Let $R$-be a ring. Let $A$ and $B$ be $R$-algebras. Let
$N$ be an $(A, B)$-bimodule. Let $N'$ be a right $B$-module.
In this situation we will think of
$$
\Hom_B(N, N')
$$
as a right $A$-module using precomposition.

\medskip\noindent
Let $R$-be a ring. Let $A$ and $B$ be $\mathbf{Z}$-graded $R$-algebras. Let
$N$ be a graded $(A, B)$-bimodule. Let $N'$ be a right graded $B$-module.
In this situation we will think of the graded $R$-module
$$
\Hom_{\text{Mod}^{gr}_B}(N, N')
$$
defined in Example \ref{example-gm-gr-cat} as a right graded $A$-module
using precomposition. The construction is functorial in $N'$ and defines
a functor
$$
\Hom_{\text{Mod}^{gr}_B}(N, -) :
\text{Mod}^{gr}_B
\longrightarrow
\text{Mod}^{gr}_A
$$
of graded categories as in Example \ref{example-gm-gr-cat}. Namely, if
$N_1$ and $N_2$ are graded $B$-modules and $f : N_1 \to N_2$ is a $B$-module
homomorphism homogeneous of degree $n$, then the induced map
$\Hom_{\text{Mod}^{gr}_B}(N, N_1) \to \Hom_{\text{Mod}^{gr}_B}(N, N_2)$
is an $A$-module homomorphism homogeneous of degree $n$.

\medskip\noindent
Let $R$ be a ring. Let $A$ and $B$ be differential $\mathbf{Z}$-graded
$R$-algebras. Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a right differential graded $B$-module. In this situation
we will think of the differential graded $R$-module
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N')
$$
defined in Example \ref{example-dgm-dg-cat} as a right differential
graded $A$-module using precomposition as in the graded case. This
is compatible with differentials because multiplication is the
composition
$$
\Hom_{\text{Mod}^{dg}_B}(N, N') \otimes_R A \to
\Hom_{\text{Mod}^{dg}_B}(N, N') \otimes_R
\Hom_{\text{Mod}^{dg}_B}(N, N) \to
\Hom_{\text{Mod}^{dg}_B}(N, N')
$$
The first arrow uses the map
of Lemma \ref{lemma-what-makes-a-bimodule-dg} and the second
arrow is the composition in the differential graded category
$\text{Mod}^{dg}_{(B, \text{d})}$.

\begin{lemma}
\label{lemma-hom}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. The construction above
defines a functor
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -) :
\text{Mod}^{dg}_{(B, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(A, \text{d})}
$$
of differential graded categories. This functor induces functors
$$
\text{Mod}_{(B, \text{d})} \to \text{Mod}_{(A, \text{d})}
\quad\text{and}\quad
K(\text{Mod}_{(B, \text{d})}) \to K(\text{Mod}_{(A, \text{d})})
$$
by an application of Lemma \ref{lemma-functorial}.
\end{lemma}

\begin{proof}
Above we have seen how the construction defines a functor of underlying
graded categories. Thus it suffices to show that the construction is
compatible with differentials. Let $N_1$ and $N_2$ be differential
graded $B$-modules. Write
$$
H_{12} = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N_1, N_2),\quad
H_1 = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N_1),\quad
H_2 = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N_2)
$$
Consider the composition
$$
c : H_{12} \otimes_R H_1 \longrightarrow H_2
$$
in the differential graded category $\text{Mod}^{dg}_{(B, \text{d})}$.
Let $f : N_1 \to N_2$ be a $B$-module homomorphism which is homogeneous
of degree $n$, in other words, $f \in H_{12}^n$.
The functor in the lemma sends $f$ to $c_f : H_1 \to H_2$, $g \mapsto c(f, g)$.
Simlarly for $\text{d}(f)$. On the other hand, the differential on
$$
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(H_1, H_2)
$$
sends $c_f$ to $\text{d}_{H_2} \circ c_f - (-1)^n c_f \circ \text{d}_{H_1}$.
As $c$ is a morphism of complexes of $R$-modules we have
$\text{d} c(f, g) = c(\text{d}f, g) + (-1)^n c(f, \text{d}g)$.
Hence we see that
\begin{align*}
(\text{d}c_f)(g)
& =
\text{d}c(f,g) - (-1)^n c(f, \text{d}g) \\
& =
c(\text{d}f, g) + (-1)^n c(f, \text{d}g)  - (-1)^n c(f, \text{d}g) \\
& =
c(\text{d}f, g) = c_{\text{d}f}(g)
\end{align*}
and the proof is complete.
\end{proof}

\begin{remark}
\label{remark-shift-hom-no-sign}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Let $N'$ be a right differential
graded $B$-module. Then for every $k \in \mathbf{Z}$ there
is an isomorphism
$$
\Hom_{\text{Mod}^{gr}_B}(N, N')[k]
\longrightarrow
\Hom_{\text{Mod}^{gr}_B}(N, N'[k])
$$
of right differential graded $A$-modules defined without the intervention
of signs, see More on Algebra, Section \ref{more-algebra-section-sign-rules}.
\end{remark}

\begin{lemma}
\label{lemma-tensor-hom-adjunction}
Let $R$ be a ring. Let $A$ and $B$ be $R$-algebras.
Let $M$ be a right $A$-module, $N$ an $(A, B)$-bimodule, and
$N'$ a right $B$-module. Then we have a canonical isomorphism
$$
\Hom_B(M \otimes_A N, N') = \Hom_A(M, \Hom_B(N, N'))
$$
of $R$-modules.
If $A$, $B$, $M$, $N$, $N'$ are compatibly graded, then we have a
canonical isomorphism
$$
\Hom_{\text{Mod}_B^{gr}}(M \otimes_A N, N') =
\Hom_{\text{Mod}_A^{gr}}(M, \Hom_{\text{Mod}_B^{gr}}(N, N'))
$$
of graded $R$-modules
If $A$, $B$, $M$, $N$, $N'$ are compatibly differential graded, then
we have a canonical isomorphism
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M \otimes_A N, N') =
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(M,
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N'))
$$
of complexes of $R$-modules.
\end{lemma}

\begin{proof}
Omitted. Hint: in the ungraded case interpret both sides as $A$-bilinear maps
$\psi : M \times N \to N'$ which are $B$-linear on the right.
In the (differential) graded case, use the isomorphism of
More on Algebra, Lemma \ref{more-algebra-lemma-compose}
and check it is compatible with the module structures.
Alternatively, use the isomorphism of Lemma \ref{lemma-characterize-hom}
and show that it is compatible with the $B$-module structures.
\end{proof}







\section{Derived Hom}
\label{section-restriction}

\noindent
This section is analogous to
More on Algebra, Section \ref{more-algebra-section-RHom}.

\medskip\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Consider the functor
\begin{equation}
\label{equation-restriction}
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -) :
\text{Mod}_{(B, \text{d})}
\longrightarrow
\text{Mod}_{(A, \text{d})}
\end{equation}
of Section \ref{section-bimodules-hom}.

\begin{lemma}
\label{lemma-restriction-homotopy}
The functor (\ref{equation-restriction}) defines an exact functor
$K(\text{Mod}_{(B, \text{d})}) \to K(\text{Mod}_{(A, \text{d})})$
of triangulated categories.
\end{lemma}

\begin{proof}
Via Lemma \ref{lemma-hom} and
Remark \ref{remark-shift-hom-no-sign}
this follows from the general principle of
Lemma \ref{lemma-functor-between-ABC}.
\end{proof}

\noindent
Recall that we have an exact functor
of triangulated categories
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -) :
K(\text{Mod}_{(B, \text{d})}) \to K(\text{Mod}_{(A, \text{d})})
$$
see Lemma \ref{lemma-restriction-homotopy}. Consider the diagram
$$
\xymatrix{
K(\text{Mod}_{(B, \text{d})}) \ar[d] \ar[rr]_{\text{see above}} \ar[rrd]_F & &
K(\text{Mod}_{(A, \text{d})}) \ar[d] \\
D(B, \text{d}) \ar@{..>}[rr] & &
D(A, \text{d})
}
$$
We would like to construct a dotted arrow as the
{\it right derived functor} of the composition $F$.
({\it Warning}: in most interesting cases the diagram will not commute.)
Namely, in the general setting of
Derived Categories, Section \ref{derived-section-derived-functors}
we want to compute the
right derived functor of $F$ with respect to the multiplicative system of
quasi-isomorphisms in $K(\text{Mod}_{(A, \text{d})})$.

\begin{lemma}
\label{lemma-derived-restriction}
In the situation above, the right derived functor of $F$ exists.
We denote it $R\Hom(N, -) : D(B, \text{d}) \to D(A, \text{d})$.
\end{lemma}

\begin{proof}
We will use
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
to prove this. As our collection $\mathcal{I}$
of objects we will use the objects with property (I).
Property (1) was shown in Lemma \ref{lemma-right-resolution}.
Property (2) holds because if $s : I \to I'$ is a quasi-isomorphism
of modules with property (I), then $s$ is a homotopy equivalence
by Lemma \ref{lemma-hom-derived}.
\end{proof}

\begin{lemma}
\label{lemma-functoriality-derived-restriction}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $f : N \to N'$ be a
homomorphism of differential graded $(A, B)$-bimodules.
Then $f$ induces a morphism of functors
$$
- \circ f : R\Hom(N', -) \longrightarrow R\Hom(N, -)
$$
If $f$ is a quasi-isomorphism, then $f \circ -$ is an isomorphism of
functors.
\end{lemma}

\begin{proof}
Write $\mathcal{B} = \text{Mod}^{dg}_{(B, \text{d})}$ the
differential graded category of differential graded $B$-modules, see
Example \ref{example-dgm-dg-cat}.
Let $I$ be a differential graded $B$-module with property (I).
Then $f \circ - : \Hom_\mathcal{B}(N', I) \to \Hom_\mathcal{B}(N, I)$
is a map of differential graded $A$-modules. Moreover, this is functorial
with respect to $I$. Since the functors
$ R\Hom(N', -)$ and $R\Hom(N, -)$ are
computed by applying $\Hom_\mathcal{B}$ into objects with property (I)
(Lemma \ref{lemma-derived-restriction}) we obtain a transformation of functors
as indicated.

\medskip\noindent
Assume that $f$ is a quasi-isomorphism. Let $F_\bullet$ be the
given filtration on $I$. Since $I = \lim I/F_pI$ we see that
$\Hom_\mathcal{B}(N', I) = \lim \Hom_\mathcal{B}(N', I/F_pI)$ and
$\Hom_\mathcal{B}(N, I) = \lim \Hom_\mathcal{B}(N, I/F_pI)$.
Since the transition maps in the system $I/F_pI$ are split
as graded modules, we see that the transition maps in the
systems $\Hom_\mathcal{B}(N', I/F_pI)$ and $\Hom_\mathcal{B}(N, I/F_pI)$
are surjective. Hence $\Hom_\mathcal{B}(N', I)$, resp. $\Hom_\mathcal{B}(N, I)$
viewed as a complex of abelian groups computes $R\lim$ of the system
of complexes
$\Hom_\mathcal{B}(N', I/F_pI)$, resp. $\Hom_\mathcal{B}(N, I/F_pI)$.
See More on Algebra, Lemma \ref{more-algebra-lemma-compute-Rlim}.
Thus it suffices to prove each
$$
\Hom_\mathcal{B}(N', I/F_pI) \to \Hom_\mathcal{B}(N, I/F_pI)
$$
is a quasi-isomorphism. Since the surjections $I/F_{p + 1}I \to I/F_pI$
are split as maps of graded $B$-modules we see that
$$
0 \to \Hom_\mathcal{B}(N', F_pI/F_{p + 1}I) \to
\Hom_\mathcal{B}(N', I/F_{p + 1}I) \to
\Hom_\mathcal{B}(N', I/F_pI) \to 0
$$
is a short exact sequence of differential graded $A$-modules.
There is a similar sequence for $N$ and $f$ induces a map
of short exact sequences. Hence by induction on $p$ (starting with $p = 0$
when $I/F_0I = 0$) we conclude that it suffices to show that
the map
$\Hom_\mathcal{B}(N', F_pI/F_{p + 1}I) \to \Hom_\mathcal{B}(N, F_pI/F_{p + 1}I)$
is a quasi-isomorphism. Since $F_pI/F_{p + 1}I$ is a product of shifts of
$A^\vee$ it suffice to prove
$\Hom_\mathcal{B}(N', B^\vee[k]) \to \Hom_\mathcal{B}(N, B^\vee[k])$
is a quasi-isomorphism. By Lemma \ref{lemma-hom-into-shift-dual-free}
it suffices to show $(N')^\vee \to N^\vee$ is a quasi-isomorphism.
This is true because $f$ is a quasi-isomorphism and $(\ )^\vee$
is an exact functor.
\end{proof}

\begin{lemma}
\label{lemma-derived-restriction-exts}
Let $(A, \text{d})$ and $(B, \text{d})$ be differential graded algebras
over a ring $R$. Let $N$ be a differential graded $(A, B)$-bimodule.
Then for every $n \in \mathbf{Z}$ there are isomorphisms
$$
H^n(R\Hom(N, M)) = \Ext^n_{D(B, \text{d})}(N, M)
$$
of $R$-modules functorial in $M$. It is also functorial in $N$
with respect to the operation described in
Lemma \ref{lemma-functoriality-derived-restriction}.
\end{lemma}

\begin{proof}
In the proof of Lemma \ref{lemma-derived-restriction}
we have seen
$$
R\Hom(N, M) = 
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, I)
$$
as a differential graded $A$-module
where $M \to I$ is a quasi-isomorphism of $M$ into a differential
graded $B$-module with property (I). Hence this complex has the
correct cohomology modules by Lemma \ref{lemma-hom-derived}.
We omit a discussion of the functorial nature of these
identifications.
\end{proof}

\begin{lemma}
\label{lemma-compute-derived-restriction}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $N$ be a differential
graded $(A, B)$-bimodule. If
$\Hom_{D(B, \text{d})}(N, N') = \Hom_{K(\text{Mod}_{(B, \text{d})})}(N, N')$
for all $N' \in K(B, \text{d})$, for example if $N$
has property (P) as a differential graded $B$-module, then
$$
R\Hom(N, M) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, M)
$$
functorially in $M$ in $D(B, \text{d})$.
\end{lemma}

\begin{proof}
By construction (Lemma \ref{lemma-derived-restriction})
to find $R\Hom(N, M)$ we choose a quasi-isomorphism
$M \to I$ where $I$ is a differential graded $B$-module
with property (I) and we set
$R\Hom(N, M) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, I)$.
By assumption the map
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, M) \longrightarrow
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, I)
$$
induced by $M \to I$ is a quasi-isomorphism, see discussion in
Example \ref{example-dgm-dg-cat}. This proves the lemma.
If $N$ has property (P) as a $B$-module, then we see that the
assumption is satisfied by Lemma \ref{lemma-hom-derived}.
\end{proof}




\section{Variant of derived Hom}
\label{section-variant}

\noindent
Let $\mathcal{A}$ be an abelian category. Consider the differential graded
category $\text{Comp}^{dg}(\mathcal{A})$ of complexes of $\mathcal{A}$, see
Example \ref{example-category-complexes}.
Let $K^\bullet$ be a complex of $\mathcal{A}$. Set
$$
(E, \text{d}) = \Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, K^\bullet)
$$
and consider the functor of differential graded categories
$$
\text{Comp}^{dg}(\mathcal{A}) \longrightarrow \text{Mod}^{dg}_{(E, \text{d})},
\quad
X^\bullet
\longmapsto
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, X^\bullet)
$$
of Lemma \ref{lemma-construction}.

\begin{lemma}
\label{lemma-existence-of-derived}
In the situation above. If the right derived functor $R\Hom(K^\bullet, -)$
of $\Hom(K^\bullet, -) : K(\mathcal{A}) \to D(\textit{Ab})$
is everywhere defined on $D(\mathcal{A})$, then we obtain a canonical exact
functor
$$
R\Hom(K^\bullet, -) : D(\mathcal{A}) \longrightarrow D(E, \text{d})
$$
of triangulated categories which reduces to the usual one  on taking
associated complexes of abelian groups.
\end{lemma}

\begin{proof}
Note that we have an associated functor
$K(\mathcal{A}) \to K(\text{Mod}_{(E, \text{d})})$ by
Lemma \ref{lemma-construction}.
We claim this functor is an exact functor of triangulated categories.
Namely, let $f : A^\bullet \to B^\bullet$ be a map of complexes
of $\mathcal{A}$. Then a computation shows that
$$
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, C(f)^\bullet)
=
C\left(
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, A^\bullet) \to
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, B^\bullet)
\right)
$$
where the right hand side is the cone in $\text{Mod}_{(E, \text{d})}$
defined earlier in this chapter.
This shows that our functor is compatible with cones, hence with
distinguished triangles. Let $X^\bullet$ be an object of $K(\mathcal{A})$.
Consider the category of quasi-isomorphisms $s : X^\bullet \to Y^\bullet$.
We are given that the functor
$(s : X^\bullet \to Y^\bullet) \mapsto \Hom_\mathcal{A}(K^\bullet, Y^\bullet)$
is essentially constant when viewed in $D(\textit{Ab})$.
But since the forgetful functor $D(E, \text{d}) \to D(\textit{Ab})$
is compatible with taking cohomology, the same thing is true in
$D(E, \text{d})$. This proves the lemma.
\end{proof}

\noindent
{\bf Warning:} Although the lemma holds as stated and may be useful
as stated, the differential algebra $E$ isn't the ``correct'' one unless
$H^n(E) = \Ext^n_{D(\mathcal{A})}(K^\bullet, K^\bullet)$
for all $n \in \mathbf{Z}$.





\section{Derived tensor product}
\label{section-base-change}

\noindent
This section is analogous to More on Algebra, Section
\ref{more-algebra-section-derived-base-change}.

\medskip\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Consider the functor
\begin{equation}
\label{equation-bc}
\text{Mod}_{(A, \text{d})}
\longrightarrow
\text{Mod}_{(B, \text{d})},\quad
M \longmapsto M \otimes_A N
\end{equation}
defined in Section \ref{section-bimodules-tensor}.

\begin{lemma}
\label{lemma-bc-homotopy}
The functor (\ref{equation-bc}) defines an exact functor
of triangulated categories
$K(\text{Mod}_{(A, \text{d})}) \to K(\text{Mod}_{(B, \text{d})})$.
\end{lemma}

\begin{proof}
Via Lemma \ref{lemma-tensor} and
Remark \ref{remark-shift-tensor-no-sign}
this follows from the general principle of
Lemma \ref{lemma-functor-between-ABC}.
\end{proof}

\noindent
At this point we can consider the diagram
$$
\xymatrix{
K(\text{Mod}_{(A, \text{d})}) \ar[d] \ar[rr]_{- \otimes_A N} \ar[rrd]_F & &
K(\text{Mod}_{(B, \text{d})}) \ar[d] \\
D(A, \text{d}) \ar@{..>}[rr] & &
D(B, \text{d})
}
$$
The dotted arrow that we will construct below will be the
{\it left derived functor} of the composition $F$.
({\it Warning}: the diagram will not commute.)
Namely, in the general setting of
Derived Categories, Section \ref{derived-section-derived-functors}
we want to compute the
left derived functor of $F$ with respect to the multiplicative system of
quasi-isomorphisms in $K(\text{Mod}_{(A, \text{d})})$.

\begin{lemma}
\label{lemma-derived-bc}
In the situation above, the left derived functor of $F$ exists.
We denote it
$- \otimes_A^\mathbf{L} N : D(A, \text{d}) \to D(B, \text{d})$.
\end{lemma}

\begin{proof}
We will use
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
to prove this. As our collection $\mathcal{P}$
of objects we will use the objects with property (P).
Property (1) was shown in Lemma \ref{lemma-resolve}.
Property (2) holds because if $s : P \to P'$ is a quasi-isomorphism
of modules with property (P), then $s$ is a homotopy equivalence
by Lemma \ref{lemma-hom-derived}.
\end{proof}

\begin{lemma}
\label{lemma-functoriality-bc}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $f : N \to N'$ be a
homomorphism of differential graded $(A, B)$-bimodules.
Then $f$ induces a morphism of functors
$$
1\otimes f :
- \otimes_A^\mathbf{L} N
\longrightarrow
- \otimes_A^\mathbf{L} N'
$$
If $f$ is a quasi-isomorphism, then $1 \otimes f$ is an isomorphism of
functors.
\end{lemma}

\begin{proof}
Let $M$ be a differential graded $A$-module with property (P).
Then $1 \otimes f : M \otimes_A N \to M \otimes_A N'$ is a
map of differential graded $B$-modules. Moreover, this is functorial
with respect to $M$. Since the functors
$- \otimes_A^\mathbf{L} N$ and $- \otimes_A^\mathbf{L} N'$ are
computed by tensoring on objects with property (P)
(Lemma \ref{lemma-derived-bc}) we obtain a transformation of functors
as indicated.

\medskip\noindent
Assume that $f$ is a quasi-isomorphism. Let $F_\bullet$ be the
given filtration on $M$. Observe that
$M \otimes_A N = \colim F_i(M) \otimes_A N$ and
$M \otimes_A N' = \colim F_i(M) \otimes_A N'$.
Hence it suffices to show that
$F_n(M) \otimes_A N \to F_n(M) \otimes_A N'$
is a quasi-isomorphism (filtered colimits are exact, see
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}).
Since the inclusions $F_n(M) \to F_{n + 1}(M)$
are split as maps of graded $A$-modules we see that
$$
0 \to F_n(M) \otimes_A N \to F_{n + 1}(M) \otimes_A N \to
F_{n + 1}(M)/F_n(M) \otimes_A N \to 0
$$
is a short exact sequence of differential graded $B$-modules.
There is a similar sequence for $N'$ and $f$ induces a map
of short exact sequences. Hence by induction on $n$ (starting with $n = -1$
when $F_{-1}(M) = 0$) we conclude that it suffices to show that
the map $F_{n + 1}(M)/F_n(M) \otimes_A N \to F_{n + 1}(M)/F_n(M) \otimes_A N'$
is a quasi-isomorphism. This is true because $F_{n + 1}(M)/F_n(M)$
is a direct sum of shifts of $A$ and the result is true for $A[k]$
as $f : N \to N'$ is a quasi-isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-compute-bc}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $N$ be a differential graded
$(A, B)$-bimodule which has property (P) as a left differential graded
$A$-module. Then $M \otimes_A^\mathbf{L} N$ is computed by
$M \otimes_A N$ for all differential graded $A$-modules $M$.
\end{lemma}

\begin{proof}
Let $f : M \to M'$ be a homomorphism of differential graded $A$-modules
which is a quasi-isomorphism. We claim that $f \otimes \text{id} :
M \otimes_A N \to M' \otimes_A N$ is a quasi-isomorphism. If this
is true, then by the construction of the derived tensor product
in the proof of Lemma \ref{lemma-derived-bc} we obtain the desired result.
The construction of the map $f \otimes \text{id}$ only depends
on the left differential graded $A$-module structure on $N$.
Moreover, we have $M \otimes_A N = N \otimes_{A^{opp}} M =
N \otimes_{A^{opp}}^\mathbf{L} M$ because $N$ has property (P) as
a differential graded $A^{opp}$-module. Hence the claim follows
from Lemma \ref{lemma-functoriality-bc}.
\end{proof}

\begin{lemma}
\label{lemma-tensor-hom-adjoint}
Let $R$ be a ring.
Let $(A, \text{d})$ and $(B, \text{d})$ be differential graded $R$-algebras.
Let $N$ be a differential graded $(A, B)$-bimodule.
Then the functor
$$
- \otimes_A^\mathbf{L} N : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
of Lemma \ref{lemma-derived-bc} is a left adjoint to the functor
$$
R\Hom(N, -) : D(B, \text{d}) \longrightarrow D(A, \text{d})
$$
of Lemma \ref{lemma-derived-restriction}.
\end{lemma}

\begin{proof}
This follows from Derived Categories, Lemma
\ref{derived-lemma-pre-derived-adjoint-functors-general}
and the fact that $- \otimes_A N$ and
$\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -)$ are adjoint by
Lemma \ref{lemma-tensor-hom-adjunction}.
\end{proof}

\begin{example}
\label{example-map-hom-tensor}
Let $R$ be a ring. Let $(A, \text{d}) \to (B, \text{d})$ be a
homomorphism of differential graded $R$-algebras. Then we can
view $B$ as a differential graded $(A, B)$-bimodule and we get a functor
$$
- \otimes_A B : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
By Lemma \ref{lemma-tensor-hom-adjoint} the left adjoint of this
is the functor $R\Hom(B, -)$. For a differential graded $B$-module
let us denote $N_A$ the differential graded $A$-module obtained
from $N$ by restriction via $A \to B$. Then we clearly have
a canonical isomorphism
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(B, N) \longrightarrow N_A,\quad
f \longmapsto f(1)
$$
functorial in the $B$-module $N$. Thus we see that
$R\Hom(B, -)$ is the restriction functor and we obtain
$$
\Hom_{D(A, \text{d})}(M, N_A) =
\Hom_{D(B, \text{d})}(M \otimes^\mathbf{L}_A B, N)
$$
bifunctorially in $M$ and $N$ exactly as in the case of commutative rings.
Finally, observe that restriction is a tensor functor as well,
since $N_A = N \otimes_B {}_BB_A = N \otimes_B^\mathbf{L} {}_BB_A$
where ${}_BB_A$ is $B$ viewed as a differential graded $(B, A)$-bimodule.
\end{example}

\begin{lemma}
\label{lemma-tensor-with-compact-fully-faithful}
With notation and assumptions as in Lemma \ref{lemma-tensor-hom-adjoint}.
Assume
\begin{enumerate}
\item $N$ defines a compact object of $D(B, \text{d})$, and
\item the map $H^k(A) \to \Hom_{D(B, \text{d})}(N, N[k])$ is an
isomorphism for all $k \in \mathbf{Z}$.
\end{enumerate}
Then the functor $-\otimes_A^\mathbf{L} N$ is fully faithful.
\end{lemma}

\begin{proof}
Our functor has a left adjoint given by
$R\Hom(N, -)$ by Lemma \ref{lemma-tensor-hom-adjoint}.
By Categories, Lemma \ref{categories-lemma-adjoint-fully-faithful}
it suffices to show that for a differential graded $A$-module $M$
the map
$$
M \longrightarrow R\Hom(N, M \otimes_A^\mathbf{L} N)
$$
is an isomorphism in $D(A, \text{d})$. For this it suffices to show that
$$
H^n(M) \longrightarrow
\text{Ext}^n_{D(B, \text{d})}(N, M \otimes_A^\mathbf{L} N)
$$
is an isomorphism, see Lemma \ref{lemma-derived-restriction-exts}.
Since $N$ is a compact object the right hand side commutes
with direct sums. Thus by Remark \ref{remark-P-resolution}
it suffices to prove this map is an isomorphism for $M = A[k]$.
Since $(A[k] \otimes_A^\mathbf{L} N) = N[k]$ by
Remark \ref{remark-shift-tensor-no-sign},
assumption (2) on $N$ is that the result holds for these.
\end{proof}

\begin{lemma}
\label{lemma-base-change-K-flat}
Let $R \to R'$ be a ring map. Let $(A, \text{d})$ be a differential
graded $R$-algebra. Let $(A', \text{d})$ be the base change, i.e.,
$A' = A \otimes_R R'$. If $A$ is K-flat as a complex of $R$-modules,
then
\begin{enumerate}
\item $- \otimes_A^\mathbf{L} A' : D(A, \text{d}) \to D(A', \text{d})$
is equal to the right derived functor of
$$
K(A, \text{d}) \longrightarrow K(A', \text{d}),\quad
M \longmapsto M \otimes_R R'
$$
\item the diagram
$$
\xymatrix{
D(A, \text{d}) \ar[r]_{- \otimes_A^\mathbf{L} A'} \ar[d]_{restriction} &
D(A', \text{d}) \ar[d]^{restriction} \\
D(R) \ar[r]^{- \otimes_R^\mathbf{L} R'} & D(R')
}
$$
commutes, and
\item if $M$ is K-flat as a complex of $R$-modules, then the
differential graded $A'$-module $M \otimes_R R'$ represents
$M \otimes_A^\mathbf{L} A'$.
\end{enumerate}
\end{lemma}

\begin{proof}
For any differential graded $A$-module $M$ there is a canonical map
$$
c_M : M \otimes_R R' \longrightarrow M \otimes_A A'
$$
Let $P$ be a differential graded $A$-module with property (P).
We claim that $c_P$ is an isomorphism and that $P$ is K-flat
as a complex of $R$-modules. This will prove all the results
stated in the lemma by formal arguments using the definition
of derived tensor product in Lemma \ref{lemma-derived-bc} and
More on Algebra, Section \ref{more-algebra-section-derived-tensor-product}.

\medskip\noindent
Let $F_\bullet$ be the filtration on $P$ showing that $P$ has property (P).
Note that $c_A$ is an isomorphism and $A$ is K-flat as a complex
of $R$-modules by assumption. Hence the same is true for
direct sums of shifts of $A$ (you can use
More on Algebra, Lemma \ref{more-algebra-lemma-colimit-K-flat}
to deal with direct sums if you like).
Hence this holds for the complexes $F_{p + 1}P/F_pP$.
Since the short exact sequences
$$
0 \to F_pP \to F_{p + 1}P \to F_{p + 1}P/F_pP \to 0
$$
are split exact as sequences of graded modules, we can argue
by induction that $c_{F_pP}$ is an isomorphism for all $p$
and that $F_pP$ is K-flat as a complex of $R$-modules (use
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-two-out-of-three}).
Finally, using that $P = \colim F_pP$ we conclude that
$c_P$ is an isomorphism and that $P$ is K-flat
as a complex of $R$-modules (use
More on Algebra, Lemma \ref{more-algebra-lemma-colimit-K-flat}).
\end{proof}

\begin{lemma}
\label{lemma-RHom-is-tensor}
Let $R$ be a ring.
Let $(A, \text{d})$ and $(B, \text{d})$ be differential graded $R$-algebras.
Let $T$ be a differential graded $(A, B)$-bimodule.
Assume
\begin{enumerate}
\item $T$ defines a compact object of $D(B, \text{d})$, and
\item $S = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(T, B)$
represents $R\Hom(T, B)$ in $D(A, \text{d})$.
\end{enumerate}
Then $S$ has a structure of a differential graded $(B, A)$-bimodule
and there is an isomorphism
$$
N \otimes_B^\mathbf{L} S \longrightarrow R\Hom(T, N)
$$
functorial in $N$ in $D(B, \text{d})$.
\end{lemma}

\begin{proof}
Write $\mathcal{B} = \text{Mod}^{dg}_{(B, \text{d})}$.
The right $A$-module structure on $S$ comes from the map
$A \to \Hom_\mathcal{B}(T, T)$ and the composition
$\Hom_\mathcal{B}(T, B) \otimes \Hom_\mathcal{B}(T, T)
\to \Hom_\mathcal{B}(T, B)$ defined in Example \ref{example-dgm-dg-cat}.
Using this multiplication a second time there is a map
$$
c_N :
N \otimes_B S = \Hom_\mathcal{B}(B, N) \otimes_B \Hom_\mathcal{B}(T, B)
\longrightarrow
\Hom_\mathcal{B}(T, N)
$$
functorial in $N$. Given $N$ we can choose quasi-isomorphisms
$P \to N \to I$ where $P$, resp.\ $I$ is a differential graded $B$-module
with property (P), resp.\ (I). Then using $c_N$ we obtain a map
$P \otimes_B S \to \Hom_\mathcal{B}(T, I)$ between the objects
representing $S \otimes_B^\mathbf{L} N$ and $R\Hom(T, N)$.
Clearly this defines a transformation of functors $c$ as in the lemma.

\medskip\noindent
To prove that $c$ is an isomorphism of functors, we may
assume $N$ is a differential graded $B$-module which
has property (P). Since $T$ defines a compact object in
$D(B, \text{d})$ and since both sides of the arrow define
exact functors of triangulated categories, we reduce using
Lemma \ref{lemma-property-P-sequence}
to the case where $N$ has a finite filtration whose
graded pieces are direct sums of $B[k]$. Using again that
both sides of the arrow are exact functors of triangulated
categories and compactness of $T$ we reduce to
the case $N = B[k]$. Assumption (2) is exactly the
assumption that $c$ is an isomorphism in this case.
\end{proof}






\section{Composition of derived tensor products}
\label{section-compose-tensor-functors}

\noindent
We encourage the reader to skip this section.

\medskip\noindent
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-module.
We denote $N_B$ the bimodule $N$ viewed as a differential graded
$B$-module (forgetting about the $A$-structure). There is a canonical map
\begin{equation}
\label{equation-plain-versus-derived}
N_B \otimes_B^\mathbf{L} N'
\longrightarrow
(N \otimes_B N')_C
\end{equation}
in $D(C, \text{d})$. Here $(N \otimes_B N')_C$ denotes the
$(A, C)$-bimodule $N \otimes_B N'$ viewed as a
differential graded $C$-module. Namely, this map
comes from the fact that the derived tensor product always maps to the
plain tensor product (as it is a left derived functor).

\begin{lemma}
\label{lemma-compose-tensor-functors-general}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-module.
Assume (\ref{equation-plain-versus-derived}) is an isomorphism.
Then the composition
$$
\xymatrix{
D(A, \text{d}) \ar[rr]^{- \otimes_A^\mathbf{L} N} & &
D(B, \text{d}) \ar[rr]^{- \otimes_B^\mathbf{L} N'} & &
D(C, \text{d})
}
$$
is isomorphic to $- \otimes_A^\mathbf{L} N''$ with
$N'' = N \otimes_B N'$ viewed as $(A, C)$-bimodule.
\end{lemma}

\begin{proof}
Let us define a transformation of functors
$$
(- \otimes_A^\mathbf{L} N) \otimes_B^\mathbf{L} N'
\longrightarrow
- \otimes_A^\mathbf{L} N''
$$
To do this, let
$M$ be a differential graded $A$-module with property (P).
According to the construction of the functor $- \otimes_A^\mathbf{L} N''$
of the proof of Lemma \ref{lemma-derived-bc} the plain tensor
product $M \otimes_A N''$ represents $M \otimes_A^\mathbf{L} N''$
in $D(C, \text{d})$. Then we write
$$
M \otimes_A N'' =
M \otimes_A (N \otimes_B N') =
(M \otimes_A N) \otimes_B N'
$$
The module $M \otimes_A N$ represents $M \otimes_A^\mathbf{L} N$
in $D(B, \text{d})$. Choose a quasi-isomorphism $Q \to M \otimes_A N$
where $Q$ is a differential graded $B$-module with property (P). Then
$Q \otimes_B N'$ represents
$(M \otimes_A^\mathbf{L} N) \otimes_B^\mathbf{L} N'$ in
$D(C, \text{d})$.
Thus we can define our map via
$$
(M \otimes_A^\mathbf{L} N) \otimes_B^\mathbf{L} N' =
Q \otimes_B N' \to
M \otimes_A N \otimes_B N' =
M \otimes_A^\mathbf{L} N''
$$
The construction of this map is functorial in $M$ and compatible
with distinguished triangles and direct sums; we omit the details.
Consider the property $T$ of objects $M$ of $D(A, \text{d})$ 
expressing that this map is an isomorphism. Then
\begin{enumerate}
\item if $T$ holds for $M_i$ then $T$ holds for $\bigoplus M_i$,
\item if $T$ holds for $2$-out-of-$3$ in a distinguished
triangle, then it holds for the third, and
\item $T$ holds for $A[k]$ because here we obtain a shift
of the map (\ref{equation-plain-versus-derived}) which we
have assumed is an isomorphism.
\end{enumerate}
Thus by Remark \ref{remark-P-resolution} property $T$
always holds and the proof is complete.
\end{proof}

\noindent
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
We temporarily denote $(A \otimes_R B)_B$ the differential
graded algebra $A \otimes_R B$ viewed as a (right) differential
graded $B$-module, and ${}_B(B \otimes_R C)_C$ the differential
graded algebra $B \otimes_R C$ viewed as a differential graded
$(B, C)$-bimodule. Then there is a canonical map
\begin{equation}
\label{equation-plain-versus-derived-algebras}
(A \otimes_R B)_B \otimes_B^\mathbf{L} {}_B(B \otimes_R C)_C
\longrightarrow
(A \otimes_R B \otimes_R C)_C
\end{equation}
in $D(C, \text{d})$ where $(A \otimes_R B \otimes_R C)_C$
denotes the differential
graded $R$-algebra $A \otimes_R B \otimes_R C$ viewed as a
(right) differential graded $C$-module. Namely, this map
comes from the identification
$$
(A \otimes_R B)_B \otimes_B {}_B(B \otimes_R C)_C =
(A \otimes_R B \otimes_R C)_C
$$
and the fact that the derived tensor product always maps to the
plain tensor product (as it is a left derived functor).

\begin{lemma}
\label{lemma-compose-tensor-functors-general-algebra}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras. Assume
that (\ref{equation-plain-versus-derived-algebras}) is an isomorphism.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-bimodule.
Then the composition
$$
\xymatrix{
D(A, \text{d}) \ar[rr]^{- \otimes_A^\mathbf{L} N} & &
D(B, \text{d}) \ar[rr]^{- \otimes_B^\mathbf{L} N'} & &
D(C, \text{d})
}
$$
is isomorphic to $- \otimes_A^\mathbf{L} N''$ for a differential graded
$(A, C)$-bimodule $N''$ described in the proof.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-functoriality-bc} we may replace $N$ and $N'$ by
quasi-isomorphic bimodules. Thus we may assume $N$, resp.\ $N'$
has property (P) as differential graded
$(A, B)$-bimodule, resp.\ $(B, C)$-bimodule, see
Lemma \ref{lemma-bimodule-resolve}. We claim the lemma holds
with the $(A, C)$-bimodule $N'' = N \otimes_B N'$.
To prove this, it suffices to show that
$$
N_B \otimes_B^\mathbf{L} N' \longrightarrow (N \otimes_B N')_C
$$
is an isomorphism in $D(C, \text{d})$, see
Lemma \ref{lemma-compose-tensor-functors-general}.

\medskip\noindent
Let $F_\bullet$ be the filtration on $N$ as in property (P) for bimodules.
By Lemma \ref{lemma-bimodule-property-P-sequence}
there is a short exact sequence
$$
0 \to
\bigoplus\nolimits F_iN \to
\bigoplus\nolimits F_iN \to N \to 0
$$
of differential graded $(A, B)$-bimodules which is split as a sequence
of graded $(A, B)$-bimodules. A fortiori this is an admissible short exact
sequence of differential graded $B$-modules and this produces a distinguished
triangle
$$
\bigoplus\nolimits F_iN_B \to
\bigoplus\nolimits F_iN_B \to N_B \to
\bigoplus\nolimits F_iN_B[1]
$$
in $D(B, \text{d})$. Using that $- \otimes_B^\mathbf{L} N'$
is an exact functor of triangulated categories and commutes
with direct sums and using that $- \otimes_B N'$ transforms
admissible exact sequences into admissible exact sequences
and commutes with direct sums we reduce to proving
that
$$
(F_pN)_B \otimes_B^\mathbf{L} N' \longrightarrow (F_pN)_B \otimes_B N'
$$
is a quasi-isomorphism for all $p$. Repeating the argument
with the short exact sequences of $(A, B)$-bimodules
$$
0 \to F_pN \to F_{p + 1}N \to F_{p + 1}N/F_pN \to 0
$$
which are split as graded $(A, B)$-bimodules
we reduce to showing the same statement for $F_{p + 1}N/F_pN$.
Since these modules are direct sums of shifts of $(A \otimes_R B)_B$
we reduce to showing that
$$
(A \otimes_R B)_B \otimes_B^\mathbf{L} N'
\longrightarrow
(A \otimes_R B)_B \otimes_B N'
$$
is a quasi-isomorphism.

\medskip\noindent
Choose a filtration $F_\bullet$ on $N'$ as in property (P) for bimodules.
Choose a quasi-isomorphism $P \to (A \otimes_R B)_B$
of differential graded $B$-modules where $P$ has property (P).
We have to show that
$P \otimes_B N' \to (A \otimes_R B)_B \otimes_B N'$ is
a quasi-isomorphism because $P \otimes_B N'$ represents
$(A \otimes_R B)_B \otimes_B^\mathbf{L} N'$ in $D(C, \text{d})$
by the construction in Lemma \ref{lemma-derived-bc}.
As $N' = \colim F_pN'$ we find
that it suffices to show that
$P \otimes_B F_pN' \to (A \otimes_R B)_B \otimes_B F_pN'$
is a quasi-isomorphism. Using the short exact sequences
$0 \to F_pN' \to F_{p + 1}N' \to F_{p + 1}N'/F_pN' \to 0$
which are split as graded $(B, C)$-bimodules we reduce to showing
$P \otimes_B F_{p + 1}N'/F_pN' \to
(A \otimes_R B)_B \otimes_B F_{p + 1}N'/F_pN'$
is a quasi-isomorphism for all $p$.
Then finally using that $F_{p + 1}N'/F_pN'$
is a direct sum of shifts of ${}_B(B \otimes_R C)_C$
we conclude that it suffices to show that
$$
P \otimes_B {}_B(B \otimes_R C)_C \to
(A \otimes_R B)_B \otimes_B {}_B(B \otimes_R C)_C
$$
is a quasi-isomorphism. Since $P \to (A \otimes_R B)_B$
is a resolution by a module satisfying property (P)
this map of differential graded $C$-modules
represents the morphism (\ref{equation-plain-versus-derived-algebras})
in $D(C, \text{d})$ and the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-compose-tensor-functors}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
If $C$ is K-flat as a complex of $R$-modules, then
(\ref{equation-plain-versus-derived-algebras})
is an isomorphism and the conclusion of
Lemma \ref{lemma-compose-tensor-functors-general-algebra} is valid.
\end{lemma}

\begin{proof}
Choose a quasi-isomorphism $P \to (A \otimes_R B)_B$ of differential
graded $B$-modules, where $P$ has property (P). Then we have to show
that
$$
P \otimes_B (B \otimes_R C) \longrightarrow
(A \otimes_R B) \otimes_B (B \otimes_R C)
$$
is a quasi-isomorphism. Equivalently we are looking at
$$
P \otimes_R C \longrightarrow
A \otimes_R B \otimes_R C
$$
This is a quasi-isomorphism if $C$ is K-flat as a complex of $R$-modules by
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-quasi-isomorphism}.
\end{proof}





\section{Variant of derived tensor product}
\label{section-variant-base-change}

\noindent
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Then we have the functors
$$
\text{Comp}(\mathcal{O}) \to K(\mathcal{O}) \to D(\mathcal{O})
$$
and as we've seen above we have differential graded enhancement
$\text{Comp}^{dg}(\mathcal{O})$. Namely, this is the differential
graded category of Example \ref{example-category-complexes} associated
to the abelian category $\textit{Mod}(\mathcal{O})$.
Let $K^\bullet$ be a complex of $\mathcal{O}$-modules in other
words, an object of $\text{Comp}^{dg}(\mathcal{O})$. Set
$$
(E, \text{d}) =
\Hom_{\text{Comp}^{dg}(\mathcal{O})}(K^\bullet, K^\bullet)
$$
This is a differential graded $\mathbf{Z}$-algebra. We claim there is
an analogue of the derived base change in this situation.

\begin{lemma}
\label{lemma-tensor-with-complex}
In the situation above there is a functor
$$
- \otimes_E K^\bullet :
\text{Mod}^{dg}_{(E, \text{d})}
\longrightarrow
\text{Comp}^{dg}(\mathcal{O})
$$
of differential graded categories. This functor sends $E$ to $K^\bullet$
and commutes with direct sums.
\end{lemma}

\begin{proof}
Let $M$ be a differential graded $E$-module. For every object $U$ of
$\mathcal{C}$ the complex $K^\bullet(U)$ is a left differential
graded $E$-module as well as a right $\mathcal{O}(U)$-module.
The actions commute, so we have a bimodule.
Thus, by the constructions in
Sections \ref{section-tensor-product} and \ref{section-bimodules}
we can form the tensor product
$$
M \otimes_E K^\bullet(U)
$$
which is a differential graded $\mathcal{O}(U)$-module, i.e., a complex
of $\mathcal{O}(U)$-modules. This construction is functorial with respect
to $U$, hence we can sheafify to get a complex of $\mathcal{O}$-modules
which we denote
$$
M \otimes_E K^\bullet
$$
Moreover, for each $U$ the construction determines a functor
$\text{Mod}^{dg}_{(E, \text{d})} \to \text{Comp}^{dg}(\mathcal{O}(U))$
of differential graded categories by Lemma \ref{lemma-tensor}.
It is therefore clear that we obtain a functor as stated in the lemma.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-complex-homotopy}
The functor of Lemma \ref{lemma-tensor-with-complex} defines an exact functor
of triangulated categories
$K(\text{Mod}_{(E, \text{d})}) \to K(\mathcal{O})$.
\end{lemma}

\begin{proof}
The functor induces a functor between homotopy categories by
Lemma \ref{lemma-functorial}.
We have to show that $- \otimes_E K^\bullet$ transforms distinguished
triangles into distinguished triangles.
Suppose that $0 \to K \to L \to M \to 0$ is an admissible short
exact sequence of differential graded $E$-modules. Let $s : M \to L$ be
a graded $E$-module homomorphism which is left inverse to $L \to M$.
Then $s$ defines a map $M \otimes_E K^\bullet \to L \otimes_E K^\bullet$
of graded $\mathcal{O}$-modules (i.e., respecting $\mathcal{O}$-module
structure and grading, but not differentials)
which is left inverse to $L \otimes_E K^\bullet \to M \otimes_E K^\bullet$.
Thus we see that
$$
0 \to K \otimes_E K^\bullet \to L \otimes_E K^\bullet \to
M \otimes_E K^\bullet \to 0
$$
is a termwise split short exact sequences of complexes, i.e., a
defines a distinguished triangle in $K(\mathcal{O})$.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-complex-derived}
The functor $K(\text{Mod}_{(E, \text{d})}) \to K(\mathcal{O})$
of Lemma \ref{lemma-tensor-with-complex-homotopy} has a left derived
version defined on all of $D(E, \text{d})$. We denote it
$- \otimes_E^\mathbf{L} K^\bullet : D(E, \text{d}) \to D(\mathcal{O})$.
\end{lemma}

\begin{proof}
We will use
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
to prove this. As our collection $\mathcal{P}$
of objects we will use the objects with property (P).
Property (1) was shown in Lemma \ref{lemma-resolve}.
Property (2) holds because if $s : P \to P'$ is a quasi-isomorphism
of modules with property (P), then $s$ is a homotopy equivalence
by Lemma \ref{lemma-hom-derived}.
\end{proof}

\begin{lemma}
\label{lemma-upgrade-tensor-with-complex-derived}
Let $R$ be a ring. Let $\mathcal{C}$ be a site. Let $\mathcal{O}$
be a sheaf of commutative $R$-algebras. Let $K^\bullet$
be a complex of $\mathcal{O}$-modules.
The functor
of Lemma \ref{lemma-tensor-with-complex-derived} has the following
property: For every $M$, $N$ in $D(E, \text{d})$ there is a
canonical map
$$
R\Hom(M, N)
\longrightarrow
R\Hom_\mathcal{O}(M \otimes_E^\mathbf{L} K^\bullet,
N \otimes_E^\mathbf{L} K^\bullet)
$$
in $D(R)$ which on cohomology modules gives the maps
$$
\Ext^n_{D(E, \text{d})}(M, N) \to
\Ext^n_{D(\mathcal{O})}
(M \otimes_E^\mathbf{L} K^\bullet, N \otimes_E^\mathbf{L} K^\bullet)
$$
induced by the functor $- \otimes_E^\mathbf{L} K^\bullet$.
\end{lemma}

\begin{proof}
The right hand side of the arrow is the global derived hom introduced
in Cohomology on Sites, Section \ref{sites-cohomology-section-global-RHom}
which has the correct cohomology modules.
For the left hand side we think of $M$ as a $(R, A)$-bimodule and
we have the derived $\Hom$ introduced in Section \ref{section-restriction}
which also has the correct cohomology modules.
To prove the lemma we may assume $M$ and $N$ are differential graded
$E$-modules with property (P); this does not change the left hand
side of the arrow by
Lemma \ref{lemma-functoriality-derived-restriction}.
By Lemma \ref{lemma-compute-derived-restriction}
this means that the left hand side of the arrow becomes
$\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, N)$.
In Lemmas \ref{lemma-tensor-with-complex},
\ref{lemma-tensor-with-complex-homotopy}, and
\ref{lemma-tensor-with-complex-derived}
we have constructed a functor
$$
- \otimes_E K^\bullet :
\text{Mod}^{dg}_{(E, \text{d})}
\longrightarrow
\text{Comp}^{dg}(\mathcal{O})
$$
of differential graded categories
and we have shown that $- \otimes_E^\mathbf{L} K^\bullet$ is computed
by evaluating this functor
on differential graded $E$-modules with property (P).
Hence we obtain a map of complexes of $R$-modules
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, N)
\longrightarrow
\Hom_{\text{Comp}^{dg}(\mathcal{O})}
(M \otimes_E K^\bullet, N \otimes_E K^\bullet)
$$
For any complexes of $\mathcal{O}$-modules
$\mathcal{F}^\bullet$, $\mathcal{G}^\bullet$ there
is a canonical map
$$
\Hom_{\text{Comp}^{dg}(\mathcal{O})}
(\mathcal{F}^\bullet, \mathcal{G}^\bullet) =
\Gamma(\mathcal{C},
\SheafHom^\bullet(\mathcal{F}^\bullet, \mathcal{G}^\bullet))
\longrightarrow
R\Hom_\mathcal{O}(\mathcal{F}^\bullet, \mathcal{G}^\bullet).
$$
Combining these maps
we obtain the desired map of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-complex-hom-adjoint}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $K^\bullet$ be a complex of $\mathcal{O}$-modules.
Then the functor
$$
- \otimes_E^\mathbf{L} K^\bullet :
D(E, \text{d})
\longrightarrow
D(\mathcal{O})
$$
of Lemma \ref{lemma-tensor-with-complex-derived} is a left adjoint
of the functor
$$
R\Hom(K^\bullet, -) : D(\mathcal{O}) \longrightarrow D(E, \text{d})
$$
of Lemma \ref{lemma-existence-of-derived}.
\end{lemma}

\begin{proof}
The statement means that we have
$$
\Hom_{D(E, \text{d})}(M, R\Hom(K^\bullet, L^\bullet)) =
\Hom_{D(\mathcal{O})}(M \otimes^\mathbf{L}_E K^\bullet, L^\bullet)
$$
bifunctorially in $M$ and $L^\bullet$. To see this we may replace $M$
by a differential graded $E$-module $P$ with property (P).
We also may replace $L^\bullet$ by a K-injective complex of
$\mathcal{O}$-modules $I^\bullet$. The computation
of the derived functors given in the lemmas referenced in the statement
combined with Lemma \ref{lemma-hom-derived} translates the above into
$$
\Hom_{K(\text{Mod}_{(E, \text{d})})}
(P, \Hom_\mathcal{B}(K^\bullet, I^\bullet)) =
\Hom_{K(\mathcal{O})}(P \otimes_E K^\bullet, I^\bullet)
$$
where $\mathcal{B} = \text{Comp}^{dg}(\mathcal{O})$. 
There is an evaluation map from right to left functorial
in $P$ and $I^\bullet$ (details omitted).
Choose a filtration $F_\bullet$ on $P$ as in the definition of property (P).
By Lemma \ref{lemma-property-P-sequence} and the fact that
both sides of the equation are homological functors in $P$
on $K(\text{Mod}_{(E, \text{d})})$
we reduce to the case where $P$ is replaced by
the differential graded $E$-module $\bigoplus F_iP$.
Since both sides turn direct sums in the variable $P$
into direct products we reduce to the case where $P$ is one of the
differential graded $E$-modules $F_iP$.
Since each $F_iP$ has a finite filtration (given by admissible
monomorphisms) whose graded pieces are graded projective $E$-modules
we reduce to the case where $P$ is a graded projective $E$-module.
In this case we clearly have
$$
\Hom_{\text{Mod}^{dg}_{(E, \text{d})}}
(P, \Hom_\mathcal{B}(K^\bullet, I^\bullet)) =
\Hom_{\text{Comp}^{dg}(\mathcal{O})}(P \otimes_E K^\bullet, I^\bullet)
$$
as graded $\mathbf{Z}$-modules (because this statement reduces to the case
$P = E[k]$ where it is obvious). As the isomorphism is compatible with
differentials we conclude.
\end{proof}

\begin{lemma}
\label{lemma-fully-faithful-in-compact-case}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $K^\bullet$ be a complex of $\mathcal{O}$-modules.
Assume
\begin{enumerate}
\item $K^\bullet$ represents a compact object of $D(\mathcal{O})$, and
\item $E = \Hom_{\text{Comp}^{dg}(\mathcal{O})}(K^\bullet, K^\bullet)$
computes the ext groups of $K^\bullet$ in $D(\mathcal{O})$.
\end{enumerate}
Then the functor
$$
- \otimes_E^\mathbf{L} K^\bullet :
D(E, \text{d})
\longrightarrow
D(\mathcal{O})
$$
of Lemma \ref{lemma-tensor-with-complex-derived} is fully faithful.
\end{lemma}

\begin{proof}
Because our functor has a left adjoint given by
$R\Hom(K^\bullet, -)$ by Lemma \ref{lemma-tensor-with-complex-hom-adjoint}
it suffices to show for a differential graded $E$-module $M$ that the map
$$
H^0(M) \longrightarrow
\Hom_{D(\mathcal{O})}(K^\bullet, M \otimes_E^\mathbf{L} K^\bullet)
$$
is an isomorphism. We may assume that $M = P$ is a differential graded
$E$-module which has property (P). Since $K^\bullet$ defines a
compact object, we reduce using
Lemma \ref{lemma-property-P-sequence}
to the case where $P$ has a finite filtration whose graded pieces
are direct sums of $E[k]$. Again using compactness we reduce
to the case $P = E[k]$. The assumption on $K^\bullet$ is that
the result holds for these.
\end{proof}











\section{Characterizing compact objects}
\label{section-compact}

\noindent
Compact objects of additive categories are defined in
Derived Categories, Definition \ref{derived-definition-compact-object}.
In this section we characterize compact objects of the derived
category of a differential graded algebra.

\begin{remark}
\label{remark-source-graded-projective}
Let $(A, \text{d})$ be a differential graded algebra. Is there a
characterization of those differential graded $A$-modules $P$
for which we have
$$
\Hom_{K(A, \text{d})}(P, M) =  \Hom_{D(A, \text{d})}(P, M)
$$
for all differential graded $A$-modules $M$? Let
$\mathcal{D} \subset K(A, \text{d})$ be the full subcategory
whose objects are the objects $P$ satisfying the above. Then $\mathcal{D}$
is a strictly full saturated triangulated subcategory of $K(A, \text{d})$.
If $P$ is projective as a graded $A$-module, then to see where $P$
is an object of $\mathcal{D}$ it is enough to check that
$\Hom_{K(A, \text{d})}(P, M) = 0$ whenever $M$ is acyclic.
However, in general it is not enough to assume that $P$ is projective as
a graded $A$-module. Example: take $A = R = k[\epsilon]$ where $k$ is
a field and $k[\epsilon] = k[x]/(x^2)$ is the ring of dual numbers.
Let $P$ be the object with $P^n = R$ for all $n \in \mathbf{Z}$
and differential given by multiplication by $\epsilon$. Then
$\text{id}_P \in \Hom_{K(A, \text{d})}(P, P)$ is a nonzero element
but $P$ is acyclic.
\end{remark}

\begin{remark}
\label{remark-graded-projective-is-compact}
Let $(A, \text{d})$ be a differential graded algebra. Let us say a
differential graded $A$-module $M$ is {\it finite} if $M$ is generated,
as a right $A$-module, by finitely many elements. If $P$ is a
differential graded $A$-module which is finite graded projective,
then we can ask: Does $P$ give a compact object of $D(A, \text{d})$?
Presumably, this is not true in general, but we do not know a
counter example. However, if $P$ is also an object of the category
$\mathcal{D}$ of Remark \ref{remark-source-graded-projective},
then this is the case (this follows from the fact that direct sums
in $D(A, \text{d})$ are given by direct sums of modules; details omitted).
\end{remark}

\begin{lemma}
\label{lemma-factor-through-nicer}
Let $(A, \text{d})$ be a differential graded algebra. Let $E$ be a compact
object of $D(A, \text{d})$. Let $P$ be a differential graded $A$-module
which has a finite filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset F_nP = P
$$
by differential graded submodules such that
$$
F_{i + 1}P/F_iP \cong \bigoplus\nolimits_{j \in J_i} A[k_{i, j}]
$$
as differential graded $A$-modules for some sets $J_i$ and integers $k_{i, j}$.
Let $E \to P$ be a morphism of $D(A, \text{d})$.
Then there exists a differential graded submodule $P' \subset P$ such that
$F_{i + 1}P \cap P'/(F_iP \cap P')$ is equal to
$\bigoplus_{j \in J'_i} A[k_{i, j}]$ for some finite subsets
$J'_i \subset J_i$ and such that $E \to P$ factors through $P'$.
\end{lemma}

\begin{proof}
We will prove by induction on $-1 \leq m \leq n$ that there exists
a differential graded submodule $P' \subset P$  such that
\begin{enumerate}
\item $F_mP \subset P'$,
\item for $i \geq m$ the quotient $F_{i + 1}P \cap P'/(F_iP \cap P')$ is
isomorphic to $\bigoplus_{j \in J'_i} A[k_{i, j}]$ for some finite subsets
$J'_i \subset J_i$, and
\item $E \to P$ factors through $P'$.
\end{enumerate}
The base case is $m = n$ where we can take $P' = P$.

\medskip\noindent
Induction step. Assume $P'$ works for $m$.
For $i \geq m$ and $j \in J'_i$ let $x_{i, j} \in F_{i + 1}P \cap P'$
be a homogeneous element of degree $k_{i, j}$ whose image in
$F_{i + 1}P \cap P'/(F_iP \cap P')$ is the generator in
the summand corresponding to $j \in J_i$. The
$x_{i, j}$ generate $P'/F_mP$ as an $A$-module. Write
$$
\text{d}(x_{i, j}) = \sum x_{i', j'} a_{i, j}^{i', j'} + y_{i, j}
$$
with $y_{i, j} \in F_mP$ and $a_{i, j}^{i', j'} \in A$.
There exists a finite subset
$J'_{m - 1} \subset J_{m - 1}$ such that each $y_{i, j}$ maps to
an element of the submodule $\bigoplus_{j \in J'_{m - 1}} A[k_{m - 1, j}]$
of $F_mP/F_{m - 1}P$. Let $P'' \subset F_mP$ be the inverse
image of $\bigoplus_{j \in J'_{m - 1}} A[k_{m - 1, j}]$ under
the map $F_mP \to F_mP/F_{m - 1}P$. Then we see that the $A$-submodule
$$
P'' + \sum x_{i, j}A
$$
is a differential graded submodule of the type we are looking for. Moreover
$$
P'/(P'' + \sum x_{i, j}A) =
\bigoplus\nolimits_{j \in J_{m - 1} \setminus J'_{m - 1}} A[k_{m - 1, j}]
$$
Since $E$ is compact, the composition of the given map $E \to P'$
with the quotient map, factors through a finite direct subsum of
the module displayed above. Hence after enlarging $J'_{m - 1}$
we may assume $E \to P'$ factors through
$P'' + \sum x_{i, j}A$ as desired.
\end{proof}

\noindent
It is not true that every compact object of $D(A, \text{d})$ comes
from a finite graded projective differential graded $A$-module,
see Examples, Section \ref{examples-section-interesting-compact}.

\begin{proposition}
\label{proposition-compact}
Let $(A, \text{d})$ be a differential graded algebra. Let $E$ be an
object of $D(A, \text{d})$. Then the following are equivalent
\begin{enumerate}
\item $E$ is a compact object,
\item $E$ is a direct summand of an object of $D(A, \text{d})$
which is represented by a differential graded module $P$ which
has a finite filtration $F_\bullet$ by differential graded submodules
such that $F_iP/F_{i - 1}P$ are finite direct sums of shifts of $A$.
\end{enumerate}
\end{proposition}

\begin{proof}
Assume $E$ is compact. By Lemma \ref{lemma-resolve} we may assume that $E$
is represented by a differential graded $A$-module $P$ with property (P).
Consider the distinguished triangle
$$
\bigoplus F_iP \to \bigoplus F_iP \to P
\xrightarrow{\delta} \bigoplus F_iP[1]
$$
coming from the admissible short exact sequence of
Lemma \ref{lemma-property-P-sequence}. Since $E$ is compact we have
$\delta = \sum_{i = 1, \ldots, n} \delta_i$ for some
$\delta_i : P \to F_iP[1]$. Since the composition of $\delta$
with the map $\bigoplus F_iP[1] \to \bigoplus F_iP[1]$ is zero
(Derived Categories, Lemma \ref{derived-lemma-composition-zero})
it follows that $\delta = 0$ (follows as $\bigoplus F_iP \to \bigoplus F_iP$
maps the summand $F_iP$ via the difference of $\text{id}$ and the inclusion
map into $F_{i - 1}P$).
Thus we see that the identity on $E$ factors through
$\bigoplus F_iP$ in $D(A, \text{d})$ (by
Derived Categories, Lemma \ref{derived-lemma-split}).
Next, we use that $P$ is compact again to see that the map
$E \to \bigoplus F_iP$ factors through $\bigoplus_{i = 1, \ldots, n} F_iP$
for some $n$. In other words, the identity on $E$ factors through
$\bigoplus_{i = 1, \ldots, n} F_iP$. By
Lemma \ref{lemma-factor-through-nicer}
we see that the identity of $E$ factors as $E \to P \to E$
where $P$ is as in part (2) of the statement of the lemma.
In other words, we have proven that (1) implies (2).

\medskip\noindent
Assume (2). By
Derived Categories, Lemma \ref{derived-lemma-compact-objects-subcategory}
it suffices to show that $P$ gives a compact object. Observe that
$P$ has property (P), hence we have
$$
\Hom_{D(A, \text{d})}(P, M) = \Hom_{K(A, \text{d})}(P, M)
$$
for any differential graded module $M$ by Lemma \ref{lemma-hom-derived}.
As direct sums in $D(A, \text{d})$ are given by direct sums of
graded modules (Lemma \ref{lemma-derived-products}) we reduce
to showing that $\Hom_{K(A, \text{d})}(P, M)$ commutes with direct
sums. Using that $K(A, \text{d})$ is a triangulated category,
that $\Hom$ is a cohomological functor in the first
variable, and the filtration on $P$, we reduce to the case that
$P$ is a finite direct sum of shifts of $A$. Thus we reduce to
the case $P = A[k]$ which is clear.
\end{proof}

\begin{lemma}
\label{lemma-compact-implies-bounded}
Let $(A, \text{d})$ be a differential graded algebra.
For every compact object $E$ of $D(A, \text{d})$ there
exist integers $a \leq b$ such that $\Hom_{D(A, \text{d})}(E, M) = 0$
if $H^i(M) = 0$ for $i \in [a, b]$.
\end{lemma}

\begin{proof}
Observe that the collection of objects of $D(A, \text{d})$ for which
such a pair of integers exists is a saturated, strictly full triangulated
subcategory of $D(A, \text{d})$.
Thus by Proposition \ref{proposition-compact} it suffices to prove
this when $E$ is represented by a differential graded module $P$ which
has a finite filtration $F_\bullet$ by differential graded submodules
such that $F_iP/F_{i - 1}P$ are finite direct sums of shifts of $A$.
Using the compatibility with triangles, we see that it suffices
to prove it for $P = A$. In this case $\Hom_{D(A, \text{d})}(A, M) = H^0(M)$
and the result holds with $a = b = 0$.
\end{proof}

\noindent
If $(A, \text{d})$ is just an algebra placed in degree $0$
with zero differential or more generally lives in
only a finite number of degrees, then we do obtain the
more precise description of compact objects.

\begin{lemma}
\label{lemma-compact}
Let $(A, \text{d})$ be a differential graded algebra. Assume that $A^n = 0$
for $|n| \gg 0$. Let $E$ be an object of $D(A, \text{d})$.
The following are equivalent
\begin{enumerate}
\item $E$ is a compact object, and
\item $E$ can be represented by a differential graded $A$-module $P$
which is finite projective as a graded $A$-module and satisfies
$\Hom_{K(A, \text{d})}(P, M) = \Hom_{D(A, \text{d})}(P, M)$
for every differential graded $A$-module $M$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $\mathcal{D} \subset K(A, \text{d})$ be the triangulated subcategory
discussed in Remark \ref{remark-source-graded-projective}.
Let $P$ be an object of $\mathcal{D}$ which is finite projective
as a graded $A$-module. Then $P$ represents a compact object of
$D(A, \text{d})$ by Remark \ref{remark-graded-projective-is-compact}.

\medskip\noindent
To prove the converse, let $E$ be a compact object of $D(A, \text{d})$.
Fix $a \leq b$ as in Lemma \ref{lemma-compact-implies-bounded}.
After decreasing $a$ and increasing $b$ if necessary, we may also
assume that $H^i(E) = 0$ for $i \not \in [a, b]$ (this follows
from Proposition \ref{proposition-compact} and our assumption on $A$).
Moreover, fix an integer $c > 0$ such that $A^n = 0$ if $|n| \geq c$.

\medskip\noindent
By Proposition \ref{proposition-compact} we see that $E$ is a direct
summand, in $D(A, \text{d})$, of a differential graded $A$-module $P$
which has a finite filtration $F_\bullet$ by differential
graded submodules such that $F_iP/F_{i - 1}P$ are finite direct sums
of shifts of $A$. In particular, $P$ has property (P) and we have
$\Hom_{D(A, \text{d})}(P, M) = \Hom_{K(A, \text{d})}(P, M)$ for any
differential graded module $M$ by Lemma \ref{lemma-hom-derived}.
In other words, $P$ is an object of the triangulated
subcategory $\mathcal{D} \subset K(A, \text{d})$ discussed in
Remark \ref{remark-source-graded-projective}.
Note that $P$ is finite free as a graded $A$-module.

\medskip\noindent
Choose $n > 0$ such that $b + 4c - n < a$.
Represent the projector onto $E$ by an endomorphism $\varphi : P \to P$ of
differential graded $A$-modules. Consider the distinguished triangle
$$
P \xrightarrow{1 - \varphi} P \to C \to P[1]
$$
in $K(A, \text{d})$ where $C$ is the cone of the first arrow. Then
$C$ is an object of $\mathcal{D}$,
we have $C \cong E \oplus E[1]$ in $D(A, \text{d})$, and
$C$ is a finite graded free $A$-module.
Next, consider a distinguished triangle
$$
C[1] \to C \to C' \to C[2]
$$
in $K(A, \text{d})$ where $C'$ is the cone on a morphism $C[1] \to C$
representing the composition
$$
C[1] \cong E[1] \oplus E[2] \to E[1] \to E \oplus E[1] \cong C
$$
in $D(A, \text{d})$. Then we see that $C'$ represents $E \oplus E[2]$.
Continuing in this manner we see that we can find a differential
graded $A$-module $P$ which is an object of $\mathcal{D}$,
is a finite free as a graded $A$-module, and represents $E \oplus E[n]$.

\medskip\noindent
Choose a basis $x_i$, $i \in I$ of homogeneous elements for $P$ as an
$A$-module. Let $d_i = \deg(x_i)$.
Let $P_1$ be the $A$-submodule of $P$ generated by $x_i$ and
$\text{d}(x_i)$ for $d_i \leq a - c - 1$.
Let $P_2$ be the $A$-submodule of $P$ generated by $x_i$ and
$\text{d}(x_i)$ for $d_i \geq b - n + c$.
We observe
\begin{enumerate}
\item $P_1$ and $P_2$ are differential graded submodules of $P$,
\item $P_1^t = 0$ for $t \geq a$,
\item $P_1^t = P^t$ for $t \leq a - 2c$,
\item $P_2^t = 0$ for $t \leq b - n$,
\item $P_2^t = P^t$ for $t \geq b - n + 2c$.
\end{enumerate}
As $b - n + 2c \geq a - 2c$ by our choice of $n$
we obtain a short exact sequence of differential graded $A$-modules
$$
0 \to P_1 \cap P_2 \to P_1 \oplus P_2 \xrightarrow{\pi} P \to 0
$$
Since $P$ is projective as a graded $A$-module this is an admissible
short exact sequence (Lemma \ref{lemma-target-graded-projective}).
Hence we obtain a boundary map
$\delta : P \to (P_1 \cap P_2)[1]$ in $K(A, \text{d})$, see
Lemma \ref{lemma-admissible-ses}.
Since $P = E \oplus E[n]$ and since $P_1 \cap P_2$ lives in
degrees $(b - n, a)$ we find that
$\Hom_{D(A, \text{d})}(E \oplus E[n], (P_1 \cap P_2)[1])$ is
zero. Therefore $\delta = 0$ as a morphism in $K(A, \text{d})$
as $P$ is an object of $\mathcal{D}$.
By Derived Categories, Lemma \ref{derived-lemma-split}
we can find a map $s : P \to P_1 \oplus P_2$ such that
$\pi \circ s = \text{id}_P + \text{d}h + h\text{d}$ for some $h : P \to P$
of degree $-1$. Since $P_1 \oplus P_2 \to P$ is surjective and since $P$
is projective as a graded $A$-module we can choose a homogeneous
lift $\tilde h : P \to P_1 \oplus P_2$ of $h$. Then we change
$s$ into $s + \text{d} \tilde h + \tilde h \text{d}$ to get
$\pi \circ s = \text{id}_P$. This means we obtain a direct
sum decomposition $P = s^{-1}(P_1) \oplus s^{-1}(P_2)$.
Since $s^{-1}(P_2)$ is equal to $P$ in degrees $\geq b - n + 2c$
we see that $s^{-1}(P_2) \to P \to E$ is a quasi-isomorphism,
i.e., an isomorphism in $D(A, \text{d})$. This finishes the proof.
\end{proof}








\section{Equivalences of derived categories}
\label{section-equivalence}

\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be differential
graded $R$-algebras. A natural question that arises in nature is what
it means that $D(A, \text{d})$ is equivalent to $D(B, \text{d})$
as an $R$-linear triangulated category. This is a rather subtle question
and it will turn out it isn't always the correct question to ask.
Nonetheless, in this section we collection some conditions
that guarantee this is the case.

\medskip\noindent
We strongly urge the reader to take a look at the groundbreaking
paper \cite{Rickard} on this topic.

\begin{lemma}
\label{lemma-qis-equivalence}
Let $R$ be a ring. Let $(A, \text{d}) \to (B, \text{d})$ be a
homomorphism of differential graded algebras over $R$, which induces
an isomorphism on cohomology algebras. Then
$$
- \otimes_A^\mathbf{L} B : D(A, \text{d}) \to D(B, \text{d})
$$
gives an $R$-linear equivalence of triangulated categories with
quasi-inverse the restriction functor $N \mapsto N_A$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-tensor-with-compact-fully-faithful}
the functor $M \longmapsto M \otimes_A^\mathbf{L} B$ is
fully faithful. By Lemma \ref{lemma-tensor-hom-adjoint}
the functor $N \longmapsto R\Hom(B, N) = N_A$ is a right adjoint, see
Example \ref{example-map-hom-tensor}.
It is clear that the kernel of $R\Hom(B, -)$ is zero.
Hence the result follows from
Derived Categories, Lemma
\ref{derived-lemma-fully-faithful-adjoint-kernel-zero}.
\end{proof}

\noindent
When we analyze the proof above we see that we obtain the
following generalization for free.

\begin{lemma}
\label{lemma-tilting-equivalence}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be 
differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Assume that
\begin{enumerate}
\item $N$ defines a compact object of $D(B, \text{d})$,
\item if $N' \in D(B, \text{d})$ and
$\Hom_{D(B, \text{d})}(N, N'[n]) = 0$ for $n \in \mathbf{Z}$,
then $N' = 0$, and
\item the map $H^k(A) \to \Hom_{D(B, \text{d})}(N, N[k])$ is an
isomorphism for all $k \in \mathbf{Z}$.
\end{enumerate}
Then
$$
- \otimes_A^\mathbf{L} N : D(A, \text{d}) \to D(B, \text{d})
$$
gives an $R$-linear equivalence of triangulated categories.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-tensor-with-compact-fully-faithful}
the functor $M \longmapsto M \otimes_A^\mathbf{L} N$ is
fully faithful. By Lemma \ref{lemma-tensor-hom-adjoint}
the functor $N' \longmapsto R\Hom(N, N')$ is a right adjoint.
By assumption (3) the kernel of $R\Hom(N, -)$ is zero.
Hence the result follows from
Derived Categories, Lemma
\ref{derived-lemma-fully-faithful-adjoint-kernel-zero}.
\end{proof}

\begin{remark}
\label{remark-tilting-equivalence}
In Lemma \ref{lemma-tilting-equivalence} we can replace
condition (2) by the condition that $N$ is a classical
generator for $D_{compact}(B, d)$, see
Derived Categories, Proposition
\ref{derived-proposition-generator-versus-classical-generator}.
Moreover, if we knew that $R\Hom(N, B)$ is a compact object
of $D(A, \text{d})$, then it suffices to check that $N$
is a weak generator for $D_{compact}(B, \text{d})$.
We omit the proof; we will add it here if we ever
need it in the Stacks project.
\end{remark}

\noindent
Sometimes the $B$-module $P$ in the lemma below is called an
``$(A, B)$-tilting complex''.

\begin{lemma}
\label{lemma-rickard}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Assume that $A = H^0(A)$.
The following are equivalent
\begin{enumerate}
\item $D(A, \text{d})$ and $D(B, \text{d})$ are equivalent as $R$-linear
triangulated categories, and
\item there exists an object $P$ of $D(B, \text{d})$ such that
\begin{enumerate}
\item $P$ is a compact object of $D(B, \text{d})$,
\item if $N \in D(B, \text{d})$ with $\Hom_{D(B, \text{d})}(P, N[i]) = 0$
for $i \in \mathbf{Z}$, then $N = 0$,
\item $\Hom_{D(B, \text{d})}(P, P[i]) = 0$ for $i \not = 0$ and
equal to $A$ for $i = 0$.
\end{enumerate}
\end{enumerate}
The equivalence $D(A, \text{d}) \to D(B, \text{d})$
constructed in (2) sends $A$ to $P$.
\end{lemma}

\begin{proof}
Let $F : D(A, \text{d}) \to D(B, \text{d})$ be an equivalence.
Then $F$ maps compact objects to compact objects. Hence $P = F(A)$ is
compact, i.e., (2)(a) holds. Conditions (2)(b) and (2)(c) are immediate
from the fact that $F$ is an equivalence.

\medskip\noindent
Let $P$ be an object as in (2). Represent $P$ by a
differential graded module with property (P). Set
$$
(E, \text{d}) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(P, P)
$$
Then $H^0(E) = A$ and $H^k(E) = 0$ for $k \not = 0$ by
Lemma \ref{lemma-hom-derived} and assumption (2)(c).
Viewing $P$ as a $(E, B)$-bimodule and using
Lemma \ref{lemma-tilting-equivalence} and assumption (2)(b)
we obtain an equivalence
$$
D(E, \text{d}) \to D(B, \text{d})
$$
sending $E$ to $P$.
Let $E' \subset E$ be the differential graded $R$-subalgebra
with
$$
(E')^i = \left\{
\begin{matrix}
E^i & \text{if }i < 0 \\
\Ker(E^0 \to E^1) & \text{if }i = 0 \\
0 & \text{if }i > 0
\end{matrix}
\right.
$$
Then there are quasi-isomorphisms of differential graded
algebras $(A, \text{d}) \leftarrow (E', \text{d}) \rightarrow (E, \text{d})$.
Thus we obtain equivalences
$$
D(A, \text{d}) \leftarrow D(E', \text{d}) \rightarrow D(E, \text{d})
\rightarrow D(B, \text{d})
$$
by Lemma \ref{lemma-qis-equivalence}.
\end{proof}

\begin{remark}
\label{remark-lift-equivalence-to-dga}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be differential
graded $R$-algebras. Suppose given an $R$-linear equivalence
$$
F : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
of triangulated categories. Set $N = F(A)$. Then $N$ is a differential
graded $B$-module. Since $F$ is an equivalence and $A$ is a compact
object of $D(A, \text{d})$, we conclude that $N$ is a compact object
of $D(B, \text{d})$. Since $A$ generates $D(A, \text{d})$ and
$F$ is an equivalence, we see that $N$ generates $D(B, \text{d})$.
Finally, $H^k(A) = \Hom_{D(A, \text{d})}(A, A[k])$ and as $F$ an equivalence
we see that $F$ induces an isomorphism
$H^k(A) = \Hom_{D(B, \text{d})}(N, N[k])$ for all $k$.
In order to conclude that there is an equivalence
$D(A, \text{d}) \longrightarrow D(B, \text{d})$ which
arises from the construction in
Lemma \ref{lemma-tilting-equivalence}
all we need is a left $A$-module structure on $N$
compatible with derivation and commuting
with the given right $B$-module structure. In fact, it
suffices to do this after replacing $N$ by a quasi-isomorphic
differential graded $B$-module.
The module structure can be constructed in certain cases.
For example, if we assume that $F$ can be lifted to a
differential graded functor
$$
F^{dg} :
\text{Mod}^{dg}_{(A, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(B, \text{d})}
$$
(for notation see Example \ref{example-dgm-dg-cat})
between the associated differential graded categories,
then this holds. Another case is discussed in the proposition below.
\end{remark}

\begin{proposition}
\label{proposition-rickard}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $F : D(A, \text{d}) \to D(B, \text{d})$
be an $R$-linear equivalence of triangulated categories. Assume that
\begin{enumerate}
\item $A = H^0(A)$, and
\item $B$ is K-flat as a complex of $R$-modules.
\end{enumerate}
Then there exists an $(A, B)$-bimodule $N$ as in
Lemma \ref{lemma-tilting-equivalence}.
\end{proposition}

\begin{proof}
As in Remark \ref{remark-lift-equivalence-to-dga} above, we set $N = F(A)$
in $D(B, \text{d})$. We may assume that $N$ is a differential graded
$B$-module with property (P). Set
$$
(E, \text{d}) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N)
$$
Then $H^0(E) = A$ and $H^k(E) = 0$ for $k \not = 0$ by
Lemma \ref{lemma-hom-derived}.
Moreover, by the discussion in Remark \ref{remark-lift-equivalence-to-dga}
and by Lemma \ref{lemma-tilting-equivalence}
we see that $N$ as a $(E, B)$-bimodule induces an
equivalence $- \otimes_E^\mathbf{L} N : D(E, \text{d}) \to D(B, \text{d})$.
Let $E' \subset E$ be the differential graded $R$-subalgebra
with
$$
(E')^i = \left\{
\begin{matrix}
E^i & \text{if }i < 0 \\
\Ker(E^0 \to E^1) & \text{if }i = 0 \\
0 & \text{if }i > 0
\end{matrix}
\right.
$$
Then there are quasi-isomorphisms of differential graded
algebras $(A, \text{d}) \leftarrow (E', \text{d}) \rightarrow (E, \text{d})$.
Thus we obtain equivalences
$$
D(A, \text{d}) \leftarrow D(E', \text{d}) \rightarrow D(E, \text{d})
\rightarrow D(B, \text{d})
$$
by Lemma \ref{lemma-qis-equivalence}.
Note that the quasi-inverse $D(A, \text{d}) \to D(E', \text{d})$
of the left vertical arrow is given
by $M \mapsto M \otimes_A^\mathbf{L} A$ where $A$ is viewed as a
$(A, E')$-bimodule, see Example \ref{example-map-hom-tensor}.
On the other hand the functor $D(E', \text{d}) \to D(B, \text{d})$ is given by
$M \mapsto M \otimes_{E'}^\mathbf{L} N$ where $N$ is as above.
We conclude by Lemma \ref{lemma-compose-tensor-functors}.
\end{proof}

\begin{remark}
\label{remark-rickard}
Let $A, B, F, N$ be as in Proposition \ref{proposition-rickard}.
It is not clear that $F$ and the functor
$G(-) = - \otimes_A^\mathbf{L} N$ are isomorphic.
By construction there is an isomorphism
$N = G(A) \to F(A)$ in $D(B, \text{d})$.
It is straightforward to extend this to a functorial isomorphism
$G(M) \to F(M)$ for $M$ is a differential graded $A$-module which
is graded projective (e.g., a sum of shifts of $A$).
Then one can conclude that $G(M) \cong F(M)$ when $M$ is a cone
of a map between such modules. We don't know whether more is true
in general.
\end{remark}

\begin{lemma}
\label{lemma-rickard-rings}
Let $R$ be a ring.
Let $A$ and $B$ be $R$-algebras. The following are equivalent
\begin{enumerate}
\item there is an $R$-linear equivalence $D(A) \to D(B)$
of triangulated categories,
\item there exists an object $P$ of $D(B)$ such that
\begin{enumerate}
\item $P$ can be represented by a finite complex
of finite projective $B$-modules,
\item if $K \in D(B)$ with $\Ext^i_B(P, K) = 0$ for
$i \in \mathbf{Z}$, then $K = 0$, and
\item $\Ext^i_B(P, P) = 0$ for $i \not = 0$ and
equal to $A$ for $i= 0$.
\end{enumerate}
\end{enumerate}
Moreover, if $B$ is flat as an $R$-module, then this is also
equivalent to
\begin{enumerate}
\item[(3)] there exists an $(A, B)$-bimodule $N$ such that
$- \otimes_A^\mathbf{L} N : D(A) \to D(B)$ is an equivalence.
\end{enumerate}
\end{lemma}

\begin{proof}
The equivalence of (1) and (2) is a special case of
Lemma \ref{lemma-rickard} combined with the result of
Lemma \ref{lemma-compact} characterizing compact objects of $D(B)$
(small detail omitted).
The equivalence with (3) if $B$ is $R$-flat follows from
Proposition \ref{proposition-rickard}.
\end{proof}

\begin{remark}
\label{remark-centers}
Let $R$ be a ring. Let $A$ and $B$ be $R$-algebras.
If $D(A)$ and $D(B)$ are equivalent as $R$-linear triangulated
categories, then the centers of $A$ and $B$ are isomorphic
as $R$-algebras. In particular, if $A$ and $B$ are commutative,
then $A \cong B$. The rather tricky proof can be found in
\cite[Proposition 9.2]{Rickard} or \cite[Proposition 6.3.2]{KZ}.
Another approach might be to use Hochschild cohomology (see
remark below).
\end{remark}

\begin{remark}
\label{remark-hochschild-cohomology}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be differential
graded $R$-algebras which are derived equivalent, i.e., such that there
exists an $R$-linear equivalence $D(A, \text{d}) \to D(B, \text{d})$
of triangulated categories. We would like to show that certain invariants
of $(A, \text{d})$ and $(B, \text{d})$ coincide. In many situations
one has more control of the situation. For example, it may happen
that there is an equivalence of the form
$$
- \otimes_A \Omega : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
for some differential graded $(A, B)$-bimodule
$\Omega$ (this happens in the situation of
Proposition \ref{proposition-rickard} and is often true
if the equivalence comes from a geometric construction).
If also the quasi-inverse of our functor is given as
$$
- \otimes_B^\mathbf{L} \Omega' : D(B, \text{d}) \longrightarrow D(A, \text{d})
$$
for a differential graded $(B, A)$-bimodule $\Omega'$
(and as before such a module $\Omega'$ often exists in practice).
In this case we can consider the functor
$$
D(A^{opp} \otimes_R A, \text{d})
\longrightarrow
D(B^{opp} \otimes_R B, \text{d}),\quad
M \longmapsto \Omega' \otimes^\mathbf{L}_A M \otimes_A^\mathbf{L} \Omega
$$
on derived categories of bimodules (use
Lemma \ref{lemma-bimodule-over-tensor} to turn bimodules into
right modules).
Observe that this functor sends the $(A, A)$-bimodule $A$ to
the $(B, B)$-bimodule $B$. Under suitable conditions
(e.g., flatness of $A$, $B$, $\Omega$ over $R$, etc)
this functor will be an equivalence as well.
If this is the case, then it follows that we have isomorphisms
of Hochschild cohomology groups
$$
HH^i(A, \text{d}) =
\Hom_{D(A^{opp} \otimes_R A, \text{d})}(A, A[i])
\longrightarrow
\Hom_{D(B^{opp} \otimes_R B, \text{d})}(B, B[i]) =
HH^i(B, \text{d}).
$$
For example, if $A = H^0(A)$, then $HH^0(A, \text{d})$
is equal to the center of $A$, and this gives a conceptual proof
of the result mentioned in Remark \ref{remark-centers}.
If we ever need this remark we will provide a precise statement
with a detailed proof here.
\end{remark}



\section{Resolutions of differential graded algebras}
\label{section-resolution-dgas}

\noindent
Let $R$ be a ring. Under our assumptions the free $R$-algebra
$R\langle S \rangle$ on a set $S$ is the algebra with $R$-basis
the expressions
$$
s_1 s_2 \ldots s_n
$$
where $n \geq 0$ and $s_1, \ldots, s_n \in S$ is a sequence of
elements of $S$. Multiplication is given by concatenation
$$
(s_1 s_2 \ldots s_n) \cdot (s'_1 s'_2 \ldots s'_m) =
s_1 \ldots s_n s'_1 \ldots s'_m
$$
This algebra is characterized by the property that the map
$$
\Mor_{R\text{-alg}}(R\langle S \rangle, A) \to
\text{Map}(S, A),\quad
\varphi \longmapsto (s \mapsto \varphi(s))
$$
is a bijection for every $R$-algebra $A$.

\medskip\noindent
In the category of graded $R$-algebras our set $S$ should come
with a grading, which we think of as a map $\deg : S \to \mathbf{Z}$.
Then $R\langle S\rangle$ has a grading such that the monomials
have degree
$$
\deg(s_1 s_2 \ldots s_n) = \deg(s_1) + \ldots + \deg(s_n)
$$
In this setting we have
$$
\Mor_{\text{graded }R\text{-alg}}(R\langle S \rangle, A) \to
\text{Map}_{\text{graded sets}}(S, A),\quad
\varphi \longmapsto (s \mapsto \varphi(s))
$$
is a bijection for every graded $R$-algebra $A$.

\medskip\noindent
If $A$ is a graded $R$-algebra and $S$ is a graded set,
then we can similarly form $A\langle S \rangle$.
Elements of $A\langle S \rangle$ are
sums of elements of the form
$$
a_0 s_1 a_1 s_2 \ldots a_{n - 1} s_n a_n
$$
with $a_i \in A$ modulo the relations that these expressions
are $R$-multilinear in $(a_0, \ldots, a_n)$.
Thus for every sequence $s_1, \ldots, s_n$ of elements of $S$
there is an inclusion
$$
A \otimes_R \ldots \otimes_R A \subset A\langle S \rangle
$$
and the algebra is the direct sum of these. With this definition the
reader shows that the map
$$
\Mor_{\text{graded }R\text{-alg}}(A\langle S \rangle, B) \to
\Mor_{\text{graded }R\text{-alg}}(A, B) \times
\text{Map}_{\text{graded sets}}(S, B),
$$
sending $\varphi$ to $(\varphi|_A, (s \mapsto \varphi(s)))$
is a bijection for every graded $R$-algebra $A$.
We observe that if $A$ was a free graded $R$-algebra,
then so is $A\langle S \rangle$.

\medskip\noindent
Suppose that $A$ is a differential graded $R$-algebra and
that $S$ is a graded set. Suppose moreover for every $s \in S$
we are given a homogeneous element $f_s \in A$ with $\deg(f_s) = \deg(s) + 1$
and $\text{d}f_s = 0$. Then there exists a unique structure of
differential graded algebra on $A\langle S \rangle$ with
$\text{d}(s) = f_s$. For example, given $a, b, c \in A$ and
$s, t \in S$ we would define
\begin{align*}
\text{d}(asbtc)
& =
\text{d}(a)sbtc + (-1)^{\deg(a)}a f_s b t c +
(-1)^{\deg(a) + \deg(s)} as\text{d}(b)tc \\
& + (-1)^{\deg(a) + \deg(s) + \deg(b)} asb f_t c +
(-1)^{\deg(a) + \deg(s) + \deg(b) + \deg(t)} asbt\text{d}(c)
\end{align*}
We omit the details.

\begin{lemma}
\label{lemma-K-flat-resolution}
Let $R$ be a ring. Let $(B, \text{d})$ be a differential graded $R$-algebra.
There exists a quasi-isomorphism $(A, \text{d}) \to (B, \text{d})$ of
differential graded $R$-algebras with the following properties
\begin{enumerate}
\item $A$ is K-flat as a complex of $R$-modules,
\item $A$ is a free graded $R$-algebra.
\end{enumerate}
\end{lemma}

\begin{proof}
First we claim we can find $(A_0, \text{d}) \to (B, \text{d})$
having (1) and (2) inducing a surjection on cohomology.
Namely, take a graded set $S$ and for each $s \in S$
a homogeneous element $b_s \in \Ker(d : B \to B)$ of degree $\deg(s)$
such that the classes $\overline{b}_s$ in $H^*(B)$
generate $H^*(B)$ as an $R$-module.
Then we can set $A_0 = R\langle S \rangle$ with zero differential
and $A_0 \to B$ given by mapping $s$ to $b_s$.

\medskip\noindent
Given $A_0 \to B$ inducing a surjection on cohomology we construct
a sequence
$$
A_0 \to A_1 \to A_2 \to \ldots B
$$
by induction. Given $A_n \to B$ we set $S_n$ be a graded set
and for each $s \in S_n$ we let $a_s \in \Ker(A_n \to A_n)$
be a homogeneous element of degree $\deg(s) + 1$
mapping to a class $\overline{a}_s$ in $H^*(A_n)$
which maps to zero in $H^*(B)$. We choose $S_n$ large enough
so that the elements $\overline{a}_s$ generate $\Ker(H^*(A_n) \to H^*(B))$
as an $R$-module. Then we set
$$
A_{n + 1} = A_n\langle S_n \rangle
$$
with differential given by $\text{d}(s) = a_s$ see discussion above.
Then each $(A_n, \text{d})$ satisfies (1) and (2), we omit the details.
The map $H^*(A_n) \to H^*(B)$ is surjective as this was true for $n = 0$.

\medskip\noindent
It is clear that $A = \colim A_n$ is a free graded $R$-algebra.
It is K-flat by More on Algebra, Lemma \ref{more-algebra-lemma-colimit-K-flat}.
The map $H^*(A) \to H^*(B)$ is an isomorphism as it is surjective
and injective: every element of $H^*(A)$ comes from an element of
$H^*(A_n)$ for some $n$ and if it dies in $H^*(B)$, then it dies
in $H^*(A_{n + 1})$ hence in $H^*(A)$.
\end{proof}

\noindent
As an application we prove the ``correct'' version of
Lemma \ref{lemma-compose-tensor-functors-general-algebra}.

\begin{lemma}
\label{lemma-compose-tensor-functors-tor}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras. Assume
$A \otimes_R C$ represents $A \otimes^\mathbf{L}_R C$ in $D(R)$.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-bimodule.
Then the composition
$$
\xymatrix{
D(A, \text{d}) \ar[rr]^{- \otimes_A^\mathbf{L} N} & &
D(B, \text{d}) \ar[rr]^{- \otimes_B^\mathbf{L} N'} & &
D(C, \text{d})
}
$$
is isomorphic to $- \otimes_A^\mathbf{L} N''$ for some differential graded
$(A, C)$-bimodule $N''$.
\end{lemma}

\begin{proof}
Using Lemma \ref{lemma-K-flat-resolution}
we choose a quasi-isomorphism $(B', \text{d}) \to (B, \text{d})$
with $B'$ K-flat as a complex of $R$-modules.
By Lemma \ref{lemma-qis-equivalence}
the functor $-\otimes^\mathbf{L}_{B'} B : D(B', \text{d}) \to D(B, \text{d})$
is an equivalence with quasi-inverse given by restriction.
Note that restriction is canonically isomorphic to the functor
$- \otimes^\mathbf{L}_B B : D(B, \text{d}) \to D(B', \text{d})$
where $B$ is viewed as a $(B, B')$-bimodule.
Thus it suffices to prove the lemma for the compositions
$$
D(A) \to D(B) \to D(B'),\quad
D(B') \to D(B) \to D(C),\quad
D(A) \to D(B') \to D(C).
$$
The first one is Lemma \ref{lemma-compose-tensor-functors}
because $B'$ is K-flat as a complex of $R$-modules.
The second one is true because
$B \otimes_B^\mathbf{L} N' = N' = B \otimes_B N'$
and hence Lemma \ref{lemma-compose-tensor-functors-general} applies.
Thus we reduce to the case where $B$ is K-flat as a complex
of $R$-modules.

\medskip\noindent
Assume $B$ is K-flat as a complex of $R$-modules. It suffices to
show that (\ref{equation-plain-versus-derived-algebras}) is an
isomorphism, see
Lemma \ref{lemma-compose-tensor-functors-general-algebra}.
Choose a quasi-isomorphism $L \to A$ where $L$ is a differential
graded $R$-module which has property (P). Then it is clear that
$P = L \otimes_R B$ has property (P) as a differential graded $B$-module.
Hence we have to show that $P \to A \otimes_R B$
induces a quasi-isomorphism
$$
P \otimes_B (B \otimes_R C)
\longrightarrow
(A \otimes_R B) \otimes_B (B \otimes_R C)
$$
We can rewrite this as
$$
P \otimes_R B \otimes_R C \longrightarrow A \otimes_R B \otimes_R C
$$
Since $B$ is K-flat as a complex of $R$-modules, it
follows from
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-quasi-isomorphism}
that it is enough
to show that
$$
P \otimes_R C \to A \otimes_R C
$$
is a quasi-isomorphism, which is exactly our assumption.
\end{proof}

\noindent
The following lemma does not really belong in this section, but there
does not seem to be a good natural spot for it.

\begin{lemma}
\label{lemma-countable}
Let $(A, \text{d})$ be a differential graded algebra with
$H^i(A)$ countable for each $i$. Let $M$ be an object of $D(A, \text{d})$.
Then the following are equivalent
\begin{enumerate}
\item $M = \text{hocolim} E_n$ with $E_n$ compact in $D(A, \text{d})$, and
\item $H^i(M)$ is countable for each $i$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1) holds. Then we have $H^i(M) = \colim H^i(E_n)$ by
Derived Categories, Lemma \ref{derived-lemma-cohomology-of-hocolim}.
Thus it suffices to prove that $H^i(E_n)$ is countable for each $n$.
By Proposition \ref{proposition-compact} we see that $E_n$
is isomorphic in $D(A, \text{d})$ to a direct summand of a
differential graded module $P$ which has a finite filtration
$F_\bullet$ by differential graded submodules
such that $F_jP/F_{j - 1}P$ are finite direct sums of shifts of $A$.
By assumption the groups $H^i(F_jP/F_{j - 1}P)$ are countable.
Arguing by induction on the length of the filtration and using
the long exact cohomology sequence we conclude that (2) is true.
The interesting implication is the other one.

\medskip\noindent
We claim there is a countable differential graded
subalgebra $A' \subset A$ such that the inclusion map
$A' \to A$ defines an isomorphism on cohomology.
To construct $A'$ we choose countable differential graded
subalgebras
$$
A_1 \subset A_2 \subset A_3 \subset \ldots
$$
such that (a) $H^i(A_1) \to H^i(A)$ is surjective, and (b)
for $n > 1$ the kernel of the map $H^i(A_{n - 1}) \to H^i(A_n)$
is the same as the kernel of the map $H^i(A_{n - 1}) \to H^i(A)$.
To construct $A_1$ take any countable collection of cochains
$S \subset A$ generating the cohomology of $A$ (as a ring or as
a graded abelian group) and let
$A_1$ be the differential graded subalgebra of $A$ generated by $S$.
To construct $A_n$ given $A_{n - 1}$ for each cochain $a \in A_{n - 1}^i$
which maps to zero in $H^i(A)$ choose $s_a \in A^{i - 1}$
with $\text{d}(s_a) = a$ and let $A_n$ be the differential graded
subalgebra of $A$ generated by $A_{n - 1}$ and the elements $s_a$.
Finally, take $A' = \bigcup A_n$.

\medskip\noindent
By Lemma \ref{lemma-qis-equivalence}
the restriction map $D(A, \text{d}) \to D(A', \text{d})$,
$M \mapsto M_{A'}$ is an equivalence. Since the cohomology
groups of $M$ and $M_{A'}$ are the same, we see that it
suffices to prove the implication (2) $\Rightarrow$ (1)
for $(A', \text{d})$.

\medskip\noindent
Assume $A$ is countable. By the exact same type of argument as
given above we see that for $M$ in $D(A, \text{d})$
the following are equivalent: $H^i(M)$ is countable for each $i$
and $M$ can be represented by a countable differential graded module.
Hence in order to prove the implication (2) $\Rightarrow$ (1)
we reduce to the situation described in the next paragraph.

\medskip\noindent
Assume $A$ is countable and that $M$ is a countable differential graded
module over $A$. We claim there exists a homomorphism
$P \to M$ of differential graded $A$-modules such that
\begin{enumerate}
\item $P \to M$ is a quasi-isomorphism,
\item $P$ has property (P), and
\item $P$ is countable.
\end{enumerate}
Looking at the proof of the construction of P-resolutions in
Lemma \ref{lemma-resolve} we see that it suffices to show that
we can prove Lemma \ref{lemma-good-quotient}
in the setting of countable differential graded modules.
This is immediate from the proof.

\medskip\noindent
Assume that $A$ is countable and that $M$ is a countable
differential graded module with property (P). Choose a filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset P
$$
by differential graded submodules such that we have
\begin{enumerate}
\item $P = \bigcup F_pP$,
\item $F_iP \to F_{i + 1}P$ is an admissible monomorphism,
\item isomorphisms of differential graded modules
$F_iP/F_{i - 1}P \to \bigoplus_{j \in J_i} A[k_j]$
for some sets $J_i$ and integers $k_j$.
\end{enumerate}
Of course $J_i$ is countable for each $i$. For each $i$ and
$j \in J_i$ choose $x_{i, j} \in F_iP$ of degree $k_j$ whose
image in $F_iP/F_{i - 1}P$ generates the summand corresponding
to $j$.

\medskip\noindent
Claim: Given $n$ and finite subsets $S_i \subset J_i$, $i = 1, \ldots, n$
there exist finite subsets $S_i \subset T_i \subset J_i$, $i = 1, \ldots, n$
such that $P' = \bigoplus_{i \leq n} \bigoplus_{j \in T_i} Ax_{i, j}$
is a differential graded submodule of $P$. This was shown in the
proof of Lemma \ref{lemma-factor-through-nicer} but it is also
easily shown directly: the elements $x_{i, j}$ freely generate
$P$ as a right $A$-module. The structure of $P$ shows that
$$
\text{d}(x_{i, j}) = \sum\nolimits_{i' < i} x_{i', j'}a_{i', j'}
$$
where of course the sum is finite.
Thus given $S_0, \ldots, S_n$ we can first choose
$S_0 \subset S'_0, \ldots, S_{n - 1} \subset S'_{n - 1}$ with
$\text{d}(x_{n, j}) \in \bigoplus_{i' < n, j' \in S'_{i'}} x_{i', j'}A$
for all $j \in S_n$. Then by induction on $n$ we can choose
$S'_0 \subset T_0, \ldots, S'_{n - 1} \subset T_{n - 1}$
to make sure that $\bigoplus_{i' < n, j' \in T_{i'}} x_{i', j'}A$
is a differential graded $A$-submodule. Setting $T_n = S_n$ we find that
$P' = \bigoplus_{i \leq n, j \in T_i} x_{i, j}A$ is as desired.

\medskip\noindent
From the claim it is clear that $P = \bigcup P'_n$
is a countable rising union of $P'_n$ as above.
By construction each $P'_n$ is a differential graded module with
property (P) such that the filtration is finite and the succesive
quotients are finite direct sums of shifts of $A$. Hence $P'_n$
defines a compact object of $D(A, \text{d})$, see for example
Proposition \ref{proposition-compact}. Since
$P = \text{hocolim} P'_n$ in $D(A, \text{d})$
by Lemma \ref{lemma-homotopy-colimit}
the proof of the implication (2) $\Rightarrow$ (1) is complete.
\end{proof}




\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}