Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
File size: 226,922 Bytes
4365a98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
:: Towards the construction of a model of Mizar concepts
::  by Grzegorz Bancerek

environ

 vocabularies NUMBERS, NAT_1, SUBSET_1, FUNCT_1, TARSKI, CARD_3, RELAT_1,
      XBOOLE_0, STRUCT_0, CATALG_1, PBOOLE, MSATERM, FACIRC_1, MSUALG_1,
      ZFMISC_1, ZF_MODEL, FUNCOP_1, CARD_1, FINSEQ_1, TREES_3, TREES_4,
      MARGREL1, MSAFREE, CLASSES1, SETFAM_1, FINSET_1, QC_LANG3, ARYTM_3,
      XXREAL_0, ORDINAL1, MCART_1, FINSEQ_2, ORDINAL4, PARTFUN1, ABCMIZ_0,
      FUNCT_2, FUNCT_4, ZF_LANG1, CAT_3, TREES_2, MSUALG_2, MEMBER_1, AOFA_000,
      CARD_5, ORDERS_2, YELLOW_1, ARYTM_0, LATTICE3, EQREL_1, LATTICES,
      YELLOW_0, ORDINAL2, WAYBEL_0, ASYMPT_0, LANG1, TDGROUP, DTCONSTR,
      BINOP_1, MATRIX_7, FUNCT_7, ABCMIZ_1, SETLIM_2;
 notations TARSKI, XBOOLE_0, ZFMISC_1, XTUPLE_0, XFAMILY, SUBSET_1, DOMAIN_1,
      SETFAM_1, RELAT_1, FUNCT_1, RELSET_1, BINOP_1, PARTFUN1, FACIRC_1,
      ENUMSET1, FUNCT_2, PARTIT_2, FUNCT_4, FUNCOP_1, XXREAL_0, ORDINAL1,
      XCMPLX_0, NAT_1, MCART_1, FINSET_1, CARD_1, NUMBERS, CARD_3, FINSEQ_1,
      FINSEQ_2, TREES_2, TREES_3, TREES_4, FUNCT_7, PBOOLE, MATRIX_7, XXREAL_2,
      STRUCT_0, LANG1, CLASSES1, ORDERS_2, LATTICE3, YELLOW_0, WAYBEL_0,
      YELLOW_1, YELLOW_7, DTCONSTR, MSUALG_1, MSUALG_2, MSAFREE, EQUATION,
      MSATERM, CATALG_1, MSAFREE3, AOFA_000, PRE_POLY;
 constructors DOMAIN_1, MATRIX_7, MSAFREE1, FUNCT_7, EQUATION, YELLOW_1,
      CATALG_1, LATTICE3, WAYBEL_0, FACIRC_1, CLASSES1, MSAFREE3, XXREAL_2,
      RELSET_1, PRE_POLY, PARTIT_2, XTUPLE_0, XFAMILY;
 registrations XBOOLE_0, SUBSET_1, XREAL_0, ORDINAL1, RELSET_1, FUNCT_1,
      FINSET_1, STRUCT_0, PBOOLE, MSUALG_1, MSUALG_2, FINSEQ_1, CARD_1,
      MSAFREE, FUNCOP_1, TREES_3, MSAFREE1, PARTFUN1, MSATERM, ORDERS_2,
      TREES_2, DTCONSTR, WAYBEL_0, YELLOW_1, LATTICE3, MEMBERED, RELAT_1,
      INDEX_1, INSTALG1, MSAFREE3, FACIRC_1, XXREAL_2, CLASSES1, FINSEQ_2,
      PARTIT_2, XTUPLE_0;
 requirements BOOLE, SUBSET, NUMERALS, ARITHM, REAL;
 definitions TARSKI, XBOOLE_0, RELAT_1, FUNCT_1, FINSEQ_2, LANG1, PBOOLE,
      TREES_3, MSUALG_1, WAYBEL_0, XTUPLE_0;
 equalities TARSKI, RELAT_1, FINSEQ_1, LANG1, LATTICE3, MSAFREE, MSAFREE3,
      CARD_3, MSUALG_1, ORDINAL1;
 expansions TARSKI, FUNCT_1, LANG1, LATTICE3, PBOOLE, TREES_3;
 theorems TARSKI, XBOOLE_0, XBOOLE_1, TREES_1, XXREAL_0, ZFMISC_1, FUNCT_1,
      FUNCT_2, FINSEQ_1, FINSEQ_2, SUBSET_1, ENUMSET1, FUNCT_4, PROB_2, LANG1,
      MATRIX_7, NAT_1, MCART_1, PBOOLE, FINSET_1, RELAT_1, RELSET_1, ORDINAL3,
      CARD_1, CARD_3, CARD_5, CLASSES1, ORDINAL1, SETFAM_1, MSUALG_2, TREES_4,
      FINSEQ_3, FUNCOP_1, MSAFREE, MSATERM, MSAFREE3, PARTFUN1, LATTICE3,
      YELLOW_0, WAYBEL_0, YELLOW_1, YELLOW_7, DTCONSTR, MSAFREE1, XXREAL_2,
      CARD_2, XTUPLE_0;
 schemes XBOOLE_0, FUNCT_1, NAT_1, FRAENKEL, PBOOLE, MSATERM, DTCONSTR,
      CLASSES1, FUNCT_2;

begin :: Variables

reserve i for Nat,
  j for Element of NAT,
  X,Y,x,y,z for set;

theorem Th1:
  for f being Function holds f.x c= Union f
proof
  let f be Function;
  x in dom f or not x in dom f;
  then f.x in rng f or f.x = {} by FUNCT_1:3,def 2;
  hence thesis by ZFMISC_1:74;
end;

theorem
  for f being Function st Union f = {} holds f.x = {} by Th1,XBOOLE_1:3;

theorem Th3:
  for f being Function for x,y being object st f = [x,y] holds x = y
proof
  let f be Function, x,y be object;
  assume
A1: f = [x,y];
  then
A2: {x} in f by TARSKI:def 2;
A3: {x,y} in f by A1,TARSKI:def 2;
  consider a,b being object such that
A4: {x} = [a,b] by A2,RELAT_1:def 1;
A5: {a} = {a,b} by A4,ZFMISC_1:5;
A6: x = {a} by A4,ZFMISC_1:4;
  consider c,d being object such that
A7: {x,y} = [c,d] by A3,RELAT_1:def 1;
A8: x = {c} & y = {c,d} or x = {c,d} & y = {c} by A7,ZFMISC_1:6;
  then c = a by A5,A6,ZFMISC_1:4;
  hence thesis by A2,A3,A4,A5,A7,A8,FUNCT_1:def 1;
end;

theorem Th4:
  (id X).:Y c= Y
proof
  let x be object;
  assume x in (id X).:Y;
  then ex y being object st [y,x] in id X & y in Y by RELAT_1:def 13;
  hence thesis by RELAT_1:def 10;
end;

theorem Th5:
  for S being non void Signature
  for X being non-empty ManySortedSet of the carrier of S
  for t being Term of S, X
  holds t is non pair
proof
  let S be non void Signature;
  let X be non-empty ManySortedSet of the carrier of S;
  let t be Term of S, X;
  given x,y being object such that
A1: t = [x,y];
  (ex s being SortSymbol of S, v being Element of X.s st t.{} = [v,s])
  or t.{} in [:the carrier' of S,{the carrier of S}:]
  by MSATERM:2;
  then (ex s being SortSymbol of S, v being Element of X.s st t.{} = [v,s])
  or ex a,b being object st a in the carrier' of S &
  b in {the carrier of S} & t.{} = [a,b] by ZFMISC_1:def 2;
  then {{}} <> {{}, t.{}} by ZFMISC_1:5;
  then
A2: [{}, t.{}] <> {x} by ZFMISC_1:5;
  {} in dom t by TREES_1:22;
  then [{}, t.{}] in t by FUNCT_1:def 2;
  then
A3: [{}, t.{}] = {x,y} by A1,A2,TARSKI:def 2;
  x = y by A1,Th3;
  hence thesis by A2,A3,ENUMSET1:29;
end;

registration
  let S be non void Signature;
  let X be non empty-yielding ManySortedSet of the carrier of S;
  cluster -> non pair for Element of Free(S,X);
  coherence
  proof
    let e be Element of Free(S,X);
    e is Term of S, X (\/) ((the carrier of S) --> {0}) by MSAFREE3:8;
    hence thesis by Th5;
  end;
end;

theorem Th6:
  for x,y,z being set st x in {z}* & y in {z}* & card x = card y holds x = y
proof
  let x,y,z be set such that
A1: x in {z}* and
A2: y in {z}* and
A3: card x = card y;
  reconsider x, y as FinSequence of {z} by A1,A2,FINSEQ_1:def 11;
A4: dom x = Seg len x by FINSEQ_1:def 3
    .= dom y by A3,FINSEQ_1:def 3;
  now
    let i be Nat;
    assume
A5: i in dom x;
    then
A6: x .i in rng x by FUNCT_1:def 3;
A7: y.i in rng y by A4,A5,FUNCT_1:def 3;
    thus x .i = z by A6,TARSKI:def 1
      .= y.i by A7,TARSKI:def 1;
  end;
  hence thesis by A4,FINSEQ_1:13;
end;

definition
  let S be non void Signature;
  let A be MSAlgebra over S;
  mode Subset of A is Subset of Union the Sorts of A;
  mode FinSequence of A is FinSequence of Union the Sorts of A;
end;

registration
  let S be non void Signature;
  let X be non empty-yielding ManySortedSet of S;
  cluster -> DTree-yielding for FinSequence of Free(S,X);
  coherence
  proof
    let p be FinSequence of Free(S,X);
    let x be object;
    assume x in rng p;
    hence thesis;
  end;
end;

theorem Th7:
  for S being non void Signature
  for X being non empty-yielding ManySortedSet of the carrier of S
  for t being Element of Free(S,X) holds
  (ex s being SortSymbol of S, v being set st
  t = root-tree [v,s] & v in X.s) or
  ex o being OperSymbol of S,
  p being FinSequence of Free(S,X) st
  t = [o,the carrier of S]-tree p & len p = len the_arity_of o &
  p is DTree-yielding &
  p is ArgumentSeq of Sym(o, X(\/)((the carrier of S)-->{0}))
proof
  let S be non void Signature;
  let X be non empty-yielding ManySortedSet of the carrier of S;
  let t be Element of Free(S,X);
  set V = X(\/)((the carrier of S)-->{0});
  reconsider t9 = t as Term of S,V by MSAFREE3:8;
  defpred P[set] means $1 is Element of Free(S,X) implies
  (ex s being SortSymbol of S, v being set st
  $1 = root-tree [v,s] & v in X.s) or
  ex o being OperSymbol of S,
  p being FinSequence of Free(S,X) st
  $1 = [o,the carrier of S]-tree p & len p = len the_arity_of o &
  p is DTree-yielding & p is ArgumentSeq of Sym(o,V);
A1: for s being SortSymbol of S, v being Element of V.s
  holds P[root-tree [v,s]]
  proof
    let s be SortSymbol of S;
    let v be Element of V.s;
    set t = root-tree [v,s];
    assume
A2: t is Element of Free(S,X);
    {} in dom t by TREES_1:22;
    then t.{} in rng t by FUNCT_1:3;
    then [v,s] in rng t by TREES_4:3;
    then v in X.s by A2,MSAFREE3:35;
    hence thesis;
  end;
A3: for o being OperSymbol of S, p being ArgumentSeq of Sym(o,V) st
  for t being Term of S,V st t in rng p holds P[t]
  holds P[[o,the carrier of S]-tree p]
  proof
    let o be OperSymbol of S;
    let p be ArgumentSeq of Sym(o,V) such that
    for t being Term of S,V st t in rng p holds P[t];
    set t = [o,the carrier of S]-tree p;
    assume t is Element of Free(S,X);
    then consider s being object such that
A4: s in dom the Sorts of Free(S,X) and
A5: t in (the Sorts of Free(S,X)).s by CARD_5:2;
    reconsider s as Element of S by A4;
A6: the Sorts of Free(S,X) = S-Terms(X,V) by MSAFREE3:24;
    the_sort_of(Sym(o,V)-tree p) = the_result_sort_of o by MSATERM:20;
    then s = the_result_sort_of o by A5,A6,MSAFREE3:17;
    then rng p c= Union (S-Terms(X,V)) by A5,A6,MSAFREE3:19;
    then
A7: p is FinSequence of Free(S,X) by A6,FINSEQ_1:def 4;
    len the_arity_of o = len p by MSATERM:22;
    hence thesis by A7;
  end;
  for t being Term of S,V holds P[t] from MSATERM:sch 1(A1,A3);
  then P[t9];
  hence thesis;
end;

definition
  let A be set;
  func varcl A -> set means
  :
  Def1: A c= it & (for x,y st [x,y] in it holds x c= it) &
  for B being set st A c= B & for x,y st [x,y] in B holds x c= B
  holds it c= B;
  uniqueness
  proof
    let B1, B2 be set;
    assume
A1: not thesis;
    then
A2: B1 c= B2;
    B2 c= B1 by A1;
    hence thesis by A1,A2,XBOOLE_0:def 10;
  end;
  existence
  proof
    set F = {C where C is Subset of Rank the_rank_of A:
    A c= C & for x,y st [x,y] in C holds x c= C};
    take D = meet F;
A3: A c= Rank the_rank_of A by CLASSES1:def 9;
A4: now
      let x,y;
      assume
A5:   [x,y] in Rank the_rank_of A;
A6:   {x} in {{x,y},{x}} by TARSKI:def 2;
A7:   {{x,y},{x}} c= Rank the_rank_of A by A5,ORDINAL1:def 2;
A8:   x in {x} by TARSKI:def 1;
      {x} c= Rank the_rank_of A by A6,A7,ORDINAL1:def 2;
      hence x c= Rank the_rank_of A by A8,ORDINAL1:def 2;
    end;
    Rank the_rank_of A c= Rank the_rank_of A;
    then
A9: Rank the_rank_of A in F by A3,A4;
    hereby
      let x be object;
      assume
A10:  x in A;
      now
        let C be set;
        assume C in F;
        then ex B being Subset of Rank the_rank_of A st C = B & A c= B &
        for x,y st [x,y] in B holds x c= B;
        hence x in C by A10;
      end;
      hence x in D by A9,SETFAM_1:def 1;
    end;
    hereby
      let x,y;
      assume
A11:  [x,y] in D;
      thus x c= D
      proof
        let z be object;
        assume
A12:    z in x;
        now
          let X;
          assume
A13:      X in F;
          then
A14:      [x,y] in X by A11,SETFAM_1:def 1;
ex B being Subset of Rank the_rank_of A st X = B & A c= B & for x,y st
          [x,y] in B holds x c= B by A13;
          then x c= X by A14;
          hence z in X by A12;
        end;
        hence thesis by A9,SETFAM_1:def 1;
      end;
    end;
    let B being set;
    assume that
A15: A c= B and
A16: for x,y st [x,y] in B holds x c= B;
    set C = B /\ Rank the_rank_of A;
    reconsider C as Subset of Rank the_rank_of A by XBOOLE_1:17;
A17: A c= C by A3,A15,XBOOLE_1:19;
    now
      let x,y;
      assume
A18:  [x,y] in C;
      then [x,y] in B by XBOOLE_0:def 4;
      then
A19:  x c= B by A16;
      x c= Rank the_rank_of A by A4,A18;
      hence x c= C by A19,XBOOLE_1:19;
    end;
    then C in F by A17;
    then
A20: D c= C by SETFAM_1:3;
    C c= B by XBOOLE_1:17;
    hence thesis by A20;
  end;
  projectivity;
end;

theorem Th8:
  varcl {} = {}
proof
A1: for x,y st [x,y] in {} holds x c= {};
  for B being set st {} c= B & for x,y st [x,y] in B holds x c= B holds {}
  c= B;
  hence thesis by A1,Def1;
end;

theorem Th9:
  for A,B being set st A c= B holds varcl A c= varcl B
proof
  let A, B be set such that
A1: A c= B;
  B c= varcl B by Def1;
  then
A2: A c= varcl B by A1;
  for x,y st [x,y] in varcl B holds x c= varcl B by Def1;
  hence thesis by A2,Def1;
end;

theorem Th10:
  for A being set holds
  varcl union A = union the set of all varcl a where a is Element of A
proof
  let A be set;
  set X = the set of all varcl a where a is Element of A;
A1: union A c= union X
  proof
    let x be object;
    assume x in union A;
    then consider Y such that
A2: x in Y and
A3: Y in A by TARSKI:def 4;
    reconsider Y as Element of A by A3;
A4: Y c= varcl Y by Def1;
    varcl Y in X;
    hence thesis by A2,A4,TARSKI:def 4;
  end;
  now
    let x,y be set;
    assume [x,y] in union X;
    then consider Y being set such that
A5: [x,y] in Y and
A6: Y in X by TARSKI:def 4;
    ex a being Element of A st ( Y = varcl a) by A6;
    then
A7: x c= Y by A5,Def1;
    Y c= union X by A6,ZFMISC_1:74;
    hence x c= union X by A7;
  end;
  hence varcl union A c= union X by A1,Def1;
  let x be object;
  assume x in union X;
  then consider Y being set such that
A8: x in Y and
A9: Y in X by TARSKI:def 4;
  consider a being Element of A such that
A10: Y = varcl a by A9;
  A is empty or A is not empty;
  then a in A or a is empty by SUBSET_1:def 1;
  then a c= union A by ZFMISC_1:74;
  then Y c= varcl union A by A10,Th9;
  hence thesis by A8;
end;

scheme Sch14{A() -> set, F(set) -> set, P[set]}:
  varcl union {F(z) where z is Element of A(): P[z]}
  = union {varcl F(z) where z is Element of A(): P[z]}
proof
  set Z = {F(z) where z is Element of A(): P[z]};
  set X = {varcl F(z) where z is Element of A(): P[z]};
A1: union Z c= union X
  proof
    let x be object;
    assume x in union Z;
    then consider Y such that
A2: x in Y and
A3: Y in Z by TARSKI:def 4;
A4: ex z being Element of A() st ( Y = F(z))&( P[z]) by A3;
A5: Y c= varcl Y by Def1;
    varcl Y in X by A4;
    hence thesis by A2,A5,TARSKI:def 4;
  end;
  now
    let x,y be set;
    assume [x,y] in union X;
    then consider Y being set such that
A6: [x,y] in Y and
A7: Y in X by TARSKI:def 4;
    ex z being Element of A() st ( Y = varcl F(z))&( P[z]) by A7;
    then
A8: x c= Y by A6,Def1;
    Y c= union X by A7,ZFMISC_1:74;
    hence x c= union X by A8;
  end;
  hence varcl union Z c= union X by A1,Def1;
  let x be object;
  assume x in union X;
  then consider Y being set such that
A9: x in Y and
A10: Y in X by TARSKI:def 4;
  consider z being Element of A() such that
A11: Y = varcl F(z) and
A12: P[z] by A10;
  F(z) in Z by A12;
  then Y c= varcl union Z by A11,Th9,ZFMISC_1:74;
  hence thesis by A9;
end;

theorem Th11:
  varcl (X \/ Y) = (varcl X) \/ (varcl Y)
proof
  set A = the set of all varcl a where a is Element of {X,Y};
  X \/ Y = union {X,Y} by ZFMISC_1:75;
  then
A1: varcl (X \/ Y) = union A by Th10;
  A = {varcl X, varcl Y}
  proof
    thus
    now
      let x be object;
      assume x in A;
      then consider a being Element of {X,Y} such that
A2:   x = varcl a;
      a = X or a = Y by TARSKI:def 2;
      hence x in {varcl X, varcl Y} by A2,TARSKI:def 2;
    end;
    let x be object;
    assume x in {varcl X, varcl Y};
    then x = varcl X & X in {X,Y} or x = varcl Y & Y in {X,Y} by TARSKI:def 2;
    hence thesis;
  end;
  hence thesis by A1,ZFMISC_1:75;
end;

theorem Th12:
  for A being non empty set st for a being Element of A holds varcl a = a
  holds varcl meet A = meet A
proof
  let B be non empty set;
  set A = meet B;
  assume
A1: for a being Element of B holds varcl a = a;
  now
    thus A c= A;
    let x,y;
    assume
A2: [x,y] in A;
    now
      let Y;
      assume
A3:   Y in B;
      then
A4:   [x,y] in Y by A2,SETFAM_1:def 1;
      Y = varcl Y by A1,A3;
      hence x c= Y by A4,Def1;
    end;
    hence x c= A by SETFAM_1:5;
  end;
  hence varcl A c= A by Def1;
  thus thesis by Def1;
end;

theorem Th13:
  varcl ((varcl X) /\ (varcl Y)) = (varcl X) /\ (varcl Y)
proof
  set A = (varcl X) /\ (varcl Y);
  now
    thus A c= A;
    let x,y;
    assume
A1: [x,y] in A;
    then
A2: [x,y] in varcl X by XBOOLE_0:def 4;
A3: [x,y] in varcl Y by A1,XBOOLE_0:def 4;
A4: x c= varcl X by A2,Def1;
    x c= varcl Y by A3,Def1;
    hence x c= A by A4,XBOOLE_1:19;
  end;
  hence varcl ((varcl X) /\ (varcl Y)) c= (varcl X) /\ (varcl Y) by Def1;
  thus thesis by Def1;
end;

registration
  let A be empty set;
  cluster varcl A -> empty;
  coherence by Th8;
end;

deffunc F(set,set) =
{[varcl A, j] where A is Subset of $2, j is Element of NAT: A is finite};

definition
  func Vars -> set means
  :
  Def2: ex V being ManySortedSet of NAT st it = Union V &
  V.0 = the set of all [{}, i] where i is Element of NAT &
  for n being Nat holds V.(n+1) =
  {[varcl A, j] where A is Subset of V.n, j is Element of NAT: A is finite};
  existence
  proof consider f being Function such that
A1: dom f = NAT and
A2: f.0 = the set of all [{}, i] where i is Element of NAT and
A3: for n being Nat holds f.(n+1) = F(n,f.n) from NAT_1:sch 11;
    reconsider f as ManySortedSet of NAT by A1,PARTFUN1:def 2,RELAT_1:def 18;
    take Union f, V = f;
    thus Union f = Union V;
    thus V.0 = the set of all [{}, i] where i is Element of NAT by A2;
    let n be Nat;
    thus thesis by A3;
  end;
  uniqueness
  proof
    let A1, A2 be set;
    given V1 being ManySortedSet of NAT such that
A4: A1 = Union V1 and
A5: V1.0 = the set of all [{}, i] where i is Element of NAT and
A6: for n being Nat holds V1.(n+1) = F(n,V1.n);
    given V2 being ManySortedSet of NAT such that
A7: A2 = Union V2 and
A8: V2.0 = the set of all [{}, i] where i is Element of NAT and
A9: for n being Nat holds V2.(n+1) = F(n,V2.n);
A10: dom V1 = NAT by PARTFUN1:def 2;
A11: dom V2 = NAT by PARTFUN1:def 2;
    V1 = V2 from NAT_1:sch 15(A10,A5,A6,A11,A8,A9);
    hence thesis by A4,A7;
  end;
end;

theorem Th14:
  for V being ManySortedSet of NAT st
  V.0 = the set of all [{}, i] where i is Element of NAT &
  for n being Nat holds
  V.(n+1) = {[varcl A, j] where A is Subset of V.n, j is Element of NAT:
  A is finite}
  for i,j being Element of NAT st i <= j holds V.i c= V.j
proof
  let V be ManySortedSet of NAT such that
A1: V.0 = the set of all [{}, i] where i is Element of NAT and
A2: for n being Nat holds
  V.(n+1) = {[varcl A, j] where A is Subset of V.n, j is Element of NAT:
  A is finite};
  defpred Q[Nat] means V.0 c= V.$1;
A3: now
    let j;
    assume Q[j];
A4: V.(j+1) = {[varcl A, k] where A is Subset of V.j, k is Element of NAT:
    A is finite} by A2;
    thus Q[j+1]
    proof
      let x be object;
      assume x in V.0;
      then
A5:   ex i being Element of NAT st x = [{}, i] by A1;
      {} c= V.j;
      hence thesis by A4,A5,Th8;
    end;
  end;
  defpred P[Nat] means for i st i <= $1 holds V.i c= V.$1;
A6: P[ 0 ] by NAT_1:3;
A7: now
    let j be Nat;
    assume
A8: P[j];
A9: V.j c= V.(j+1) proof per cases by NAT_1:6;
      suppose j = 0;
        hence thesis by A3;
      end;
      suppose ex k being Nat st j = k+1;
        then consider k being Nat such that
A10:    j = k+1;
        reconsider k as Element of NAT by ORDINAL1:def 12;
A11:    V.j = {[varcl A, n] where A is Subset of V.k, n is Element of NAT:
        A is finite} by A2,A10;
        A12:    V
.(j+1) = {[varcl A, n] where A is Subset of V.j,n is Element of NAT:
        A is finite} by A2;
A13:    V.k c= V.j by A8,A10,NAT_1:11;
        let x be object;
        assume x in V.j;
        then consider A being Subset of V.k, n being Element of NAT such that
A14:    x = [varcl A, n] and
A15:    A is finite by A11;
        A c= V.j by A13;
        hence thesis by A12,A14,A15;
      end;
    end;
    thus P[j+1]
    proof
      let i;
      assume i <= j+1;
      then i = j+1 or V.i c= V.j by A8,NAT_1:8;
      hence thesis by A9;
    end;
  end;
  for j being Nat holds P[j] from NAT_1:sch 2(A6,A7);
  hence thesis;
end;

theorem Th15:
  for V being ManySortedSet of NAT st
  V.0 = the set of all [{}, i] where i is Element of NAT &
  for n being Nat holds
  V.(n+1) = {[varcl A, j] where A is Subset of V.n, j is Element of NAT:
  A is finite}
  for A being finite Subset of Vars
  ex i being Element of NAT st A c= V.i
proof
  let V be ManySortedSet of NAT such that
A1: V.0 = the set of all [{}, i] where i is Element of NAT and
A2: for n being Nat holds
  V.(n+1) = {[varcl A, j] where A is Subset of V.n, j is Element of NAT:
  A is finite};
  let A be finite Subset of Vars;
A3: Vars = Union V by A1,A2,Def2;
  defpred P[object,object] means $1 in V.$2;
A4: now
    let x be object;
    assume x in A;
    then consider Y such that
A5: x in Y and
A6: Y in rng V by A3,TARSKI:def 4;
    consider i being object such that
A7: i in dom V and
A8: Y = V.i by A6,FUNCT_1:def 3;
     reconsider i as object;
    take i;
    thus i in NAT & P[x,i] by A5,A7,A8;
  end;
  consider f being Function such that
A9: dom f = A & rng f c= NAT and
A10: for x being object st x in A holds P[x,f.x] from FUNCT_1:sch 6(A4);
  per cases;
  suppose A = {};
    then A c= V.0;
    hence thesis;
  end;
  suppose A <> {};
    then reconsider B = rng f as finite non empty Subset of NAT
    by A9,FINSET_1:8,RELAT_1:42;
    reconsider i = max B as Element of NAT by ORDINAL1:def 12;
    take i;
    let x be object;
    assume
A11: x in A;
    then
A12: f.x in B by A9,FUNCT_1:def 3;
    then reconsider j = f.x as Element of NAT;
    j <= i by A12,XXREAL_2:def 8;
    then
A13: V.j c= V.i by A1,A2,Th14;
    x in V.j by A10,A11;
    hence thesis by A13;
  end;
end;

theorem Th16:
  the set of all [{}, i] where i is Element of NAT c= Vars
proof consider V being ManySortedSet of NAT such that
A1: Vars = Union V and
A2: V.0 = the set of all [{}, i] where i is Element of NAT and
  for n being Nat holds
  V.(n+1) = {[varcl A, j] where A is Subset of V.n, j is Element of NAT:
  A is finite} by Def2;
  dom V = NAT by PARTFUN1:def 2;
  then V.0 in rng V by FUNCT_1:def 3;
  hence thesis by A1,A2,ZFMISC_1:74;
end;

theorem Th17:
  for A being finite Subset of Vars, i being Nat holds [varcl A, i] in Vars
proof
  let A be finite Subset of Vars, i be Nat;
  consider V being ManySortedSet of NAT such that
A1: Vars = Union V and
A2: V.0 = the set of all [{}, k] where k is Element of NAT and
A3: for n being Nat holds
  V.(n+1) = {[varcl b, j] where b is Subset of V.n, j is Element of NAT:
  b is finite} by Def2;
  consider j being Element of NAT such that
A4: A c= V.j by A2,A3,Th15;
A5: V.(j+1) = {[varcl B, k] where B is Subset of V.j, k is Element of NAT: B
  is finite} by A3;
  i in NAT by ORDINAL1:def 12;
  then
A6: [varcl A, i] in V.(j+1) by A4,A5;
  dom V = NAT by PARTFUN1:def 2;
  hence thesis by A1,A6,CARD_5:2;
end;

theorem Th18:
  Vars = {[varcl A, j] where A is Subset of Vars, j is Element of NAT:
  A is finite}
proof consider V being ManySortedSet of NAT such that
A1: Vars = Union V and
A2: V.0 = the set of all [{}, i] where i is Element of NAT and
A3: for n being Nat holds V.(n+1) =
  {[varcl A, j] where A is Subset of V.n, j is Element of NAT: A is finite}
  by Def2;
  set X = {[varcl A, j] where A is Subset of Vars, j is Element of NAT:
  A is finite};
A4: dom V = NAT by PARTFUN1:def 2;
  defpred P[Nat] means V.$1 c= X;
A5: P[ 0]
  proof
    let x be object;
    assume
A6: x in V.0;
A7: {} c= Vars;
    ex i being Element of NAT st x = [{}, i] by A2,A6;
    hence thesis by A7,Th8;
  end;
A8: now
    let i be Nat;
    assume P[i];
A9: V.(i+1) = {[varcl A, j] where A is Subset of V.i, j is Element of NAT:
    A is finite} by A3;
    thus P[i+1]
    proof
      let x be object;
      assume x in V.(i+1);
      then consider A being Subset of V.i, j being Element of NAT such that
A10:  x = [varcl A, j] and
A11:  A is finite by A9;
      reconsider ii=i as Element of NAT by ORDINAL1:def 12;
      V.ii in rng V by A4,FUNCT_1:def 3;
      then V.i c= Vars by A1,ZFMISC_1:74;
      then A c= Vars;
      hence thesis by A10,A11;
    end;
  end;
A12: for i being Nat holds P[i] from NAT_1:sch 2(A5,A8);
  now
    let x;
    assume x in rng V;
    then ex y being object st y in NAT & x = V.y by A4,FUNCT_1:def 3;
    hence x c= X by A12;
  end;
  hence Vars c= X by A1,ZFMISC_1:76;
  let x be object;
  assume x in X;
  then ex A being Subset of Vars, j being Element of NAT st
  x = [varcl A, j] & A is finite;
  hence thesis by Th17;
end;

theorem Th19:
  varcl Vars = Vars proof consider V being ManySortedSet of NAT such that
A1: Vars = Union V and
A2: V.0 = the set of all [{}, i] where i is Element of NAT and
A3: for n being Nat holds V.(n+1) =
  {[varcl A, j] where A is Subset of V.n, j is Element of NAT: A is finite}
  by Def2;
  defpred P[Nat] means varcl(V.$1) = V.$1;
  now
    let x,y;
    assume [x,y] in V.0;
    then ex i being Element of NAT st [x,y] = [{}, i] by A2;
    then x = {} by XTUPLE_0:1;
    hence x c= V.0;
  end;
  then
A4: varcl (V.0) c= V.0 by Def1;
  V.0 c= varcl (V.0) by Def1;
  then
A5: P[ 0] by A4,XBOOLE_0:def 10;
A6: now
    let i;
    assume
A7: P[i];
    reconsider i9 = i as Element of NAT by ORDINAL1:def 12;
A8: V.(i+1) = {[varcl A, j] where A is Subset of V.i, j is Element of NAT:
    A is finite} by A3;
    now
      let x,y;
      assume [x,y] in V.(i+1);
      then consider A being Subset of V.i, j being Element of NAT such that
A9:   [x,y] = [varcl A, j] and A is finite by A8;
      x = varcl A by A9,XTUPLE_0:1;
      then
A10:  x c= V.i by A7,Th9;
      V.i9 c= V.(i9+1) by A2,A3,Th14,NAT_1:11;
      hence x c= V.(i+1) by A10;
    end;
    then
A11: varcl (V.(i+1)) c= V.(i+1) by Def1;
    V.(i+1) c= varcl (V.(i+1)) by Def1;
    hence P[i+1] by A11,XBOOLE_0:def 10;
  end;
A12: P[i] from NAT_1:sch 2(A5,A6);
  A13: varcl
 Vars = union the set of all varcl a where a is Element of rng V
  by A1,Th10;
  thus
  now
    let x be object;
    assume x in varcl Vars;
    then consider Y such that
A14: x in Y and
A15: Y in the set of all varcl a where a is Element of rng V
    by A13,TARSKI:def 4;
    consider a being Element of rng V such that
A16: Y = varcl a by A15;
    consider i being object such that
A17: i in dom V and
A18: a = V.i by FUNCT_1:def 3;
    reconsider i as Element of NAT by A17;
    varcl (V.i) = a by A12,A18;
    hence x in Vars by A1,A14,A16,A17,A18,CARD_5:2;
  end;
  thus thesis by Def1;
end;

theorem Th20:
  for X st the_rank_of X is finite holds X is finite
proof
  let X;
  assume the_rank_of X is finite;
  then the_rank_of X in NAT by CARD_1:61;
  then
A1: Rank the_rank_of X is finite by CARD_2:67;
  X c= Rank the_rank_of X by CLASSES1:def 9;
  hence thesis by A1;
end;

theorem Th21:
  the_rank_of varcl X = the_rank_of X
proof
A1: X c= Rank the_rank_of X by CLASSES1:def 9;
  set a = the_rank_of X;
A2: a c= succ a by ORDINAL3:1;
  succ a c= succ succ a by ORDINAL3:1;
  then a c= succ succ a by A2;
  then
A3: Rank a c= Rank succ succ a by CLASSES1:37;
  now
    let x,y;
    assume [x,y] in Rank the_rank_of X;
    then x in Rank a by A3,CLASSES1:45;
    hence x c= Rank the_rank_of X by ORDINAL1:def 2;
  end;
  then varcl X c= Rank a by A1,Def1;
  hence the_rank_of varcl X c= a by CLASSES1:65;
  X c= varcl X by Def1;
  hence thesis by CLASSES1:67;
end;

theorem Th22:
  for X being finite Subset of Rank omega holds X in Rank omega
proof
  let X be finite Subset of Rank omega;
  deffunc F(object) = the_rank_of $1;
  consider f being Function such that
A1: dom f = X and
A2: for x being object st x in X holds f.x = F(x) from FUNCT_1:sch 3;
A3: rng f c= NAT
  proof
    let y be object;
    assume y in rng f;
    then consider x being object such that
A4: x in X and
A5: y = f.x by A1,FUNCT_1:def 3;
    the_rank_of x in omega by A4,CLASSES1:66;
    hence thesis by A2,A4,A5;
  end;
  per cases;
  suppose X = {};
    then the_rank_of X = 0 by CLASSES1:71;
    hence thesis by CLASSES1:66;
  end;
  suppose X <> {};
    then reconsider Y = rng f as finite non empty Subset of NAT
    by A1,A3,FINSET_1:8,RELAT_1:42;
    reconsider mY = max Y as Element of NAT by ORDINAL1:def 12;
    set i = 1+mY;
    X c= Rank i
    proof
      let x be object;
      reconsider xx=x as set by TARSKI:1;
      assume
A6:   x in X;
      then
A7:   f.x in Y by A1,FUNCT_1:def 3;
A8:   f.x = the_rank_of xx by A2,A6;
      reconsider j = f.x as Element of NAT by A7;
      j <= mY by A7,XXREAL_2:def 8;
      then Segm j c= Segm mY by NAT_1:39;
      then
A9:   j in succ mY by ORDINAL1:22;
      succ Segm mY = Segm i by NAT_1:38;
      hence thesis by A8,A9,CLASSES1:66;
    end;
    then the_rank_of X c= i by CLASSES1:65;
    then
A10: the_rank_of X in succ i by ORDINAL1:22;
    Segm(i+1) = succ Segm i by NAT_1:38;
    hence thesis by A10,CLASSES1:66;
  end;
end;

theorem Th23:
  Vars c= Rank omega proof consider V being ManySortedSet of NAT such that
A1: Vars = Union V and
A2: V.0 = the set of all [{}, i] where i is Element of NAT and
A3: for n being Nat holds V.(n+1) =
  {[varcl a, j] where a is Subset of V.n, j is Element of NAT: a is finite}
  by Def2;
  let x be object;
  assume x in Vars;
  then consider i being object such that
A4: i in dom V and
A5: x in V.i by A1,CARD_5:2;
  reconsider i as Element of NAT by A4;
  defpred P[Nat] means V.$1 c= Rank omega;
A6: P[ 0]
  proof
    let x be object;
    assume x in V.0;
    then consider i being Element of NAT such that
A7: x = [{}, i] by A2;
A8: Segm(i+1) = succ Segm i by NAT_1:38;
A9: {} c= i;
A10: i in i+1 by A8,ORDINAL1:6;
A11: {} in i+1 by A8,A9,ORDINAL1:6,12;
A12: the_rank_of {} = {} by CLASSES1:73;
A13: the_rank_of i = i by CLASSES1:73;
A14: {} in Rank (i+1) by A11,A12,CLASSES1:66;
    i in Rank (i+1) by A10,A13,CLASSES1:66;
    then
A15: x in Rank succ succ (i+1) by A7,A14,CLASSES1:45;
    succ succ (i+1) c= omega;
    then Rank succ succ (i+1) c= Rank omega by CLASSES1:37;
    hence thesis by A15;
  end;
A16: now
    let n be Nat such that
A17: P[n];
A18: V.(n+1) = {[varcl a, j] where a is Subset of V.n, j is Element of NAT:
    a is finite} by A3;
    thus P[n+1]
    proof
      let x be object;
      assume x in V.(n+1);
      then consider a being Subset of V.n, j being Element of NAT such that
A19:  x = [varcl a, j] and
A20:  a is finite by A18;
      a c= Rank omega by A17,XBOOLE_1:1;
      then a in Rank omega by A20,Th22;
      then reconsider i = the_rank_of a as Element of NAT by CLASSES1:66;
      reconsider k = j \/ i as Element of NAT by ORDINAL3:12;
A21:  the_rank_of varcl a = i by Th21;
A22:  the_rank_of j = j by CLASSES1:73;
A23:  k in succ k by ORDINAL1:6;
      then
A24:  i in succ k by ORDINAL1:12,XBOOLE_1:7;
A25:  j in succ k by A23,ORDINAL1:12,XBOOLE_1:7;
A26:  succ Segm k = Segm(k+1) by NAT_1:38;
      then
A27:  varcl a in Rank (k+1) by A21,A24,CLASSES1:66;
      j in Rank (k+1) by A22,A25,A26,CLASSES1:66;
      then
A28:  x in Rank succ succ (k+1) by A19,A27,CLASSES1:45;
      succ succ (k+1) c= omega;
      then Rank succ succ (k+1) c= Rank omega by CLASSES1:37;
      hence thesis by A28;
    end;
  end;
  for n being Nat holds P[n] from NAT_1:sch 2(A6,A16);
  then V.i c= Rank omega;
  hence thesis by A5;
end;

theorem Th24:
  for A being finite Subset of Vars holds varcl A is finite Subset of Vars
proof
  let A be finite Subset of Vars;
  A c= Rank omega by Th23;
  then A in Rank omega by Th22;
  then the_rank_of A in omega by CLASSES1:66;
  then the_rank_of varcl A is finite by Th21;
  hence thesis by Th9,Th19,Th20;
end;

registration
  cluster Vars -> non empty;
  correctness
  proof
    [{},0] in the set of all [{}, i] where i is Element of NAT;
    hence thesis by Th16;
  end;
end;

definition
  mode variable is Element of Vars;
end;

registration
  let x be variable;
  cluster x`1 -> finite for set;
  coherence
  proof x in Vars;
    then consider A being Subset of Vars, j being Element of NAT such that
A1: x = [varcl A,j] and
A2: A is finite by Th18;
    x`1 = varcl A by A1;
    hence thesis by A2,Th24;
  end;
end;

notation
  let x be variable;
  synonym vars x for x`1;
end;

definition
  let x be variable;
  redefine func vars x -> Subset of Vars;
  coherence
  proof x in Vars;
    then consider A being Subset of Vars, j being Element of NAT such that
A1: x = [varcl A,j] and
A2: A is finite by Th18;
    x`1 = varcl A by A1;
    hence thesis by A2,Th24;
  end;
end;

theorem
  [{}, i] in Vars proof i in NAT by ORDINAL1:def 12;
  then [{}, i] in the set of all [{}, j];
  hence thesis by Th16;
end;

theorem Th26:
  for A being Subset of Vars holds
  varcl {[varcl A, j]} = (varcl A) \/ {[varcl A, j]}
proof
  let A be Subset of Vars;
A1: {[varcl A, j]} c= (varcl A) \/ {[varcl A, j]} by XBOOLE_1:7;
A2: varcl A c= (varcl A) \/ {[varcl A, j]} by XBOOLE_1:7;
  now
    let x,y;
    assume [x,y] in (varcl A) \/ {[varcl A, j]};
    then [x,y] in varcl A or [x,y] in {[varcl A, j]} by XBOOLE_0:def 3;
    then [x,y] in varcl A or [x,y] = [varcl A, j] by TARSKI:def 1;
    then x c= varcl A or x = varcl A by Def1,XTUPLE_0:1;
    hence x c= (varcl A) \/ {[varcl A, j]} by A2;
  end;
  hence varcl {[varcl A, j]} c= (varcl A) \/ {[varcl A, j]} by A1,Def1;
A3: {[varcl A, j]} c= varcl {[varcl A, j]} by Def1;
  [varcl A, j] in {[varcl A, j]} by TARSKI:def 1;
  then varcl A c= varcl {[varcl A, j]} by A3,Def1;
  hence thesis by A3,XBOOLE_1:8;
end;

theorem Th27:
  for x being variable holds varcl {x} = (vars x) \/ {x}
proof
  let x be variable;
  x in Vars;
  then consider A being Subset of Vars, j such that
A1: x = [varcl A, j] and A is finite by Th18;
  varcl {x} = (varcl A) \/ {x} by A1,Th26;
  hence thesis by A1;
end;

theorem
  for x being variable holds [(vars x) \/ {x}, i] in Vars
proof
  let x be variable;
  x in Vars;
  then consider A being Subset of Vars, j such that
A1: x = [varcl A, j] and A is finite by Th18;
A2: varcl {x} = (varcl A) \/ {x} by A1,Th26;
A3: vars x = varcl A by A1;
  i in NAT by ORDINAL1:def 12;
  hence thesis by A2,A3,Th18;
end;

begin :: Quasi loci

notation
  let R be Relation, A be set;
  synonym R dom A for R|A;
end;

definition
  func QuasiLoci -> FinSequenceSet of Vars means
:Def3: for p being FinSequence of Vars holds p in it iff p is one-to-one &
  for i st i in dom p holds (p.i)`1 c= rng (p dom i);
  existence
  proof
    defpred P[object] means
ex p being Function st p = $1 & p is one-to-one &
    for i st i in dom p holds (p.i)`1 c= rng (p|i);
    consider L being set such that
A1: for x being object holds x in L iff x in Vars* & P[ x ]
from XBOOLE_0:sch 1;
    L is FinSequenceSet of Vars
    proof
      let x be object;
      assume x in L;
      then x in Vars* by A1;
      hence thesis by FINSEQ_1:def 11;
    end;
    then reconsider L as FinSequenceSet of Vars;
    take L;
    let p be FinSequence of Vars;
    p in L iff p in Vars* & ex q being Function st q = p & q is one-to-one &
    for i st i in dom q holds (q.i)`1 c= rng (q|i) by A1;
    hence thesis by FINSEQ_1:def 11;
  end;
  correctness
  proof
    let L1, L2 be FinSequenceSet of Vars such that
A2: for p being FinSequence of Vars holds p in L1 iff p is one-to-one &
    for i st i in dom p holds (p.i)`1 c= rng (p|(i qua set)) and
A3: for p being FinSequence of Vars holds p in L2 iff p is one-to-one &
    for i st i in dom p holds (p.i)`1 c= rng (p|(i qua set));
    thus
    now
      let x be object;
      assume
A4:   x in L1;
      then reconsider p = x as FinSequence of Vars by FINSEQ_2:def 3;
A5:   p is one-to-one by A2,A4;
      for i st i in dom p holds (p.i)`1 c= rng (p|(i qua set)) by A2,A4;
      hence x in L2 by A3,A5;
    end;
    let x be object;
    assume
A6: x in L2;
    then reconsider p = x as FinSequence of Vars by FINSEQ_2:def 3;
A7: p is one-to-one by A3,A6;
    for i st i in dom p holds (p.i)`1 c= rng (p|(i qua set)) by A3,A6;
    hence thesis by A2,A7;
  end;
end;

theorem Th29:
  <*>Vars in QuasiLoci
proof
 reconsider p = <*>Vars as FinSequence of Vars;
   p is one-to-one &
   for i st i in dom p holds (p.i)`1 c= rng (p dom i);
  hence thesis by Def3;
end;

registration
  cluster QuasiLoci -> non empty;
  correctness by Th29;
end;

definition
  mode quasi-loci is Element of QuasiLoci;
end;

registration
  cluster -> one-to-one for quasi-loci;
  coherence by Def3;
end;

theorem Th30:
  for l being one-to-one FinSequence of Vars holds l is quasi-loci iff
  for i being Nat, x being variable st i in dom l & x = l.i
  for y being variable st y in vars x
  ex j being Nat st j in dom l & j < i & y = l.j
proof
  let l be one-to-one FinSequence of Vars;
  thus
  now
    assume
A1: l is quasi-loci;
    let i be Nat, x be variable such that
A2: i in dom l and
A3: x = l.i;
    let y be variable such that
A4: y in vars x;
    vars x c= rng (l|(i qua set)) by A1,A2,A3,Def3;
    then consider z being object such that
A5: z in dom (l dom i) and
A6: y = (l dom i).z by A4,FUNCT_1:def 3;
A7: dom (l dom i) = dom l /\ i by RELAT_1:61;
    reconsider z as Element of NAT by A5,A7;
    reconsider j = z as Nat;
    take j;
A8: card Segm z = z;
    card Segm i = i;
    hence j in dom l & j < i & y = l.j by A5,A6,A7,A8,FUNCT_1:47,NAT_1:41
,XBOOLE_0:def 4;
  end;
  assume
A9: for i being Nat, x being variable st i in dom l & x = l.i
  for y being variable st y in vars x
  ex j being Nat st j in dom l & j < i & y = l.j;
  now
    let i;
    assume
A10: i in dom l;
    then l.i in rng l by FUNCT_1:def 3;
    then reconsider x = l.i as variable;
    thus (l.i)`1 c= rng (l dom i)
    proof
      let y be object;
      assume y in (l.i)`1;
      then
A11:  y in vars x;
      then reconsider y as variable;
      consider j being Nat such that
A12:  j in dom l and
A13:  j < i and
A14:  y = l.j by A9,A10,A11;
A15:  card Segm i = i;
      card Segm j = j;
      then j in i by A13,A15,NAT_1:41;
      hence thesis by A12,A14,FUNCT_1:50;
    end;
  end;
  hence thesis by Def3;
end;

theorem Th31:
  for l being quasi-loci, x being variable holds
  l^<*x*> is quasi-loci iff not x in rng l & vars x c= rng l
proof
  let l be quasi-loci, x be variable;
A1: (l^<*x*>).(1+len l) = x by FINSEQ_1:42;
A2: dom (l^<*x*>) = Seg (len l + len <*x*>) by FINSEQ_1:def 7
    .= Seg (len l + 1) by FINSEQ_1:39;
  1 <= 1+len l by NAT_1:11;
  then
A3: 1+len l in dom (l^<*x*>) by A2;
A4: dom l = Seg len l by FINSEQ_1:def 3;
  thus
  now
    assume
A5: l^<*x*> is quasi-loci;
    thus not x in rng l
    proof
      assume x in rng l;
      then consider a being object such that
A6:   a in dom l and
A7:   x = l.a by FUNCT_1:def 3;
      reconsider a as Element of NAT by A6;
A8:   (l^<*x*>).a = x by A6,A7,FINSEQ_1:def 7;
A9:   a <= len l by A4,A6,FINSEQ_1:1;
A10:  len l < 1+len l by NAT_1:13;
      dom l c= dom (l^<*x*>) by FINSEQ_1:26;
      hence thesis by A1,A3,A5,A6,A8,A9,A10,FUNCT_1:def 4;
    end;
    thus vars x c= rng l
    proof
      let a be object;
      assume
A11:  a in vars x;
      then reconsider a as variable;
      consider j being Nat such that
A12:  j in dom (l^<*x*>) and
A13:  j < 1+len l and
A14:  a = (l^<*x*>).j by A1,A3,A5,A11,Th30;
      reconsider j as Element of NAT by ORDINAL1:def 12;
A15:  j <= len l by A13,NAT_1:13;
      j >= 1 by A2,A12,FINSEQ_1:1;
      then
A16:  j in dom l by A4,A15;
      then a = l.j by A14,FINSEQ_1:def 7;
      hence thesis by A16,FUNCT_1:def 3;
    end;
  end;
  assume that
A17: not x in rng l and
A18: vars x c= rng l;
A19: (l^<*x*>) is one-to-one
  proof
    let a,b be object;
    assume that
A20: a in dom (l^<*x*>) and
A21: b in dom (l^<*x*>) and
A22: (l^<*x*>).a = (l^<*x*>).b;
    reconsider a,b as Element of NAT by A20,A21;
A23: a >= 1 by A2,A20,FINSEQ_1:1;
A24: b >= 1 by A2,A21,FINSEQ_1:1;
A25: a <= 1+len l by A2,A20,FINSEQ_1:1;
A26: b <= 1+len l by A2,A21,FINSEQ_1:1;
A27: a <= len l or a = 1+len l by A25,NAT_1:8;
A28: b <= len l or b = 1+len l by A26,NAT_1:8;
A29: a in dom l or a = 1+len l by A4,A23,A27;
A30: b in dom l or b = 1+len l by A4,A24,A28;
A31: a in dom l & l.a = (l^<*x*>).a & l.a in rng l or a = 1+len l by A29,
FINSEQ_1:def 7,FUNCT_1:def 3;
    b in dom l & l.b = (l^<*x*>).b & l.b in rng l or b = 1+len l by A30,
FINSEQ_1:def 7,FUNCT_1:def 3;
    hence thesis by A17,A22,A31,FINSEQ_1:42,FUNCT_1:def 4;
  end;
  now
    let i be Nat, z be variable;
    assume that
A32: i in dom (l^<*x*>) and
A33: z = (l^<*x*>).i;
A34: i >= 1 by A2,A32,FINSEQ_1:1;
    i <= 1+len l by A2,A32,FINSEQ_1:1;
    then i <= len l or i = 1+len l by NAT_1:8;
    then
A35: i in dom l or i = 1+len l & z = x by A4,A33,A34,FINSEQ_1:42;
    let y be variable;
    assume
A36: y in vars z;
    thus ex j being Nat st j in dom (l^<*x*>) & j < i & y = (l^<*x*>).j
    proof per cases by A33,A35,FINSEQ_1:def 7;
      suppose
A37:    i = 1+len l & z = x;
        then consider k being object such that
A38:    k in dom l and
A39:    y = l.k by A18,A36,FUNCT_1:def 3;
        reconsider k as Element of NAT by A38;
        take k;
A40:    dom l c= dom (l^<*x*>) by FINSEQ_1:26;
        k <= len l by A4,A38,FINSEQ_1:1;
        hence thesis by A37,A38,A39,A40,FINSEQ_1:def 7,NAT_1:13;
      end;
      suppose i in dom l & z = l.i;
        then consider j being Nat such that
A41:    j in dom l and
A42:    j < i and
A43:    y = l.j by A36,Th30;
        take j;
        dom l c= dom (l^<*x*>) by FINSEQ_1:26;
        hence thesis by A41,A42,A43,FINSEQ_1:def 7;
      end;
    end;
  end;
  hence thesis by A19,Th30;
end;

theorem Th32:
  for p,q being FinSequence st p^q is quasi-loci
  holds p is quasi-loci & q is FinSequence of Vars
proof
  let p,q be FinSequence;
  assume
A1: p^q is quasi-loci;
  then
A2: p is one-to-one FinSequence of Vars by FINSEQ_1:36,FINSEQ_3:91;
  now
    let i be Nat, x be variable such that
A3: i in dom p and
A4: x = p.i;
    let y be variable such that
A5: y in vars x;
A6: dom p c= dom (p^q) by FINSEQ_1:26;
    x = (p^q).i by A3,A4,FINSEQ_1:def 7;
    then consider j being Nat such that
A7: j in dom (p^q) and
A8: j < i and
A9: y = (p^q).j by A1,A3,A5,A6,Th30;
    take j;
A10: dom p = Seg len p by FINSEQ_1:def 3;
    dom (p^q) = Seg len (p^q) by FINSEQ_1:def 3;
    then
A11: j >= 1 by A7,FINSEQ_1:1;
    i <= len p by A3,A10,FINSEQ_1:1;
    then j < len p by A8,XXREAL_0:2;
    hence j in dom p & j < i by A8,A10,A11;
    hence y = p.j by A9,FINSEQ_1:def 7;
  end;
  hence thesis by A1,A2,Th30,FINSEQ_1:36;
end;

theorem
  for l being quasi-loci holds varcl rng l = rng l
proof
  let l be quasi-loci;
  now
    let x,y;
    assume
A1: [x,y] in rng l;
    then reconsider xy = [x,y] as variable;
    consider i being object such that
A2: i in dom l and
A3: xy = l.i by A1,FUNCT_1:def 3;
    reconsider i as Nat by A2;
A4: vars xy = x;
    thus x c= rng l
    proof
      let a be object;
      assume
A5:   a in x;
      then reconsider a as variable by A4;
      ex j being Nat st j in dom l & j < i & a = l.j by A2,A3,A4,A5,Th30;
      hence thesis by FUNCT_1:def 3;
    end;
  end;
  hence varcl rng l c= rng l by Def1;
  thus thesis by Def1;
end;

theorem Th34:
  for x being variable holds <*x*> is quasi-loci iff vars x = {}
proof
  let x be variable;
A1: <*x*> = (<*>Vars)^<*x*> by FINSEQ_1:34;
A2: rng {} = {};
  vars x c= {} implies vars x = {};
  hence thesis by A1,A2,Th29,Th31;
end;

theorem Th35:
  for x,y being variable holds
  <*x,y*> is quasi-loci iff vars x = {} & x <> y & vars y c= {x}
proof
  let x,y be variable;
A1: rng <*x*> = {x} by FINSEQ_1:38;
A2: <*x*> is quasi-loci iff vars x = {} by Th34;
  y in {x} iff y = x by TARSKI:def 1;
  hence thesis by A1,A2,Th31,Th32;
end;

theorem
  for x,y,z being variable holds
  <*x,y,z*> is quasi-loci iff vars x = {} & x <> y & vars y c= {x} &
  x <> z & y <> z & vars z c= {x,y}
proof
  let x,y,z be variable;
A1: rng <*x,y*> = {x,y} by FINSEQ_2:127;
A2: <*x,y*> is quasi-loci iff vars x = {} & x <> y & vars y c= {x} by Th35;
  z in {x,y} iff z = x or z = y by TARSKI:def 2;
  hence thesis by A1,A2,Th31,Th32;
end;

definition
  let l be quasi-loci;
  redefine func l" -> PartFunc of Vars, NAT;
  coherence
  proof
A1: dom (l") = rng l by FUNCT_1:33;
    rng (l") = dom l by FUNCT_1:33;
    hence thesis by A1,RELSET_1:4;
  end;
end;

begin :: Mizar Constructor Signature

definition
  func a_Type -> set equals
  0;
  coherence;
  func an_Adj -> set equals
  1;
  coherence;
  func a_Term -> set equals
  2;
  coherence;
  func * -> set equals
  0;
  coherence;
  func non_op -> set equals
  1;
  coherence;

:: func an_ExReg  equals 3; coherence;
:: func a_CondReg equals 4; coherence;
:: func a_FuncReg equals 5; coherence;
end;

definition
  let C be Signature;
  attr C is constructor means
  :
  Def9: the carrier of C = {a_Type, an_Adj, a_Term} &
  {*, non_op} c= the carrier' of C &
  (the Arity of C).* = <*an_Adj, a_Type*> &
  (the Arity of C).non_op = <*an_Adj*> &
  (the ResultSort of C).* = a_Type &
  (the ResultSort of C).non_op = an_Adj &
  for o being Element of the carrier' of C st o <> * & o <> non_op
  holds (the Arity of C).o in {a_Term}*;
end;

registration
  cluster constructor -> non empty non void for Signature;
  coherence;
end;

definition
  func MinConstrSign -> strict Signature means
  :
  Def10: it is constructor & the carrier' of it = {*, non_op};
  existence
  proof
    set A = {a_Type, an_Adj, a_Term};
    reconsider t = a_Type, a = an_Adj as Element of A by ENUMSET1:def 1;
    reconsider aa = <*a*> as Element of A*;
    set C = ManySortedSign(# A, {*, non_op},
      (*, non_op) --> (<*a,t*>, aa),
      (*, non_op) --> (t, a) #);
    reconsider C as non void non empty strict ManySortedSign;
    take C;
    thus the carrier of C = {a_Type, an_Adj, a_Term} &
    {*, non_op} c= the carrier' of C;
    thus (the Arity of C).* = <*an_Adj, a_Type*> by FUNCT_4:63;
    thus (the Arity of C).non_op = <*an_Adj*> by FUNCT_4:63;
    thus (the ResultSort of C).* = a_Type by FUNCT_4:63;
    thus (the ResultSort of C).non_op = an_Adj by FUNCT_4:63;
    thus thesis by TARSKI:def 2;
  end;
  correctness
  proof
    let C1, C2 be strict Signature such that
A1: C1 is constructor and
A2: the carrier' of C1 = {*, non_op} and
A3: C2 is constructor and
A4: the carrier' of C2 = {*, non_op};
    set A = {a_Type, an_Adj, a_Term};
A5: the carrier of C1 = A by A1;
A6: the carrier of C2 = A by A3;
A7: (the Arity of C1).* = <*an_Adj, a_Type*> by A1;
A8: (the Arity of C2).* = <*an_Adj, a_Type*> by A3;
A9: (the Arity of C1).non_op = <*an_Adj*> by A1;
A10: (the Arity of C2).non_op = <*an_Adj*> by A3;
A11: (the ResultSort of C1).* = a_Type by A1;
A12: (the ResultSort of C2).* = a_Type by A3;
A13: (the ResultSort of C1).non_op = an_Adj by A1;
A14: (the ResultSort of C2).non_op = an_Adj by A3;
A15: dom the Arity of C1 = {*, non_op} by A2,FUNCT_2:def 1;
A16: dom the Arity of C2 = {*, non_op} by A4,FUNCT_2:def 1;
A17: the Arity of C1 = (*, non_op) --> (<*an_Adj, a_Type*>, <*an_Adj*>) by A7
,A9,A15,FUNCT_4:66;
A18: the Arity of C2 = (*, non_op) --> (<*an_Adj, a_Type*>, <*an_Adj*>) by A8
,A10,A16,FUNCT_4:66;
A19: dom the ResultSort of C1 = {*, non_op} by A1,A2,FUNCT_2:def 1;
A20: dom the ResultSort of C2 = {*, non_op} by A3,A4,FUNCT_2:def 1;
    the ResultSort of C1 = (*, non_op) --> (a_Type, an_Adj) by A11,A13,A19,
FUNCT_4:66;
    hence thesis by A2,A4,A5,A6,A12,A14,A17,A18,A20,FUNCT_4:66;
  end;
end;

registration
  cluster MinConstrSign -> constructor;
  coherence by Def10;
end;

registration
  cluster constructor strict for Signature;
  existence
  proof
    take MinConstrSign;
    thus thesis; end;
end;

definition
  mode ConstructorSignature is constructor Signature;
end;

:: theorem ::?
::  for C being ConstructorSignature holds the carrier of C = 3
::   by CONSTRSIGN,YELLOW11:1;

definition
  let C be ConstructorSignature;
  let o be OperSymbol of C;
  attr o is constructor means
  :
  Def11: o <> * & o <> non_op;
end;

theorem
  for S being ConstructorSignature
  for o being OperSymbol of S st o is constructor
  holds the_arity_of o = (len the_arity_of o) |-> a_Term
proof
  let S be ConstructorSignature;
  let o be OperSymbol of S such that
A1: o <> * and
A2: o <> non_op;
  reconsider t = a_Term as Element of {a_Term} by TARSKI:def 1;
A3: len ((len the_arity_of o)|->a_Term) = len the_arity_of o by CARD_1:def 7;
A4: the_arity_of o in {a_Term}* by A1,A2,Def9;
  (len the_arity_of o)|->t in {a_Term}* by FINSEQ_1:def 11;
  hence thesis by A3,A4,Th6;
end;

definition
  let C be non empty non void Signature;
  attr C is initialized means
  :
  Def12: ex m, a being OperSymbol of C st
  the_result_sort_of m = a_Type & the_arity_of m = {} &  :: set
  the_result_sort_of a = an_Adj & the_arity_of a = {};   :: empty
end;

definition
  let C be ConstructorSignature;
A1: the carrier of C = {a_Type, an_Adj, a_Term} by Def9;
  func a_Type C -> SortSymbol of C equals
  a_Type;
  coherence by A1,ENUMSET1:def 1;
  func an_Adj C -> SortSymbol of C equals
  an_Adj;
  coherence by A1,ENUMSET1:def 1;
  func a_Term C -> SortSymbol of C equals
  a_Term;
  coherence by A1,ENUMSET1:def 1;
A2: {*, non_op} c= the carrier' of C by Def9;
A3: * in {*, non_op} by TARSKI:def 2;
A4: non_op in {*, non_op} by TARSKI:def 2;
  func non_op C -> OperSymbol of C equals
  non_op;
  coherence by A2,A4;
  func ast C -> OperSymbol of C equals
  *;
  coherence by A2,A3;
end;

theorem
  for C being ConstructorSignature holds the_arity_of non_op C = <*an_Adj C*> &
  the_result_sort_of non_op C = an_Adj C &
  the_arity_of ast C = <*an_Adj C, a_Type C*> &
  the_result_sort_of ast C = a_Type C by Def9;

definition
  func Modes -> set equals
  [:{a_Type},[:QuasiLoci,NAT:]:];
  correctness;
  func Attrs -> set equals
  [:{an_Adj},[:QuasiLoci,NAT:]:];
  correctness;
  func Funcs -> set equals
  [:{a_Term},[:QuasiLoci,NAT:]:];
  correctness;
end;

registration
  cluster Modes -> non empty;
  coherence;
  cluster Attrs -> non empty;
  coherence;
  cluster Funcs -> non empty;
  coherence;
end;

definition
  func Constructors -> non empty set equals
  Modes \/ Attrs \/ Funcs;
  coherence;
end;

theorem
  {*, non_op} misses Constructors
proof
  assume not thesis;
  then consider x being object such that
A1: x in {*, non_op} and
A2: x in Constructors by XBOOLE_0:3;
  x in Modes \/ Attrs or x in Funcs by A2,XBOOLE_0:def 3;
  then x in Modes or x in Attrs or x in Funcs by XBOOLE_0:def 3;
  then consider Y,Z being set such that
A3: x in [:Y,Z:];
A4: ex y,z being object st ( y in Y)&( z in Z)&( [y,z] = x)
    by A3,ZFMISC_1:def 2;
  reconsider x as set by TARSKI:1;
  x = * or x = non_op by A1,TARSKI:def 2;
  then the_rank_of x = 0 or the_rank_of x = 1 by CLASSES1:73;
  then the_rank_of x c= 1;
  then the_rank_of x in succ succ {} by ORDINAL1:6,12;
  then x in Rank succ succ {} by CLASSES1:66;
  hence thesis by A4,CLASSES1:29,45;
end;

definition
  let x be Element of [:QuasiLoci, NAT:];
  redefine func x`1 -> quasi-loci;
  coherence by MCART_1:10;
  redefine func x`2 -> Element of NAT;
  coherence by MCART_1:10;
end;

notation
  let c be Element of Constructors;
  synonym kind_of c for c`1;
end;

definition
  let c be Element of Constructors;
  redefine func kind_of c -> Element of {a_Type, an_Adj, a_Term};
  coherence
  proof
    c in Modes \/ Attrs or c in Funcs by XBOOLE_0:def 3;
    then c in Modes or c in Attrs or c in Funcs by XBOOLE_0:def 3;
    then c`1 in {a_Type} or c`1 in {an_Adj} or c`1 in {a_Term} by MCART_1:10;
    then c`1 = a_Type or c`1 = an_Adj or c`1 = a_Term by TARSKI:def 1;
    hence thesis by ENUMSET1:def 1;
  end;
  redefine func c`2 -> Element of [:QuasiLoci, NAT:];
  coherence
  proof
    c in Modes \/ Attrs or c in Funcs by XBOOLE_0:def 3;
    then c in Modes or c in Attrs or c in Funcs by XBOOLE_0:def 3;
    hence thesis by MCART_1:10;
  end;
end;

definition
  let c be Element of Constructors;
  func loci_of c -> quasi-loci equals
  c`2`1;
  coherence;
  func index_of c -> Nat equals
  c`2`2;
  coherence;
end;

theorem
  for c being Element of Constructors holds
  (kind_of c = a_Type iff c in Modes) &
  (kind_of c = an_Adj iff c in Attrs) &
  (kind_of c = a_Term iff c in Funcs)
proof
  let x be Element of Constructors;
A1: x in Modes \/ Attrs or x in Funcs by XBOOLE_0:def 3;
A2: x in Modes implies x`1 in {a_Type} by MCART_1:10;
A3: x in Attrs implies x`1 in {an_Adj} by MCART_1:10;
  x in Funcs implies x`1 in {a_Term} by MCART_1:10;
  hence thesis by A1,A2,A3,TARSKI:def 1,XBOOLE_0:def 3;
end;

definition
  func MaxConstrSign -> strict ConstructorSignature means
  :
  Def24: the carrier' of it = {*, non_op} \/ Constructors &
  for o being OperSymbol of it st o is constructor
  holds (the ResultSort of it).o = o`1 &
  card ((the Arity of it).o) = card o`2`1;
  existence
  proof
    set S = {a_Type, an_Adj, a_Term};
    set O = {*, non_op} \/ Constructors;
    deffunc F(Element of Constructors) = (len loci_of $1)|->a_Term;
    consider f being ManySortedSet of Constructors such that
A1: for c being Element of Constructors holds f.c = F(c) from PBOOLE:sch 5;
    deffunc G(Element of Constructors) = kind_of $1;
    consider g being ManySortedSet of Constructors such that
A2: for c being Element of Constructors holds g.c = G(c) from PBOOLE:sch 5;
    reconsider t = a_Type, a = an_Adj, tr = a_Term as Element of S
    by ENUMSET1:def 1;
    reconsider aa = <*a*> as Element of S*;
    set A = f+*(*, non_op)-->(<*a,t*>, aa);
    set R = g+*(*, non_op)-->(t, a);
A3: dom (*, non_op)-->(<*a,t*>, aa) = {*, non_op} by FUNCT_4:62;
A4: dom (*, non_op)-->(t, a) = {*, non_op} by FUNCT_4:62;
A5: dom f = Constructors by PARTFUN1:def 2;
A6: dom g = Constructors by PARTFUN1:def 2;
A7: dom A = O by A3,A5,FUNCT_4:def 1;
A8: dom R = O by A4,A6,FUNCT_4:def 1;
    rng f c= S*
    proof
      let y be object;
      assume y in rng f;
      then consider x being object such that
A9:   x in Constructors and
A10:  y = f.x by A5,FUNCT_1:def 3;
      reconsider x as Element of Constructors by A9;
      y = (len loci_of x)|->tr by A1,A10;
      hence thesis by FINSEQ_1:def 11;
    end;
    then
A11: rng f \/ rng (*, non_op)-->(<*a,t*>, aa) c= (S*) \/ (S*) by XBOOLE_1:13;
    rng g c= S
    proof
      let y be object;
      assume y in rng g;
      then consider x being object such that
A12:  x in Constructors and
A13:  y = g.x by A6,FUNCT_1:def 3;
      reconsider x as Element of Constructors by A12;
      y = kind_of x by A2,A13;
      hence thesis;
    end;
    then
A14: rng g \/ rng (*, non_op)-->(t, a) c= S \/ S by XBOOLE_1:13;
    rng A c= rng f \/ rng (*, non_op)-->(<*a,t*>, aa) by FUNCT_4:17;
    then reconsider A as Function of O, S* by A7,A11,FUNCT_2:2,XBOOLE_1:1;
    rng R c= rng g \/ rng (*, non_op)-->(t, a) by FUNCT_4:17;
    then reconsider R as Function of O, S by A8,A14,FUNCT_2:2,XBOOLE_1:1;
    reconsider Max = ManySortedSign(# S, O, A, R #) as
    non empty non void strict Signature;
    Max is constructor
    proof
      thus the carrier of Max = {a_Type, an_Adj, a_Term};
      thus {*, non_op} c= the carrier' of Max by XBOOLE_1:7;
A15:  * in {*, non_op} by TARSKI:def 2;
A16:  non_op in {*, non_op} by TARSKI:def 2;
      thus (the Arity of Max).* = ((*, non_op)-->(<*a,t*>, aa)).*
      by A3,A15,FUNCT_4:13
        .= <*an_Adj, a_Type*> by FUNCT_4:63;
      thus
      (the Arity of Max).non_op = ((*, non_op)-->(<*a,t*>, aa)).non_op
      by A3,A16,FUNCT_4:13
        .= <*an_Adj*> by FUNCT_4:63;
      thus (the ResultSort of Max).* = ((*, non_op)-->(t, a)).*
      by A4,A15,FUNCT_4:13
        .= a_Type by FUNCT_4:63;
      thus (the ResultSort of Max).non_op = ((*, non_op)-->(t, a)).non_op
      by A4,A16,FUNCT_4:13
        .= an_Adj by FUNCT_4:63;
      let o be Element of the carrier' of Max;
      assume that
A17:  o <> * and
A18:  o <> non_op;
A19:  not o in {*, non_op} by A17,A18,TARSKI:def 2;
      then reconsider c = o as Element of Constructors by XBOOLE_0:def 3;
      reconsider tr as Element of {a_Term} by TARSKI:def 1;
      (the Arity of Max).o = f.c by A3,A5,A19,FUNCT_4:def 1
        .= (len loci_of c)|->tr by A1;
      hence (the Arity of Max).o in {a_Term}* by FINSEQ_1:def 11;
    end;
    then reconsider Max as strict ConstructorSignature;
    take Max;
    thus the carrier' of Max = {*, non_op} \/ Constructors;
    let o being OperSymbol of Max;
    assume that
A20: o <> * and
A21: o <> non_op;
A22: not o in {*, non_op} by A20,A21,TARSKI:def 2;
    then reconsider c = o as Element of Constructors by XBOOLE_0:def 3;
    thus (the ResultSort of Max).o = g.c by A4,A6,A22,FUNCT_4:def 1
      .= o`1
    by A2;
    thus card ((the Arity of Max).o) = card (f.c) by A3,A5,A22,FUNCT_4:def 1
      .= card F(c) by A1
      .= card o`2`1 by CARD_1:def 7;
  end;
  uniqueness
  proof
    let it1, it2 be strict ConstructorSignature such that
A23: the carrier' of it1 = {*, non_op} \/ Constructors and
A24: for o being OperSymbol of it1 st o is constructor
    holds (the ResultSort of it1).o = o`1 &
    card ((the Arity of it1).o) = card o`2`1 and
A25: the carrier' of it2 = {*, non_op} \/ Constructors and
A26: for o being OperSymbol of it2 st o is constructor
    holds (the ResultSort of it2).o = o`1 &
    card ((the Arity of it2).o) = card o`2`1;
    set S = {a_Type, an_Adj, a_Term};
A27: the carrier of it1 = S by Def9;
A28: the carrier of it2 = S by Def9;
A29: now
      let c be Element of Constructors;
      reconsider o1 = c as OperSymbol of it1 by A23,XBOOLE_0:def 3;
      reconsider o2 = o1 as OperSymbol of it2 by A23,A25;
      assume that
A30:  c <> * and
A31:  c <> non_op;
A32:  o1 is constructor by A30,A31;
A33:  o2 is constructor by A30,A31;
A34:  card ((the Arity of it1).o1) = card c`2`1 by A24,A32;
A35:  card ((the Arity of it2).o2) = card c`2`1 by A26,A33;
A36:  (the Arity of it1).o1 in {a_Term}* by A30,A31,Def9;
      (the Arity of it2).o2 in {a_Term}* by A30,A31,Def9;
      then reconsider p1 = (the Arity of it1).o1, p2 = (the Arity of it2).o2
      as FinSequence of {a_Term} by A36,FINSEQ_1:def 11;
A37:  dom p1 = Seg len p1 by FINSEQ_1:def 3;
A38:  dom p2 = Seg len p2 by FINSEQ_1:def 3;
      now
        let i be Nat;
        assume
A39:    i in dom p1;
        then
A40:    p1.i in rng p1 by FUNCT_1:def 3;
A41:    p2.i in rng p2 by A34,A35,A37,A38,A39,FUNCT_1:def 3;
        p1.i = a_Term by A40,TARSKI:def 1;
        hence p1.i = p2.i by A41,TARSKI:def 1;
      end;
      hence (the Arity of it1).c = (the Arity of it2).c by A34,A35,A37,A38;
    end;
    now
      let o be OperSymbol of it1;
      o in {*, non_op} or not o in {*, non_op};
      then o = * or o = non_op or o in Constructors & o <> * & o <> non_op
      by A23,TARSKI:def 2,XBOOLE_0:def 3;
      then (the Arity of it1).o = <*an_Adj,a_Type*> &
      (the Arity of it2).o = <*an_Adj,a_Type*> or
      (the Arity of it1).o = <*an_Adj*> & (the Arity of it2).o = <*an_Adj*> or
      (the Arity of it1).o = (the Arity of it2).o
      by A29,Def9;
      hence (the Arity of it1).o = (the Arity of it2).o;
    end;
    then
A42: the Arity of it1 = the Arity of it2 by A23,A25,A27,A28,FUNCT_2:63;
    now
      let o be OperSymbol of it1;
      reconsider o9 = o as OperSymbol of it2 by A23,A25;
      not o in {*, non_op} or o in {*,non_op};
      then o = * or o = non_op or o in Constructors & o is constructor &
      o9 is constructor by A23,TARSKI:def 2,XBOOLE_0:def 3;
      then (the ResultSort of it1).o = a_Type &
      (the ResultSort of it2).o = a_Type or
      (the ResultSort of it1).o = an_Adj &
      (the ResultSort of it2).o = an_Adj or
      (the ResultSort of it1).o = o`1 & (the ResultSort of it2).o = o`1
      by A24,A26,Def9;
      hence (the ResultSort of it1).o = (the ResultSort of it2).o;
    end;
    hence thesis by A23,A25,A27,A28,A42,FUNCT_2:63;
  end;
end;

registration
  cluster MinConstrSign -> non initialized;
  correctness
  proof
    given m, a being OperSymbol of MinConstrSign such that
    the_result_sort_of m = a_Type and
A1: the_arity_of m = {} and
    the_result_sort_of a = an_Adj and the_arity_of a = {};
    the carrier' of MinConstrSign = {*, non_op} by Def10;
    then m = * or m = non_op by TARSKI:def 2;
    hence contradiction by A1,Def9;
  end;
  cluster MaxConstrSign -> initialized;
  correctness
  proof
    set m = [a_Type, [{}, 0]], a = [an_Adj, [{}, 0]];
A2: a_Type in {a_Type} by TARSKI:def 1;
A3: an_Adj in {an_Adj} by TARSKI:def 1;
A4: [<*> Vars, 0] in [:QuasiLoci, NAT:] by Th29,ZFMISC_1:def 2;
    then
A5: m in Modes by A2,ZFMISC_1:def 2;
A6: a in Attrs by A3,A4,ZFMISC_1:def 2;
A7: m in Modes \/ Attrs by A5,XBOOLE_0:def 3;
A8: a in Modes \/ Attrs by A6,XBOOLE_0:def 3;
A9: m in Constructors by A7,XBOOLE_0:def 3;
A10: a in Constructors by A8,XBOOLE_0:def 3;
    the carrier' of MaxConstrSign = {*, non_op} \/ Constructors by Def24;
    then reconsider m,a as OperSymbol of MaxConstrSign by A9,A10,XBOOLE_0:def 3
;
A11: m is constructor;
A12: a is constructor;
    take m, a;
    thus the_result_sort_of m = m`1 by A11,Def24
      .= a_Type;
    len the_arity_of m = card m`2`1 by A11,Def24
      .= card [{}, 0]`1
      .= 0;
    hence the_arity_of m = {};
    thus the_result_sort_of a = a`1 by A12,Def24
      .= an_Adj;
    len the_arity_of a = card a`2`1 by A12,Def24
      .= card [{}, 0]`1
      .= 0;
    hence thesis;
  end;
end;

registration
  cluster initialized strict for ConstructorSignature;
  correctness
  proof
    take MaxConstrSign;
    thus thesis; end;
end;

registration
  let C be initialized ConstructorSignature;
  cluster constructor for OperSymbol of C;
  existence
  proof
    consider m, a being OperSymbol of C such that
A1: the_result_sort_of m = a_Type and
A2: the_arity_of m = {} and
    the_result_sort_of a = an_Adj and the_arity_of a = {} by Def12;
    take m;
    thus m <> * by A2,Def9;
    thus thesis by A1,Def9;
  end;
end;

begin :: Mizar Expressions

definition
  let C be ConstructorSignature;
A1: the carrier of C = {a_Type, an_Adj, a_Term} by Def9;
  func MSVars C -> ManySortedSet of the carrier of C means
  :
  Def25: it.a_Type = {} & it.an_Adj = {} & it.a_Term = Vars;
  uniqueness
  proof
    let V1,V2 be ManySortedSet of the carrier of C such that
A2: V1.a_Type = {} and
A3: V1.an_Adj = {} and
A4: V1.a_Term = Vars and
A5: V2.a_Type = {} and
A6: V2.an_Adj = {} and
A7: V2.a_Term = Vars;
    now
      let x be object;
      assume x in the carrier of C;
      then x = a_Type or x = an_Adj or x = a_Term by A1,ENUMSET1:def 1;
      hence V1.x = V2.x by A2,A3,A4,A5,A6,A7;
    end;
    hence thesis;
  end;
  existence
  proof
    deffunc F(object) = IFEQ($1, a_Term, Vars, {});
    consider V being ManySortedSet of the carrier of C such that
A8: for x being object st x in the carrier of C holds V.x = F(x)
      from PBOOLE:sch 4;
    take V;
A9: IFEQ(a_Type, a_Term, Vars, {}) = {} by FUNCOP_1:def 8;
A10: IFEQ(an_Adj, a_Term, Vars, {}) = {} by FUNCOP_1:def 8;
A11: IFEQ(a_Term, a_Term, Vars, {}) = Vars by FUNCOP_1:def 8;
A12: a_Type in the carrier of C by A1,ENUMSET1:def 1;
A13: an_Adj in the carrier of C by A1,ENUMSET1:def 1;
    a_Term in the carrier of C by A1,ENUMSET1:def 1;
    hence thesis by A8,A9,A10,A11,A12,A13;
  end;
end;

:: theorem
::  for C being ConstructorSignature
::  for x being variable holds
::    (C variables_in root-tree [x, a_Term]).a_Term C = {x} by MSAFREE3:11;

registration
  let C be ConstructorSignature;
  cluster MSVars C -> non empty-yielding;
  coherence
  proof
    take a_Term;
    the carrier of C = {a_Type, an_Adj, a_Term} by Def9;
    hence a_Term in the carrier of C by ENUMSET1:def 1;
    thus thesis by Def25;
  end;
end;

registration
  let C be initialized ConstructorSignature;
  cluster Free(C, MSVars C) -> non-empty;
  correctness
  proof
    set X = MSVars C;
    consider m, a being OperSymbol of C such that
A1: the_result_sort_of m = a_Type and
A2: the_arity_of m = {} and
A3: the_result_sort_of a = an_Adj and
A4: the_arity_of a = {} by Def12;
A5: root-tree [m, the carrier of C] in (the Sorts of Free(C, X)).a_Type
    by A1,A2,MSAFREE3:5;
A6: root-tree [a, the carrier of C] in (the Sorts of Free(C, X)).an_Adj
    by A3,A4,MSAFREE3:5;
    set x = the variable;
A7: a_Term C = a_Term;
    (MSVars C).a_Term = Vars by Def25;
    then
A8: root-tree [x, a_Term] in (the Sorts of Free(C, X)).a_Term by A7,MSAFREE3:4;
    assume the Sorts of Free(C, X) is not non-empty;
    then {} in rng the Sorts of Free(C, X) by RELAT_1:def 9;
    then consider s being object such that
A9: s in dom the Sorts of Free(C, X) and
A10: {} = (the Sorts of Free(C, X)).s by FUNCT_1:def 3;
    s in the carrier of C by A9;
    then s in {a_Type, an_Adj, a_Term} by Def9;
    hence thesis by A5,A6,A8,A10,ENUMSET1:def 1;
  end;
end;

definition
  let S be non void Signature;
  let X be non empty-yielding ManySortedSet of the carrier of S;
  let t be Element of Free(S,X);
  attr t is ground means
  Union (S variables_in t) = {};
  attr t is compound means
  :
  Def27: t.{} in [:the carrier' of S, {the carrier of S}:];
end;

reserve C for initialized ConstructorSignature,
  s for SortSymbol of C,
  o for OperSymbol of C,
  c for constructor OperSymbol of C;

definition
  let C;
  mode expression of C is Element of Free(C, MSVars C);
end;

definition
  let C, s;
  mode expression of C, s -> expression of C means
    :
    Def28: it in (the Sorts of Free(C, MSVars C)).s;
  existence
  proof set t = the Element of (the Sorts of Free(C, MSVars C)).s;
    dom the Sorts of Free(C, MSVars C) = the carrier of C by PARTFUN1:def 2;
    then t in Union the Sorts of Free(C, MSVars C) by CARD_5:2;
    hence thesis;
  end;
end;

theorem Th41:
  z is expression of C, s iff z in (the Sorts of Free(C, MSVars C)).s
proof
A1: dom the Sorts of Free(C, MSVars C) = the carrier of C by PARTFUN1:def 2;
  (the Sorts of Free(C, MSVars C)).s c= Union the Sorts of Free(C, MSVars C)
  by A1,CARD_5:2;
  hence thesis by Def28;
end;

definition
  let C;
  let c such that
A1: len the_arity_of c = 0;
  func c term -> expression of C equals
  [c, the carrier of C]-tree {};
  coherence
  proof
    the_arity_of c = {} by A1;
    then
A2: root-tree [c, the carrier of C] in
    (the Sorts of Free(C, MSVars C)).the_result_sort_of c
    by MSAFREE3:5;
    dom the Sorts of Free(C, MSVars C) = the carrier of C by PARTFUN1:def 2;
    then
    root-tree [c, the carrier of C] in Union (the Sorts of Free(C, MSVars C))
    by A2,CARD_5:2;
    hence thesis by TREES_4:20;
  end;
end;

theorem Th42:
  for o st len the_arity_of o = 1 for a being expression of C st
  ex s st s = (the_arity_of o).1 & a is expression of C, s
  holds
  [o, the carrier of C]-tree <*a*> is expression of C, the_result_sort_of o
proof
  let o be OperSymbol of C such that
A1: len the_arity_of o = 1;
  set X = MSVars C;
  set Y = X (\/) ((the carrier of C)-->{0});
  let a be expression of C;
  given s being SortSymbol of C such that
A2: s = (the_arity_of o).1 and
A3: a is expression of C, s;
  reconsider ta = a as Term of C,Y by MSAFREE3:8;
A4: dom <*ta*> = Seg 1 by FINSEQ_1:38;
A5: dom <*s*> = Seg 1 by FINSEQ_1:38;
A6: the_arity_of o = <*s*> by A1,A2,FINSEQ_1:40;
A7: the Sorts of Free(C, X) = C-Terms(X, Y) by MSAFREE3:24;
  now
    let i be Nat;
    assume i in dom <*ta*>;
    then
A8: i = 1 by A4,FINSEQ_1:2,TARSKI:def 1;
    let t be Term of C, Y;
    assume
A9: t = <*ta*>.i;
A10: the Sorts of Free(C, X) c= the Sorts of FreeMSA Y by A7,PBOOLE:def 18;
A11: t = a by A8,A9,FINSEQ_1:40;
A12: (the Sorts of Free(C, X)).s c= (the Sorts of FreeMSA Y).s by A10;
    t in (the Sorts of Free(C, X)).s by A3,A11,Th41;
    hence the_sort_of t = (the_arity_of o).i by A2,A8,A12,MSAFREE3:7;
  end;
  then reconsider p = <*ta*> as ArgumentSeq of Sym(o, Y) by A4,A5,A6,MSATERM:25
;
A13: variables_in (Sym(o, Y)-tree p) c= X
  proof
    let s be object;
    assume s in the carrier of C;
    then reconsider s9 = s as SortSymbol of C;
    let x be object;
    assume x in (variables_in (Sym(o, Y)-tree p)).s;
    then consider t being DecoratedTree such that
A14: t in rng p and
A15: x in (C variables_in t).s9 by MSAFREE3:11;
A16: C variables_in a c= X by MSAFREE3:27;
A17: rng p = {a} by FINSEQ_1:38;
A18: (C variables_in a).s9 c= X.s9 by A16;
    t = a by A14,A17,TARSKI:def 1;
    hence thesis by A15,A18;
  end;
  set s9 = the_result_sort_of o;
A19: the_sort_of (Sym(o, Y)-tree p) = the_result_sort_of o by MSATERM:20;
  (the Sorts of Free(C, X)).s9 =
  {t where t is Term of C,Y: the_sort_of t = s9 & variables_in t c= X}
  by A7,MSAFREE3:def 5;
  then [o, the carrier of C]-tree <*a*> in (the Sorts of Free(C, X)).s9 by A13
,A19;
  hence thesis by Th41;
end;

definition
  let C,o such that
A1: len the_arity_of o = 1;
  let e be expression of C such that
A2: ex s being SortSymbol of C st
  s = (the_arity_of o).1 & e is expression of C, s;
  func o term e -> expression of C equals
  :
  Def30: [o, the carrier of C]-tree<*e*>;
  coherence by A1,A2,Th42;
end;

reserve a,b for expression of C, an_Adj C;

theorem Th43:
  (non_op C)term a is expression of C, an_Adj C &
  (non_op C)term a = [non_op, the carrier of C]-tree <*a*>
proof
A1: the_result_sort_of non_op C = an_Adj C by Def9;
A2: the_arity_of non_op C = <*an_Adj C*> by Def9;
  then
A3: len the_arity_of non_op C = 1 by FINSEQ_1:40;
A4: (the_arity_of non_op C).1 = an_Adj C by A2,FINSEQ_1:40;
  then (non_op C)term a = [non_op, the carrier of C]-tree <*a*> by A3,Def30;
  hence thesis by A1,A3,A4,Th42;
end;

theorem Th44:
  (non_op C)term a = (non_op C)term b implies a = b
proof
  assume (non_op C)term a = (non_op C)term b;
  then [non_op, the carrier of C]-tree <*a*> = (non_op C)term b by Th43
    .= [non_op, the carrier of C]-tree <*b*> by Th43;
  then <*a*> = <*b*> by TREES_4:15;
  hence thesis by FINSEQ_1:76;
end;

registration
  let C,a;
  cluster (non_op C)term a -> compound;
  coherence
  proof
    (non_op C)term a = [non_op, the carrier of C]-tree <*a*> by Th43;
    then ((non_op C)term a).{} = [non_op C, the carrier of C] by TREES_4:def 4;
    hence
    ((non_op C)term a).{} in [:the carrier' of C, {the carrier of C}:]
    by ZFMISC_1:106;
  end;
end;

registration
  let C;
  cluster compound for expression of C;
  existence
  proof
    set a = the expression of C, an_Adj C;
    (non_op C)term a is compound;
    hence thesis;
  end;
end;

theorem Th45:
  for o st len the_arity_of o = 2 for a,b being expression of C st
  ex s1,s2 being SortSymbol of C st
  s1 = (the_arity_of o).1 & s2 = (the_arity_of o).2 &
  a is expression of C, s1 & b is expression of C, s2
  holds
  [o, the carrier of C]-tree <*a,b*> is expression of C, the_result_sort_of o
proof
  let o be OperSymbol of C such that
A1: len the_arity_of o = 2;
  set X = MSVars C;
  set Y = X (\/) ((the carrier of C)-->{0});
  let a,b be expression of C;
  given s1,s2 being SortSymbol of C such that
A2: s1 = (the_arity_of o).1 and
A3: s2 = (the_arity_of o).2 and
A4: a is expression of C, s1 and
A5: b is expression of C, s2;
  reconsider ta = a, tb = b as Term of C,Y by MSAFREE3:8;
A6: dom <*ta,tb*> = Seg 2 by FINSEQ_1:89;
A7: dom <*s1,s2*> = Seg 2 by FINSEQ_1:89;
A8: the_arity_of o = <*s1,s2*> by A1,A2,A3,FINSEQ_1:44;
A9: the Sorts of Free(C, X) = C-Terms(X, Y) by MSAFREE3:24;
  now
    let i be Nat;
    assume i in dom <*ta,tb*>;
    then
A10: i = 1 or i = 2 by A6,FINSEQ_1:2,TARSKI:def 2;
    let t be Term of C, Y;
    assume
A11: t = <*ta,tb*>.i;
A12: the Sorts of Free(C, X) c= the Sorts of FreeMSA Y by A9,PBOOLE:def 18;
A13: i = 1 & t = a or i = 2 & t = b by A10,A11,FINSEQ_1:44;
A14: (the Sorts of Free(C, X)).s1 c= (the Sorts of FreeMSA Y).s1 by A12;
A15: (the Sorts of Free(C, X)).s2 c= (the Sorts of FreeMSA Y).s2 by A12;
    i = 1 & t in (the Sorts of Free(C, X)).s1 or i = 2 & t in (the Sorts
    of Free(C, X)).s2 by A4,A5,A13,Th41;
    hence the_sort_of t = (the_arity_of o).i by A2,A3,A14,A15,MSAFREE3:7;
  end;
  then reconsider p = <*ta,tb*> as ArgumentSeq of Sym(o, Y) by A6,A7,A8,
MSATERM:25;
A16: variables_in (Sym(o, Y)-tree p) c= X
  proof
    let s be object;
    assume s in the carrier of C;
    then reconsider s9 = s as SortSymbol of C;
    let x be object;
    assume x in (variables_in (Sym(o, Y)-tree p)).s;
    then consider t being DecoratedTree such that
A17: t in rng p and
A18: x in (C variables_in t).s9 by MSAFREE3:11;
A19: C variables_in a c= X by MSAFREE3:27;
A20: C variables_in b c= X by MSAFREE3:27;
A21: rng p = {a,b} by FINSEQ_2:127;
A22: (C variables_in a).s9 c= X.s9 by A19;
A23: (C variables_in b).s9 c= X.s9 by A20;
    t = a or t = b by A17,A21,TARSKI:def 2;
    hence thesis by A18,A22,A23;
  end;
  set s9 = the_result_sort_of o;
A24: the_sort_of (Sym(o, Y)-tree p) = the_result_sort_of o by MSATERM:20;
  (the Sorts of Free(C, X)).s9 =
  {t where t is Term of C,Y: the_sort_of t = s9 & variables_in t c= X}
  by A9,MSAFREE3:def 5;
  then [o, the carrier of C]-tree <*a,b*> in (the Sorts of Free(C, X)).s9
  by A16,A24;
  hence thesis by Th41;
end;

definition
  let C,o such that
A1: len the_arity_of o = 2;
  let e1,e2 be expression of C such that
A2: ex s1,s2 being SortSymbol of C st
  s1 = (the_arity_of o).1 & s2 = (the_arity_of o).2 &
  e1 is expression of C, s1 & e2 is expression of C, s2;
  func o term(e1,e2) -> expression of C equals
  :
  Def31: [o, the carrier of C]-tree<*e1,e2*>;
  coherence by A1,A2,Th45;
end;

reserve t, t1,t2 for expression of C, a_Type C;

theorem Th46:
  (ast C)term(a,t) is expression of C, a_Type C &
  (ast C)term(a,t) = [ *, the carrier of C]-tree <*a,t*>
proof
A1: the_result_sort_of ast C = a_Type C by Def9;
A2: the_arity_of ast C = <*an_Adj C, a_Type C*> by Def9;
  then
A3: len the_arity_of ast C = 2 by FINSEQ_1:44;
A4: (the_arity_of ast C).1 = an_Adj C by A2,FINSEQ_1:44;
A5: (the_arity_of ast C).2 = a_Type C by A2,FINSEQ_1:44;
  then (ast C)term(a,t) = [ *, the carrier of C]-tree <*a,t*> by A3,A4,Def31;
  hence thesis by A1,A3,A4,A5,Th45;
end;

theorem
  (ast C)term(a,t1) = (ast C)term(b,t2) implies a = b & t1 = t2
proof
  assume (ast C)term(a,t1) = (ast C)term(b,t2);
  then [ *, the carrier of C]-tree<*a,t1*> = (ast C)term(b,t2) by Th46
    .= [ *, the carrier of C]-tree<*b,t2*> by Th46;
  then <*a,t1*> = <*b,t2*> by TREES_4:15;
  hence thesis by FINSEQ_1:77;
end;

registration
  let C,a,t;
  cluster (ast C)term(a,t) -> compound;
  coherence
  proof
    (ast C)term(a,t) = [ *, the carrier of C]-tree <*a,t*> by Th46;
    then ((ast C)term(a,t)).{} = [ast C, the carrier of C] by TREES_4:def 4;
    hence
    ((ast C)term(a,t)).{} in [:the carrier' of C, {the carrier of C}:]
    by ZFMISC_1:106;
  end;
end;

definition
  let S be non void Signature;
  let s be SortSymbol of S such that
A1: ex o being OperSymbol of S st the_result_sort_of o = s;
  mode OperSymbol of s -> OperSymbol of S means
    the_result_sort_of it = s;
  existence by A1;
end;

definition
  let C be ConstructorSignature;
  redefine func non_op C -> OperSymbol of an_Adj C;
  coherence
  proof
    the_result_sort_of non_op C = an_Adj C by Def9;
    hence ex o being OperSymbol of C st the_result_sort_of o = an_Adj C;
    thus thesis by Def9;
  end;
  redefine func ast C -> OperSymbol of a_Type C;
  coherence
  proof
    the_result_sort_of ast C = a_Type C by Def9;
    hence ex o being OperSymbol of C st the_result_sort_of o = a_Type C;
    thus thesis by Def9;
  end;
end;

theorem Th48:
  for s1,s2 being SortSymbol of C st s1 <> s2 for t1 being expression of C, s1
  for t2 being expression of C, s2
  holds t1 <> t2
proof
  set X = MSVars C;
  set Y = X (\/) ((the carrier of C) --> {0});
A1: ex A being MSSubset of FreeMSA Y st ( Free(C, X) = GenMSAlg
  A)&( A = (Reverse Y)""X) by MSAFREE3:def 1;
  let s1,s2 be SortSymbol of C;
  the Sorts of Free(C, X) is MSSubset of FreeMSA Y by A1,MSUALG_2:def 9;
  then
A2: the Sorts of Free(C, X) c= the Sorts of FreeMSA Y by PBOOLE:def 18;
  then
A3: (the Sorts of Free(C,X)).s1 c= (the Sorts of FreeMSA Y).s1;
A4: (the Sorts of Free(C,X)).s2 c= (the Sorts of FreeMSA Y).s2 by A2;
  assume s1 <> s2;
  then
A5: (the Sorts of FreeMSA Y).s1 misses (the Sorts of FreeMSA Y).s2
  by PROB_2:def 2;
  let t1 be expression of C, s1;
  let t2 be expression of C, s2;
A6: t1 in (the Sorts of Free(C,X)).s1 by Def28;
  t2 in (the Sorts of Free(C,X)).s2 by Def28;
  hence thesis by A3,A4,A5,A6,XBOOLE_0:3;
end;

begin :: Quasi-terms

definition
  let C;
A1: (the Sorts of Free(C, MSVars C)).a_Term C c=
  Union the Sorts of Free(C, MSVars C)
  proof
    let x be object;
    dom the Sorts of Free(C, MSVars C) = the carrier of C by PARTFUN1:def 2;
    hence thesis by CARD_5:2;
  end;
  func QuasiTerms C -> Subset of Free(C, MSVars C) equals
  (the Sorts of Free(C, MSVars C)).a_Term C;
  coherence by A1;
end;

registration
  let C;
  cluster QuasiTerms C -> non empty constituted-DTrees;
  coherence;
end;

definition
  let C;
  mode quasi-term of C is expression of C, a_Term C;
end;

theorem
  z is quasi-term of C iff z in QuasiTerms C by Th41;

definition
  let x be variable;
  let C;
  func x-term C -> quasi-term of C equals
  root-tree [x, a_Term];
  coherence
  proof
    (MSVars C).a_Term = Vars by Def25;
    then root-tree [x, a_Term] in QuasiTerms C by MSAFREE3:4;
    hence thesis by Th41;
  end;
end;

theorem Th50:
  for x1,x2 being variable for C1,C2 being initialized ConstructorSignature
  st x1-term C1 = x2-term C2
  holds x1 = x2
proof
  let x1,x2 be variable;
  let C1,C2 be initialized ConstructorSignature;
  assume x1-term C1 = x2-term C2;
  then [x1, a_Term] = [x2, a_Term] by TREES_4:4;
  hence thesis by XTUPLE_0:1;
end;

registration
  let x be variable;
  let C;
  cluster x-term C -> non compound;
  coherence
  proof
    a_Term C in the carrier of C;
    then
A1: a_Term C <> the carrier of C;
A2: (x-term C).{} = [x, a_Term C] by TREES_4:3;
    a_Term C nin {the carrier of C} by A1,TARSKI:def 1;
    hence (x-term C).{} nin [:the carrier' of C, {the carrier of C}:]
    by A2,ZFMISC_1:87;
  end;
end;

theorem Th51:
  for p being DTree-yielding FinSequence holds
  [c, the carrier of C]-tree p is expression of C
  iff len p = len the_arity_of c & p in (QuasiTerms C)*
proof
  set o = c;
A1: o <> * by Def11;
A2: o <> non_op by Def11;
  let p be DTree-yielding FinSequence;
  set V = (MSVars C) (\/) ((the carrier of C) --> {0});
A3: the Sorts of Free(C, MSVars C) = C-Terms(MSVars C, V) by MSAFREE3:24;
  thus
  now
    assume
A4: [o, the carrier of C]-tree p is expression of C;
    then
A5: [o, the carrier of C]-tree p is Term of C, V by MSAFREE3:8;
    then
A6: p is ArgumentSeq of Sym(o,V) by MSATERM:1;
    hence len p = len the_arity_of o by MSATERM:22;
    reconsider q = p as ArgumentSeq of Sym(o,V) by A5,MSATERM:1;
A7: the_sort_of ((Sym(o,V))-tree q) = the_result_sort_of o by MSATERM:20;
A8: variables_in ((Sym(o,V))-tree q) c= MSVars C by A4,MSAFREE3:27;
    (C-Terms(MSVars C,V)).the_result_sort_of o =
    {t where t is Term of C,V: the_sort_of t = the_result_sort_of o &
    variables_in t c= MSVars C} by MSAFREE3:def 5;
    then Sym(o,V)-tree p in (C-Terms(MSVars C,V)).the_result_sort_of o
    by A7,A8;
    then
A9: rng p c= Union (C-Terms(MSVars C,V)) by A6,MSAFREE3:19;
    rng p c= QuasiTerms C
    proof
      let a be object;
      assume
A10:  a in rng p;
      then reconsider ta = a as expression of C by A9,MSAFREE3:24;
      consider i being object such that
A11:  i in dom p and
A12:  a = p.i by A10,FUNCT_1:def 3;
      reconsider i as Nat by A11;
      reconsider t = p.i as Term of C, V by A6,A11,MSATERM:22;
A13:  (the Arity of C).o in {a_Term}* by A1,A2,Def9;
A14:  dom p = dom the_arity_of o by A6,MSATERM:22;
A15:  the_arity_of o is FinSequence of {a_Term} by A13,FINSEQ_1:def 11;
A16:  (the_arity_of o).i in rng the_arity_of o by A11,A14,FUNCT_1:def 3;
      rng the_arity_of o c= {a_Term C} by A15,FINSEQ_1:def 4;
      then (the_arity_of o).i = a_Term C by A16,TARSKI:def 1;
      then
A17:  the_sort_of t = a_Term C by A6,A11,MSATERM:23;
      t = ta by A12;
      then variables_in t c= MSVars C by MSAFREE3:27;
      then t in {T where T is Term of C,V: the_sort_of T = a_Term C &
      variables_in T c= MSVars C} by A17;
      then t in (C-Terms(MSVars C,V)).a_Term C by MSAFREE3:def 5;
      hence thesis by A12,MSAFREE3:23;
    end;
    then p is FinSequence of QuasiTerms C by FINSEQ_1:def 4;
    hence p in (QuasiTerms C)* by FINSEQ_1:def 11;
  end;
  assume
A18: len p = len the_arity_of o;
  assume
A19: p in (QuasiTerms C)*;
  Free(C, MSVars C) = (FreeMSA V)|(C-Terms(MSVars C, V)) by MSAFREE3:25;
  then the Sorts of Free(C, MSVars C) is ManySortedSubset of
  the Sorts of FreeMSA V by MSUALG_2:def 9;
  then the Sorts of Free(C, MSVars C) c= the Sorts of FreeMSA V
  by PBOOLE:def 18;
  then
A20: QuasiTerms C c= (the Sorts of FreeMSA V).a_Term C;
A21: p is FinSequence of QuasiTerms C by A19,FINSEQ_1:def 11;
  then
A22: rng p c= QuasiTerms C by FINSEQ_1:def 4;
  now
    let i be Nat;
    assume
A23: i in dom p;
    then p.i in rng p by FUNCT_1:def 3;
    then
A24: p.i in QuasiTerms C by A22;
    then reconsider t = p.i as expression of C;
A25: (the Arity of C).o in {a_Term}* by A1,A2,Def9;
A26: dom p = dom the_arity_of o by A18,FINSEQ_3:29;
A27: the_arity_of o is FinSequence of {a_Term} by A25,FINSEQ_1:def 11;
A28: (the_arity_of o).i in rng the_arity_of o by A23,A26,FUNCT_1:def 3;
    rng the_arity_of o c= {a_Term C} by A27,FINSEQ_1:def 4;
    then
A29: (the_arity_of o).i = a_Term C by A28,TARSKI:def 1;
    reconsider T = t as Term of C,V by MSAFREE3:8;
    take T;
    thus T = p.i;
    T in (the Sorts of FreeMSA V).a_Term C by A20,A24;
    then T in FreeSort(V, a_Term C) by MSAFREE:def 11;
    hence the_sort_of T = (the_arity_of o).i by A29,MSATERM:def 5;
  end;
  then
A30: p is ArgumentSeq of Sym(o,V) by A18,MSATERM:24;
A31: dom the Sorts of Free(C, MSVars C) = the carrier of C by PARTFUN1:def 2;
  rng p c= Union (C-Terms(MSVars C, V)) by A3,A21,FINSEQ_1:def 4;
  then Sym(o,V)-tree p in (C-Terms(MSVars C, V)).the_result_sort_of o
  by A30,MSAFREE3:19;
  hence thesis by A3,A31,CARD_5:2;
end;

reserve p for FinSequence of QuasiTerms C;

definition
  let C,c;
  let p such that
A1: len p = len the_arity_of c;
A2: p in (QuasiTerms C)* by FINSEQ_1:def 11;
  func c-trm p -> compound expression of C equals
  :
  Def35: [c, the carrier of C]-tree p;
  coherence
  proof
    reconsider t = [c, the carrier of C]-tree p as expression of C by A1,A2
,Th51;
    t.{} = [c, the carrier of C] by TREES_4:def 4;
    then t.{} in [:the carrier' of C, {the carrier of C}:] by ZFMISC_1:106;
    hence thesis by Def27;
  end;
end;

theorem Th52:
  len p = len the_arity_of c implies
  c-trm p is expression of C, the_result_sort_of c
proof
  set X = MSVars C;
  set V = X(\/)((the carrier of C)-->{0});
  assume len p = len the_arity_of c;
  then
A1: Sym(c,V)-tree p = c-trm p by Def35;
A2: the Sorts of Free(C,X) = C-Terms(X,V) by MSAFREE3:24;
  c-trm p is Term of C,V by MSAFREE3:8;
  then reconsider q = p as ArgumentSeq of Sym(c,V) by A1,MSATERM:1;
  rng q c= Union the Sorts of Free(C,X) by FINSEQ_1:def 4;
  then c-trm p in (C-Terms(X,V)).the_result_sort_of c by A1,A2,MSAFREE3:19;
  hence thesis by A2,Def28;
end;

theorem Th53:
  for e being expression of C holds (ex x being variable st e = x-term C) or
  (ex c being constructor OperSymbol of C st
  ex p being FinSequence of QuasiTerms C st
  len p = len the_arity_of c & e = c-trm p) or
  (ex a being expression of C, an_Adj C st e = (non_op C)term a) or
  ex a being expression of C, an_Adj C st
  ex t being expression of C, a_Type C st e = (ast C)term(a,t)
proof
  let t be expression of C;
  set X = MSVars C;
  set V = X(\/)((the carrier of C)-->{0});
  per cases by Th7;
  suppose
    ex s being SortSymbol of C, v being set st t = root-tree [v,s] & v in X.s;
    then consider s being SortSymbol of C, v being set such that
A1: t = root-tree [v,s] and
A2: v in X.s;
    the carrier of C = {a_Type, an_Adj, a_Term} by Def9;
    then
A3: s = a_Term or s = an_Adj or s = a_Type by ENUMSET1:def 1;
    then reconsider v as variable by A2,Def25;
    t = v-term C by A1,A2,A3,Def25;
    hence thesis;
  end;
  suppose
    ex o being OperSymbol of C, p being FinSequence of Free(C,X) st
    t = [o,the carrier of C]-tree p & len p = len the_arity_of o &
    p is DTree-yielding & p is ArgumentSeq of Sym(o,V);
    then consider o being OperSymbol of C,
    p being FinSequence of Free(C,X) such that
A4: t = [o, the carrier of C]-tree p and
A5: len p = len the_arity_of o and
    p is DTree-yielding and
A6: p is ArgumentSeq of Sym(o,V);
    per cases;
    suppose
A7:   o = *;
      then
A8:   the_arity_of o = <*an_Adj,a_Type*> by Def9;
A9:   dom p = dom the_arity_of o by A6,MSATERM:22;
A10:  dom the_arity_of o = Seg 2 by A8,FINSEQ_1:89;
A11:  len the_arity_of o = 2 by A8,FINSEQ_1:44;
A12:  1 in Seg 2;
A13:  2 in Seg 2;
A14:  p.1 in rng p by A9,A10,A12,FUNCT_1:3;
      p.2 in rng p by A9,A10,A13,FUNCT_1:3;
      then reconsider p1 = p.1, p2 = p.2 as expression of C by A14;
      reconsider t1 = p1, t2 = p2 as Term of C,V by MSAFREE3:8;
A15:  C variables_in p1 c= X by MSAFREE3:27;
A16:  variables_in t1 = C variables_in t1;
A17:  C variables_in p2 c= X by MSAFREE3:27;
A18:  variables_in t2 = C variables_in t2;
A19:  <*an_Adj,a_Type*>.2 = a_Type C by FINSEQ_1:44;
A20:  <*an_Adj,a_Type*>.1 = an_Adj C by FINSEQ_1:44;
      the_sort_of t1 = (the_arity_of o).1 by A6,A9,A10,A12,MSATERM:23;
      then t1 in {q where q is Term of C,V: the_sort_of q = an_Adj C &
      variables_in q c= X} by A8,A15,A16,A20;
      then p1 in C-Terms(X,V).an_Adj C by MSAFREE3:def 5;
      then p1 in (the Sorts of Free(C,X)).an_Adj C by MSAFREE3:24;
      then reconsider a = p1 as expression of C, an_Adj C by Def28;
      the_sort_of t2 = (the_arity_of o).2 by A6,A9,A10,A13,MSATERM:23;
      then t2 in {q where q is Term of C,V: the_sort_of q = a_Type C &
      variables_in q c= X} by A8,A17,A18,A19;
      then p2 in C-Terms(X,V).a_Type C by MSAFREE3:def 5;
      then p2 in (the Sorts of Free(C,X)).a_Type C by MSAFREE3:24;
      then reconsider q = p2 as expression of C, a_Type C by Def28;
      p = <*a,q*> by A5,A11,FINSEQ_1:44;
      then t = (ast C)term(a,q) by A4,A7,A8,A11,A19,A20,Def31;
      hence thesis;
    end;
    suppose
A21:  o = non_op;
      then
A22:  the_arity_of o = <*an_Adj*> by Def9;
A23:  dom p = dom the_arity_of o by A6,MSATERM:22;
A24:  dom the_arity_of o = Seg 1 by A22,FINSEQ_1:38;
A25:  len the_arity_of o = 1 by A22,FINSEQ_1:39;
A26:  1 in Seg 1;
      then p.1 in rng p by A23,A24,FUNCT_1:3;
      then reconsider p1 = p.1 as expression of C;
      reconsider t1 = p1 as Term of C,V by MSAFREE3:8;
A27:  C variables_in p1 c= X by MSAFREE3:27;
A28:  variables_in t1 = C variables_in t1;
A29:  <*an_Adj*>.1 = an_Adj C by FINSEQ_1:40;
      the_sort_of t1 = (the_arity_of o).1 by A6,A23,A24,A26,MSATERM:23;
      then t1 in {q where q is Term of C,V: the_sort_of q = an_Adj C &
      variables_in q c= X} by A22,A27,A28,A29;
      then p1 in C-Terms(X,V).an_Adj C by MSAFREE3:def 5;
      then p1 in (the Sorts of Free(C,X)).an_Adj C by MSAFREE3:24;
      then reconsider a = p1 as expression of C, an_Adj C by Def28;
      p = <*a*> by A5,A25,FINSEQ_1:40;
      then t = (non_op C)term(a) by A4,A21,A22,A25,A29,Def30;
      hence thesis;
    end;
    suppose o is constructor;
      then reconsider o as constructor OperSymbol of C;
      t = [o, the carrier of C]-tree p by A4;
      then p in (QuasiTerms C)* by Th51;
      then reconsider p as FinSequence of QuasiTerms C by FINSEQ_1:def 11;
      t = o-trm p by A4,A5,Def35;
      hence thesis by A5;
    end;
  end;
end;

theorem Th54:
  len p = len the_arity_of c implies c-trm p <> (non_op C)term a
proof
  assume len p = len the_arity_of c;
  then c-trm p = [c, the carrier of C]-tree p by Def35;
  then
A1: (c-trm p).{} = [c, the carrier of C] by TREES_4:def 4;
  assume c-trm p = (non_op C)term a;
  then c-trm p = [non_op, the carrier of C]-tree<*a*> by Th43;
  then [c, the carrier of C] = [non_op, the carrier of C] by A1,TREES_4:def 4;
  then c = non_op by XTUPLE_0:1;
  hence thesis by Def11;
end;

theorem Th55:
  len p = len the_arity_of c implies c-trm p <> (ast C)term(a,t)
proof
  assume len p = len the_arity_of c;
  then c-trm p = [c, the carrier of C]-tree p by Def35;
  then
A1: (c-trm p).{} = [c, the carrier of C] by TREES_4:def 4;
  assume c-trm p = (ast C)term(a,t);
  then c-trm p = [ *, the carrier of C]-tree<*a,t*> by Th46;
  then [c, the carrier of C] = [ *, the carrier of C] by A1,TREES_4:def 4;
  then c = * by XTUPLE_0:1;
  hence thesis by Def11;
end;

theorem
  (non_op C)term a <> (ast C)term(b,t)
proof
  assume (non_op C)term a = (ast C)term(b,t);
  then (non_op C)term a = [ *, the carrier of C]-tree<*b,t*> by Th46;
  then ((non_op C)term a).{} = [ *, the carrier of C] by TREES_4:def 4;
  then ([non_op,the carrier of C]-tree<*a*>).{} = [ *, the carrier of C]
  by Th43;
  then [non_op, the carrier of C] = [ *, the carrier of C] by TREES_4:def 4;
  hence thesis by XTUPLE_0:1;
end;

reserve e for expression of C;

theorem Th57:
  e.{} = [non_op, the carrier of C] implies ex a st e = (non_op C)term a
proof
  assume
A1: e.{} = [non_op, the carrier of C];
  non_op C in the carrier' of C;
  then
A2: e.{} in [:the carrier' of C, {the carrier of C}:] by A1,ZFMISC_1:106;
  per cases by Th53;
  suppose
    ex x being variable st e = x-term C;
    hence thesis by A2,Def27;
  end;
  suppose
    ex c,p st len p = len the_arity_of c & e = c-trm p;
    then consider c being constructor OperSymbol of C,
    p being FinSequence of QuasiTerms C such that
A3: len p = len the_arity_of c and
A4: e = c-trm p;
    e = [c, the carrier of C]-tree p by A3,A4,Def35;
    then e.{} = [c, the carrier of C] by TREES_4:def 4;
    then non_op = c by A1,XTUPLE_0:1;
    hence thesis by Def11;
  end;
  suppose
    ex a st e = (non_op C)term a;
    hence thesis;
  end;
  suppose
    ex a,t st e = (ast C)term(a,t);
    then consider a,t such that
A5: e = (ast C)term(a,t);
    e = [ *, the carrier of C]-tree <*a,t*> by A5,Th46;
    then e.{} = [ *, the carrier of C] by TREES_4:def 4;
    hence thesis by A1,XTUPLE_0:1;
  end;
end;

theorem Th58:
  e.{} = [ *, the carrier of C] implies ex a, t st e = (ast C)term(a,t)
proof
  assume
A1: e.{} = [ *, the carrier of C];
  ast C in the carrier' of C;
  then
A2: e.{} in [:the carrier' of C, {the carrier of C}:] by A1,ZFMISC_1:106;
  per cases by Th53;
  suppose
    ex x being variable st e = x-term C;
    hence thesis by A2,Def27;
  end;
  suppose
    ex c,p st len p = len the_arity_of c & e = c-trm p;
    then consider c being constructor OperSymbol of C,
    p being FinSequence of QuasiTerms C such that
A3: len p = len the_arity_of c and
A4: e = c-trm p;
    e = [c, the carrier of C]-tree p by A3,A4,Def35;
    then e.{} = [c, the carrier of C] by TREES_4:def 4;
    then * = c by A1,XTUPLE_0:1;
    hence thesis by Def11;
  end;
  suppose
    ex a being expression of C, an_Adj C st e = (non_op C)term a;
    then consider a being expression of C, an_Adj C such that
A5: e = (non_op C)term a;
    e = [non_op, the carrier of C]-tree <*a*> by A5,Th43;
    then e.{} = [non_op, the carrier of C] by TREES_4:def 4;
    hence thesis by A1,XTUPLE_0:1;
  end;
  suppose
    ex a,t st e = (ast C)term(a,t);
    hence thesis;
  end;
end;

begin :: Quasi-adjectives

reserve a,a9 for expression of C, an_Adj C;

definition
  let C,a;
  func Non a -> expression of C, an_Adj C equals
  :
  Def36: a|<* 0 *> if ex a9 st a = (non_op C)term a9
  otherwise (non_op C)term a;
  coherence
  proof
    thus
    now
      given a9 being expression of C, an_Adj C such that
A1:   a = (non_op C)term a9;
A2:   a = [non_op, the carrier of C]-tree <*a9*> by A1,Th43;
      len <*a9*> = 1 by FINSEQ_1:40;
      then a|<* 0*> = <*a9*>.(0+1) by A2,TREES_4:def 4;
      hence a|<* 0*> is expression of C, an_Adj C by FINSEQ_1:40;
    end;
    thus thesis by Th43;
  end;
  consistency;
end;

definition
  let C,a;
  attr a is positive means
  :
  Def37: not ex a9 st a = (non_op C)term a9;
end;

registration
  let C;
  cluster positive for expression of C, an_Adj C;
  existence
  proof consider m, a being OperSymbol of C such that
    the_result_sort_of m = a_Type and the_arity_of m = {} and
A1: the_result_sort_of a = an_Adj and
A2: the_arity_of a = {} by Def12;
    set X = MSVars C;
    root-tree [a, the carrier of C] in (the Sorts of Free(C, X)).an_Adj by A1
,A2,MSAFREE3:5;
    then reconsider
    v = root-tree [a, the carrier of C] as expression of C, an_Adj C
    by Th41;
    take v;
    given a9 being expression of C, an_Adj C such that
A3: v = (non_op C)term a9;
    v = [non_op, the carrier of C]-tree<*a9*> by A3,Th43;
    then [non_op, the carrier of C] = v.{} by TREES_4:def 4
      .= [a, the carrier of C] by TREES_4:3;
    then a = non_op C by XTUPLE_0:1;
    hence contradiction by A2,Def9;
  end;
end;

theorem Th59:
  for a being positive expression of C, an_Adj C holds Non a = (non_op C)term a
proof
  let a be positive expression of C, an_Adj C;
  not ex a9 being expression of C, an_Adj C st a = (non_op C)term a9 by Def37;
  hence thesis by Def36;
end;

definition
  let C,a;
  attr a is negative means
  :
  Def38: ex a9 st a9 is positive & a = (non_op C)term a9;
end;

registration
  let C;
  let a be positive expression of C, an_Adj C;
  cluster Non a -> negative non positive;
  coherence
  proof
    thus Non a is negative
    proof
      take a;
      thus thesis by Th59; end;
    take a;
    thus thesis by Th59;
  end;
end;

registration
  let C;
  cluster negative non positive for expression of C, an_Adj C;
  existence
  proof set a = the positive expression of C, an_Adj C;
    take Non a;
    thus thesis;
  end;
end;

theorem Th60:
  for a being non positive expression of C, an_Adj C
  ex a9 being expression of C, an_Adj C
  st a = (non_op C)term a9 & Non a = a9
proof
  let a be non positive expression of C, an_Adj C;
  consider a9 being expression of C, an_Adj C such that
A1: a = (non_op C)term a9 by Def37;
A2: a = [non_op, the carrier of C]-tree<*a9*> by A1,Th43;
  take a9;
  len <*a9*> = 1 by FINSEQ_1:40;
  then a|<* 0*> = <*a9*>.(0+1) by A2,TREES_4:def 4
    .= a9 by FINSEQ_1:40;
  hence thesis by A1,Def36;
end;

theorem Th61:
  for a being negative expression of C, an_Adj C
  ex a9 being positive expression of C, an_Adj C
  st a = (non_op C)term a9 & Non a = a9
proof
  let a be negative expression of C, an_Adj C;
  consider a9 being expression of C, an_Adj C such that
A1: a9 is positive and
A2: a = (non_op C)term a9 by Def38;
A3: a = [non_op, the carrier of C]-tree<*a9*> by A2,Th43;
  reconsider a9 as positive expression of C, an_Adj C by A1;
  take a9;
  len <*a9*> = 1 by FINSEQ_1:40;
  then a|<* 0*> = <*a9*>.(0+1) by A3,TREES_4:def 4
    .= a9 by FINSEQ_1:40;
  hence thesis by A2,Def36;
end;

theorem Th62:
  for a being non positive expression of C, an_Adj C
  holds (non_op C)term (Non a) = a
proof
  let a be non positive expression of C, an_Adj C;
  ex a9 being expression of C, an_Adj C st ( a = (non_op C)
  term a9)&( Non a = a9) by Th60;
  hence thesis;
end;

registration
  let C;
  let a be negative expression of C, an_Adj C;
  cluster Non a -> positive;
  coherence
  proof
    ex a9 being positive expression of C, an_Adj C st
    a = (non_op C)term a9 & Non a = a9 by Th61;
    hence thesis;
  end;
end;

definition
  let C,a;
  attr a is regular means
  :
  Def39: a is positive or a is negative;
end;

registration
  let C;
  cluster positive -> regular non negative for expression of C, an_Adj C;
  coherence;
  cluster negative -> regular non positive for expression of C, an_Adj C;
  coherence;
end;

registration
  let C;
  cluster regular for expression of C, an_Adj C;
  existence
  proof
    set a = the positive expression of C, an_Adj C;
    take a;
    thus thesis;
  end;
end;

definition
  let C;
  set X = {a: a is regular};
A1: X c= Union the Sorts of Free(C, MSVars C)
  proof
    let x be object;
    assume x in X;
    then ex a st x = a & a is regular;
    hence thesis;
  end;
  func QuasiAdjs C -> Subset of Free(C, MSVars C) equals
  {a: a is regular};
  coherence by A1;
end;

registration
  let C;
  cluster QuasiAdjs C -> non empty constituted-DTrees;
  coherence
  proof set v = the positive expression of C, an_Adj C;
    v in {a: a is regular};
    hence QuasiAdjs C is non empty;
    let x be object;
    assume x in QuasiAdjs C;
    hence thesis;
  end;
end;

definition
  let C;
  mode quasi-adjective of C is regular expression of C, an_Adj C;
end;

theorem Th63:
  z is quasi-adjective of C iff z in QuasiAdjs C
proof
  z in QuasiAdjs C iff ex a st z = a & a is regular;
  hence thesis;
end;

theorem
  z is quasi-adjective of C iff z is positive expression of C, an_Adj C or
  z is negative expression of C, an_Adj C by Def39;

registration
  let C;
  cluster non positive -> negative for quasi-adjective of C;
  coherence by Def39;
  cluster non negative -> positive for quasi-adjective of C;
  coherence;
end;

registration
  let C;
  cluster positive for quasi-adjective of C;
  existence
  proof set a = the positive expression of C, an_Adj C;
    a is quasi-adjective of C;
    hence thesis;
  end;
  cluster negative for quasi-adjective of C;
  existence
  proof set a = the negative expression of C, an_Adj C;
    a is quasi-adjective of C;
    hence thesis;
  end;
end;

theorem Th65:
  for a being positive quasi-adjective of C
  ex v being constructor OperSymbol of C st the_result_sort_of v = an_Adj C &
  ex p st len p = len the_arity_of v & a = v-trm p
proof
  let e be positive quasi-adjective of C;
  per cases by Th53;
  suppose
    ex x being variable st e = x-term C;
    hence thesis by Th48;
  end;
  suppose
    ex c being constructor OperSymbol of C st
    ex p being FinSequence of QuasiTerms C st
    len p = len the_arity_of c & e = c-trm p;
    then consider c being constructor OperSymbol of C,
    p being FinSequence of QuasiTerms C such that
A1: len p = len the_arity_of c and
A2: e = c-trm p;
    take c;
    e is expression of C, the_result_sort_of c by A1,A2,Th52;
    hence the_result_sort_of c = an_Adj C by Th48;
    take p;
    thus thesis by A1,A2;
  end;
  suppose
    ex a st e = (non_op C)term a;
    hence thesis by Def37;
  end;
  suppose
    ex a,t st e = (ast C)term(a,t);
    then e is expression of C, a_Type C by Th46;
    hence thesis by Th48;
  end;
end;

theorem Th66:
  for v being constructor OperSymbol of C
  st the_result_sort_of v = an_Adj C & len p = len the_arity_of v
  holds v-trm p is positive quasi-adjective of C
proof
  let v be constructor OperSymbol of C such that
A1: the_result_sort_of v = an_Adj C;
  assume
A2: len p = len the_arity_of v;
  then reconsider a = v-trm p as expression of C, an_Adj C by A1,Th52;
  a is positive
  by A2,Th54;
  hence thesis;
end;

registration
  let C;
  let a be quasi-adjective of C;
  cluster Non a -> regular;
  coherence
  proof per cases;
    suppose a is positive;
      then reconsider a9 = a as positive expression of C, an_Adj C;
      Non a9 is negative;
      hence thesis;
    end;
    suppose a is negative;
      then reconsider a9 = a as negative expression of C, an_Adj C;
      Non a9 is positive;
      hence thesis;
    end;
  end;
end;

theorem Th67:
  for a being quasi-adjective of C holds Non Non a = a
proof
  let a be quasi-adjective of C;
  per cases;
  suppose a is positive;
    then reconsider a9 = a as positive expression of C, an_Adj C;
A1: ex b being positive expression of C, an_Adj C st ( Non a9 =
    (non_op C)term b)&( Non Non a9 = b) by Th61;
    Non a9 = (non_op C)term a by Th59;
    hence thesis by A1,Th44;
  end;
  suppose a is negative;
    then reconsider a9 = a as negative expression of C, an_Adj C;
    ex b being positive expression of C, an_Adj C st
    a9 = (non_op C)term b & Non a9 = b by Th61;
    hence thesis by Th59;
  end;
end;

theorem
  for a1,a2 being quasi-adjective of C st Non a1 = Non a2 holds a1 = a2
proof
  let a1,a2 be quasi-adjective of C;
  Non Non a1 = a1 by Th67;
  hence thesis by Th67;
end;

theorem
  for a being quasi-adjective of C holds Non a <> a
proof
  let a be quasi-adjective of C;
  per cases;
  suppose a is positive;
    then reconsider a9 = a as positive quasi-adjective of C;
    Non a9 is negative quasi-adjective of C;
    hence thesis;
  end;
  suppose a is negative;
    then reconsider a9 = a as negative quasi-adjective of C;
    Non a9 is positive quasi-adjective of C;
    hence thesis;
  end;
end;

begin :: Quasi-types

definition
  let C;
  let q be expression of C, a_Type C;
  attr q is pure means
  :
  Def41: not ex a, t st q = (ast C)term(a,t);
end;

theorem Th70:
  for m being OperSymbol of C
  st the_result_sort_of m = a_Type & the_arity_of m = {}
  ex t st t = root-tree [m, the carrier of C] & t is pure
proof
  let m be OperSymbol of C such that
A1: the_result_sort_of m = a_Type and
A2: the_arity_of m = {};
  set X = MSVars C;
  root-tree [m, the carrier of C] in (the Sorts of Free(C, X)).a_Type by A1,A2,
MSAFREE3:5;
  then reconsider
  T = root-tree [m, the carrier of C] as expression of C, a_Type C
  by Th41;
  take T;
  thus T = root-tree [m, the carrier of C];
  given a,t such that
A3: T = (ast C)term(a,t);
  T = [ *, the carrier of C]-tree<*a,t*> by A3,Th46;
  then [ *, the carrier of C] = T.{} by TREES_4:def 4
    .= [m, the carrier of C] by TREES_4:3;
  then m = ast C by XTUPLE_0:1;
  hence contradiction by A2,Def9;
end;

theorem Th71:
  for v being OperSymbol of C
  st the_result_sort_of v = an_Adj & the_arity_of v = {}
  ex a st a = root-tree [v, the carrier of C] & a is positive
proof
  let m be OperSymbol of C such that
A1: the_result_sort_of m = an_Adj and
A2: the_arity_of m = {};
  set X = MSVars C;
  root-tree [m, the carrier of C] in (the Sorts of Free(C, X)).an_Adj
  by A1,A2,MSAFREE3:5;
  then reconsider
  T = root-tree [m, the carrier of C] as expression of C, an_Adj C
  by Th41;
  take T;
  thus T = root-tree [m, the carrier of C];
  given a being expression of C, an_Adj C such that
A3: T = (non_op C)term a;
  T = [non_op, the carrier of C]-tree<*a*> by A3,Th43;
  then [non_op, the carrier of C] = T.{} by TREES_4:def 4
    .= [m, the carrier of C] by TREES_4:3;
  then m = non_op by XTUPLE_0:1;
  hence contradiction by A2,Def9;
end;

registration
  let C;
  cluster pure for expression of C, a_Type C;
  existence
  proof consider m, a being OperSymbol of C such that
A1: the_result_sort_of m = a_Type and
A2: the_arity_of m = {} and
    the_result_sort_of a = an_Adj and the_arity_of a = {} by Def12;
    ex t being expression of C, a_Type C st
    t = root-tree [m, the carrier of C] & t is pure by A1,A2,Th70;
    hence thesis;
  end;
end;

reserve q for pure expression of C, a_Type C,
  A for finite Subset of QuasiAdjs C;

definition
  let C;
  func QuasiTypes C -> set equals
  {[A,t]: t is pure};
  coherence;
end;

registration
  let C;
  cluster QuasiTypes C -> non empty;
  coherence
  proof set q = the pure expression of C, a_Type C;
    {} is finite Subset of QuasiAdjs C by XBOOLE_1:2;
    then [{},q] in {[A,t]: t is pure};
    hence thesis;
  end;
end;

definition
  let C;
  mode quasi-type of C -> set means
    :
    Def43: it in QuasiTypes C;
  existence
  proof set T = the Element of QuasiTypes C;
    take T;
    thus thesis;
  end;
end;

theorem Th72:
  z is quasi-type of C iff ex A,q st z = [A,q]
proof
  z in QuasiTypes C iff ex t,A st z = [A,t] & t is pure;
  hence thesis by Def43;
end;

theorem Th73:
  [x,y] is quasi-type of C iff
  x is finite Subset of QuasiAdjs C & y is pure expression of C, a_Type C
proof
  thus
  now
    assume [x,y] is quasi-type of C;
    then ex A,q st ( [x,y] = [A,q]) by Th72;
    hence x is finite Subset of QuasiAdjs C &
    y is pure expression of C, a_Type C by XTUPLE_0:1;
  end;
  thus thesis by Th72;
end;

reserve T for quasi-type of C;

registration
  let C;
  cluster -> pair for quasi-type of C;
  coherence
  proof
    let x be quasi-type of C;
    ex A,q st x = [A,q] by Th72;
    hence thesis;
  end;
end;

theorem Th74:
  ex m being constructor OperSymbol of C st the_result_sort_of m = a_Type C &
  ex p st len p = len the_arity_of m & q = m-trm p
proof
  set e = q;
  per cases by Th53;
  suppose
    ex x being variable st e = x-term C;
    hence thesis by Th48;
  end;
  suppose
    ex c being constructor OperSymbol of C st
    ex p being FinSequence of QuasiTerms C st
    len p = len the_arity_of c & e = c-trm p;
    then consider c being constructor OperSymbol of C,
    p being FinSequence of QuasiTerms C such that
A1: len p = len the_arity_of c and
A2: e = c-trm p;
    take c;
    e is expression of C, the_result_sort_of c by A1,A2,Th52;
    hence the_result_sort_of c = a_Type C by Th48;
    take p;
    thus thesis by A1,A2;
  end;
  suppose
    ex a st e = (non_op C)term a;
    then e is expression of C, an_Adj C by Th43;
    hence thesis by Th48;
  end;
  suppose
    ex a st ex q being expression of C, a_Type C st e = (ast C)term(a,q);
    hence thesis by Def41;
  end;
end;

theorem Th75:
  for m being constructor OperSymbol of C
  st the_result_sort_of m = a_Type C & len p = len the_arity_of m
  holds m-trm p is pure expression of C, a_Type C
proof
  let v be constructor OperSymbol of C such that
A1: the_result_sort_of v = a_Type C;
  assume
A2: len p = len the_arity_of v;
  then reconsider a = v-trm p as expression of C, a_Type C by A1,Th52;
  a is pure
  by A2,Th55;
  hence thesis;
end;

theorem
  QuasiTerms C misses QuasiAdjs C & QuasiTerms C misses QuasiTypes C &
  QuasiTypes C misses QuasiAdjs C
proof
  set X = MSVars C;
  set Y = X (\/) ((the carrier of C) --> {0});
  ex A being MSSubset of FreeMSA Y st ( Free(C, X) = GenMSAlg
  A)&( A = (Reverse Y)""X) by MSAFREE3:def 1;
  then the Sorts of Free(C, X) is MSSubset of FreeMSA Y by MSUALG_2:def 9;
  then
A1: the Sorts of Free(C, X) c= the Sorts of FreeMSA Y by PBOOLE:def 18;
  then
A2: QuasiTerms C c= (the Sorts of FreeMSA Y).a_Term C;
A3: (the Sorts of Free(C,X)).an_Adj C c= (the Sorts of FreeMSA Y).an_Adj C
  by A1;
  QuasiAdjs C c= (the Sorts of Free(C,X)).an_Adj C
  proof
    let x be object;
    assume x in QuasiAdjs C;
    then ex a st x = a & a is regular;
    hence thesis by Def28;
  end;
  then
A4: QuasiAdjs C c= (the Sorts of FreeMSA Y).an_Adj C by A3;
  (the Sorts of FreeMSA Y).a_Term C misses (the Sorts of FreeMSA Y).an_Adj C
  by PROB_2:def 2;
  hence QuasiTerms C misses QuasiAdjs C by A2,A4,XBOOLE_1:64;
  now
    let x be object;
    assume that
A5: x in QuasiTerms C and
A6: x in QuasiTypes C;
    x is quasi-type of C by A6,Def43;
    hence contradiction by A5;
  end;
  hence QuasiTerms C misses QuasiTypes C by XBOOLE_0:3;
  now
    let x be object;
    assume that
A7: x in QuasiAdjs C and
A8: x in QuasiTypes C;
    x is quasi-type of C by A8,Def43;
    hence contradiction by A7;
  end;
  hence thesis by XBOOLE_0:3;
end;

theorem
  for e being set holds
  (e is quasi-term of C implies e is not quasi-adjective of C) &
  (e is quasi-term of C implies e is not quasi-type of C) &
  (e is quasi-type of C implies e is not quasi-adjective of C)
  by Th48;

notation
  let C,A,q;
  synonym A ast q for [A,q];
end;

definition
  let C,A,q;
  redefine func A ast q -> quasi-type of C;
  coherence by Th73;
end;

registration
  let C,T;
  cluster T`1 -> finite for set;
  coherence
  proof
    ex A,q st T = [A,q] by Th72;
    hence thesis;
  end;
end;

notation
  let C,T;
  synonym adjs T for T`1;
  synonym the_base_of T for T`2;
end;

definition
  let C,T;
  redefine func adjs T -> Subset of QuasiAdjs C;
  coherence
  proof
    ex A,q st T = [A,q] by Th72;
    hence thesis;
  end;
  redefine func the_base_of T -> pure expression of C, a_Type C;
  coherence
  proof
    ex A,q st T = [A,q] by Th72;
    hence thesis;
  end;
end;

theorem
  adjs (A ast q) = A & the_base_of (A ast q) = q;

theorem
  for A1,A2 being finite Subset of QuasiAdjs C
  for q1,q2 being pure expression of C, a_Type C
  st A1 ast q1 = A2 ast q2
  holds A1 = A2 & q1 = q2 by XTUPLE_0:1;

theorem Th80:
  T = (adjs T) ast the_base_of T;

theorem
  for T1,T2 being quasi-type of C
  st adjs T1 = adjs T2 & the_base_of T1 = the_base_of T2
  holds T1 = T2
proof
  let T1,T2 be quasi-type of C;
  T1 = (adjs T1) ast the_base_of T1;
  hence thesis by Th80;
end;

definition
  let C,T;
  let a be quasi-adjective of C;
  func a ast T -> quasi-type of C equals
  [{a} \/ adjs T, the_base_of T];
  coherence
  proof a in QuasiAdjs C;
    then {a} c= QuasiAdjs C by ZFMISC_1:31;
    then {a} \/ adjs T is Subset of QuasiAdjs C by XBOOLE_1:8;
    hence thesis by Th73;
  end;
end;

theorem
  for a being quasi-adjective of C
  holds adjs (a ast T) = {a} \/ adjs T & the_base_of (a ast T) = the_base_of T;

theorem
  for a being quasi-adjective of C holds a ast (a ast T) = a ast T
proof
  let a be quasi-adjective of C;
  thus a ast (a ast T)
  = [{a} \/ ({a} \/ adjs T), the_base_of (a ast T)]
    .= [{a} \/ {a} \/ adjs T, the_base_of (a ast T)] by XBOOLE_1:4
    .= a ast T;
end;

theorem
  for a,b being quasi-adjective of C holds a ast (b ast T) = b ast (a ast T)
by XBOOLE_1:4;

begin :: Variables in quasi-types

registration
  let S be non void Signature;
  let s be SortSymbol of S;
  let X be non-empty ManySortedSet of the carrier of S;
  let t be Term of S,X;
  cluster (variables_in t).s -> finite;
  coherence
  proof
    defpred P[non empty Relation] means
    for s being SortSymbol of S holds (S variables_in $1).s is finite;
    A1: for
 z being SortSymbol of S, v being Element of X.z holds P[root-tree[v,z]]
    proof
      let z be SortSymbol of S, v be Element of X.z;
      let s be SortSymbol of S;
      s = z or s <> z;
      hence thesis by MSAFREE3:10;
    end;
A2: for o being OperSymbol of S, p being ArgumentSeq of Sym(o,X)
    st for t being Term of S,X st t in rng p holds P[t]
    holds P[[o,the carrier of S]-tree p]
    proof
      let o be OperSymbol of S, p be ArgumentSeq of Sym(o,X) such that
A3:   for t being Term of S,X st t in rng p
      for s being SortSymbol of S holds (S variables_in t).s is finite;
      let s be SortSymbol of S;
      deffunc F(Term of S,X) = (S variables_in $1).s;
      set A = {F(q) where q is Term of S,X: q in rng p};
A4:   rng p is finite;
A5:   A is finite from FRAENKEL:sch 21(A4);
      now
        let B be set;
        assume B in A;
        then ex q being Term of S,X st B = (S variables_in q).s & q in rng p;
        hence B is finite by A3;
      end;
      then
A6:   union A is finite by A5,FINSET_1:7;
      (S variables_in ([o,the carrier of S]-tree p)).s c= union A
      proof
        let x be object;
        assume x in (S variables_in ([o,the carrier of S]-tree p)).s;
        then consider t being DecoratedTree such that
A7:     t in rng p and
A8:     x in (S variables_in t).s by MSAFREE3:11;
        consider i being object such that
A9:     i in dom p and
A10:    t = p.i by A7,FUNCT_1:def 3;
        reconsider i as Nat by A9;
        reconsider t = p.i as Term of S,X by A9,MSATERM:22;
        (S variables_in t).s in A by A7,A10;
        hence thesis by A8,A10,TARSKI:def 4;
      end;
      hence thesis by A6;
    end;
    for t being Term of S,X holds P[t] from MSATERM:sch 1(A1,A2);
    hence thesis;
  end;
end;

registration
  let S be non void Signature;
  let s be SortSymbol of S;
  let X be non empty-yielding ManySortedSet of the carrier of S;
  let t be Element of Free(S,X);
  cluster (S variables_in t).s -> finite;
  coherence
  proof
    reconsider t as Term of S, X (\/) ((the carrier of S) --> {0})
                 by MSAFREE3:8;
    (S variables_in t).s = (variables_in t).s;
    hence thesis;
  end;
end;

definition
  let S be non void Signature;
  let X be non empty-yielding ManySortedSet of the carrier of S;
  let s be SortSymbol of S;
  func (X,s) variables_in ->
  Function of Union the Sorts of Free(S,X), bool (X.s) means
  :
  Def45: for t being Element of Free(S,X) holds it.t = (S variables_in t).s;
  uniqueness
  proof
    let f1,f2 be Function of Union the Sorts of Free(S,X), bool (X.s)
    such that
A1: for t being Element of Free(S,X) holds f1.t = (S variables_in t).s and
A2: for t being Element of Free(S,X) holds f2.t = (S variables_in t).s;
    now
      let x be Element of Union the Sorts of Free(S,X);
      reconsider t = x as Element of Free(S,X);
      thus f1.x = (S variables_in t).s by A1
        .= f2.x by A2;
    end;
    hence thesis by FUNCT_2:63;
  end;
  existence
  proof
    defpred P[object,object] means
    ex t being Element of Free(S,X) st t = $1 & $2 = (S variables_in t).s;
A3: now
      let x be object;
      assume x in Union the Sorts of Free(S,X);
      then reconsider t = x as Element of Free(S,X);
      S variables_in t c= X by MSAFREE3:27;
      then (S variables_in t).s c= X.s;
      hence ex y being object st y in bool (X.s) & P[x,y];
    end;
    consider f being Function such that
A4: dom f = Union the Sorts of Free(S,X) & rng f c= bool (X.s) and
A5: for x being object st x in Union the Sorts of Free(S,X) holds P[x, f.x]
    from FUNCT_1:sch 6(A3);
    reconsider f as Function of Union the Sorts of Free(S,X), bool (X.s)
    by A4,FUNCT_2:2;
    take f;
    let x be Element of Free(S,X);
    ex t being Element of Free(S,X) st t = x & f.x = (S variables_in t).s
    by A5;
    hence thesis;
  end;
end;

definition
  let C be initialized ConstructorSignature;
  let e be expression of C;
  func variables_in e -> Subset of Vars equals
  (C variables_in e).a_Term C;
  coherence
  proof
A1: (MSVars C).a_Term C = Vars by Def25;
    C variables_in e c= MSVars C by MSAFREE3:27;
    hence thesis by A1;
  end;
end;

registration
  let C,e;
  cluster variables_in e -> finite;
  coherence;
end;

definition
  let C,e;
  func vars e -> finite Subset of Vars equals
  varcl variables_in e;
  coherence by Th24;
end;

theorem
  varcl vars e = vars e;

theorem
  for x being variable holds variables_in (x-term C) = {x} by MSAFREE3:10;

theorem
  for x being variable holds vars (x-term C) = {x} \/ vars x
proof
  let x be variable;
  thus vars (x-term C) = varcl {x} by MSAFREE3:10
    .= {x} \/ vars x by Th27;
end;

theorem Th88:
  for p being DTree-yielding FinSequence st e = [c, the carrier of C]-tree p
  holds variables_in e =
  union {variables_in t where t is quasi-term of C: t in rng p}
proof
  let p be DTree-yielding FinSequence;
  set X = {variables_in t where t is quasi-term of C: t in rng p};
  assume
A1: e = [c, the carrier of C]-tree p;
  then p in (QuasiTerms C)* by Th51;
  then p is FinSequence of QuasiTerms C by FINSEQ_1:def 11;
  then
A2: rng p c= QuasiTerms C by FINSEQ_1:def 4;
  thus variables_in e c= union X
  proof
    let a be object;
    assume a in variables_in e;
    then consider t being DecoratedTree such that
A3: t in rng p and
A4: a in (C variables_in t).a_Term C by A1,MSAFREE3:11;
    reconsider t as quasi-term of C by A2,A3,Th41;
    variables_in t in X by A3;
    hence thesis by A4,TARSKI:def 4;
  end;
  let a be object;
  assume a in union X;
  then consider Y being set such that
A5: a in Y and
A6: Y in X by TARSKI:def 4;
  ex t being quasi-term of C st Y = variables_in t & t in rng p by A6;
  hence thesis by A1,A5,MSAFREE3:11;
end;

theorem Th89:
  for p being DTree-yielding FinSequence st e = [c, the carrier of C]-tree p
  holds vars e = union {vars t where t is quasi-term of C: t in rng p}
proof
  let p be DTree-yielding FinSequence;
  assume
A1: e = [c, the carrier of C]-tree p;
  set A = {variables_in t where t is quasi-term of C: t in rng p};
  set B = {vars t where t is quasi-term of C: t in rng p};
  per cases;
  suppose
A2: A = {};
    set b = the Element of B;
    now
      assume B <> {};
      then b in B;
      then consider t being quasi-term of C such that
      b = vars t and
A3:   t in rng p;
      variables_in t in A by A3;
      hence contradiction by A2;
    end;
    hence thesis by A1,A2,Th8,Th88,ZFMISC_1:2;
  end;
  suppose A <> {};
    then reconsider A as non empty set;
    set D = the set of all varcl s where s is Element of A;
A4: B c= D
    proof
      let a be object;
      assume a in B;
      then consider t being quasi-term of C such that
A5:   a = vars t and
A6:   t in rng p;
      variables_in t in A by A6;
      then reconsider s = variables_in t as Element of A;
      a = varcl s by A5;
      hence thesis;
    end;
A7: D c= B
    proof
      let a be object;
      assume a in D;
      then consider s being Element of A such that
A8:   a = varcl s;
      s in A;
      then consider t being quasi-term of C such that
A9:   s = variables_in t and
A10:  t in rng p;
      vars t = a by A8,A9;
      hence thesis by A10;
    end;
    thus vars e = varcl union A by A1,Th88
      .= union D by Th10
      .= union B by A4,A7,XBOOLE_0:def 10;
  end;
end;

theorem
  len p = len the_arity_of c implies variables_in (c-trm p) =
  union {variables_in t where t is quasi-term of C: t in rng p}
proof
  assume len p = len the_arity_of c;
  then c-trm p = [c, the carrier of C]-tree p by Def35;
  hence thesis by Th88;
end;

theorem
  len p = len the_arity_of c implies
  vars (c-trm p) = union {vars t where t is quasi-term of C: t in rng p}
proof
  assume len p = len the_arity_of c;
  then c-trm p = [c, the carrier of C]-tree p by Def35;
  hence thesis by Th89;
end;

theorem
  for S being ManySortedSign, o being set holds
  S variables_in ([o, the carrier of S]-tree {}) = EmptyMS the carrier of S
proof
  let S be ManySortedSign, o be set;
  now
    let s be object;
    assume
A1: s in the carrier of S;
    now
      let x be object;
      rng {} = {};
      then x in (S variables_in ([o, the carrier of S]-tree {})).s iff
      ex q being DecoratedTree st q in {} & x in (S variables_in q).s
      by A1,MSAFREE3:11;
      hence x in (S variables_in ([o, the carrier of S]-tree {})).s iff
      x in (EmptyMS the carrier of S).s;
    end;
    hence (S variables_in ([o, the carrier of S]-tree {})).s =
    (EmptyMS the carrier of S).s by TARSKI:2;
  end;
  hence thesis;
end;

theorem Th93:
  for S being ManySortedSign, o being set, t being DecoratedTree holds
  S variables_in ([o, the carrier of S]-tree <*t*>) = S variables_in t
proof
  let S be ManySortedSign, o be set, t be DecoratedTree;
  now
    let s be object;
    assume
A1: s in the carrier of S;
A2: t in {t} by TARSKI:def 1;
    now
      let x be object;
      rng <*t*> = {t} by FINSEQ_1:39;
      then x in (S variables_in ([o, the carrier of S]-tree <*t*>)).s iff
      ex q being DecoratedTree st q in {t} & x in (S variables_in q).s
      by A1,MSAFREE3:11;
      hence
      x in (S variables_in ([o, the carrier of S]-tree <*t*>)).s iff
      x in (S variables_in t).s by A2,TARSKI:def 1;
    end;
    hence (S variables_in ([o, the carrier of S]-tree <*t*>)).s =
    (S variables_in t).s by TARSKI:2;
  end;
  hence thesis;
end;

theorem Th94:
  variables_in ((non_op C)term a) = variables_in a
proof
  (non_op C)term a = [non_op, the carrier of C]-tree <*a*> by Th43;
  hence thesis by Th93;
end;

theorem
  vars ((non_op C)term a) = vars a by Th94;

theorem Th96:
  for S being ManySortedSign, o being set, t1,t2 being DecoratedTree holds
  S variables_in ([o, the carrier of S]-tree <*t1,t2*>)
  = (S variables_in t1) (\/) (S variables_in t2)
proof
  let S be ManySortedSign, o be set, t1,t2 be DecoratedTree;
  now
    let s be object;
    assume
A1: s in the carrier of S;
A2: t1 in {t1,t2} by TARSKI:def 2;
A3: t2 in {t1,t2} by TARSKI:def 2;
    now
      let x be object;
      rng <*t1,t2*> = {t1,t2} by FINSEQ_2:127;
      then
      x in (S variables_in ([o, the carrier of S]-tree <*t1,t2*>)).s iff
      ex q being DecoratedTree st q in {t1,t2} & x in (S variables_in q).s
      by A1,MSAFREE3:11;
      then
      x in (S variables_in ([o, the carrier of S]-tree <*t1,t2*>)).s iff
      x in (S variables_in t1).s or x in (S variables_in t2).s
      by A2,A3,TARSKI:def 2;
      then
      x in (S variables_in ([o, the carrier of S]-tree <*t1,t2*>)).s iff
      x in (S variables_in t1).s \/ (S variables_in t2).s by XBOOLE_0:def 3;
      hence
      x in (S variables_in ([o, the carrier of S]-tree <*t1,t2*>)).s iff
      x in ((S variables_in t1) (\/) (S variables_in t2)).s
      by A1,PBOOLE:def 4;
    end;
    hence (S variables_in ([o, the carrier of S]-tree <*t1,t2*>)).s =
    ((S variables_in t1) (\/) (S variables_in t2)).s by TARSKI:2;
  end;
  hence thesis;
end;

theorem Th97:
  variables_in ((ast C)term(a,t)) = (variables_in a)\/(variables_in t)
proof
  (ast C)term(a,t) = [ *, the carrier of C]-tree <*a,t*> by Th46;
  then variables_in ((ast C)term(a,t))
  = ((C variables_in a)(\/)(C variables_in t)).a_Term by Th96;
  hence thesis by PBOOLE:def 4;
end;

theorem
  vars ((ast C)term(a,t)) = (vars a)\/(vars t)
proof
  thus vars ((ast C)term(a,t))
  = varcl((variables_in a)\/(variables_in t)) by Th97
    .= (vars a)\/(vars t) by Th11;
end;

theorem Th99:
  variables_in Non a = variables_in a proof per cases;
  suppose a is non positive;
    then consider a9 being expression of C, an_Adj C such that
A1: a = (non_op C)term a9 and
A2: Non a = a9 by Th60;
    [non_op C, the carrier of C]-tree<*a9*> = a by A1,Th43;
    hence thesis by A2,Th93;
  end;
  suppose a is positive;
    then Non a = (non_op C)term a by Th59
      .= [non_op, the carrier of C]-tree <*a*> by Th43;
    hence thesis by Th93;
  end;
end;

theorem
  vars Non a = vars a by Th99;

definition
  let C;
  let T be quasi-type of C;
  func variables_in T -> Subset of Vars equals
  (union (((MSVars C, a_Term C) variables_in).:adjs T)) \/
  variables_in the_base_of T;
  coherence
  proof
A1: ((MSVars C, a_Term C) variables_in).:adjs T is Subset of bool Vars by Def25
;
    union bool Vars = Vars by ZFMISC_1:81;
    then (union (((MSVars C, a_Term C) variables_in).:adjs T)) c= Vars
    by A1,ZFMISC_1:77;
    hence thesis by XBOOLE_1:8;
  end;
end;

registration
  let C;
  let T be quasi-type of C;
  cluster variables_in T -> finite;
  coherence
  proof
    now
      let A be set;
      assume A in ((MSVars C, a_Term C) variables_in).:adjs T;
      then consider x being object such that
A1:   x in Union the Sorts of Free(C, MSVars C) and x in adjs T and
A2:   A = ((MSVars C, a_Term C) variables_in).x by FUNCT_2:64;
      reconsider x as expression of C by A1;
      A = (C variables_in x).a_Term C by A2,Def45;
      hence A is finite;
    end;
    then union (((MSVars C, a_Term C) variables_in).:adjs T) is finite
    by FINSET_1:7;
    hence thesis;
  end;
end;

definition
  let C;
  let T be quasi-type of C;
  func vars T -> finite Subset of Vars equals
  varcl variables_in T;
  coherence by Th24;
end;

theorem
  for T being quasi-type of C holds varcl vars T = vars T;

theorem Th102:
  for T being quasi-type of C for a being quasi-adjective of C holds
  variables_in (a ast T) = (variables_in a) \/ (variables_in T)
proof
  let T be quasi-type of C;
  let a be quasi-adjective of C;
A1: dom ((MSVars C, a_Term C) variables_in)
  = Union the Sorts of Free(C, MSVars C) by FUNCT_2:def 1;
  thus variables_in (a ast T)
  = (union (((MSVars C, a_Term C) variables_in).:adjs(a ast T)))
  \/ variables_in the_base_of T
    .= (union (((MSVars C, a_Term C) variables_in).:({a} \/ adjs T)))
  \/ variables_in the_base_of T
    .= (union ((((MSVars C, a_Term C) variables_in).:{a}) \/
  (((MSVars C, a_Term C) variables_in).:adjs T)))
  \/ variables_in the_base_of T by RELAT_1:120
    .= (union (((MSVars C, a_Term C) variables_in).:{a})) \/
  (union (((MSVars C, a_Term C) variables_in).:adjs T))
  \/ variables_in the_base_of T by ZFMISC_1:78
    .= (union (Im((MSVars C, a_Term C) variables_in,a))) \/
  variables_in T by XBOOLE_1:4
    .= (union {((MSVars C, a_Term C) variables_in).a}) \/
  variables_in T by A1,FUNCT_1:59
    .= (((MSVars C, a_Term C) variables_in).a) \/
  variables_in T by ZFMISC_1:25
    .= (variables_in a) \/ variables_in T by Def45;
end;

theorem
  for T being quasi-type of C for a being quasi-adjective of C holds
  vars (a ast T) = (vars a) \/ (vars T)
proof
  let T be quasi-type of C;
  let a be quasi-adjective of C;
  thus vars (a ast T) = varcl((variables_in a)\/variables_in T) by Th102
    .= (vars a) \/ vars T by Th11;
end;

theorem Th104:
  variables_in (A ast q) =
  (union {variables_in a where a is quasi-adjective of C: a in A}) \/
  (variables_in q)
proof
  set X = ((MSVars C, a_Term C) variables_in).:A;
  set Y = {variables_in a where a is quasi-adjective of C: a in A};
A1: X c= Y
  proof
    let z be object;
    assume z in X;
    then consider a being object such that
    a in dom ((MSVars C, a_Term C) variables_in) and
A2: a in A and
A3: z = ((MSVars C, a_Term C) variables_in).a by FUNCT_1:def 6;
    reconsider a as quasi-adjective of C by A2,Th63;
    z = variables_in a by A3,Def45;
    hence thesis by A2;
  end;
A4: Y c= X
  proof
    let z be object;
    assume z in Y;
    then consider a being quasi-adjective of C such that
A5: z = variables_in a and
A6: a in A;
A7: z = ((MSVars C, a_Term C) variables_in).a by A5,Def45;
    dom ((MSVars C, a_Term C) variables_in) = Union the Sorts of Free(C,
    MSVars C) by FUNCT_2:def 1;
    hence thesis by A6,A7,FUNCT_1:def 6;
  end;
  thus variables_in (A ast q)
  = (union (((MSVars C, a_Term C) variables_in).:adjs(A ast q)))
  \/ variables_in q
    .= (union (((MSVars C, a_Term C) variables_in).:A))
  \/ variables_in q
    .= (union {variables_in a where a is quasi-adjective of C: a in A})
  \/ (variables_in q) by A1,A4,XBOOLE_0:def 10;
end;

theorem
  vars (A ast q) =
  (union {vars a where a is quasi-adjective of C: a in A}) \/ (vars q)
proof
  set X = {variables_in a where a is quasi-adjective of C: a in A};
  set Y = {vars a where a is quasi-adjective of C: a in A};
A1: union X c= union Y
  proof
    let x be object;
    assume x in union X;
    then consider Z being set such that
A2: x in Z and
A3: Z in X by TARSKI:def 4;
    consider a being quasi-adjective of C such that
A4: Z = variables_in a and
A5: a in A by A3;
A6: Z c= vars a by A4,Def1;
    vars a in Y by A5;
    hence thesis by A2,A6,TARSKI:def 4;
  end;
  for x,y st [x,y] in union Y holds x c= union Y
  proof
    let x,y;
    assume [x,y] in union Y;
    then consider Z being set such that
A7: [x,y] in Z and
A8: Z in Y by TARSKI:def 4;
    ex a being quasi-adjective of C st ( Z = vars a)&( a in A) by A8;
    then
A9: x c= Z by A7,Def1;
    Z c= union Y by A8,ZFMISC_1:74;
    hence thesis by A9;
  end;
  then
A10: varcl union X c= union Y by A1,Def1;
A11: union Y c= varcl union X
  proof
    let x be object;
    assume x in union Y;
    then consider Z being set such that
A12: x in Z and
A13: Z in Y by TARSKI:def 4;
    consider a being quasi-adjective of C such that
A14: Z = vars a and
A15: a in A by A13;
    variables_in a in X by A15;
    then vars a c= varcl union X by Th9,ZFMISC_1:74;
    hence thesis by A12,A14;
  end;
  thus vars (A ast q) = varcl((union X) \/ (variables_in q)) by Th104
    .= (varcl union X) \/ (vars q) by Th11
    .= (union Y) \/ (vars q) by A10,A11,XBOOLE_0:def 10;
end;

theorem Th106:
  variables_in (({}QuasiAdjs C) ast q) = variables_in q
proof
  set A = {}QuasiAdjs C;
  set AA = {variables_in a where a is quasi-adjective of C: a in A};
  AA c= {}
  proof
    let x be object;
    assume x in AA;
    then ex a being quasi-adjective of C st x = variables_in a & a in A;
    hence thesis;
  end;
  then
A1: AA = {};
  variables_in (A ast q) = (union AA) \/ (variables_in q) by Th104;
  hence thesis by A1,ZFMISC_1:2;
end;

theorem Th107:
  e is ground iff variables_in e = {}
proof
  thus e is ground implies variables_in e = {}
  by Th1,XBOOLE_1:3;
  assume that
A1: variables_in e = {} and
A2: Union (C variables_in e) <> {};
  set x = the Element of Union (C variables_in e);
A3: ex y being object st ( y in dom (C variables_in e))&( x in (C
  variables_in e).y) by A2,CARD_5:2;
A4: dom (C variables_in e) = the carrier of C by PARTFUN1:def 2
    .= {a_Type, an_Adj, a_Term} by Def9;
A5: C variables_in e c= MSVars C by MSAFREE3:27;
A6: (MSVars C).an_Adj = {} by Def25;
A7: (MSVars C).a_Type = {} by Def25;
A8: (C variables_in e).an_Adj C c= {} by A5,A6;
  (C variables_in e).a_Type C c= {} by A5,A7;
  hence thesis by A1,A3,A4,A8,ENUMSET1:def 1;
end;

definition
  let C;
  let T be quasi-type of C;
  attr T is ground means
  :
  Def50: variables_in T = {};
end;

registration
  let C;
  cluster ground pure for expression of C, a_Type C;
  existence
  proof
    consider m, a being OperSymbol of C such that
A1: the_result_sort_of m = a_Type and
A2: the_arity_of m = {} and
    the_result_sort_of a = an_Adj and the_arity_of a = {} by Def12;
    root-tree [m, the carrier of C] in
    (the Sorts of Free(C,MSVars C)).a_Type C by A1,A2,MSAFREE3:5;
    then reconsider
    mm = root-tree [m, the carrier of C] as expression of C, a_Type C
    by Th41;
    take mm;
    set p = <*>Union the Sorts of Free(C, MSVars C);
A3: mm = [m, the carrier of C]-tree p by TREES_4:20;
A4: m <> * by A2,Def9;
    m <> non_op by A1,Def9;
    then
A5: m is constructor by A4;
    variables_in mm c= {}
    proof
      let x be object;
      assume x in variables_in mm;
      then
      x in union {variables_in t where t is quasi-term of C: t in rng p}
      by A3,A5,Th88;
      then consider Y such that
      x in Y and
A6:   Y in {variables_in t where t is quasi-term of C: t in rng p}
      by TARSKI:def 4;
      ex t being quasi-term of C st Y = variables_in t & t in rng p by A6;
      hence thesis;
    end;
    then variables_in mm = {};
    hence mm is ground by Th107;
    ex t being expression of C, a_Type C st
    t = root-tree [m, the carrier of C] & t is pure by A1,A2,Th70;
    hence thesis;
  end;
  cluster ground for quasi-adjective of C;
  existence
  proof
    consider m, a being OperSymbol of C such that
    the_result_sort_of m = a_Type and the_arity_of m = {} and
A7: the_result_sort_of a = an_Adj and
A8: the_arity_of a = {} by Def12;
    consider mm being expression of C, an_Adj C such that
A9: mm = root-tree [a, the carrier of C] and
A10: mm is positive by A7,A8,Th71;
    reconsider mm as quasi-adjective of C by A10;
    take mm;
    set p = <*>Union the Sorts of Free(C, MSVars C);
A11: mm = [a, the carrier of C]-tree p by A9,TREES_4:20;
A12: a <> * by A7,Def9;
    a <> non_op by A8,Def9;
    then
A13: a is constructor by A12;
    variables_in mm c= {}
    proof
      let x be object;
      assume x in variables_in mm;
      then x in union {variables_in t where t is quasi-term of C: t in rng p}
      by A11,A13,Th88;
      then consider Y such that
      x in Y and
A14:  Y in {variables_in t where t is quasi-term of C: t in rng p}
      by TARSKI:def 4;
      ex t being quasi-term of C st Y = variables_in t & t in rng p by A14;
      hence thesis;
    end;
    then variables_in mm = {};
    hence thesis by Th107;
  end;
end;

theorem Th108:
  for t being ground pure expression of C, a_Type C
  holds ({} QuasiAdjs C) ast t is ground
proof
  let t be ground pure expression of C, a_Type C;
  set T = ({} QuasiAdjs C) ast t;
  thus variables_in T = variables_in t by Th106
    .= {} by Th107;
end;

registration
  let C;
  let t be ground pure expression of C, a_Type C;
  cluster ({} QuasiAdjs C) ast t -> ground for quasi-type of C;
  coherence by Th108;
end;

registration
  let C;
  cluster ground for quasi-type of C;
  existence
  proof
    set t = the ground pure expression of C, a_Type C;
    take ({} QuasiAdjs C) ast t;
    thus thesis;
  end;
end;

registration
  let C;
  let T be ground quasi-type of C;
  let a be ground quasi-adjective of C;
  cluster a ast T -> ground;
  coherence
  proof
    thus variables_in(a ast T) = (variables_in a)\/variables_in T by Th102
      .= {}\/variables_in T by Th107
      .= {} by Def50;
  end;
end;

begin :: Smooth Type Widening
:: Type widening is smooth iff
::  vars-function is sup-semilattice homomorphism from widening sup-semilattice
::   into VarPoset

definition
  func VarPoset -> strict non empty Poset equals
  (InclPoset the set of all varcl A where A is finite Subset of Vars)opp;
  coherence
  proof set A0 = the finite Subset of Vars;
    set V = the set of all varcl A where A is finite Subset of Vars;
    varcl A0 in V;
    then reconsider V as non empty set;
    reconsider P = InclPoset V as non empty Poset;
    P opp is non empty;
    hence thesis;
  end;
end;

theorem Th109:
  for x, y being Element of VarPoset holds x <= y iff y c= x
proof
  let x, y be Element of VarPoset;
  set V = the set of all varcl A where A is finite Subset of Vars;
  set A0 = the finite Subset of Vars;
  varcl A0 in V;
  then reconsider V as non empty set;
  reconsider a = x, b = y as Element of (InclPoset V) opp;
  x <= y iff ~a >= ~b by YELLOW_7:1;
  hence thesis by YELLOW_1:3;
end;

:: registration
::   let V1,V2 be Element of VarPoset;
::   identify V1 <= V2 with V2 c= V1;
::   compatibility by Th22;
:: end;

theorem Th110:
  for x holds
  x is Element of VarPoset iff x is finite Subset of Vars & varcl x = x
proof
  let x;
  set V = the set of all varcl A where A is finite Subset of Vars;
  set A0 = the finite Subset of Vars;
  varcl A0 in V;
  then reconsider V as non empty set;
  the carrier of InclPoset V = V by YELLOW_1:1;
  then x is Element of VarPoset iff x in V;
  then x is Element of VarPoset iff
  ex A being finite Subset of Vars st x = varcl A;
  hence thesis by Th24;
end;

registration
  cluster VarPoset -> with_infima with_suprema;
  coherence
  proof
    set V = the set of all varcl A where A is finite Subset of Vars;
    set A0 = the finite Subset of Vars;
    varcl A0 in V;
    then reconsider V as non empty set;
    now
      let x,y;
      assume x in V;
      then consider A1 being finite Subset of Vars such that
A1:   x = varcl A1;
      assume y in V;
      then consider A2 being finite Subset of Vars such that
A2:   y = varcl A2;
      x \/ y = varcl (A1 \/ A2) by A1,A2,Th11;
      hence x \/ y in V;
    end;
    then InclPoset V is with_suprema by YELLOW_1:11;
    hence VarPoset is with_infima by LATTICE3:10;
    now
      let x,y;
      assume x in V;
      then consider A1 being finite Subset of Vars such that
A3:   x = varcl A1;
      assume y in V;
      then consider A2 being finite Subset of Vars such that
A4:   y = varcl A2;
      reconsider V1 = varcl A1, V2 = varcl A2 as finite Subset of Vars by Th24;
      x /\ y = varcl (V1 /\ V2) by A3,A4,Th13;
      hence x /\ y in V;
    end;
    then InclPoset V is with_infima by YELLOW_1:12;
    hence thesis by YELLOW_7:16;
  end;
end;

theorem Th111:
  for V1, V2 being Element of VarPoset holds
  V1 "\/" V2 = V1 /\ V2 & V1 "/\" V2 = V1 \/ V2
proof
  let V1, V2 be Element of VarPoset;
  set V = the set of all varcl A where A is finite Subset of Vars;
  set A0 = the finite Subset of Vars;
  varcl A0 in V;
  then reconsider V as non empty set;
A1: VarPoset = (InclPoset V) opp;
A2: the carrier of InclPoset V = V by YELLOW_1:1;
  reconsider v1 = V1, v2 = V2 as Element of (InclPoset V) opp;
  reconsider a1 = V1, a2 = V2 as Element of InclPoset V;
  V1 in V by A2;
  then consider A1 being finite Subset of Vars such that
A3: V1 = varcl A1;
  V2 in V by A2;
  then consider A2 being finite Subset of Vars such that
A4: V2 = varcl A2;
A5: a1~ = v1;
A6: a2~ = v2;
A7: InclPoset V is with_infima with_suprema by A1,LATTICE3:10,YELLOW_7:16;
  reconsider x1 = V1, x2 = V2 as finite Subset of Vars by A3,A4,Th24;
  V1 /\ V2 = varcl (x1 /\ x2) by A3,A4,Th13;
  then V1 /\ V2 in V;
  then a1 "/\" a2 = V1 /\ V2 by YELLOW_1:9;
  hence V1 "\/" V2 = V1 /\ V2 by A5,A6,A7,YELLOW_7:21;
  V1 \/ V2 = varcl (A1 \/ A2) by A3,A4,Th11;
  then a1 \/ a2 in V;
  then a1 "\/" a2 = V1 \/ V2 by YELLOW_1:8;
  hence thesis by A5,A6,A7,YELLOW_7:23;
end;

registration
  let V1,V2 be Element of VarPoset;
  identify V1 "\/" V2 with V1 /\ V2;
  compatibility by Th111;
  identify V1 "/\" V2 with V1 \/ V2;
  compatibility by Th111;
end;

theorem Th112:
  for X being non empty Subset of VarPoset holds
  ex_sup_of X, VarPoset & sup X = meet X
proof
  let X be non empty Subset of VarPoset;
  set a = the Element of X;
A1: meet X c= a by SETFAM_1:3;
A2: a is finite Subset of Vars by Th110;
  then
A3: meet X c= Vars by A1,XBOOLE_1:1;
  for a being Element of X holds varcl a = a by Th110;
  then varcl meet X = meet X by Th12;
  then reconsider m = meet X as Element of VarPoset by A1,A2,A3,Th110;
A4: now
    thus X is_<=_than m
    by SETFAM_1:3,Th109;
    let b be Element of VarPoset;
    assume
A5: X is_<=_than b;
    for Y st Y in X holds b c= Y by Th109,A5;
    then b c= m by SETFAM_1:5;
    hence m <= b by Th109;
  end;
  hence ex_sup_of X, VarPoset by YELLOW_0:15;
  hence thesis by A4,YELLOW_0:def 9;
end;

registration
  cluster VarPoset -> up-complete;
  coherence
  proof
    for X being non empty directed Subset of VarPoset
    holds ex_sup_of X, VarPoset by Th112;
    hence thesis by WAYBEL_0:75;
  end;
end;

theorem
  Top VarPoset = {}
proof
  set V = the set of all varcl A where A is finite Subset of Vars;
A1: {} Vars in V by Th8;
A2: VarPoset opp is lower-bounded by YELLOW_7:31;
  (Bottom InclPoset V)~ = {} by A1,YELLOW_1:13;
  hence thesis by A2,YELLOW_7:33;
end;

definition
  let C;
  func vars-function C -> Function of QuasiTypes C, the carrier of VarPoset
  means
  for T being quasi-type of C holds it.T = vars T;
  uniqueness
  proof
    let f1,f2 be Function of QuasiTypes C, the carrier of VarPoset such
    that
A1: for T being quasi-type of C holds f1.T = vars T and
A2: for T being quasi-type of C holds f2.T = vars T;
    now
      let T be Element of QuasiTypes C;
      reconsider t = T as quasi-type of C by Def43;
      thus f1.T = vars t by A1
        .= f2.T by A2;
    end;
    hence thesis by FUNCT_2:63;
  end;
  existence
  proof
    defpred P[object,object] means
    ex T being quasi-type of C st $1 = T & $2 = vars T;
A3: for x being object st x in QuasiTypes C
     ex y being object st P[x,y]
    proof
      let x be object;
      assume x in QuasiTypes C;
      then reconsider T = x as quasi-type of C by Def43;
      take vars T, T;
      thus thesis;
    end;
    consider f being Function such that
A4: dom f = QuasiTypes C and
A5: for x being object st x in QuasiTypes C holds P[x,f.x]
         from CLASSES1:sch 1(A3);
    rng f c= the carrier of VarPoset
    proof
      let y be object;
      assume y in rng f;
      then consider x being object such that
A6:   x in dom f and
A7:   y = f.x by FUNCT_1:def 3;
      consider T being quasi-type of C such that
      x = T and
A8:   y = vars T by A4,A5,A6,A7;
      varcl vars T = vars T;
      then y is Element of VarPoset by A8,Th110;
      hence thesis;
    end;
    then reconsider f as Function of QuasiTypes C, the carrier of VarPoset
    by A4,FUNCT_2:2;
    take f;
    let x be quasi-type of C;
    x in QuasiTypes C by Def43;
    then ex T being quasi-type of C st x = T & f.x = vars T by A5;
    hence thesis;
  end;
end;

definition
  let L be non empty Poset;
  attr L is smooth means
  ex C being initialized ConstructorSignature,
  f being Function of L, VarPoset st
  the carrier of L c= QuasiTypes C &
  f = (vars-function C)|the carrier of L &
  for x,y being Element of L holds f preserves_sup_of {x,y};
end;

registration
  let C be initialized ConstructorSignature;
  let T be ground quasi-type of C;
  cluster RelStr(#{T}, id {T}#) -> smooth;
  coherence
  proof
    set L = RelStr(#{T}, id {T}#);
A1: T in QuasiTypes C by Def43;
    then {T} c= QuasiTypes C by ZFMISC_1:31;
    then reconsider f = (vars-function C)|{T} as Function of L, VarPoset
    by FUNCT_2:32;
    take C, f;
    thus the carrier of L c= QuasiTypes C by A1,ZFMISC_1:31;
    thus f = (vars-function C)|the carrier of L;
    let x,y be Element of L;
    set F = {x,y};
    assume ex_sup_of F, L;
A2: x = T by TARSKI:def 1;
    y = T by TARSKI:def 1;
    then
A3: F = {T} by A2,ENUMSET1:29;
    dom f = {T} by FUNCT_2:def 1;
    then
A4: Im(f,T) = {f.x} by A2,FUNCT_1:59;
    hence ex_sup_of f.:F, VarPoset by A3,YELLOW_0:38;
    thus sup (f.:F) = f.x by A3,A4,YELLOW_0:39
      .= f.sup F by A2,TARSKI:def 1;
  end;
end;

begin :: Structural induction

scheme StructInd
  {C() -> initialized ConstructorSignature, P[set], t() -> expression of C()}:
  P[t()]
provided
A1: for x being variable holds P[x-term C()] and
A2: for c being constructor OperSymbol of C()
for p being FinSequence of QuasiTerms C()
st len p = len the_arity_of c &
for t being quasi-term of C() st t in rng p holds P[t]
holds P[c-trm p] and
A3: for a being expression of C(), an_Adj C() st P[a]
holds P[(non_op C())term a] and
A4: for a being expression of C(), an_Adj C() st P[a]
for t being expression of C(), a_Type C() st P[t]
holds P[(ast C())term(a,t)]
proof
  defpred Q[set] means $1 is expression of C() implies P[ $1 ];
  set X = MSVars C();
  set V = X (\/) ((the carrier of C())-->{0});
  set S = C(), C = C();
A5: t() is Term of S,V by MSAFREE3:8;
A6: for s being SortSymbol of S, v being Element of V.s
  holds Q[root-tree [v,s]]
  proof
    let s be SortSymbol of S;
    let v be Element of V.s;
    set t = root-tree [v,s];
    assume
A7: t is expression of S;
A8: t.{} = [v,s] by TREES_4:3;
A9: s in the carrier of C;
A10: (t.{})`2 = s by A8;
A11: s <> the carrier of C by A9;
    per cases by A7,Th53;
    suppose ex x being variable st t = x-term C;
      hence thesis by A1;
    end;
    suppose ex c being constructor OperSymbol of C st
      ex p being FinSequence of QuasiTerms C st
      len p = len the_arity_of c & t = c-trm p;
      then consider c being constructor OperSymbol of C,
      p being FinSequence of QuasiTerms C such that
A12:  len p = len the_arity_of c and
A13:  t = c-trm p;
      t = [c, the carrier of C]-tree p by A12,A13,Def35;
      then t.{} = [c, the carrier of C] by TREES_4:def 4;
      hence thesis by A10,A11;
    end;
    suppose
      ex a being expression of C(), an_Adj C() st t = (non_op C)term a;
      then consider a being expression of C(), an_Adj C() such that
A14:  t = (non_op C)term a;
A15:  the_arity_of non_op C = <*an_Adj C*> by Def9;
A16:  <*an_Adj C*>.1 = an_Adj C by FINSEQ_1:40;
      len <*an_Adj C*> = 1 by FINSEQ_1:40;
      then t = [non_op C, the carrier of C]-tree<*a*> by A14,A15,A16,Def30;
      then t.{} = [non_op C, the carrier of C] by TREES_4:def 4;
      hence thesis by A10,A11;
    end;
    suppose ex a being expression of C(), an_Adj C() st
      ex q being expression of C, a_Type C st t = (ast C)term(a,q);
      then consider a being expression of C, an_Adj C,
      q being expression of C, a_Type C such that
A17:  t = (ast C)term(a,q);
A18:  the_arity_of ast C = <*an_Adj C,a_Type C*> by Def9;
A19:  <*an_Adj C,a_Type C*>.1 = an_Adj C by FINSEQ_1:44;
A20:  <*an_Adj C,a_Type C*>.2 = a_Type C by FINSEQ_1:44;
      len <*an_Adj C,a_Type C*> = 2 by FINSEQ_1:44;
      then t = [ast C, the carrier of C]-tree<*a,q*> by A17,A18,A19,A20,Def31;
      then t.{} = [ast C, the carrier of C] by TREES_4:def 4;
      hence thesis by A10,A11;
    end;
  end;
A21: for o being OperSymbol of S, p being ArgumentSeq of Sym(o,V) st
  for t being Term of S,V st t in rng p holds Q[t]
  holds Q[[o,the carrier of S]-tree p]
  proof
    let o be OperSymbol of S;
    let p be ArgumentSeq of Sym(o,V) such that
A22: for t being Term of S,V st t in rng p holds Q[t];
    set t = [o,the carrier of S]-tree p;
    assume
A23: t is expression of S;
    per cases by A23,Th53;
    suppose ex x being variable st t = x-term C;
      hence thesis by A1;
    end;
    suppose ex c being constructor OperSymbol of C st
      ex p being FinSequence of QuasiTerms C st
      len p = len the_arity_of c & t = c-trm p;
      then consider c being constructor OperSymbol of C,
      q being FinSequence of QuasiTerms C such that
A24:  len q = len the_arity_of c and
A25:  t = c-trm q;
      t = [c, the carrier of C]-tree q by A24,A25,Def35;
      then
A26:  p = q by TREES_4:15;
      now
        let t be quasi-term of C;
        t is Term of S,V by MSAFREE3:8;
        hence t in rng q implies P[t] by A22,A26;
      end;
      hence thesis by A2,A24,A25;
    end;
    suppose
      ex a being expression of C(), an_Adj C() st t = (non_op C)term a;
      then consider a being expression of C(), an_Adj C() such that
A27:  t = (non_op C)term a;
A28:  the_arity_of non_op C = <*an_Adj C*> by Def9;
A29:  <*an_Adj C*>.1 = an_Adj C by FINSEQ_1:40;
      len <*an_Adj C*> = 1 by FINSEQ_1:40;
      then t = [non_op C, the carrier of C]-tree<*a*> by A27,A28,A29,Def30;
      then
A30:  p = <*a*> by TREES_4:15;
A31:  rng <*a*> = {a} by FINSEQ_1:39;
A32:  a in {a} by TARSKI:def 1;
      a is Term of S,V by MSAFREE3:8;
      hence thesis by A3,A22,A27,A30,A31,A32;
    end;
    suppose ex a being expression of C(), an_Adj C() st
      ex q being expression of C, a_Type C st t = (ast C)term(a,q);
      then consider a being expression of C, an_Adj C,
      q being expression of C, a_Type C such that
A33:  t = (ast C)term(a,q);
A34:  the_arity_of ast C = <*an_Adj C,a_Type C*> by Def9;
A35:  <*an_Adj C,a_Type C*>.1 = an_Adj C by FINSEQ_1:44;
A36:  <*an_Adj C,a_Type C*>.2 = a_Type C by FINSEQ_1:44;
      len <*an_Adj C,a_Type C*> = 2 by FINSEQ_1:44;
      then t = [ast C, the carrier of C]-tree<*a,q*> by A33,A34,A35,A36,Def31;
      then
A37:  p = <*a,q*> by TREES_4:15;
A38:  rng <*a,q*> = {a,q} by FINSEQ_2:127;
A39:  a in {a,q} by TARSKI:def 2;
A40:  q in {a,q} by TARSKI:def 2;
A41:  a is Term of S,V by MSAFREE3:8;
A42:  q is Term of S,V by MSAFREE3:8;
      P[a] by A22,A37,A38,A39,A41;
      hence thesis by A4,A22,A33,A37,A38,A40,A42;
    end;
  end;
  for t being Term of S,V holds Q[t] from MSATERM:sch 1(A6,A21);
  hence thesis by A5;
end;

definition
  let S be ManySortedSign;
  attr S is with_an_operation_for_each_sort means
  :
  Def54: the carrier of S c= rng the ResultSort of S;
  let X be ManySortedSet of the carrier of S;
  attr X is with_missing_variables means
   X"{{}} c= rng the ResultSort of S;
end;

theorem Th114:
  for S being non void Signature for X being ManySortedSet of the carrier of S
  holds X is with_missing_variables iff
  for s being SortSymbol of S st X.s = {}
  ex o being OperSymbol of S st the_result_sort_of o = s
proof
  let S be non void Signature;
  let X be ManySortedSet of the carrier of S;
A1: dom X = the carrier of S by PARTFUN1:def 2;
  hereby
    assume X is with_missing_variables;
    then
A2: X"{{}} c= rng the ResultSort of S;
    let s be SortSymbol of S;
    assume X.s = {};
    then X.s in {{}} by TARSKI:def 1;
    then s in X"{{}} by A1,FUNCT_1:def 7;
    then consider o being object such that
A3: o in the carrier' of S and
A4: (the ResultSort of S).o = s by A2,FUNCT_2:11;
    reconsider o as OperSymbol of S by A3;
    take o;
    thus the_result_sort_of o = s by A4;
  end;
  assume
A5: for s being SortSymbol of S st X.s = {}
  ex o being OperSymbol of S st the_result_sort_of o = s;
  let x be object;
  assume
A6: x in X"{{}};
  then
A7: X.x in {{}} by FUNCT_1:def 7;
  reconsider x as SortSymbol of S by A1,A6,FUNCT_1:def 7;
  X.x = {} by A7,TARSKI:def 1;
  then ex o being OperSymbol of S st the_result_sort_of o = x by A5;
  hence thesis by FUNCT_2:4;
end;

registration
  cluster MaxConstrSign -> with_an_operation_for_each_sort;
  coherence
  proof
    set C = MaxConstrSign;
    set m = [a_Type, [{}, 0]], a = [an_Adj, [{}, 0]], f = [a_Term, [{}, 0]];
A1: a_Type in {a_Type} by TARSKI:def 1;
A2: an_Adj in {an_Adj} by TARSKI:def 1;
A3: a_Term in {a_Term} by TARSKI:def 1;
A4: [<*> Vars, 0] in [:QuasiLoci, NAT:] by Th29,ZFMISC_1:def 2;
    then
A5: m in Modes by A1,ZFMISC_1:def 2;
A6: a in Attrs by A2,A4,ZFMISC_1:def 2;
A7: f in Funcs by A3,A4,ZFMISC_1:def 2;
A8: m in Modes \/ Attrs by A5,XBOOLE_0:def 3;
A9: a in Modes \/ Attrs by A6,XBOOLE_0:def 3;
A10: m in Constructors by A8,XBOOLE_0:def 3;
A11: a in Constructors by A9,XBOOLE_0:def 3;
A12: f in Constructors by A7,XBOOLE_0:def 3;
    the carrier' of MaxConstrSign = {*, non_op} \/ Constructors by Def24;
    then reconsider m,a,f as OperSymbol of MaxConstrSign by A10,A11,A12,
XBOOLE_0:def 3;
A13: m is constructor;
A14: a is constructor;
A15: f is constructor;
A16: (the ResultSort of C).m = m`1 by A13,Def24;
A17: (the ResultSort of C).a = a`1 by A14,Def24;
A18: (the ResultSort of C).f = f`1 by A15,Def24;
A19: (the ResultSort of C).m = a_Type by A16;
A20: (the ResultSort of C).a = an_Adj by A17;
A21: (the ResultSort of C).f = a_Term by A18;
A22: the carrier of C = {a_Type, an_Adj, a_Term} by Def9;
    let x be object;
    assume x in the carrier of C;
    then x = a_Type or x = an_Adj or x = a_Term by A22,ENUMSET1:def 1;
    hence thesis by A19,A20,A21,FUNCT_2:4;
  end;
  let C be ConstructorSignature;
  cluster MSVars C -> with_missing_variables;
  coherence
  proof
    set X = MSVars C;
    let x be object;
    assume
A23: x in X"{{}};
    then
A24: x in dom X by FUNCT_1:def 7;
A25: X.x in {{}} by A23,FUNCT_1:def 7;
    x in the carrier of C by A24;
    then x in {a_Type, an_Adj, a_Term} by Def9;
    then
A26: x = a_Type or x = an_Adj or x = a_Term by ENUMSET1:def 1;
A27: X.x = {} by A25,TARSKI:def 1;
A28: (the ResultSort of C).(ast C) = a_Type by Def9;
    (the ResultSort of C).(non_op C) = an_Adj by Def9;
    hence thesis by A26,A27,A28,Def25,FUNCT_2:4;
  end;
end;

registration
  let S be ManySortedSign;
  cluster non-empty -> with_missing_variables
    for ManySortedSet of the carrier of S;
  coherence
  proof
    let X be ManySortedSet of the carrier of S such that
A1: X is non-empty;
    let x be object;
    assume
A2: x in X"{{}};
    then
A3: x in dom X by FUNCT_1:def 7;
A4: X.x in {{}} by A2,FUNCT_1:def 7;
A5: X.x in rng X by A3,FUNCT_1:def 3;
    X.x = {} by A4,TARSKI:def 1;
    hence thesis by A1,A5;
  end;
end;

registration
  let S be ManySortedSign;
  cluster with_missing_variables for ManySortedSet of the carrier of S;
  existence
  proof
    set A = the non-empty ManySortedSet of the carrier of S;
    take A;
    thus thesis;
  end;
end;

registration
  cluster initialized with_an_operation_for_each_sort
    strict for ConstructorSignature;
  existence
  proof
    take MaxConstrSign;
    thus thesis;
  end;
end;

registration
  let C be with_an_operation_for_each_sort ManySortedSign;
  cluster -> with_missing_variables for ManySortedSet of the carrier of C;
  coherence
  proof
    let X be ManySortedSet of the carrier of C;
A1: X"{{}} c= dom X by RELAT_1:132;
A2: dom X = the carrier of C by PARTFUN1:def 2;
    the carrier of C c= rng the ResultSort of C by Def54;
    hence X"{{}} c= rng the ResultSort of C by A1,A2;
  end;
end;

definition
  let G be non empty DTConstrStr;
  redefine func Terminals G -> Subset of G;
  coherence
  proof
    the carrier of G = Terminals G \/NonTerminals G by LANG1:1;
    hence thesis by XBOOLE_1:7;
  end;
  redefine func NonTerminals G -> Subset of G;
  coherence
  proof
    the carrier of G = Terminals G \/NonTerminals G by LANG1:1;
    hence thesis by XBOOLE_1:7;
  end;
end;

theorem Th115:
  for D1,D2 being non empty DTConstrStr st the Rules of D1 c= the Rules of D2
  holds NonTerminals D1 c= NonTerminals D2 &
  (the carrier of D1) /\ Terminals D2 c= Terminals D1 &
  (Terminals D1 c= Terminals D2 implies the carrier of D1 c= the carrier of D2)
proof
  let D1,D2 be non empty DTConstrStr such that
A1: the Rules of D1 c= the Rules of D2;
  thus
A2: NonTerminals D1 c= NonTerminals D2
  proof
    let x be object;
    assume x in NonTerminals D1;
    then ex s being Symbol of D1 st x = s & ex n being FinSequence st s ==> n;
    then consider s being Symbol of D1, n being FinSequence such that
A3: x = s and
A4: s ==> n;
A5: [s,n] in the Rules of D1 by A4;
    then [s,n] in the Rules of D2 by A1;
    then reconsider s9 = s as Symbol of D2 by ZFMISC_1:87;
    s9 ==> n by A1,A5;
    hence thesis by A3;
  end;
  hereby
    let x be object;
    assume
A6: x in (the carrier of D1) /\ Terminals D2;
    then
A7: x in Terminals D2 by XBOOLE_0:def 4;
    reconsider s9 = x as Symbol of D1 by A6,XBOOLE_0:def 4;
    reconsider s = x as Symbol of D2 by A6;
    assume not x in Terminals D1;
    then consider n being FinSequence such that
A8: s9 ==> n;
    [s9,n] in the Rules of D1 by A8;
    then s ==> n by A1;
    then not ex s being Symbol of D2 st x = s &
    not ex n being FinSequence st s ==> n;
    hence contradiction by A7;
  end;
  assume Terminals D1 c= Terminals D2;
  then Terminals D1 \/ NonTerminals D1 c= Terminals D2 \/ NonTerminals D2
  by A2,XBOOLE_1:13;
  then Terminals D1 \/ NonTerminals D1 c= the carrier of D2 by LANG1:1;
  hence thesis by LANG1:1;
end;

theorem Th116:
  for D1,D2 being non empty DTConstrStr st Terminals D1 c= Terminals D2 &
  the Rules of D1 c= the Rules of D2
  holds TS D1 c= TS D2
proof
  let G,G9 be non empty DTConstrStr such that
A1: Terminals G c= Terminals G9 and
A2: the Rules of G c= the Rules of G9;
A3: the carrier of G9 = (Terminals G9) \/ NonTerminals G9 by LANG1:1;
A4: the carrier of G c= the carrier of G9 by A1,A2,Th115;
  defpred P[set] means $1 in TS G9;
A5: for s being Symbol of G st s in Terminals G holds P[root-tree s]
  proof
    let s be Symbol of G;
    assume
A6: s in Terminals G;
    then reconsider s9 = s as Symbol of G9 by A1,A3,XBOOLE_0:def 3;
    root-tree s = root-tree s9;
    hence thesis by A1,A6,DTCONSTR:def 1;
  end;
A7: for nt being Symbol of G,
  ts being FinSequence of TS(G) st nt ==> roots ts &
  for t being DecoratedTree of the carrier of G st t in rng ts
  holds P[t]
  holds P[nt-tree ts]
  proof
    let n be Symbol of G;
    let s be FinSequence of TS(G) such that
A8: [n, roots s] in the Rules of G and
    A9: for t being DecoratedTree of the carrier of G st t in rng s holds P[t];
    rng s c= TS G9
    by A9;
    then reconsider s9 = s as FinSequence of TS G9 by FINSEQ_1:def 4;
    reconsider n9 = n as Symbol of G9 by A4;
    n9 ==> roots s9 by A2,A8;
    hence thesis by DTCONSTR:def 1;
  end;
A10: for t being DecoratedTree of the carrier of G st t in TS(G) holds P[t]
  from DTCONSTR:sch 7(A5,A7);
  let x be object;
  assume
A11: x in TS G;
  then reconsider t = x as Element of FinTrees(the carrier of G);
  P[t] by A10,A11;
  hence thesis;
end;

theorem Th117:
  for S being ManySortedSign
  for X,Y being ManySortedSet of the carrier of S st X c= Y
  holds X is with_missing_variables implies Y is with_missing_variables
proof
  let S be ManySortedSign;
  let X,Y be ManySortedSet of the carrier of S such that
A1: X c= Y and
A2: X"{{}} c= rng the ResultSort of S;
  let x be object;
  assume
A3: x in Y"{{}};
  then
A4: x in dom Y by FUNCT_1:def 7;
A5: Y.x in {{}} by A3,FUNCT_1:def 7;
A6: dom X = the carrier of S by PARTFUN1:def 2;
A7: Y.x = {} by A5,TARSKI:def 1;
  X.x c= Y.x by A1,A4;
  then X.x = {} by A7;
  then X.x in {{}} by TARSKI:def 1;
  then x in X"{{}} by A4,A6,FUNCT_1:def 7;
  hence thesis by A2;
end;

theorem Th118:
  for S being set for X,Y being ManySortedSet of S st X c= Y
  holds Union coprod X c= Union coprod Y
proof
  let S be set;
  let X,Y be ManySortedSet of S such that
A1: X c= Y;
A2: dom Y = S by PARTFUN1:def 2;
  let x be object;
  assume
A3: x in Union coprod X;
  then
A4: x`2 in dom X by CARD_3:22;
A5: x`1 in X.x`2 by A3,CARD_3:22;
A6: x = [x`1,x`2] by A3,CARD_3:22;
  X.x`2 c= Y.x`2 by A1,A4;
  hence thesis by A2,A4,A5,A6,CARD_3:22;
end;

theorem
  for S being non void Signature
  for X,Y being ManySortedSet of the carrier of S st X c= Y
  holds the carrier of DTConMSA X c= the carrier of DTConMSA Y
  by Th118,XBOOLE_1:9;

theorem Th120:
  for S being non void Signature for X being ManySortedSet of the carrier of S
  st X is with_missing_variables
  holds
  NonTerminals DTConMSA X = [:the carrier' of S,{the carrier of S}:] &
  Terminals DTConMSA X = Union coprod X
proof
  let S be non void Signature;
  let X be ManySortedSet of the carrier of S such that
A1: X is with_missing_variables;
  set D = DTConMSA X,
  A = [:the carrier' of S,{the carrier of S}:] \/
  Union (coprod (X qua ManySortedSet of the carrier of S));
A2: Union(coprod X) misses [:the carrier' of S,{the carrier of S}:]
  by MSAFREE:4;
A3: (Terminals D) misses (NonTerminals D) by DTCONSTR:8;
  thus
  NonTerminals DTConMSA X c= [:the carrier' of S,{the carrier of S}:]
  by MSAFREE:6;
  thus
A4: [:the carrier' of S,{the carrier of S}:] c= NonTerminals D
  proof
    let o,x2 be object;
    assume
A5: [o,x2] in [:the carrier' of S,{the carrier of S}:];
    then
A6: x2 in {the carrier of S} by ZFMISC_1:87;
    reconsider o as OperSymbol of S by A5,ZFMISC_1:87;
A7: the carrier of S = x2 by A6,TARSKI:def 1;
    then reconsider xa = [o,the carrier of S]
    as Element of (the carrier of D) by A5,XBOOLE_0:def 3;
    set O = the_arity_of o;
    defpred P[object,object] means
    $2 in A &
    (X.(O.$1) <> {} implies $2 in coprod(O.$1,X)) &
    (X.(O.$1) = {} implies ex o being OperSymbol of S st
    $2 = [o,the carrier of S] & the_result_sort_of o = O.$1);
A8: for a be object st a in Seg len O ex b be object st P[a,b]
    proof
      let a be object;
      assume a in Seg len O;
      then
A9:   a in dom O by FINSEQ_1:def 3;
      then
A10:  O.a in rng O by FUNCT_1:def 3;
      then reconsider s = O.a as SortSymbol of S;
      per cases;
      suppose X.(O.a) is non empty;
        then consider x be object such that
A11:    x in X.(O.a) by XBOOLE_0:def 1;
        take y = [x,O.a];
A12:    y in coprod(O.a,X) by A10,A11,MSAFREE:def 2;
A13:    O.a in rng O by A9,FUNCT_1:def 3;
        dom coprod(X) = the carrier of S by PARTFUN1:def 2;
        then (coprod(X)).(O.a) in rng coprod(X) by A13,FUNCT_1:def 3;
        then coprod(O.a,X) in rng coprod(X) by A13,MSAFREE:def 3;
        then y in Union coprod(X) by A12,TARSKI:def 4;
        hence thesis by A10,A11,MSAFREE:def 2,XBOOLE_0:def 3;
      end;
      suppose
A14:    X.(O.a) = {};
        then consider o being OperSymbol of S such that
A15:    the_result_sort_of o = s by A1,Th114;
        take y = [o,the carrier of S];
        the carrier of S in {the carrier of S} by TARSKI:def 1;
        then y in [:the carrier' of S,{the carrier of S}:] by ZFMISC_1:87;
        hence thesis by A14,A15,XBOOLE_0:def 3;
      end;
    end;
    consider b be Function such that
A16: dom b = Seg len O &
    for a be object st a in Seg len O holds P[a,b.a]
   from CLASSES1:sch 1(A8);
    reconsider b as FinSequence by A16,FINSEQ_1:def 2;
    rng b c= A
    proof
      let a be object;
      assume a in rng b;
      then ex c being object st c in dom b & b.c = a by FUNCT_1:def 3;
      hence thesis by A16;
    end;
    then reconsider b as FinSequence of A by FINSEQ_1:def 4;
    reconsider b as Element of A* by FINSEQ_1:def 11;
A17: len b = len O by A16,FINSEQ_1:def 3;
    now
      let c be set;
      assume
A18:  c in dom b;
      then
A19:  P[c,b.c] by A16;
      dom O = Seg len O by FINSEQ_1:def 3;
      then
A20:  O.c in rng O by A16,A18,FUNCT_1:def 3;
      dom coprod(X) = the carrier of S by PARTFUN1:def 2;
      then (coprod(X)).(O.c) in rng coprod(X) by A20,FUNCT_1:def 3;
      then coprod(O.c,X) in rng coprod(X) by A20,MSAFREE:def 3;
      then X.(O.c) <> {} implies b.c in Union coprod(X) by A19,TARSKI:def 4;
      hence b.c in [:the carrier' of S,{the carrier of S}:] implies
      for o1 being OperSymbol of S st [o1,the carrier of S] = b.c
      holds the_result_sort_of o1 = O.c
      by A2,A19,XBOOLE_0:3,XTUPLE_0:1;
      assume
A21:  b.c in Union (coprod X);
      now
        assume X.(O.c) = {};
        then
A22:    ex o being OperSymbol of S st ( b.c = [o,the carrier of S])
        &( the_result_sort_of o = O.c) by A16,A18;
        the carrier of S in {the carrier of S} by TARSKI:def 1;
        then b.c in [:the carrier' of S,{the carrier of S}:]
        by A22,ZFMISC_1:87;
        hence contradiction by A2,A21,XBOOLE_0:3;
      end;
      hence b.c in coprod(O.c,X) by A16,A18;
    end;
    then [xa,b] in REL(X) by A17,MSAFREE:5;
    then xa ==> b;
    hence thesis by A7;
  end;
  thus Terminals D c= Union coprod X
  proof
    let x be object;
    assume
A23: x in Terminals D;
    then not x in [:the carrier' of S,{the carrier of S}:] by A3,A4,XBOOLE_0:3;
    hence thesis by A23,XBOOLE_0:def 3;
  end;
  thus thesis by MSAFREE:6;
end;

theorem
  for S being non void Signature
  for X,Y being ManySortedSet of the carrier of S
  st X c= Y & X is with_missing_variables
  holds
  Terminals DTConMSA X c= Terminals DTConMSA Y &
  the Rules of DTConMSA X c= the Rules of DTConMSA Y &
  TS DTConMSA X c= TS DTConMSA Y
proof
  let S be non void Signature;
  let X,Y be ManySortedSet of the carrier of S such that
A1: X c= Y and
A2: X is with_missing_variables;
A3: Y is with_missing_variables by A1,A2,Th117;
  set G = DTConMSA X, G9 = DTConMSA Y;
A4: the carrier of G c= the carrier of G9 by A1,Th118,XBOOLE_1:9;
A5: Terminals G = Union coprod X by A2,Th120;
A6: Terminals G9 = Union coprod Y by A3,Th120;
  hence
  Terminals G c= Terminals G9 by A1,A5,Th118;
A7: (the carrier of G)* c= (the carrier of G9)* by A4,FINSEQ_1:62;
  thus the Rules of G c= the Rules of G9
  proof
    let a,b be object;
    assume
A8: [a,b] in the Rules of G;
    then
A9: a in [:the carrier' of S,{the carrier of S}:] by MSAFREE1:2;
    reconsider a as Element of [:the carrier' of S,{the carrier of S}:]
    \/ Union coprod X by A9,XBOOLE_0:def 3;
    reconsider a9 = a as
    Element of [:the carrier' of S,{the carrier of S}:]
    \/ Union coprod Y by A9,XBOOLE_0:def 3;
    reconsider b as Element of
    ([:the carrier' of S,{the carrier of S}:] \/ Union coprod X)* by A8,
MSAFREE1:2;
    reconsider b9 = b as Element of
    ([:the carrier' of S,{the carrier of S}:] \/ Union coprod Y)*
    by A7;
    now
      let o be OperSymbol of S;
      assume
A10:  [o,the carrier of S] = a9;
      hence
A11:  len b9 = len (the_arity_of o) by A8,MSAFREE:def 7;
      let x be set;
      assume
A12:  x in dom b9;
      hence b9.x in [:the carrier' of S,{the carrier of S}:] implies
      for o1 be OperSymbol of S st [o1,the carrier of S] = b.x
      holds the_result_sort_of o1 = (the_arity_of o).x
      by A8,A10,MSAFREE:def 7;
A13:  Union coprod Y misses [:the carrier' of S,{the carrier of S}:] by
MSAFREE:4;
A14:  b.x in [:the carrier' of S,{the carrier of S}:] \/ Union coprod X
      by A12,DTCONSTR:2;
A15:  dom b9 = Seg len b9 by FINSEQ_1:def 3;
      dom the_arity_of o = Seg len b9 by A11,FINSEQ_1:def 3;
      then
A16:  (the_arity_of o).x in the carrier of S by A12,A15,DTCONSTR:2;
      assume
A17:  b9.x in Union coprod Y;
      b.x in [:the carrier' of S,{the carrier of S}:] or b.x in Union coprod
      X by A14,XBOOLE_0:def 3;
      then b.x in coprod((the_arity_of o).x,X) by A8,A10,A12,A13,A17,
MSAFREE:def 7,XBOOLE_0:3;
      then
A18:  ex a being set st ( a in X.((the_arity_of o).x))&( b.x = [a
      , (the_arity_of o).x]) by A16,MSAFREE:def 2;
      X.((the_arity_of o).x) c= Y.((the_arity_of o).x) by A1,A16;
      hence b9.x in coprod((the_arity_of o).x,Y) by A16,A18,MSAFREE:def 2;
    end;
    hence thesis by A9,MSAFREE:def 7;
  end;
  hence thesis by A1,A5,A6,Th116,Th118;
end;

theorem Th122:
  for t being set holds t in Terminals DTConMSA MSVars C iff
  ex x being variable st t = [x,a_Term C]
proof
  let t be set;
  set X = MSVars C;
A1: Terminals DTConMSA X = Union coprod X by Th120;
A2: dom X = the carrier of C by PARTFUN1:def 2;
A3: the carrier of C = {a_Type, an_Adj, a_Term} by Def9;
A4: X.a_Type = {} by Def25;
A5: X.an_Adj = {} by Def25;
A6: X.a_Term = Vars by Def25;
  hereby
    assume
A7: t in Terminals DTConMSA X;
    then
A8: t`2 in dom X by A1,CARD_3:22;
A9: t`1 in X.t`2 by A1,A7,CARD_3:22;
A10: t`2 = a_Type or t`2 = an_Adj or t`2 = a_Term by A3,A8,ENUMSET1:def 1;
    reconsider x = t`1 as variable by A3,A4,A5,A6,A8,A9,ENUMSET1:def 1;
    take x;
    thus t = [x,a_Term C] by A1,A4,A5,A7,A10,CARD_3:22;
  end;
  given x being variable such that
A11: t = [x,a_Term C];
A12: t`1 = x by A11;
  t`2 = a_Term by A11;
  hence thesis by A1,A2,A6,A11,A12,CARD_3:22;
end;

theorem Th123:
  for t being set holds t in NonTerminals DTConMSA MSVars C iff
  t = [ast C, the carrier of C] or
  t = [non_op C, the carrier of C] or
  ex c being constructor OperSymbol of C st t = [c, the carrier of C]
proof
  let t be set;
  set X = MSVars C;
A1: NonTerminals DTConMSA X = [:the carrier' of C,{the carrier of C}:]
  by Th120;
  hereby
    assume t in NonTerminals DTConMSA MSVars C;
    then consider a,b being object such that
A2: a in the carrier' of C and
A3: b in {the carrier of C} and
A4: t = [a,b] by A1,ZFMISC_1:def 2;
    reconsider a as OperSymbol of C by A2;
A5: b = the carrier of C by A3,TARSKI:def 1;
    a is constructor or a is not constructor;
    hence t = [ast C, the carrier of C] or t = [non_op C, the carrier of C] or
    ex c being constructor OperSymbol of C st t = [c, the carrier of C]
    by A4,A5;
  end;
  the carrier of C in {the carrier of C} by TARSKI:def 1;
  hence thesis by A1,ZFMISC_1:87;
end;

theorem Th124:
  for S being non void Signature
  for X being with_missing_variables ManySortedSet of the carrier of S
  for t being set st t in Union the Sorts of Free(S,X)
  holds t is Term of S, X (\/) ((the carrier of S)-->{0})
proof
  let S be non void Signature;
  let X be with_missing_variables ManySortedSet of the carrier of S;
  set V = X (\/) ((the carrier of S)-->{0});
  set A = Free(S, X);
  set U = the Sorts of A;
A1: U = S-Terms(X, V) by MSAFREE3:24;
  let t be set;
  assume t in Union U;
  then consider s being object such that
A2: s in dom U and
A3: t in U.s by CARD_5:2;
  reconsider s as SortSymbol of S by A2;
  U.s = {r where r is Term of S,V: the_sort_of r = s & variables_in r c= X}
  by A1,MSAFREE3:def 5;
  then
  ex r being Term of S,V st t = r & the_sort_of r = s & variables_in r c= X
  by A3;
  hence thesis;
end;

theorem
  for S being non void Signature
  for X being with_missing_variables ManySortedSet of the carrier of S
  for t being Term of S, X (\/) ((the carrier of S)-->{0})
  st t in Union the Sorts of Free(S,X)
  holds t in (the Sorts of Free(S,X)).the_sort_of t
proof
  let S be non void Signature;
  let X be with_missing_variables ManySortedSet of the carrier of S;
  set V = X (\/) ((the carrier of S)-->{0});
  set A = Free(S, X);
  set U = the Sorts of A;
A1: U = S-Terms(X, V) by MSAFREE3:24;
  let t be Term of S, X (\/) ((the carrier of S)-->{0});
  assume t in Union U;
  then consider s being object such that
A2: s in dom U and
A3: t in U.s by CARD_5:2;
  reconsider s as SortSymbol of S by A2;
  U.s = {r where r is Term of S,V: the_sort_of r = s & variables_in r c= X}
  by A1,MSAFREE3:def 5;
  then
  ex r being Term of S,V st t = r & the_sort_of r = s & variables_in r c= X
  by A3;
  hence thesis by A3;
end;

theorem
  for G being non empty DTConstrStr for s being Element of G
  for p being FinSequence st s ==> p
  holds p is FinSequence of the carrier of G
proof
  let G be non empty DTConstrStr;
  let s be Element of G;
  let p be FinSequence;
  assume s ==> p;
  then [s,p] in the Rules of G;
  then p in (the carrier of G)* by ZFMISC_1:87;
  hence thesis by FINSEQ_1:def 11;
end;

theorem Th127:
  for S being non void Signature
  for X,Y being ManySortedSet of the carrier of S
  for g1 being Symbol of DTConMSA X
  for g2 being Symbol of DTConMSA Y
  for p1 being FinSequence of the carrier of DTConMSA X
  for p2 being FinSequence of the carrier of DTConMSA Y
  st g1 = g2 & p1 = p2 & g1 ==> p1
  holds g2 ==> p2
proof
  let S be non void Signature;
  let X,Y be ManySortedSet of the carrier of S;
A1: dom Y = the carrier of S by PARTFUN1:def 2;
  set G1 = DTConMSA X;
  set G2 = DTConMSA Y;
  let g1 be Symbol of G1;
  let g2 be Symbol of G2;
  let p1 be FinSequence of the carrier of G1;
  let p2 be FinSequence of the carrier of G2;
  assume that
A2: g1 = g2 and
A3: p1 = p2 and
A4: g1 ==> p1;
A5: [g1, p1] in REL X by A4;
  then
A6: p1 in ([:the carrier' of S,{the carrier of S}:] \/ Union (coprod X))*
  by ZFMISC_1:87;
  then
A7: g1 in [:the carrier' of S,{the carrier of S}:] by A5,MSAFREE:def 7;
A8: p2 in ([:the carrier' of S, {the carrier of S}:] \/
  Union (coprod Y))* by FINSEQ_1:def 11;
  now
    let o9 be OperSymbol of S;
    assume
A9: [o9,the carrier of S] = g2;
    hence
A10: len p2 = len the_arity_of o9 by A2,A3,A5,A6,MSAFREE:def 7;
    let x be set;
    assume
A11: x in dom p2;
    hence p2.x in [:the carrier' of S,{the carrier of S}:] implies
    for o1 be OperSymbol of S st [o1,the carrier of S] = p2.x
    holds the_result_sort_of o1 = (the_arity_of o9).x
    by A2,A3,A5,A6,A9,MSAFREE:def 7;
    x in dom the_arity_of o9 by A10,A11,FINSEQ_3:29;
    then (the_arity_of o9).x in rng the_arity_of o9 by FUNCT_1:def 3;
    then reconsider i = (the_arity_of o9).x as SortSymbol of S;
    assume
A12: p2.x in Union coprod Y;
    then
A13: (p2.x)`2 in dom Y by CARD_3:22;
A14: (p2.x)`1 in Y.(p2.x)`2 by A12,CARD_3:22;
A15: p2.x = [(p2.x)`1,(p2.x)`2] by A12,CARD_3:22;
    reconsider nn = the carrier of S as set;
A:    not nn in nn;
    p2.x in rng p1 by A3,A11,FUNCT_1:def 3;
    then the carrier of S nin the carrier of S &
    p2.x in [:the carrier' of S,{the carrier of S}:] or
    p2.x in Union coprod X by XBOOLE_0:def 3,A;
    then p2.x in coprod(i,X)
    by A1,A2,A3,A5,A6,A9,A11,A13,A15,MSAFREE:def 7,ZFMISC_1:106;
    then ex a being set st ( a in X.i)&( p2.x = [a,i]) by MSAFREE:def 2;
    then i = (p2.x)`2;
    hence p2.x in coprod((the_arity_of o9).x,Y) by A14,A15,MSAFREE:def 2;
  end;
  then [g2, p2] in REL Y by A2,A7,A8,MSAFREE:def 7;
  hence thesis;
end;

theorem Th128:
  for S being non void Signature
  for X being with_missing_variables ManySortedSet of the carrier of S holds
  Union the Sorts of Free(S, X) = TS DTConMSA X
proof
  let S be non void Signature;
  let X be with_missing_variables ManySortedSet of the carrier of S;
  set V = X (\/) ((the carrier of S)-->{0});
  set A = Free(S, X);
  set U = the Sorts of A;
  set G = DTConMSA X;
A1: U = S-Terms(X, V) by MSAFREE3:24;
A2: dom U = the carrier of S by PARTFUN1:def 2;
  defpred P[set] means $1 in Union U implies $1 in TS G;
A3: for s being SortSymbol of S, v being Element of V.s
  holds P[root-tree [v,s]]
  proof
    let s be SortSymbol of S;
    let v be Element of V.s;
    assume root-tree [v,s] in Union U;
    then consider s1 being object such that
A4: s1 in dom U and
A5: root-tree [v,s] in U.s1 by CARD_5:2;
    reconsider s1 as SortSymbol of S by A4;
    U.s1={t where t is Term of S,V: the_sort_of t = s1 & variables_in t c= X}
    by A1,MSAFREE3:def 5;
    then consider t being Term of S,V such that
A6: root-tree [v,s] = t and the_sort_of t = s1 and
A7: variables_in t c= X by A5;
    (variables_in t).s = {v} by A6,MSAFREE3:10;
    then {v} c= X.s by A7;
    then v in X.s by ZFMISC_1:31;
    then [v,s] in Terminals G by MSAFREE:7;
    hence thesis by DTCONSTR:def 1;
  end;
A8: for o being OperSymbol of S, p being ArgumentSeq of Sym(o,V) st
  for t being Term of S,V st t in rng p holds P[t]
  holds P[[o,the carrier of S]-tree p]
  proof
    let o be OperSymbol of S;
    let p be ArgumentSeq of Sym(o,V) such that
A9: for t being Term of S,V st t in rng p holds P[t] and
A10: [o,the carrier of S]-tree p in Union U;
    consider s being object such that
A11: s in dom U and
A12: [o,the carrier of S]-tree p in U.s by A10,CARD_5:2;
    reconsider s as SortSymbol of S by A11;
    U.s={t where t is Term of S,V: the_sort_of t = s & variables_in t c= X}
    by A1,MSAFREE3:def 5;
    then consider t being Term of S,V such that
A13: [o,the carrier of S]-tree p = t and
A14: the_sort_of t = s and variables_in t c= X by A12;
    t.{} = [o,the carrier of S] by A13,TREES_4:def 4;
    then the_result_sort_of o = s by A14,MSATERM:17;
    then
A15: rng p c= Union U by A1,A12,MSAFREE3:19;
    rng p c= TS G
    proof
      let x be object;
      assume
A16:  x in rng p;
      then x is Term of S,V by A15,Th124;
      hence thesis by A9,A15,A16;
    end;
    then reconsider q = p as FinSequence of TS G by FINSEQ_1:def 4;
    NonTerminals G = [:the carrier' of S,{the carrier of S}:] by Th120;
    then [o,the carrier of S] in NonTerminals G by ZFMISC_1:106;
    then reconsider oo = [o,the carrier of S] as Symbol of G;
    Sym(o,V) ==> roots p by MSATERM:21;
    then oo ==> roots q by Th127;
    hence thesis by DTCONSTR:def 1;
  end;
A17: for t being Term of S,V holds P[t] from MSATERM:sch 1(A3,A8);
A18: NonTerminals DTConMSA X = [:the carrier' of S,{the carrier of S}:] by
Th120;
A19: Terminals DTConMSA X = Union coprod X by Th120;
  defpred Q[set] means $1 in Union U;
A20: for s being Symbol of G st s in Terminals G holds Q[root-tree s]
  proof
    let s be Symbol of G;
    assume
A21: s in Terminals G;
    then
A22: s`2 in dom X by A19,CARD_3:22;
A23: s`1 in X.s`2 by A19,A21,CARD_3:22;
A24: s = [s`1,s`2] by A19,A21,CARD_3:22;
A25: dom U = the carrier of S by PARTFUN1:def 2;
    root-tree s in (the Sorts of Free(S,X)).s`2 by A22,A23,A24,MSAFREE3:4;
    hence thesis by A22,A25,CARD_5:2;
  end;
  A26: for
 nt being Symbol of G, ts being FinSequence of TS G st nt ==> roots ts &
  for t being DecoratedTree of the carrier of G st t in rng ts holds Q[t]
  holds Q[nt-tree ts]
  proof
    let nt be Symbol of G;
    let ts be FinSequence of TS G such that
A27: nt ==> roots ts and
    A28: for
 t being DecoratedTree of the carrier of G st t in rng ts holds Q[t];
    nt in NonTerminals G by A27;
    then consider o,z being object such that
A29: o in the carrier' of S and
A30: z in {the carrier of S} and
A31: nt = [o,z] by A18,ZFMISC_1:def 2;
    reconsider o as OperSymbol of S by A29;
A32: rng ts c= Union U
    by A28;
    rng ts c= TS DTConMSA V
    proof
      let a be object;
      assume a in rng ts;
      then
A33:  a is Element of S-TermsV by A32,Th124;
      S-TermsV = TS DTConMSA V by MSATERM:def 1;
      hence thesis by A33;
    end;
    then reconsider p = ts as FinSequence of TS DTConMSA V by FINSEQ_1:def 4;
    reconsider q = p as FinSequence of S-TermsV by MSATERM:def 1;
A34: z = the carrier of S by A30,TARSKI:def 1;
    then Sym(o, V) ==> roots p by A27,A31,Th127;
    then reconsider q as ArgumentSeq of Sym(o, V) by MSATERM:21;
    set t = Sym(o, V)-tree q;
    t in U.the_result_sort_of o by A1,A32,MSAFREE3:19;
    hence thesis by A2,A31,A34,CARD_5:2;
  end;
A35: for t being DecoratedTree of the carrier of G
  st t in TS G holds Q[t] from DTCONSTR:sch 7(A20,A26);
  thus Union U c= TS DTConMSA X
  proof
    let x be object;
    assume
A36: x in Union U;
    then consider s being object such that
A37: s in dom U and
A38: x in U.s by CARD_5:2;
    reconsider s as SortSymbol of S by A37;
    x in U.s by A38;
    then x is Term of S,V by A1,MSAFREE3:16;
    hence thesis by A17,A36;
  end;
  let x be object;
  assume
A39: x in TS G;
  then reconsider TG = TS G as non empty Subset of FinTrees(the carrier of G);
  x is Element of TG by A39;
  hence thesis by A35;
end;

definition
  let S be non void Signature;
  let X be ManySortedSet of the carrier of S;
  mode term-transformation of S,X -> UnOp of Union the Sorts of Free(S,X) means
    :Def56:
    for s being SortSymbol of S holds
    it.:((the Sorts of Free(S,X)).s) c= (the Sorts of Free(S,X)).s;
  existence
  proof
    set f = id Union the Sorts of Free(S,X);
A1: dom f = Union the Sorts of Free(S,X);
    rng f = Union the Sorts of Free(S,X);
    then reconsider f as UnOp of Union the Sorts of Free(S,X) by A1,FUNCT_2:2;
    take f;
    thus thesis by Th4;
  end;
end;

theorem Th129:
  for S being non void Signature
  for X being non empty ManySortedSet of the carrier of S
  for f being UnOp of Union the Sorts of Free(S,X)
  holds f is term-transformation of S,X iff
  for s being SortSymbol of S
  for a being set st a in (the Sorts of Free(S,X)).s
  holds f.a in (the Sorts of Free(S,X)).s
proof
  let S be non void Signature;
  let X be non empty ManySortedSet of the carrier of S;
A1: dom the Sorts of Free(S,X) = the carrier of S by PARTFUN1:def 2;
  let f be UnOp of Union the Sorts of Free(S,X);
A2: dom f = Union the Sorts of Free(S,X) by FUNCT_2:52;
  hereby
    assume
A3: f is term-transformation of S,X;
    let s be SortSymbol of S;
A4: f.:((the Sorts of Free(S,X)).s) c= (the Sorts of Free(S,X)).s by A3,Def56;
    (the Sorts of Free(S,X)).s in rng the Sorts of Free(S,X)
    by A1,FUNCT_1:def 3;
    then
A5: (the Sorts of Free(S,X)).s c= Union the Sorts of Free(S,X) by ZFMISC_1:74;
    let a be set;
    assume a in (the Sorts of Free(S,X)).s;
    then f.a in f.:((the Sorts of Free(S,X)).s) by A2,A5,FUNCT_1:def 6;
    hence f.a in (the Sorts of Free(S,X)).s by A4;
  end;
  assume
A6: for s being SortSymbol of S
  for a being set st a in (the Sorts of Free(S,X)).s
  holds f.a in (the Sorts of Free(S,X)).s;
  let s be SortSymbol of S;
  let x be object;
  assume x in f.:((the Sorts of Free(S,X)).s);
  then
  ex a being object
    st a in dom f & a in (the Sorts of Free(S,X)).s & x = f.a
  by FUNCT_1:def 6;
  hence thesis by A6;
end;

theorem Th130:
  for S being non void Signature
  for X being non empty ManySortedSet of the carrier of S
  for f being term-transformation of S,X
  for s being SortSymbol of S
  for p being FinSequence of (the Sorts of Free(S,X)).s
  holds f*p is FinSequence of (the Sorts of Free(S,X)).s &
  card (f*p) = len p
proof
  let S be non void Signature;
  let X be non empty ManySortedSet of the carrier of S;
  set A = Free(S,X);
  let f be term-transformation of S,X;
  let s be SortSymbol of S;
  let p be FinSequence of (the Sorts of A).s;
A1: Union the Sorts of A = {} or Union the Sorts of A <> {};
A2: dom the Sorts of A = the carrier of S by PARTFUN1:def 2;
A3: dom f = Union the Sorts of A by A1,FUNCT_2:def 1;
  (the Sorts of A).s in rng the Sorts of A by A2,FUNCT_1:def 3;
  then (the Sorts of A).s c= Union the Sorts of A by ZFMISC_1:74;
  then rng p c= dom f by A3;
  then
A4: dom (f*p) = dom p by RELAT_1:27;
  dom p = Seg len p by FINSEQ_1:def 3;
  then
A5: f*p is FinSequence by A4,FINSEQ_1:def 2;
A6: rng(f*p) c= (the Sorts of A).s
  proof
    let z be object;
    assume z in rng(f*p);
    then consider i being object such that
A7: i in dom(f*p) and
A8: z = (f*p).i by FUNCT_1:def 3;
    p.i in rng p by A4,A7,FUNCT_1:def 3;
    then f.(p.i) in (the Sorts of A).s by Th129;
    hence thesis by A7,A8,FUNCT_1:12;
  end;
  hence f*p is FinSequence of (the Sorts of Free(S,X)).s by A5,FINSEQ_1:def 4;
  reconsider q = f*p as FinSequence of (the Sorts of A).s by A5,A6,
FINSEQ_1:def 4;
  thus card(f*p) = len q .= len p by A4,FINSEQ_3:29;
end;

definition
  let S be non void Signature;
  let X be ManySortedSet of the carrier of S;
  let t be term-transformation of S,X;
  attr t is substitution means
  for o being OperSymbol of S for p,q being FinSequence of Free(S,X)
  st [o, the carrier of S]-tree p in Union the Sorts of Free(S,X) & q = t*p
  holds t.([o, the carrier of S]-tree p) = [o, the carrier of S]-tree q;
end;

scheme StructDef
  {C() -> initialized ConstructorSignature,
  V,N(set) -> (expression of C()),
  F,A(set,set) -> (expression of C())}:
  ex f being term-transformation of C(), MSVars C() st
  (for x being variable holds f.(x-term C()) = V(x)) &
  (for c being constructor OperSymbol of C()
  for p,q being FinSequence of QuasiTerms C()
  st len p = len the_arity_of c & q = f*p
  holds f.(c-trm p) = F(c, q)) &
  (for a being expression of C(), an_Adj C()
  holds f.((non_op C())term a) = N(f.a)) &
  for a being expression of C(), an_Adj C()
  for t being expression of C(), a_Type C()
  holds f.((ast C())term(a,t)) = A(f.a, f.t)
provided
A1: for x being variable holds V(x) is quasi-term of C() and
A2: for c being constructor OperSymbol of C()
for p being FinSequence of QuasiTerms C()
st len p = len the_arity_of c
holds F(c, p) is expression of C(), the_result_sort_of c and
A3: for a being expression of C(), an_Adj C()
holds N(a) is expression of C(), an_Adj C() and
A4: for a being expression of C(), an_Adj C()
for t being expression of C(), a_Type C()
holds A(a,t) is expression of C(), a_Type C()
proof
  set V = MSVars C();
  set X = V(\/)((the carrier of C())-->{0});
  set A = Free(C(), V);
  set U = the Sorts of A;
  set D = Union U;
  set G = DTConMSA V;
  deffunc TermVal(Symbol of G) = V($1`1);
  deffunc NTermVal(Symbol of G, FinSequence, Function) =
  IFEQ($1`1,*, A($3.1,$3.2), IFEQ($1`1,non_op, N($3.1), F($1`1,$3)));
  consider f being Function of TS G, D such that
A5: for t being Symbol of G st t in Terminals G
  holds f.(root-tree t) = TermVal(t) and
  A6: for nt being Symbol of G, ts being FinSequence of TS G st nt ==> roots ts
  holds f.(nt-tree ts) = NTermVal(nt, roots ts, f * ts)
  from DTCONSTR:sch 8;
  D = TS G by Th128;
  then reconsider f as Function of D,D;
  f is term-transformation of C(), V
  proof
    let s be SortSymbol of C();
    let x be object;
    assume x in f.:((the Sorts of A).s);
    then consider a being Element of D such that
A7: a in (the Sorts of A).s and
A8: x = f.a by FUNCT_2:65;
    defpred P[expression of C()] means
    for s being SortSymbol of C() st $1 in (the Sorts of A).s
    holds f.$1 in (the Sorts of A).s;
A9: for x being variable holds P[x-term C()]
    proof
      let y be variable;
      set a = y-term C();
      let s be SortSymbol of C();
      assume
A10:  a in (the Sorts of A).s;
A11:  [y,a_Term C()] in Terminals G by Th122;
      then reconsider t = [y,a_Term C()] as Symbol of G;
      f.a = TermVal(t) by A5,A11
        .= V(y);
      then
A12:  f.a is quasi-term of C() by A1;
      a is expression of C(), s by A10,Def28;
      then s = a_Term C() by Th48;
      hence thesis by A12,Def28;
    end;
A13: for c being constructor OperSymbol of C()
    for p being FinSequence of QuasiTerms C()
    st len p = len the_arity_of c &
    for t being quasi-term of C() st t in rng p holds P[t]
    holds P[c-trm p]
    proof
      let c be constructor OperSymbol of C();
      let p be FinSequence of QuasiTerms C();
      assume that
A14:  len p = len the_arity_of c and
A15:  for t being quasi-term of C() st t in rng p holds P[t];
      set a = c-trm p;
      set nt = [c, the carrier of C()];
      let s be SortSymbol of C() such that
A16:  a in (the Sorts of A).s;
      nt in NonTerminals G by Th123;
      then reconsider nt as Symbol of G;
      reconsider ts = p as FinSequence of TS G by Th128;
A17:  a = nt-tree ts by A14,Def35;
      reconsider aa = a as Term of C(), X by MSAFREE3:8;
      the Sorts of A = C()-Terms(V,X) by MSAFREE3:24;
      then the Sorts of A c= the Sorts of FreeMSA X by PBOOLE:def 18;
      then (the Sorts of A).s c= (the Sorts of FreeMSA X).s;
      then aa in (FreeSort X).s by A16;
      then aa in FreeSort(X,s) by MSAFREE:def 11;
      then
A18:  the_sort_of aa = s by MSATERM:def 5;
A19:  c <> * by Def11;
A20:  c <> non_op by Def11;
A21:  rng p c= QuasiTerms C() by FINSEQ_1:def 4;
      dom f = D by FUNCT_2:def 1;
      then
A22:  rng p c= dom f;
      rng(f*p) c= QuasiTerms C()
      proof
        let z be object;
        assume z in rng(f*p);
        then consider i being object such that
A23:    i in dom(f*p) and
A24:    z = (f*p).i by FUNCT_1:def 3;
        i in dom p by A22,A23,RELAT_1:27;
        then
A25:    p.i in rng p by FUNCT_1:def 3;
        then reconsider pi1 = p.i as quasi-term of C() by A21,Th41;
        pi1 in (the Sorts of A).a_Term C() by Th41;
        then f.pi1 in (the Sorts of A).a_Term C() by A15,A25;
        hence thesis by A23,A24,FUNCT_1:12;
      end;
      then reconsider q = f*p as FinSequence of QuasiTerms C() by
FINSEQ_1:def 4;
      rng p c= C()-Terms X
      proof
        let z be object;
        assume z in rng p;
        then z is Element of C()-TermsX by MSAFREE3:8;
        hence thesis;
      end;
      then reconsider r = p as FinSequence of C()-Terms X by FINSEQ_1:def 4;
A26:  len q = len p by A22,FINSEQ_2:29;
      a is Term of C(), X by MSAFREE3:8;
      then
A27:  r is ArgumentSeq of Sym(c, X) by A17,MSATERM:1;
      then
A28:  the_result_sort_of c = s by A17,A18,MSATERM:20;
      Sym(c, X) ==> roots r by A27,MSATERM:21;
      then nt ==> roots ts by Th127;
      then f.a = NTermVal(nt, roots ts, f * ts) by A6,A17
        .= IFEQ(c,non_op, N((f * ts).1), F(c, f * ts)) by A19,
FUNCOP_1:def 8
        .= F(c, f * ts) by A20,FUNCOP_1:def 8;
      then f.a is expression of C(), the_result_sort_of c by A2,A14,A26;
      hence thesis by A28,Def28;
    end;
A29: for a being expression of C(), an_Adj C() st P[a]
    holds P[(non_op C())term a]
    proof
      let v be expression of C(), an_Adj C() such that
A30:  P[v];
A31:  v in U.an_Adj C() by Def28;
      then f.v in U.an_Adj C() by A30;
      then reconsider fv = f.v as expression of C(), an_Adj C() by Def28;
      let s be SortSymbol of C();
      assume
A32:  (non_op C())term v in U.s;
A33:  (non_op C())term v is expression of C(), an_Adj C() by Th43;
      (non_op C())term v is expression of C(), s by A32,Def28;
      then
A34:  s = an_Adj C() by A33,Th48;
      set QA = U.an_Adj C();
      rng <*v*> = {v} by FINSEQ_1:38;
      then rng <*v*> c= QA by A31,ZFMISC_1:31;
      then reconsider p = <*v*> as FinSequence of QA by FINSEQ_1:def 4;
      set c = non_op C();
      set a = (non_op C())term v;
      set nt = [c, the carrier of C()];
      nt in NonTerminals G by Th123;
      then reconsider nt as Symbol of G;
      reconsider ts = p as FinSequence of TS G by Th128;
A35:  a = nt-tree ts by Th43;
      dom f = D by FUNCT_2:def 1;
      then
A36:  f*p = <*fv*> by FINSEQ_2:34;
      rng p c= C()-Terms X
      proof
        let z be object;
        assume z in rng p;
        then z is expression of C(), an_Adj C() by Th41;
        then z is Element of C()-TermsX by MSAFREE3:8;
        hence thesis;
      end;
      then reconsider r = p as FinSequence of C()-Terms X by FINSEQ_1:def 4;
      a is Term of C(), X by MSAFREE3:8;
      then r is ArgumentSeq of Sym(c, X) by A35,MSATERM:1;
      then Sym(c, X) ==> roots r by MSATERM:21;
      then nt ==> roots ts by Th127;
      then f.a = NTermVal(nt, roots ts, f * ts) by A6,A35
        .= IFEQ(c,non_op, N((f * ts).1), F(c, f * ts)) by FUNCOP_1:def 8
        .= N((f*ts).1) by FUNCOP_1:def 8
        .= N(fv) by A36,FINSEQ_1:40;
      then f.a is expression of C(), an_Adj C() by A3;
      hence thesis by A34,Def28;
    end;
A37: for a being expression of C(), an_Adj C() st P[a]
    for t being expression of C(), a_Type C() st P[t]
    holds P[(ast C())term(a,t)]
    proof
      let v be expression of C(), an_Adj C() such that
A38:  P[v];
      let t be expression of C(), a_Type C() such that
A39:  P[t];
A40:  v in U.an_Adj C() by Def28;
A41:  t in U.a_Type C() by Def28;
A42:  f.v in U.an_Adj C() by A38,A40;
A43:  f.t in U.a_Type C() by A39,A41;
      reconsider fv = f.v as expression of C(), an_Adj C() by A42,Def28;
      reconsider ft = f.t as expression of C(), a_Type C() by A43,Def28;
      let s be SortSymbol of C();
      assume
A44:  (ast C())term(v,t) in U.s;
A45:  (ast C())term(v,t) is expression of C(), a_Type C() by Th46;
      (ast C())term(v,t) is expression of C(), s by A44,Def28;
      then
A46:  s = a_Type C() by A45,Th48;
      reconsider p = <*v,t*> as FinSequence of D;
      set c = ast C();
      set a = (ast C())term(v,t);
      set nt = [c, the carrier of C()];
      nt in NonTerminals G by Th123;
      then reconsider nt as Symbol of G;
      reconsider ts = p as FinSequence of TS G by Th128;
A47:  a = nt-tree ts by Th46;
A48:  f*p = <*fv,ft*> by FINSEQ_2:36;
      rng p c= C()-Terms X
      proof
        let z be object;
        assume z in rng p;
        then z is Element of C()-TermsX by MSAFREE3:8;
        hence thesis;
      end;
      then reconsider r = p as FinSequence of C()-Terms X by FINSEQ_1:def 4;
      a is Term of C(), X by MSAFREE3:8;
      then r is ArgumentSeq of Sym(c, X) by A47,MSATERM:1;
      then Sym(c, X) ==> roots r by MSATERM:21;
      then nt ==> roots ts by Th127;
      then f.a = NTermVal(nt, roots ts, f * ts) by A6,A47
        .= A((f*ts).1,(f*ts).2) by FUNCOP_1:def 8
        .= A(fv,(f*ts).2) by A48,FINSEQ_1:44
        .= A(fv,ft) by A48,FINSEQ_1:44;
      then f.a is expression of C(), a_Type C() by A4;
      hence thesis by A46,Def28;
    end;
    P[a] from StructInd(A9,A13,A29,A37);
    hence thesis by A7,A8;
  end;
  then reconsider f as term-transformation of C(), MSVars C();
  take f;
  hereby
    let x be variable;
    x in Vars;
    then
A49: x in V.a_Term C() by Def25;
    reconsider x9 = x as Element of V.a_Term C() by Def25;
    reconsider xx = [x9,a_Term C()] as Symbol of G by A49,MSAFREE3:2;
    xx in Terminals G by A49,MSAFREE:7;
    hence f.(x-term C()) = V(xx`1) by A5
      .= V(x);
  end;
  hereby
    let c be constructor OperSymbol of C();
    let p,q be FinSequence of QuasiTerms C();
    assume that
A50: len p = len the_arity_of c and
A51: q = f*p;
    set a = c-trm p;
    set nt = [c, the carrier of C()];
    nt in NonTerminals G by Th123;
    then reconsider nt as Symbol of G;
    reconsider ts = p as FinSequence of TS G by Th128;
A52: a = nt-tree ts by A50,Def35;
A53: c <> * by Def11;
A54: c <> non_op by Def11;
    rng p c= C()-Terms X
    proof
      let z be object;
      assume z in rng p;
      then z is Element of C()-TermsX by MSAFREE3:8;
      hence thesis;
    end;
    then reconsider r = p as FinSequence of C()-Terms X by FINSEQ_1:def 4;
    a is Term of C(), X by MSAFREE3:8;
    then r is ArgumentSeq of Sym(c, X) by A52,MSATERM:1;
    then Sym(c, X) ==> roots r by MSATERM:21;
    then nt ==> roots ts by Th127;
    then f.a = NTermVal(nt, roots ts, f * ts) by A6,A52
      .= IFEQ(c,non_op, N((f * ts).1), F(c, f * ts)) by A53,FUNCOP_1:def 8
      .= F(c, f * ts) by A54,FUNCOP_1:def 8;
    hence f.(c-trm p) = F(c, q) by A51;
  end;
  hereby
    let v be expression of C(), an_Adj C();
A55: v in U.an_Adj C() by Def28;
    then f.v in U.an_Adj C() by Th129;
    then reconsider fv = f.v as expression of C(), an_Adj C() by Def28;
    set QA = U.an_Adj C();
    rng <*v*> = {v} by FINSEQ_1:38;
    then rng <*v*> c= QA by A55,ZFMISC_1:31;
    then reconsider p = <*v*> as FinSequence of QA by FINSEQ_1:def 4;
    set c = non_op C();
    set a = (non_op C())term v;
    set nt = [c, the carrier of C()];
    nt in NonTerminals G by Th123;
    then reconsider nt as Symbol of G;
    reconsider ts = p as FinSequence of TS G by Th128;
A56: a = nt-tree ts by Th43;
    dom f = D by FUNCT_2:def 1;
    then
A57: f*p = <*fv*> by FINSEQ_2:34;
    rng p c= C()-Terms X
    proof
      let z be object;
      assume z in rng p;
      then z is expression of C(), an_Adj C() by Th41;
      then z is Element of C()-TermsX by MSAFREE3:8;
      hence thesis;
    end;
    then reconsider r = p as FinSequence of C()-Terms X by FINSEQ_1:def 4;
    a is Term of C(), X by MSAFREE3:8;
    then r is ArgumentSeq of Sym(c, X) by A56,MSATERM:1;
    then Sym(c, X) ==> roots r by MSATERM:21;
    then nt ==> roots ts by Th127;
    then f.a = NTermVal(nt, roots ts, f * ts) by A6,A56
      .= IFEQ(c,non_op, N((f * ts).1), F(c, f * ts)) by FUNCOP_1:def 8
      .= N((f*ts).1) by FUNCOP_1:def 8;
    hence f.((non_op C())term v) = N(f.v) by A57,FINSEQ_1:40;
  end;
  let v be expression of C(), an_Adj C();
  let t be expression of C(), a_Type C();
A58: v in U.an_Adj C() by Def28;
A59: t in U.a_Type C() by Def28;
A60: f.v in U.an_Adj C() by A58,Th129;
A61: f.t in U.a_Type C() by A59,Th129;
  reconsider fv = f.v as expression of C(), an_Adj C() by A60,Def28;
  reconsider ft = f.t as expression of C(), a_Type C() by A61,Def28;
  reconsider p = <*v,t*> as FinSequence of D;
  set c = ast C();
  set a = (ast C())term(v,t);
  set nt = [c, the carrier of C()];
  nt in NonTerminals G by Th123;
  then reconsider nt as Symbol of G;
  reconsider ts = p as FinSequence of TS G by Th128;
A62: a = nt-tree ts by Th46;
A63: f*p = <*fv,ft*> by FINSEQ_2:36;
  rng p c= C()-Terms X
  proof
    let z be object;
    assume z in rng p;
    then z is Element of C()-TermsX by MSAFREE3:8;
    hence thesis;
  end;
  then reconsider r = p as FinSequence of C()-Terms X by FINSEQ_1:def 4;
  a is Term of C(), X by MSAFREE3:8;
  then r is ArgumentSeq of Sym(c, X) by A62,MSATERM:1;
  then Sym(c, X) ==> roots r by MSATERM:21;
  then nt ==> roots ts by Th127;
  then f.a = NTermVal(nt, roots ts, f * ts) by A6,A62
    .= A((f*ts).1,(f*ts).2) by FUNCOP_1:def 8
    .= A(fv,(f*ts).2) by A63,FINSEQ_1:44;
  hence thesis by A63,FINSEQ_1:44;
end;

begin :: Substitution

definition
  let A be set;
  let x,y be set;
  let a,b be Element of A;
  redefine func IFIN(x,y,a,b) -> Element of A;
  coherence by MATRIX_7:def 1;
end;

definition
  let C be initialized ConstructorSignature;
  mode valuation of C is PartFunc of Vars, QuasiTerms C;
end;

definition
  let C be initialized ConstructorSignature;
  let f be valuation of C;
  attr f is irrelevant means
  :
  Def58: for x being variable st x in dom f
  ex y being variable st f.x = y-term C;
end;

notation
  let C be initialized ConstructorSignature;
  let f be valuation of C;
  antonym f is relevant for f is irrelevant;
end;

registration
  let C be initialized ConstructorSignature;
  cluster empty -> irrelevant for valuation of C;
  coherence;
end;

registration
  let C be initialized ConstructorSignature;
  cluster empty for valuation of C;
  existence
  proof
    take {}(Vars, QuasiTerms C);
    thus thesis;
  end;
end;

definition
  let C be initialized ConstructorSignature;
  let X be Subset of Vars;
  func C idval X -> valuation of C equals
  {[x, x-term C] where x is variable: x in X};
  coherence
  proof
    set f = {[x, x-term C] where x is variable: x in X};
    defpred P[variable,set] means $2 = $1-term C;
A1: now
      let x be variable;
      reconsider t = x-term C as Element of QuasiTerms C by Def28;
      take t;
      thus P[x,t];
    end;
    consider g being Function of Vars, QuasiTerms C such that
A2: for x being variable holds P[x,g.x] from FUNCT_2:sch 3(A1);
    f c= g
    proof
      let a be object;
      assume a in f;
      then consider x being variable such that
A3:   a = [x, x-term C] and x in X;
A4:   g.x = x-term C by A2;
      dom g = Vars by FUNCT_2:def 1;
      hence thesis by A3,A4,FUNCT_1:1;
    end;
    hence thesis by RELSET_1:1;
  end;
end;

theorem Th131:
  for X being Subset of Vars holds dom (C idval X) = X &
  for x being variable st x in X holds (C idval X).x = x-term C
proof
  let X be Subset of Vars;
  set f = C idval X;
  thus dom f c= X
  proof
    let a being object;
    assume a in dom f;
    then [a,f.a] in f by FUNCT_1:def 2;
    then ex x being variable st [a,f.a] = [x,x-term C] & x in X;
    hence thesis by XTUPLE_0:1;
  end;
  hereby
    let x be object;
    assume
A1: x in X;
    then reconsider a = x as variable;
    [a,a-term C] in f by A1;
    hence x in dom f by FUNCT_1:1;
  end;
  let x be variable;
  assume x in X;
  then [x,x-term C] in C idval X;
  hence thesis by FUNCT_1:1;
end;

registration
  let C be initialized ConstructorSignature;
  let X be Subset of Vars;
  cluster C idval X -> irrelevant one-to-one;
  coherence
  proof
    set f = C idval X;
A1: dom f = X by Th131;
    hereby
      let x be variable;
      assume
A2:   x in dom f;
      take y = x;
      thus f.x = y-term C by A1,A2,Th131;
    end;
    let x,y be object;
    assume that
A3: x in dom f and
A4: y in dom f;
    reconsider x,y as variable by A3,A4;
A5: f.x = x-term C by A1,A3,Th131;
    f.y = y-term C by A1,A4,Th131;
    hence thesis by A5,Th50;
  end;
end;

registration
  let C be initialized ConstructorSignature;
  let X be empty Subset of Vars;
  cluster C idval X -> empty;
  coherence
  proof
    dom (C idval X) = X by Th131;
    hence thesis;
  end;
end;

definition
  let C;
  let f be valuation of C;
  func f# -> term-transformation of C, MSVars C means
  :
  Def60: (for x being variable holds (x in dom f implies it.(x-term C) = f.x) &
  (not x in dom f implies it.(x-term C) = x-term C)) &
  (for c being constructor OperSymbol of C
  for p,q being FinSequence of QuasiTerms C
  st len p = len the_arity_of c & q = it*p
  holds it.(c-trm p) = c-trm q) &
  (for a being expression of C, an_Adj C
  holds it.((non_op C)term a) = (non_op C)term (it.a)) &
  for a being expression of C, an_Adj C
  for t being expression of C, a_Type C
  holds it.((ast C)term(a,t)) = (ast C)term(it.a, it.t);
  existence
  proof
    deffunc V(variable) = IFIN($1, dom f,
    (f/.$1 qua Element of (QuasiTerms C)
    qua non empty Subset of Free(C, MSVars C))
    qua (expression of C), $1-term C);
    deffunc F(constructor OperSymbol of C,FinSequence of QuasiTerms C) =
    $1-trm $2;
    deffunc N(expression of C) = (non_op C)term $1;
    deffunc A((expression of C), expression of C) = (ast C)term($1,$2);
A1: for x being variable holds V(x) is quasi-term of C
    proof
      let x be variable;
      f/.x is quasi-term of C by Th41;
      hence thesis by MATRIX_7:def 1;
    end;
A2: for c being constructor OperSymbol of C
    for p being FinSequence of QuasiTerms C
    st len p = len the_arity_of c
    holds F(c, p) is expression of C, the_result_sort_of c by Th52;
A3: for a holds N(a) is expression of C, an_Adj C by Th43;
A4: for a,t holds A(a,t) is expression of C, a_Type C by Th46;
    consider f9 being term-transformation of C, MSVars C such that
A5: (for x being variable holds f9.(x-term C) = V(x)) &
    (for c being constructor OperSymbol of C
    for p,q being FinSequence of QuasiTerms C
    st len p = len the_arity_of c & q = f9*p
    holds f9.(c-trm p) = F(c, q)) &
    (for a holds f9.((non_op C)term a) = N(f9.a)) &
    for a,t holds f9.((ast C)term(a,t)) = A(f9.a, f9.t)
    from StructDef(A1,A2,A3,A4);
    take f9;
    hereby
      let x be variable;
A6:   f9.(x-term C) = V(x) by A5;
      x in dom f implies f/.x = f.x by PARTFUN1:def 6;
      hence x in dom f implies f9.(x-term C) = f.x by A6,MATRIX_7:def 1;
      thus not x in dom f implies f9.(x-term C) = x-term C by A6,MATRIX_7:def 1
      ;
    end;
    thus thesis by A5;
  end;
  correctness
  proof
    let f1,f2 be term-transformation of C, MSVars C such that
A7: for x being variable holds (x in dom f implies f1.(x-term C) = f.x) &
    (not x in dom f implies f1.(x-term C) = x-term C) and
A8: for c being constructor OperSymbol of C for p,q being FinSequence
of QuasiTerms C st len p = len the_arity_of c & q = f1*p holds f1.(c-trm p) = c
    -trm q and
A9: for a being expression of C, an_Adj C holds f1.((non_op C)term a)
    = (non_op C)term (f1.a) and
A10: for a being expression of C, an_Adj C for t being expression of C,
    a_Type C holds f1.((ast C)term(a,t)) = (ast C)term(f1.a, f1.t) and
A11: for x being variable holds (x in dom f implies f2.(x-term C) = f.x
    ) & (not x in dom f implies f2.(x-term C) = x-term C) and
A12: for c being constructor OperSymbol of C for p,q being FinSequence
of QuasiTerms C st len p = len the_arity_of c & q = f2*p holds f2.(c-trm p) = c
    -trm q and
A13: for a being expression of C, an_Adj C holds f2.((non_op C)term a)
    = (non_op C)term (f2.a) and
A14: for a being expression of C, an_Adj C for t being expression of C,
    a_Type C holds f2.((ast C)term(a,t)) = (ast C)term(f2.a, f2.t);
    set D = Union the Sorts of Free(C, MSVars C);
A15: dom f1 = D by FUNCT_2:def 1;
A16: dom f2 = D by FUNCT_2:def 1;
    defpred P[expression of C] means f1.$1 = f2.$1;
A17: for x being variable holds P[x-term C]
    proof
      let x be variable;
      x in dom f & f1.(x-term C) = f.x or
      x nin dom f & f1.(x-term C) = x-term C by A7;
      hence thesis by A11;
    end;
A18: for c being constructor OperSymbol of C
    for p being FinSequence of QuasiTerms C
    st len p = len the_arity_of c &
    for t being quasi-term of C st t in rng p holds P[t]
    holds P[c-trm p]
    proof
      let c be constructor OperSymbol of C;
      let p be FinSequence of QuasiTerms C;
      assume that
A19:  len p = len the_arity_of c and
A20:  for t being quasi-term of C st t in rng p holds P[t];
A21:  rng p c= QuasiTerms C by FINSEQ_1:def 4;
A22:  rng(f1*p) = f1.:rng p by RELAT_1:127;
A23:  rng(f2*p) = f2.:rng p by RELAT_1:127;
A24:  rng(f1*p) c= f1.:QuasiTerms C by A21,A22,RELAT_1:123;
A25:  rng(f2*p) c= f2.:QuasiTerms C by A21,A23,RELAT_1:123;
A26:  f1.:QuasiTerms C c= QuasiTerms C by Def56;
A27:  f2.:QuasiTerms C c= QuasiTerms C by Def56;
A28:  rng(f1*p) c= QuasiTerms C by A24,A26;
      rng(f2*p) c= QuasiTerms C by A25,A27;
      then reconsider q1 = f1*p, q2 = f2*p as FinSequence of QuasiTerms C
      by A28,FINSEQ_1:def 4;
A29:  rng p c= D;
      then
A30:  dom q1 = dom p by A15,RELAT_1:27;
A31:  dom q2 = dom p by A16,A29,RELAT_1:27;
      now
        let i be Nat;
        assume
A32:    i in dom p;
        then
A33:    q1.i = f1.(p.i) by FUNCT_1:13;
A34:    q2.i = f2.(p.i) by A32,FUNCT_1:13;
A35:    p.i in rng p by A32,FUNCT_1:def 3;
        then p.i is quasi-term of C by A21,Th41;
        hence q1.i = q2.i by A20,A33,A34,A35;
      end;
      then f1.(c-trm p) = c-trm q2 by A8,A19,A30,A31,FINSEQ_1:13;
      hence thesis by A12,A19;
    end;
A36: for a being expression of C, an_Adj C st P[a] holds P[(non_op C)term a]
    proof
      let a be expression of C, an_Adj C;
      assume P[a];
      then f1.((non_op C)term a) = (non_op C)term (f2.a) by A9;
      hence thesis by A13;
    end;
A37: for a being expression of C, an_Adj C st P[a]
    for t being expression of C, a_Type C st P[t]
    holds P[(ast C)term(a,t)]
    proof
      let a be expression of C, an_Adj C such that
A38:  P[a];
      let t be expression of C, a_Type C;
      assume P[t];
      then f1.((ast C)term(a,t)) = (ast C)term(f2.a,f2.t) by A10,A38;
      hence thesis by A14;
    end;
    now
      let t be expression of C;
      thus P[t] from StructInd(A17,A18,A36,A37);
    end;
    hence thesis by FUNCT_2:63;
  end;
end;

registration
  let C;
  let f be valuation of C;
  cluster f# -> substitution;
  coherence
  proof
    let o be OperSymbol of C;
    let p,q be FinSequence of Free(C, MSVars C) such that
A1: [o, the carrier of C]-tree p in Union the Sorts of Free(C, MSVars C) and
A2: q = f# *p;
A3: dom (f# ) = Union the Sorts of Free(C, MSVars C) by FUNCT_2:def 1;
    reconsider t = [o, the carrier of C]-tree p as expression of C by A1;
A4: t.{} = [o, the carrier of C] by TREES_4:def 4;
    per cases;
    suppose o is constructor;
      then reconsider c = o as constructor OperSymbol of C;
A5:   t = [c, the carrier of C]-tree p;
      then
A6:   len p = len the_arity_of c by Th51;
      p in (QuasiTerms C)* by A5,Th51;
      then reconsider p9 = p as FinSequence of QuasiTerms C by FINSEQ_1:def 11;
      reconsider q9 = f# *p9 as FinSequence of QuasiTerms C by Th130;
A7:   len q9 = len p by Th130;
      thus f# .([o, the carrier of C]-tree p) = f# .(c-trm p9) by A6,Def35
        .= c-trm q9 by A6,Def60
        .= [o, the carrier of C]-tree q by A2,A6,A7,Def35;
    end;
    suppose
A8:   o = *;
      then consider a being expression of C, an_Adj C,
      s being expression of C, a_Type C such that
A9:   t = (ast C)term(a,s) by A4,Th58;
      a in (the Sorts of Free(C, MSVars C)).an_Adj C by Def28;
      then f#.a in (the Sorts of Free(C, MSVars C)).an_Adj C by Th129;
      then reconsider fa = f#.a as expression of C, an_Adj C by Th41;
      s in (the Sorts of Free(C, MSVars C)).a_Type C by Def28;
      then f#.s in (the Sorts of Free(C, MSVars C)).a_Type C by Th129;
      then reconsider fs = f#.s as expression of C, a_Type C by Th41;
      t = [ast C, the carrier of C]-tree <*a,s*> by A9,Th46;
      then p = <*a,s*> by TREES_4:15;
      then q = <*fa, fs*> by A2,A3,FINSEQ_2:125;
      then [o, the carrier of C]-tree q = (ast C)term(fa, fs) by A8,Th46;
      hence thesis by A9,Def60;
    end;
    suppose
A10:  o = non_op;
      then consider a such that
A11:  t = (non_op C)term a by A4,Th57;
      a in (the Sorts of Free(C, MSVars C)).an_Adj C by Def28;
      then f#.a in (the Sorts of Free(C, MSVars C)).an_Adj C by Th129;
      then reconsider fa = f#.a as expression of C, an_Adj C by Th41;
      t = [non_op C, the carrier of C]-tree <*a*> by A11,Th43;
      then p = <*a*> by TREES_4:15;
      then q = <*fa*> by A2,A3,FINSEQ_2:34;
      then [o, the carrier of C]-tree q = (non_op C)term fa by A10,Th43;
      hence thesis by A11,Def60;
    end;
  end;
end;

reserve f for valuation of C;

definition
  let C,f,e;
  func e at f -> expression of C equals
  f#.e;
  coherence;
end;

definition
  let C,f;
  let p be FinSequence such that
A1: rng p c= Union the Sorts of Free(C, MSVars C);
  func p at f -> FinSequence equals
  :
  Def62: f# * p;
  coherence
  proof
    set A = Free(C, MSVars C);
    dom (f# ) = Union the Sorts of A by FUNCT_2:def 1;
    then
A2: dom (f# *p) = dom p by A1,RELAT_1:27;
    dom p = Seg len p by FINSEQ_1:def 3;
    hence thesis by A2,FINSEQ_1:def 2;
  end;
end;

definition
  let C,f;
  let p be FinSequence of QuasiTerms C;
  redefine func p at f -> FinSequence of QuasiTerms C equals
  f# * p;
  coherence
  proof
A1: f# *p is FinSequence of QuasiTerms C by Th130;
    rng p c= Union the Sorts of Free(C, MSVars C);
    hence thesis by A1,Def62;
  end;
  compatibility
  proof
    rng p c= Union the Sorts of Free(C, MSVars C);
    hence thesis by Def62;
  end;
end;

reserve x for variable;

theorem
  not x in dom f implies (x-term C)at f = x-term C by Def60;

theorem
  x in dom f implies (x-term C)at f = f.x by Def60;

theorem
  len p = len the_arity_of c implies (c-trm p)at f = c-trm p at f by Def60;

theorem
  ((non_op C)term a)at f = (non_op C)term(a at f) by Def60;

theorem
  ((ast C)term(a,t))at f = (ast C)term(a at f,t at f) by Def60;

theorem Th137:
  for X being Subset of Vars holds e at (C idval X) = e
proof
  set t = e;
  let X be Subset of Vars;
  set f = C idval X;
  defpred P[expression of C] means $1 at f = $1;
A1: for x being variable holds P[x-term C]
  proof
    let x be variable;
A2: x in X or x nin X;
A3: dom f = X by Th131;
    x in X implies f.x = x-term C by Th131;
    hence thesis by A2,A3,Def60;
  end;
A4: for c being constructor OperSymbol of C
  for p being FinSequence of QuasiTerms C
  st len p = len the_arity_of c &
  for t being quasi-term of C st t in rng p holds P[t]
  holds P[c-trm p]
  proof
    let c be constructor OperSymbol of C;
    let p be FinSequence of QuasiTerms C such that
A5: len p = len the_arity_of c and
A6: for t being quasi-term of C st t in rng p holds P[t];
    len (p at f) = len p by Th130;
    then
A7: dom (p at f) = dom p by FINSEQ_3:29;
    now
      let i be Nat;
      assume
A8:   i in dom p;
      then
A9:   p.i in rng p by FUNCT_1:def 3;
      rng p c= QuasiTerms C by FINSEQ_1:def 4;
      then reconsider pi1 = p.i as quasi-term of C by A9,Th41;
      (p at f).i = pi1 at f by A8,FUNCT_1:13;
      hence (p at f).i = p.i by A6,A9;
    end;
    then p at f = p by A7;
    hence thesis by A5,Def60;
  end;
A10: for a being expression of C, an_Adj C st P[a]
  holds P[(non_op C)term a] by Def60;
A11: for a being expression of C, an_Adj C st P[a]
  for t being expression of C, a_Type C st P[t]
  holds P[(ast C)term(a,t)] by Def60;
  thus P[t] from StructInd(A1,A4,A10,A11);
end;

theorem
  for X being Subset of Vars
  holds (C idval X)# = id Union the Sorts of Free(C, MSVars C)
proof
  let X be Subset of Vars;
  set f = C idval X;
A1: dom (f# ) = Union the Sorts of Free(C, MSVars C) by FUNCT_2:def 1;
  now
    let x be object;
    assume x in Union the Sorts of Free(C, MSVars C);
    then reconsider t = x as expression of C;
    thus (f# ).x = t at f .= x by Th137;
  end;
  hence thesis by A1,FUNCT_1:17;
end;

theorem Th139:
  for f being empty valuation of C holds e at f = e
proof
  let f be empty valuation of C;
  f = C idval {}Vars;
  hence thesis by Th137;
end;

theorem
  for f being empty valuation of C
  holds f# = id Union the Sorts of Free(C, MSVars C)
proof
  let f be empty valuation of C;
A1: dom (f# ) = Union the Sorts of Free(C, MSVars C) by FUNCT_2:def 1;
  now
    let x be object;
    assume x in Union the Sorts of Free(C, MSVars C);
    then reconsider t = x as expression of C;
    thus (f# ).x = t at f .= x by Th139;
  end;
  hence thesis by A1,FUNCT_1:17;
end;

definition
  let C,f;
  let t be quasi-term of C;
  redefine func t at f -> quasi-term of C;
  coherence
  proof
    t in QuasiTerms C by Def28;
    then t at f in QuasiTerms C by Th129;
    hence thesis by Th41;
  end;
end;

definition
  let C,f;
  let a be expression of C, an_Adj C;
  redefine func a at f -> expression of C, an_Adj C;
  coherence
  proof
    a in (the Sorts of Free(C, MSVars C)).an_Adj C by Def28;
    then a at f in (the Sorts of Free(C, MSVars C)).an_Adj C by Th129;
    hence thesis by Th41;
  end;
end;

registration
  let C,f;
  let a be positive expression of C, an_Adj C;
  cluster a at f -> positive for expression of C, an_Adj C;
  coherence
  proof consider v being constructor OperSymbol of C such that
A1: the_result_sort_of v = an_Adj C and
A2: ex p being FinSequence of QuasiTerms C st
    len p = len the_arity_of v & a = v-trm p by Th65;
    consider p being FinSequence of QuasiTerms C such that
A3: len p = len the_arity_of v and
A4: a = v-trm p by A2;
A5: len (p at f) = len p by Th130;
    a at f = v-trm(p at f) by A3,A4,Def60;
    hence thesis by A1,A3,A5,Th66;
  end;
end;

registration
  let C,f;
  let a be negative expression of C, an_Adj C;
  cluster a at f -> negative for expression of C, an_Adj C;
  coherence
  proof
    (non_op C)term (Non a) = a by Th62;
    then a at f = (non_op C)term((Non a)at f) by Def60
      .= Non ((Non a)at f) by Th59;
    hence thesis;
  end;
end;

definition
  let C,f;
  let a be quasi-adjective of C;
  redefine func a at f -> quasi-adjective of C;
  coherence
  proof
    per cases;
    suppose a is positive;
      then reconsider a as positive quasi-adjective of C;
      a at f is positive;
      hence thesis;
    end;
    suppose a is negative;
      then reconsider a as negative quasi-adjective of C;
      a at f is negative;
      hence thesis;
    end;
  end;
end;

theorem
  (Non a) at f = Non (a at f) proof per cases;
  suppose a is positive;
    then reconsider b = a as positive expression of C, an_Adj C;
    reconsider af = b at f as positive expression of C, an_Adj C;
    thus (Non a) at f = ((non_op C)term b) at f by Th59
      .= (non_op C)term af by Def60
      .= Non (a at f) by Th59;
  end;
  suppose a is non positive;
    then consider b being expression of C, an_Adj C such that
A1: a = (non_op C)term b and
A2: Non a = b by Th60;
A3: a at f = (non_op C)term(b at f) by A1,Def60;
    then a at f is non positive;
    then ex k being expression of C, an_Adj C st
    a at f = (non_op C)term k & Non(a at f) = k by Th60;
    hence thesis by A2,A3,Th44;
  end;
end;

definition
  let C,f;
  let t be expression of C, a_Type C;
  redefine func t at f -> expression of C, a_Type C;
  coherence
  proof
    t in (the Sorts of Free(C, MSVars C)).a_Type C by Def28;
    then t at f in (the Sorts of Free(C, MSVars C)).a_Type C by Th129;
    hence thesis by Th41;
  end;
end;

registration
  let C,f;
  let t be pure expression of C, a_Type C;
  cluster t at f -> pure for expression of C, a_Type C;
  coherence
  proof consider m being constructor OperSymbol of C such that
A1: the_result_sort_of m = a_Type C and
A2: ex p being FinSequence of QuasiTerms C st
    len p = len the_arity_of m & t = m-trm p by Th74;
    consider p being FinSequence of QuasiTerms C such that
A3: len p = len the_arity_of m and
A4: t = m-trm p by A2;
A5: len (p at f) = len p by Th130;
    t at f = m-trm(p at f) by A3,A4,Def60;
    hence thesis by A1,A3,A5,Th75;
  end;
end;

theorem
  for f being irrelevant one-to-one valuation of C
  ex g being irrelevant one-to-one valuation of C
  st for x,y being variable holds
  x in dom f & f.x = y-term C iff y in dom g & g.y = x-term C
proof
  let f be irrelevant one-to-one valuation of C;
  set Y = {x where x is variable: x-term C in rng f};
  defpred P[object,object] means
  ex x being set st x in dom f & f.x = root-tree [ $1, a_Term] &
  $2 = root-tree [x, a_Term];
A1: for x being object st x in Y ex y being object st P[x,y]
  proof
    let x be object;
    assume x in Y;
    then
A2: ex z being variable st x = z & z-term C in rng f;
    then reconsider z = x as variable;
    consider y being object such that
A3: y in dom f and
A4: z-term C = f.y by A2,FUNCT_1:def 3;
    reconsider y as variable by A3;
    take y-term C;
    thus thesis by A3,A4;
  end;
  consider g being Function such that
A5: dom g = Y and
A6: for y being object st y in Y holds P[y,g.y]
       from CLASSES1:sch 1(A1);
A7: Y c= Vars
  proof
    let x be object;
    assume x in Y;
    then ex z being variable st x = z & z-term C in rng f;
    hence thesis;
  end;
  rng g c= QuasiTerms C
  proof
    let y be object;
    assume y in rng g;
    then consider x being object such that
A8: x in dom g and
A9: y = g.x by FUNCT_1:def 3;
    reconsider x as variable by A5,A7,A8;
    consider z being set such that
A10: z in dom f and f.z = x-term C and
A11: g.x = root-tree [z,a_Term] by A5,A6,A8;
    reconsider z as variable by A10;
    y = z-term C by A9,A11;
    hence thesis by Def28;
  end;
  then reconsider g as valuation of C by A5,A7,RELSET_1:4;
A12: g is irrelevant
  proof
    let x be variable;
    assume x in dom g;
    then consider y being set such that
A13: y in dom f and f.y = x-term C and
A14: g.x = root-tree [y,a_Term] by A5,A6;
    reconsider y as variable by A13;
    take y;
    thus thesis by A14;
  end;
  g is one-to-one
  proof
    let z1,z2 be object;
    assume that
A15: z1 in dom g and
A16: z2 in dom g and
A17: g.z1 = g.z2;
    reconsider z1,z2 as variable by A15,A16;
    consider x1 being set such that
A18: x1 in dom f and
A19: f.x1 = z1-term C and
A20: g.z1 = root-tree[x1,a_Term] by A5,A6,A15;
    consider x2 being set such that
A21: x2 in dom f and
A22: f.x2 = z2-term C and
A23: g.z1 = root-tree[x2,a_Term] by A5,A6,A16,A17;
    reconsider x1,x2 as variable by A18,A21;
    x1-term C = x2-term C by A20,A23;
    then x1 = x2 by Th50;
    hence thesis by A19,A22,Th50;
  end;
  then reconsider g as irrelevant one-to-one valuation of C by A12;
  take g;
  let x,y be variable;
  hereby
    assume that
A24: x in dom f and
A25: f.x = y-term C;
    f.x in rng f by A24,FUNCT_1:def 3;
    hence y in dom g by A5,A25;
    then P[y,g.y] by A5,A6;
    hence g.y = x-term C by A24,A25,FUNCT_1:def 4;
  end;
  assume that
A26: y in dom g and
A27: g.y = x-term C;
  consider z being set such that
A28: z in dom f and
A29: f.z = root-tree [y, a_Term] and
A30: x-term C = root-tree [z, a_Term] by A5,A6,A26,A27;
  reconsider z as variable by A28;
  x-term C = z-term C by A30;
  hence thesis by A28,A29,Th50;
end;

theorem
  for f,g being irrelevant one-to-one valuation of C
  st for x,y being variable holds
  x in dom f & f.x = y-term C implies y in dom g & g.y = x-term C
  for e st variables_in e c= dom f
  holds e at f at g = e
proof
  let f,g be irrelevant one-to-one valuation of C such that
A1: for x,y being variable holds
  x in dom f & f.x = y-term C implies y in dom g & g.y = x-term C;
  let t be expression of C;
  defpred P[expression of C] means
  variables_in $1 c= dom f implies $1 at f at g = $1;
A2: for x being variable holds P[x-term C]
  proof
    let x be variable;
    assume variables_in (x-term C) c= dom f;
    then {x} c= dom f by MSAFREE3:10;
    then
A3: x in dom f by ZFMISC_1:31;
    then consider y being variable such that
A4: f.x = y-term C by Def58;
A5: y in dom g by A1,A3,A4;
A6: g.y = x-term C by A1,A3,A4;
    (x-term C) at f = y-term C by A3,A4,Def60;
    hence thesis by A5,A6,Def60;
  end;
A7: for c being constructor OperSymbol of C
  for p being FinSequence of QuasiTerms C
  st len p = len the_arity_of c &
  for t being quasi-term of C st t in rng p holds P[t]
  holds P[c-trm p]
  proof
    let c be constructor OperSymbol of C;
    let p be FinSequence of QuasiTerms C such that
A8: len p = len the_arity_of c and
A9: for t being quasi-term of C st t in rng p holds P[t] and
A10: variables_in (c-trm p) c= dom f;
    c-trm p = [c, the carrier of C]-tree p by A8,Def35;
    then
A11: variables_in (c-trm p) = union {variables_in s where
    s is quasi-term of C: s in rng p} by Th88;
A12: len (p at f) = len p by Th130;
A13: len (p at f at g) = len (p at f) by Th130;
A14: dom (p at f) = dom p by A12,FINSEQ_3:29;
A15: dom (p at f at g) = dom (p at f) by A13,FINSEQ_3:29;
    now
      let i be Nat;
      assume
A16:  i in dom p;
      then
A17:  (p at f).i = f# .(p.i) by FUNCT_1:13;
A18:  p.i in rng p by A16,FUNCT_1:def 3;
      rng p c= QuasiTerms C by FINSEQ_1:def 4;
      then reconsider pi1 = p.i as quasi-term of C by A18,Th41;
      variables_in pi1 in {variables_in s where s is quasi-term of C:
      s in rng p} by A18;
      then
A19:  variables_in pi1 c= variables_in (c-trm p) by A11,ZFMISC_1:74;
      (p at f at g).i = pi1 at f at g by A14,A16,A17,FUNCT_1:13;
      hence (p at f at g).i = p.i by A9,A10,A18,A19,XBOOLE_1:1;
    end;
    then
A20: p at f at g = p by A14,A15;
    (c-trm p) at f = c-trm (p at f) by A8,Def60;
    hence thesis by A8,A12,A20,Def60;
  end;
A21: for a being expression of C, an_Adj C st P[a] holds P[(non_op C)term a]
  proof
    let a be expression of C, an_Adj C such that
A22: P[a] and
A23: variables_in ((non_op C)term a) c= dom f;
A24: (non_op C)term a = [non_op, the carrier of C]-tree <*a*> by Th43;
    thus ((non_op C)term a) at f at g = ((non_op C)term (a at f)) at g by Def60
      .= (non_op C)term a by A22,A23,A24,Def60,Th93;
  end;
A25: for a being expression of C, an_Adj C st P[a]
  for t being expression of C, a_Type C st P[t]
  holds P[(ast C)term(a,t)]
  proof
    let a be expression of C, an_Adj C such that
A26: P[a];
    let t be expression of C, a_Type C such that
A27: P[t] and
A28: variables_in ((ast C)term(a,t)) c= dom f;
    (ast C)term(a,t) = [ *, the carrier of C]-tree <*a,t*> by Th46;
    then
A29: variables_in ((ast C)term(a,t))
    = ((C variables_in a)(\/)(C variables_in t)).a_Term by Th96
      .= (variables_in a)\/variables_in t by PBOOLE:def 4;
    thus ((ast C)term(a,t)) at f at g
    = ((ast C)term (a at f, t at f)) at g by Def60
      .= (ast C)term(a,t) by A26,A27,A28,A29,Def60,XBOOLE_1:11;
  end;
  thus P[t] from StructInd(A2,A7,A21,A25);
end;

definition
  let C,f;
  let A be Subset of QuasiAdjs C;
  func A at f -> Subset of QuasiAdjs C equals
  {a at f where a is quasi-adjective of C: a in A};
  coherence
  proof
    set X = {a at f where a is quasi-adjective of C: a in A};
    X c= QuasiAdjs C
    proof
      let x be object;
      assume x in X;
      then ex a being quasi-adjective of C st x = a at f & a in A;
      hence thesis;
    end;
    hence thesis;
  end;
end;

theorem Th144:
  for A being Subset of QuasiAdjs C for a being quasi-adjective of C st A = {a}
  holds A at f = {a at f}
proof
  let A be Subset of QuasiAdjs C;
  let a be quasi-adjective of C such that
A1: A = {a};
  thus A at f c= {a at f}
  proof
    let x be object;
    assume x in A at f;
    then ex b being quasi-adjective of C st x = b at f & b in A;
    then x = a at f by A1,TARSKI:def 1;
    hence thesis by TARSKI:def 1;
  end;
  let x be object;
  assume x in {a at f};
  then
A2: x = a at f by TARSKI:def 1;
  a in A by A1,TARSKI:def 1;
  hence thesis by A2;
end;

theorem Th145:
  for A,B being Subset of QuasiAdjs C
  holds (A \/ B) at f = (A at f) \/ (B at f)
proof
  let A,B be Subset of QuasiAdjs C;
  thus (A \/ B) at f c= (A at f) \/ (B at f)
  proof
    let x be object;
    assume x in (A \/ B) at f;
    then consider a being quasi-adjective of C such that
A1: x = a at f and
A2: a in A \/ B;
    a in A or a in B by A2,XBOOLE_0:def 3;
    then x in A at f or x in B at f by A1;
    hence thesis by XBOOLE_0:def 3;
  end;
  let x be object;
  assume x in (A at f) \/ (B at f);
  then x in (A at f) or x in (B at f) by XBOOLE_0:def 3;
  then
  A c= A\/B & (ex a being quasi-adjective of C st x = a at f & a in A) or
  B c= A\/B & ex a being quasi-adjective of C st x = a at f & a in B
  by XBOOLE_1:7;
  hence thesis;
end;

theorem
  for A,B being Subset of QuasiAdjs C st A c= B holds A at f c= B at f
proof
  let A,B be Subset of QuasiAdjs C;
  assume A c= B;
  then A\/B = B by XBOOLE_1:12;
  then B at f = (A at f)\/(B at f) by Th145;
  hence thesis by XBOOLE_1:7;
end;

registration
  let C be initialized ConstructorSignature;
  let f be valuation of C;
  let A be finite Subset of QuasiAdjs C;
  cluster A at f -> finite;
  coherence
  proof
A1: A is finite;
    deffunc F(expression of C) = $1 at f;
A2: { F(w) where w is expression of C: w in A } is finite
    from FRAENKEL:sch 21(A1);
    A at f c= { F(w) where w is expression of C: w in A }
    proof
      let x be object;
      assume x in A at f;
      then ex a being quasi-adjective of C st x = a at f & a in A;
      hence thesis;
    end;
    hence thesis by A2;
  end;
end;

definition
  let C be initialized ConstructorSignature;
  let f be valuation of C;
  let T be quasi-type of C;
  func T at f -> quasi-type of C equals
  ((adjs T) at f)ast((the_base_of T) at f);
  coherence;
end;

theorem
  for T being quasi-type of C holds adjs(T at f) = (adjs T) at f &
  the_base_of (T at f) = (the_base_of T) at f;

theorem
  for T being quasi-type of C for a being quasi-adjective of C
  holds (a ast T) at f = (a at f) ast (T at f)
proof
  let T be quasi-type of C;
  let a be quasi-adjective of C;
  a in QuasiAdjs C;
  then reconsider A = {a} as Subset of QuasiAdjs C by ZFMISC_1:31;
  thus (a ast T) at f
  = [(adjs (a ast T)) at f,((the_base_of T) at f)]
    .= [(A\/(adjs T)) at f,((the_base_of T) at f)]
    .= [(A at f)\/((adjs T) at f),(the_base_of T) at f] by Th145
    .= [{a at f}\/((adjs T) at f),(the_base_of T) at f] by Th144
    .= [{a at f}\/(adjs (T at f)),(the_base_of T) at f]
    .= (a at f) ast (T at f);
end;

definition
  let C be initialized ConstructorSignature;
  let f,g be valuation of C;
  func f at g -> valuation of C means
  :
  Def66: dom it = (dom f) \/ dom g & for x being variable st x in dom it
  holds it.x = ((x-term C) at f) at g;
  existence
  proof
    deffunc h(object) = ((In($1,Vars)-term C) at f) at g;
    consider h being Function such that
A1: dom h = (dom f) \/ dom g and
A2: for x being object st x in (dom f) \/ dom g holds h.x = h(x)
    from FUNCT_1:sch 3;
    rng h c= QuasiTerms C
    proof
      let y be object;
      assume y in rng h;
      then consider x being object such that
A3:   x in dom h and
A4:   y = h.x by FUNCT_1:def 3;
      y = h(x) by A1,A2,A3,A4;
      hence thesis by Def28;
    end;
    then reconsider h as valuation of C by A1,RELSET_1:4;
    take h;
    thus dom h = (dom f) \/ dom g by A1;
    let x be variable;
    assume x in dom h;
    then h.x = h(x) by A1,A2;
    hence thesis;
  end;
  uniqueness
  proof
    let h1,h2 be valuation of C such that
A5: dom h1 = (dom f) \/ dom g and
A6: for x being variable st x in dom h1 holds h1.x = ((x-term C) at f) at g and
A7: dom h2 = (dom f) \/ dom g and
A8: for x being variable st x in dom h2 holds h2.x = ((x-term C) at f) at g;
    now
      let x be variable;
      assume
A9:   x in dom h1;
      then h1.x = ((x-term C) at f) at g by A6;
      hence h1.x = h2.x by A5,A7,A8,A9;
    end;
    hence thesis by A5,A7;
  end;
end;

registration
  let C be initialized ConstructorSignature;
  let f,g be irrelevant valuation of C;
  cluster f at g -> irrelevant;
  coherence
  proof
    let x be variable;
    assume
A1: x in dom (f at g);
    then
A2: (f at g).x = ((x-term C) at f) at g by Def66;
A3: dom (f at g) = dom f \/ dom g by Def66;
    per cases;
    suppose
A4:   x in dom f;
      then consider y being variable such that
A5:   f.x = y-term C by Def58;
A6:   (x-term C) at f = y-term C by A4,A5,Def60;
      then
A7:   y in dom g implies (f at g).x = g.y by A2,Def60;
      y nin dom g implies (f at g).x = y-term C by A2,A6,Def60;
      hence thesis by A7,Def58;
    end;
    suppose
A8:   x nin dom f;
      then
A9:   (x-term C) at f = x-term C by Def60;
A10:  x in dom g by A1,A3,A8,XBOOLE_0:def 3;
      then (f at g).x = g.x by A2,A9,Def60;
      hence thesis by A10,Def58;
    end;
  end;
end;

theorem Th149:
  for f1,f2 being valuation of C holds (e at f1) at f2 = e at (f1 at f2)
proof
  set t = e;
  let f1,f2 be valuation of C;
A1: dom (f1 at f2) = (dom f1) \/ dom f2 by Def66;
  defpred P[expression of C] means ($1 at f1) at f2 = $1 at (f1 at f2);
A2: for x being variable holds P[x-term C]
  proof
    let x be variable;
    per cases;
    suppose
A3:   x in dom (f1 at f2);
      then (x-term C) at (f1 at f2) = (f1 at f2).x by Def60;
      hence thesis by A3,Def66;
    end;
    suppose
A4:   x nin dom (f1 at f2);
      then
A5:   x nin dom f1 by A1,XBOOLE_0:def 3;
A6:   x nin dom f2 by A1,A4,XBOOLE_0:def 3;
A7:   (x-term C) at f1 = x-term C by A5,Def60;
      (x-term C) at f2 = x-term C by A6,Def60;
      hence thesis by A4,A7,Def60;
    end;
  end;
A8: for c being constructor OperSymbol of C
  for p being FinSequence of QuasiTerms C
  st len p = len the_arity_of c &
  for t being quasi-term of C st t in rng p holds P[t]
  holds P[c-trm p]
  proof
    let c be constructor OperSymbol of C;
    let p be FinSequence of QuasiTerms C such that
A9: len p = len the_arity_of c and
A10: for t being quasi-term of C st t in rng p holds P[t];
A11: len (p at f1) = len p by Th130;
A12: len (p at (f1 at f2)) = len p by Th130;
A13: len ((p at f1) at f2) = len (p at f1) by Th130;
A14: dom (p at f1) = dom p by A11,FINSEQ_3:29;
A15: dom (p at (f1 at f2)) = dom p by A12,FINSEQ_3:29;
A16: dom ((p at f1) at f2) = dom p by A11,A13,FINSEQ_3:29;
    now
      let i be Nat;
      assume
A17:  i in dom p;
      then
A18:  ((p at f1) at f2).i = f2# .((p at f1).i) by A14,FUNCT_1:13;
A19:  p.i in rng p by A17,FUNCT_1:def 3;
      rng p c= QuasiTerms C by FINSEQ_1:def 4;
      then reconsider pi1 = p.i as quasi-term of C by A19,Th41;
      thus (p at f1 at f2).i = (pi1 at f1) at f2 by A17,A18,FUNCT_1:13
        .= pi1 at (f1 at f2) by A10,A19
        .= (p at (f1 at f2)).i by A17,FUNCT_1:13;
    end;
    then
A20: p at f1 at f2 = p at (f1 at f2) by A15,A16;
    thus (c-trm p) at f1 at f2 = (c-trm(p at f1)) at f2 by A9,Def60
      .= c-trm (p at (f1 at f2)) by A9,A11,A20,Def60
      .= (c-trm p) at (f1 at f2) by A9,Def60;
  end;
A21: for a being expression of C, an_Adj C st P[a] holds P[(non_op C)term a]
  proof
    let a be expression of C, an_Adj C;
    assume P[a];
    then
    ((non_op C)term (a at f1)) at f2 = (non_op C)term (a at (f1 at f2))
    by Def60
      .= ((non_op C)term a) at (f1 at f2) by Def60;
    hence thesis by Def60;
  end;
A22: for a being expression of C, an_Adj C st P[a]
  for t being expression of C, a_Type C st P[t]
  holds P[(ast C)term(a,t)]
  proof
    let a be expression of C, an_Adj C such that
A23: P[a];
    let t be expression of C, a_Type C;
    assume P[t];
    then ((ast C)term (a at f1,t at f1)) at f2
    = (ast C)term (a at (f1 at f2),t at (f1 at f2)) by A23,Def60
      .= ((ast C)term(a,t)) at (f1 at f2) by Def60;
    hence thesis by Def60;
  end;
  thus P[t] from StructInd(A2,A8,A21,A22);
end;

theorem Th150:
  for A being Subset of QuasiAdjs C for f1,f2 being valuation of C
  holds (A at f1) at f2 = A at (f1 at f2)
proof
  let A be Subset of QuasiAdjs C;
  let f1,f2 be valuation of C;
  thus (A at f1) at f2 c= A at (f1 at f2)
  proof
    let x be object;
    assume x in (A at f1) at f2;
    then consider a being quasi-adjective of C such that
A1: x = a at f2 and
A2: a in A at f1;
    consider b being quasi-adjective of C such that
A3: a = b at f1 and
A4: b in A by A2;
    x = b at (f1 at f2) by A1,A3,Th149;
    hence thesis by A4;
  end;
  let x be object;
  assume x in A at (f1 at f2);
  then consider a being quasi-adjective of C such that
A5: x = a at (f1 at f2) and
A6: a in A;
A7: x = a at f1 at f2 by A5,Th149;
  a at f1 in A at f1 by A6;
  hence thesis by A7;
end;

theorem
  for T being quasi-type of C for f1,f2 being valuation of C
  holds (T at f1) at f2 = T at (f1 at f2)
proof
  let T be quasi-type of C;
  let f1,f2 be valuation of C;
  thus (T at f1) at f2
  = (((adjs T) at f1) at f2)ast((the_base_of (T at f1))at f2)
    .= ((adjs T) at (f1 at f2))ast((the_base_of (T at f1))at f2) by Th150
    .= ((adjs T) at (f1 at f2))ast(((the_base_of T) at f1)at f2)
    .= T at (f1 at f2) by Th149;
end;