:: MSAFREE semantic presentation

theorem Th1: :: MSAFREE:1
for b1 being set
for b2 being non empty set
for b3 being Function of b1,b2 *
for b4 being ManySortedSet of b2
for b5 being Element of b2 *
for b6 being set st b6 in b1 & b5 = b3 . b6 holds
((b4 # ) * b3) . b6 = product (b4 * b5)
proof end;

definition
let c1 be set ;
let c2, c3 be ManySortedSet of c1;
let c4 be ManySortedSubset of c2;
let c5 be ManySortedFunction of c2,c3;
func c5 || c4 -> ManySortedFunction of a4,a3 means :Def1: :: MSAFREE:def 1
for b1 being set st b1 in a1 holds
for b2 being Function of a2 . b1,a3 . b1 st b2 = a5 . b1 holds
a6 . b1 = b2 | (a4 . b1);
existence
ex b1 being ManySortedFunction of c4,c3 st
for b2 being set st b2 in c1 holds
for b3 being Function of c2 . b2,c3 . b2 st b3 = c5 . b2 holds
b1 . b2 = b3 | (c4 . b2)
proof end;
uniqueness
for b1, b2 being ManySortedFunction of c4,c3 st ( for b3 being set st b3 in c1 holds
for b4 being Function of c2 . b3,c3 . b3 st b4 = c5 . b3 holds
b1 . b3 = b4 | (c4 . b3) ) & ( for b3 being set st b3 in c1 holds
for b4 being Function of c2 . b3,c3 . b3 st b4 = c5 . b3 holds
b2 . b3 = b4 | (c4 . b3) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines || MSAFREE:def 1 :
for b1 being set
for b2, b3 being ManySortedSet of b1
for b4 being ManySortedSubset of b2
for b5 being ManySortedFunction of b2,b3
for b6 being ManySortedFunction of b4,b3 holds
( b6 = b5 || b4 iff for b7 being set st b7 in b1 holds
for b8 being Function of b2 . b7,b3 . b7 st b8 = b5 . b7 holds
b6 . b7 = b8 | (b4 . b7) );

definition
let c1 be set ;
let c2 be ManySortedSet of c1;
let c3 be set ;
assume E3: c3 in c1 ;
func coprod c3,c2 -> set means :Def2: :: MSAFREE:def 2
for b1 being set holds
( b1 in a4 iff ex b2 being set st
( b2 in a2 . a3 & b1 = [b2,a3] ) );
existence
ex b1 being set st
for b2 being set holds
( b2 in b1 iff ex b3 being set st
( b3 in c2 . c3 & b2 = [b3,c3] ) )
proof end;
uniqueness
for b1, b2 being set st ( for b3 being set holds
( b3 in b1 iff ex b4 being set st
( b4 in c2 . c3 & b3 = [b4,c3] ) ) ) & ( for b3 being set holds
( b3 in b2 iff ex b4 being set st
( b4 in c2 . c3 & b3 = [b4,c3] ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def2 defines coprod MSAFREE:def 2 :
for b1 being set
for b2 being ManySortedSet of b1
for b3 being set st b3 in b1 holds
for b4 being set holds
( b4 = coprod b3,b2 iff for b5 being set holds
( b5 in b4 iff ex b6 being set st
( b6 in b2 . b3 & b5 = [b6,b3] ) ) );

notation
let c1 be set ;
let c2 be ManySortedSet of c1;
synonym coprod c2 for disjoin c1;
end;

definition
let c1 be set ;
let c2 be ManySortedSet of c1;
redefine func coprod as coprod c2 -> ManySortedSet of a1 means :Def3: :: MSAFREE:def 3
for b1 being set st b1 in a1 holds
a3 . b1 = coprod b1,a2;
coherence
coprod is ManySortedSet of c1
proof end;
compatibility
for b1 being ManySortedSet of c1 holds
( b1 = coprod iff for b2 being set st b2 in c1 holds
b1 . b2 = coprod b2,c2 )
proof end;
end;

:: deftheorem Def3 defines coprod MSAFREE:def 3 :
for b1 being set
for b2, b3 being ManySortedSet of b1 holds
( b3 = coprod b2 iff for b4 being set st b4 in b1 holds
b3 . b4 = coprod b4,b2 );

registration
let c1 be non empty set ;
let c2 be V3 ManySortedSet of c1;
cluster coprod -> non-empty ;
coherence
coprod c2 is non-empty
proof end;
end;

registration
let c1 be non empty set ;
let c2 be V3 ManySortedSet of c1;
cluster Union a2 -> non empty ;
coherence
not Union c2 is empty
proof end;
end;

theorem Th2: :: MSAFREE:2
for b1 being set
for b2 being ManySortedSet of b1
for b3 being set st b3 in b1 holds
( b2 . b3 <> {} iff (coprod b2) . b3 <> {} )
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be MSAlgebra of c1;
mode GeneratorSet of c2 -> MSSubset of a2 means :Def4: :: MSAFREE:def 4
the Sorts of (GenMSAlg a3) = the Sorts of a2;
existence
ex b1 being MSSubset of c2 st the Sorts of (GenMSAlg b1) = the Sorts of c2
proof end;
end;

:: deftheorem Def4 defines GeneratorSet MSAFREE:def 4 :
for b1 being non empty non void ManySortedSign
for b2 being MSAlgebra of b1
for b3 being MSSubset of b2 holds
( b3 is GeneratorSet of b2 iff the Sorts of (GenMSAlg b3) = the Sorts of b2 );

theorem Th3: :: MSAFREE:3
for b1 being non empty non void ManySortedSign
for b2 being strict non-empty MSAlgebra of b1
for b3 being MSSubset of b2 holds
( b3 is GeneratorSet of b2 iff GenMSAlg b3 = b2 )
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be MSAlgebra of c1;
let c3 be GeneratorSet of c2;
attr a3 is free means :Def5: :: MSAFREE:def 5
for b1 being non-empty MSAlgebra of a1
for b2 being ManySortedFunction of a3,the Sorts of b1 ex b3 being ManySortedFunction of a2,b1 st
( b3 is_homomorphism a2,b1 & b3 || a3 = b2 );
end;

:: deftheorem Def5 defines free MSAFREE:def 5 :
for b1 being non empty non void ManySortedSign
for b2 being MSAlgebra of b1
for b3 being GeneratorSet of b2 holds
( b3 is free iff for b4 being non-empty MSAlgebra of b1
for b5 being ManySortedFunction of b3,the Sorts of b4 ex b6 being ManySortedFunction of b2,b4 st
( b6 is_homomorphism b2,b4 & b6 || b3 = b5 ) );

definition
let c1 be non empty non void ManySortedSign ;
let c2 be MSAlgebra of c1;
attr a2 is free means :Def6: :: MSAFREE:def 6
ex b1 being GeneratorSet of a2 st b1 is free;
end;

:: deftheorem Def6 defines free MSAFREE:def 6 :
for b1 being non empty non void ManySortedSign
for b2 being MSAlgebra of b1 holds
( b2 is free iff ex b3 being GeneratorSet of b2 st b3 is free );

theorem Th4: :: MSAFREE:4
for b1 being non empty non void ManySortedSign
for b2 being ManySortedSet of the carrier of b1 holds Union (coprod b2) misses [:the OperSymbols of b1,{the carrier of b1}:]
proof end;

registration
let c1 be non void ManySortedSign ;
cluster the OperSymbols of a1 -> non empty ;
coherence
not the OperSymbols of c1 is empty
by MSUALG_1:def 5;
end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be ManySortedSet of the carrier of c1;
canceled;
canceled;
func REL c2 -> Relation of [:the OperSymbols of a1,{the carrier of a1}:] \/ (Union (coprod a2)),([:the OperSymbols of a1,{the carrier of a1}:] \/ (Union (coprod a2))) * means :Def9: :: MSAFREE:def 9
for b1 being Element of [:the OperSymbols of a1,{the carrier of a1}:] \/ (Union (coprod a2))
for b2 being Element of ([:the OperSymbols of a1,{the carrier of a1}:] \/ (Union (coprod a2))) * holds
( [b1,b2] in a3 iff ( b1 in [:the OperSymbols of a1,{the carrier of a1}:] & ( for b3 being OperSymbol of a1 st [b3,the carrier of a1] = b1 holds
( len b2 = len (the_arity_of b3) & ( for b4 being set st b4 in dom b2 holds
( ( b2 . b4 in [:the OperSymbols of a1,{the carrier of a1}:] implies for b5 being OperSymbol of a1 st [b5,the carrier of a1] = b2 . b4 holds
the_result_sort_of b5 = (the_arity_of b3) . b4 ) & ( b2 . b4 in Union (coprod a2) implies b2 . b4 in coprod ((the_arity_of b3) . b4),a2 ) ) ) ) ) ) );
existence
ex b1 being Relation of [:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2)),([:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))) * st
for b2 being Element of [:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))
for b3 being Element of ([:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))) * holds
( [b2,b3] in b1 iff ( b2 in [:the OperSymbols of c1,{the carrier of c1}:] & ( for b4 being OperSymbol of c1 st [b4,the carrier of c1] = b2 holds
( len b3 = len (the_arity_of b4) & ( for b5 being set st b5 in dom b3 holds
( ( b3 . b5 in [:the OperSymbols of c1,{the carrier of c1}:] implies for b6 being OperSymbol of c1 st [b6,the carrier of c1] = b3 . b5 holds
the_result_sort_of b6 = (the_arity_of b4) . b5 ) & ( b3 . b5 in Union (coprod c2) implies b3 . b5 in coprod ((the_arity_of b4) . b5),c2 ) ) ) ) ) ) )
proof end;
uniqueness
for b1, b2 being Relation of [:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2)),([:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))) * st ( for b3 being Element of [:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))
for b4 being Element of ([:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))) * holds
( [b3,b4] in b1 iff ( b3 in [:the OperSymbols of c1,{the carrier of c1}:] & ( for b5 being OperSymbol of c1 st [b5,the carrier of c1] = b3 holds
( len b4 = len (the_arity_of b5) & ( for b6 being set st b6 in dom b4 holds
( ( b4 . b6 in [:the OperSymbols of c1,{the carrier of c1}:] implies for b7 being OperSymbol of c1 st [b7,the carrier of c1] = b4 . b6 holds
the_result_sort_of b7 = (the_arity_of b5) . b6 ) & ( b4 . b6 in Union (coprod c2) implies b4 . b6 in coprod ((the_arity_of b5) . b6),c2 ) ) ) ) ) ) ) ) & ( for b3 being Element of [:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))
for b4 being Element of ([:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))) * holds
( [b3,b4] in b2 iff ( b3 in [:the OperSymbols of c1,{the carrier of c1}:] & ( for b5 being OperSymbol of c1 st [b5,the carrier of c1] = b3 holds
( len b4 = len (the_arity_of b5) & ( for b6 being set st b6 in dom b4 holds
( ( b4 . b6 in [:the OperSymbols of c1,{the carrier of c1}:] implies for b7 being OperSymbol of c1 st [b7,the carrier of c1] = b4 . b6 holds
the_result_sort_of b7 = (the_arity_of b5) . b6 ) & ( b4 . b6 in Union (coprod c2) implies b4 . b6 in coprod ((the_arity_of b5) . b6),c2 ) ) ) ) ) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def7 MSAFREE:def 7 :
canceled;

:: deftheorem Def8 MSAFREE:def 8 :
canceled;

:: deftheorem Def9 defines REL MSAFREE:def 9 :
for b1 being non empty non void ManySortedSign
for b2 being ManySortedSet of the carrier of b1
for b3 being Relation of [:the OperSymbols of b1,{the carrier of b1}:] \/ (Union (coprod b2)),([:the OperSymbols of b1,{the carrier of b1}:] \/ (Union (coprod b2))) * holds
( b3 = REL b2 iff for b4 being Element of [:the OperSymbols of b1,{the carrier of b1}:] \/ (Union (coprod b2))
for b5 being Element of ([:the OperSymbols of b1,{the carrier of b1}:] \/ (Union (coprod b2))) * holds
( [b4,b5] in b3 iff ( b4 in [:the OperSymbols of b1,{the carrier of b1}:] & ( for b6 being OperSymbol of b1 st [b6,the carrier of b1] = b4 holds
( len b5 = len (the_arity_of b6) & ( for b7 being set st b7 in dom b5 holds
( ( b5 . b7 in [:the OperSymbols of b1,{the carrier of b1}:] implies for b8 being OperSymbol of b1 st [b8,the carrier of b1] = b5 . b7 holds
the_result_sort_of b8 = (the_arity_of b6) . b7 ) & ( b5 . b7 in Union (coprod b2) implies b5 . b7 in coprod ((the_arity_of b6) . b7),b2 ) ) ) ) ) ) ) );

theorem Th5: :: MSAFREE:5
for b1 being non empty non void ManySortedSign
for b2 being ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1
for b4 being Element of ([:the OperSymbols of b1,{the carrier of b1}:] \/ (Union (coprod b2))) * holds
( [[b3,the carrier of b1],b4] in REL b2 iff ( len b4 = len (the_arity_of b3) & ( for b5 being set st b5 in dom b4 holds
( ( b4 . b5 in [:the OperSymbols of b1,{the carrier of b1}:] implies for b6 being OperSymbol of b1 st [b6,the carrier of b1] = b4 . b5 holds
the_result_sort_of b6 = (the_arity_of b3) . b5 ) & ( b4 . b5 in Union (coprod b2) implies b4 . b5 in coprod ((the_arity_of b3) . b5),b2 ) ) ) ) )
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be ManySortedSet of the carrier of c1;
func DTConMSA c2 -> DTConstrStr equals :: MSAFREE:def 10
DTConstrStr(# ([:the OperSymbols of a1,{the carrier of a1}:] \/ (Union (coprod a2))),(REL a2) #);
correctness
coherence
DTConstrStr(# ([:the OperSymbols of c1,{the carrier of c1}:] \/ (Union (coprod c2))),(REL c2) #) is DTConstrStr
;
;
end;

:: deftheorem Def10 defines DTConMSA MSAFREE:def 10 :
for b1 being non empty non void ManySortedSign
for b2 being ManySortedSet of the carrier of b1 holds DTConMSA b2 = DTConstrStr(# ([:the OperSymbols of b1,{the carrier of b1}:] \/ (Union (coprod b2))),(REL b2) #);

registration
let c1 be non empty non void ManySortedSign ;
let c2 be ManySortedSet of the carrier of c1;
cluster DTConMSA a2 -> non empty strict ;
coherence
( DTConMSA c2 is strict & not DTConMSA c2 is empty )
;
end;

theorem Th6: :: MSAFREE:6
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds
( NonTerminals (DTConMSA b2) = [:the OperSymbols of b1,{the carrier of b1}:] & Terminals (DTConMSA b2) = Union (coprod b2) )
proof end;

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
cluster DTConMSA a2 -> non empty strict with_terminals with_nonterminals with_useful_nonterminals ;
coherence
( DTConMSA c2 is with_terminals & DTConMSA c2 is with_nonterminals & DTConMSA c2 is with_useful_nonterminals )
proof end;
end;

theorem Th7: :: MSAFREE:7
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being set holds
( b3 in Terminals (DTConMSA b2) iff ex b4 being SortSymbol of b1ex b5 being set st
( b5 in b2 . b4 & b3 = [b5,b4] ) )
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be OperSymbol of c1;
func Sym c3,c2 -> Symbol of (DTConMSA a2) equals :: MSAFREE:def 11
[a3,the carrier of a1];
coherence
[c3,the carrier of c1] is Symbol of (DTConMSA c2)
proof end;
end;

:: deftheorem Def11 defines Sym MSAFREE:def 11 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1 holds Sym b3,b2 = [b3,the carrier of b1];

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be SortSymbol of c1;
func FreeSort c2,c3 -> Subset of (TS (DTConMSA a2)) equals :: MSAFREE:def 12
{ b1 where B is Element of TS (DTConMSA a2) : ( ex b1 being set st
( b2 in a2 . a3 & b1 = root-tree [b2,a3] ) or ex b1 being OperSymbol of a1 st
( [b2,the carrier of a1] = b1 . {} & the_result_sort_of b2 = a3 ) )
}
;
coherence
{ b1 where B is Element of TS (DTConMSA c2) : ( ex b1 being set st
( b2 in c2 . c3 & b1 = root-tree [b2,c3] ) or ex b1 being OperSymbol of c1 st
( [b2,the carrier of c1] = b1 . {} & the_result_sort_of b2 = c3 ) )
}
is Subset of (TS (DTConMSA c2))
proof end;
end;

:: deftheorem Def12 defines FreeSort MSAFREE:def 12 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being SortSymbol of b1 holds FreeSort b2,b3 = { b4 where B is Element of TS (DTConMSA b2) : ( ex b1 being set st
( b5 in b2 . b3 & b4 = root-tree [b5,b3] ) or ex b1 being OperSymbol of b1 st
( [b5,the carrier of b1] = b4 . {} & the_result_sort_of b5 = b3 ) )
}
;

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be SortSymbol of c1;
cluster FreeSort a2,a3 -> non empty ;
coherence
not FreeSort c2,c3 is empty
proof end;
end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
func FreeSort c2 -> ManySortedSet of the carrier of a1 means :Def13: :: MSAFREE:def 13
for b1 being SortSymbol of a1 holds a3 . b1 = FreeSort a2,b1;
existence
ex b1 being ManySortedSet of the carrier of c1 st
for b2 being SortSymbol of c1 holds b1 . b2 = FreeSort c2,b2
proof end;
uniqueness
for b1, b2 being ManySortedSet of the carrier of c1 st ( for b3 being SortSymbol of c1 holds b1 . b3 = FreeSort c2,b3 ) & ( for b3 being SortSymbol of c1 holds b2 . b3 = FreeSort c2,b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def13 defines FreeSort MSAFREE:def 13 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1 holds
( b3 = FreeSort b2 iff for b4 being SortSymbol of b1 holds b3 . b4 = FreeSort b2,b4 );

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
cluster FreeSort a2 -> V3 ;
coherence
FreeSort c2 is non-empty
proof end;
end;

theorem Th8: :: MSAFREE:8
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1
for b4 being set st b4 in (((FreeSort b2) # ) * the Arity of b1) . b3 holds
b4 is FinSequence of TS (DTConMSA b2)
proof end;

theorem Th9: :: MSAFREE:9
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1
for b4 being FinSequence of TS (DTConMSA b2) holds
( b4 in (((FreeSort b2) # ) * the Arity of b1) . b3 iff ( dom b4 = dom (the_arity_of b3) & ( for b5 being Nat st b5 in dom b4 holds
b4 . b5 in FreeSort b2,((the_arity_of b3) /. b5) ) ) )
proof end;

theorem Th10: :: MSAFREE:10
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1
for b4 being FinSequence of TS (DTConMSA b2) holds
( Sym b3,b2 ==> roots b4 iff b4 in (((FreeSort b2) # ) * the Arity of b1) . b3 )
proof end;

theorem Th11: :: MSAFREE:11
canceled;

theorem Th12: :: MSAFREE:12
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds union (rng (FreeSort b2)) = TS (DTConMSA b2)
proof end;

theorem Th13: :: MSAFREE:13
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3, b4 being SortSymbol of b1 st b3 <> b4 holds
(FreeSort b2) . b3 misses (FreeSort b2) . b4
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be OperSymbol of c1;
func DenOp c3,c2 -> Function of (((FreeSort a2) # ) * the Arity of a1) . a3,((FreeSort a2) * the ResultSort of a1) . a3 means :Def14: :: MSAFREE:def 14
for b1 being FinSequence of TS (DTConMSA a2) st Sym a3,a2 ==> roots b1 holds
a4 . b1 = (Sym a3,a2) -tree b1;
existence
ex b1 being Function of (((FreeSort c2) # ) * the Arity of c1) . c3,((FreeSort c2) * the ResultSort of c1) . c3 st
for b2 being FinSequence of TS (DTConMSA c2) st Sym c3,c2 ==> roots b2 holds
b1 . b2 = (Sym c3,c2) -tree b2
proof end;
uniqueness
for b1, b2 being Function of (((FreeSort c2) # ) * the Arity of c1) . c3,((FreeSort c2) * the ResultSort of c1) . c3 st ( for b3 being FinSequence of TS (DTConMSA c2) st Sym c3,c2 ==> roots b3 holds
b1 . b3 = (Sym c3,c2) -tree b3 ) & ( for b3 being FinSequence of TS (DTConMSA c2) st Sym c3,c2 ==> roots b3 holds
b2 . b3 = (Sym c3,c2) -tree b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def14 defines DenOp MSAFREE:def 14 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1
for b4 being Function of (((FreeSort b2) # ) * the Arity of b1) . b3,((FreeSort b2) * the ResultSort of b1) . b3 holds
( b4 = DenOp b3,b2 iff for b5 being FinSequence of TS (DTConMSA b2) st Sym b3,b2 ==> roots b5 holds
b4 . b5 = (Sym b3,b2) -tree b5 );

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
func FreeOper c2 -> ManySortedFunction of ((FreeSort a2) # ) * the Arity of a1,(FreeSort a2) * the ResultSort of a1 means :Def15: :: MSAFREE:def 15
for b1 being OperSymbol of a1 holds a3 . b1 = DenOp b1,a2;
existence
ex b1 being ManySortedFunction of ((FreeSort c2) # ) * the Arity of c1,(FreeSort c2) * the ResultSort of c1 st
for b2 being OperSymbol of c1 holds b1 . b2 = DenOp b2,c2
proof end;
uniqueness
for b1, b2 being ManySortedFunction of ((FreeSort c2) # ) * the Arity of c1,(FreeSort c2) * the ResultSort of c1 st ( for b3 being OperSymbol of c1 holds b1 . b3 = DenOp b3,c2 ) & ( for b3 being OperSymbol of c1 holds b2 . b3 = DenOp b3,c2 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def15 defines FreeOper MSAFREE:def 15 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedFunction of ((FreeSort b2) # ) * the Arity of b1,(FreeSort b2) * the ResultSort of b1 holds
( b3 = FreeOper b2 iff for b4 being OperSymbol of b1 holds b3 . b4 = DenOp b4,b2 );

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
func FreeMSA c2 -> MSAlgebra of a1 equals :: MSAFREE:def 16
MSAlgebra(# (FreeSort a2),(FreeOper a2) #);
coherence
MSAlgebra(# (FreeSort c2),(FreeOper c2) #) is MSAlgebra of c1
;
end;

:: deftheorem Def16 defines FreeMSA MSAFREE:def 16 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds FreeMSA b2 = MSAlgebra(# (FreeSort b2),(FreeOper b2) #);

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
cluster FreeMSA a2 -> strict non-empty ;
coherence
( FreeMSA c2 is strict & FreeMSA c2 is non-empty )
by MSUALG_1:def 8;
end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be SortSymbol of c1;
func FreeGen c3,c2 -> Subset of ((FreeSort a2) . a3) means :Def17: :: MSAFREE:def 17
for b1 being set holds
( b1 in a4 iff ex b2 being set st
( b2 in a2 . a3 & b1 = root-tree [b2,a3] ) );
existence
ex b1 being Subset of ((FreeSort c2) . c3) st
for b2 being set holds
( b2 in b1 iff ex b3 being set st
( b3 in c2 . c3 & b2 = root-tree [b3,c3] ) )
proof end;
uniqueness
for b1, b2 being Subset of ((FreeSort c2) . c3) st ( for b3 being set holds
( b3 in b1 iff ex b4 being set st
( b4 in c2 . c3 & b3 = root-tree [b4,c3] ) ) ) & ( for b3 being set holds
( b3 in b2 iff ex b4 being set st
( b4 in c2 . c3 & b3 = root-tree [b4,c3] ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def17 defines FreeGen MSAFREE:def 17 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being SortSymbol of b1
for b4 being Subset of ((FreeSort b2) . b3) holds
( b4 = FreeGen b3,b2 iff for b5 being set holds
( b5 in b4 iff ex b6 being set st
( b6 in b2 . b3 & b5 = root-tree [b6,b3] ) ) );

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be SortSymbol of c1;
cluster FreeGen a3,a2 -> non empty ;
coherence
not FreeGen c3,c2 is empty
proof end;
end;

theorem Th14: :: MSAFREE:14
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being SortSymbol of b1 holds FreeGen b3,b2 = { (root-tree b4) where B is Symbol of (DTConMSA b2) : ( b4 in Terminals (DTConMSA b2) & b4 `2 = b3 ) }
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
func FreeGen c2 -> GeneratorSet of FreeMSA a2 means :Def18: :: MSAFREE:def 18
for b1 being SortSymbol of a1 holds a3 . b1 = FreeGen b1,a2;
existence
ex b1 being GeneratorSet of FreeMSA c2 st
for b2 being SortSymbol of c1 holds b1 . b2 = FreeGen b2,c2
proof end;
uniqueness
for b1, b2 being GeneratorSet of FreeMSA c2 st ( for b3 being SortSymbol of c1 holds b1 . b3 = FreeGen b3,c2 ) & ( for b3 being SortSymbol of c1 holds b2 . b3 = FreeGen b3,c2 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def18 defines FreeGen MSAFREE:def 18 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being GeneratorSet of FreeMSA b2 holds
( b3 = FreeGen b2 iff for b4 being SortSymbol of b1 holds b3 . b4 = FreeGen b4,b2 );

theorem Th15: :: MSAFREE:15
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds FreeGen b2 is non-empty
proof end;

theorem Th16: :: MSAFREE:16
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds union (rng (FreeGen b2)) = { (root-tree b3) where B is Symbol of (DTConMSA b2) : b3 in Terminals (DTConMSA b2) }
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be SortSymbol of c1;
func Reverse c3,c2 -> Function of FreeGen a3,a2,a2 . a3 means :Def19: :: MSAFREE:def 19
for b1 being Symbol of (DTConMSA a2) st root-tree b1 in FreeGen a3,a2 holds
a4 . (root-tree b1) = b1 `1 ;
existence
ex b1 being Function of FreeGen c3,c2,c2 . c3 st
for b2 being Symbol of (DTConMSA c2) st root-tree b2 in FreeGen c3,c2 holds
b1 . (root-tree b2) = b2 `1
proof end;
uniqueness
for b1, b2 being Function of FreeGen c3,c2,c2 . c3 st ( for b3 being Symbol of (DTConMSA c2) st root-tree b3 in FreeGen c3,c2 holds
b1 . (root-tree b3) = b3 `1 ) & ( for b3 being Symbol of (DTConMSA c2) st root-tree b3 in FreeGen c3,c2 holds
b2 . (root-tree b3) = b3 `1 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def19 defines Reverse MSAFREE:def 19 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being SortSymbol of b1
for b4 being Function of FreeGen b3,b2,b2 . b3 holds
( b4 = Reverse b3,b2 iff for b5 being Symbol of (DTConMSA b2) st root-tree b5 in FreeGen b3,b2 holds
b4 . (root-tree b5) = b5 `1 );

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
func Reverse c2 -> ManySortedFunction of FreeGen a2,a2 means :Def20: :: MSAFREE:def 20
for b1 being SortSymbol of a1 holds a3 . b1 = Reverse b1,a2;
existence
ex b1 being ManySortedFunction of FreeGen c2,c2 st
for b2 being SortSymbol of c1 holds b1 . b2 = Reverse b2,c2
proof end;
uniqueness
for b1, b2 being ManySortedFunction of FreeGen c2,c2 st ( for b3 being SortSymbol of c1 holds b1 . b3 = Reverse b3,c2 ) & ( for b3 being SortSymbol of c1 holds b2 . b3 = Reverse b3,c2 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def20 defines Reverse MSAFREE:def 20 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedFunction of FreeGen b2,b2 holds
( b3 = Reverse b2 iff for b4 being SortSymbol of b1 holds b3 . b4 = Reverse b4,b2 );

definition
let c1 be non empty non void ManySortedSign ;
let c2, c3 be V3 ManySortedSet of the carrier of c1;
let c4 be ManySortedFunction of FreeGen c2,c3;
let c5 be Symbol of (DTConMSA c2);
assume E26: c5 in Terminals (DTConMSA c2) ;
func pi c4,c3,c5 -> Element of Union a3 means :Def21: :: MSAFREE:def 21
for b1 being Function st b1 = a4 . (a5 `2 ) holds
a6 = b1 . (root-tree a5);
existence
ex b1 being Element of Union c3 st
for b2 being Function st b2 = c4 . (c5 `2 ) holds
b1 = b2 . (root-tree c5)
proof end;
uniqueness
for b1, b2 being Element of Union c3 st ( for b3 being Function st b3 = c4 . (c5 `2 ) holds
b1 = b3 . (root-tree c5) ) & ( for b3 being Function st b3 = c4 . (c5 `2 ) holds
b2 = b3 . (root-tree c5) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def21 defines pi MSAFREE:def 21 :
for b1 being non empty non void ManySortedSign
for b2, b3 being V3 ManySortedSet of the carrier of b1
for b4 being ManySortedFunction of FreeGen b2,b3
for b5 being Symbol of (DTConMSA b2) st b5 in Terminals (DTConMSA b2) holds
for b6 being Element of Union b3 holds
( b6 = pi b4,b3,b5 iff for b7 being Function st b7 = b4 . (b5 `2 ) holds
b6 = b7 . (root-tree b5) );

definition
let c1 be non empty non void ManySortedSign ;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be Symbol of (DTConMSA c2);
assume E27: ex b1 being FinSequence st c3 ==> b1 ;
func @ c2,c3 -> OperSymbol of a1 means :Def22: :: MSAFREE:def 22
[a4,the carrier of a1] = a3;
existence
ex b1 being OperSymbol of c1 st [b1,the carrier of c1] = c3
proof end;
uniqueness
for b1, b2 being OperSymbol of c1 st [b1,the carrier of c1] = c3 & [b2,the carrier of c1] = c3 holds
b1 = b2
by ZFMISC_1:33;
end;

:: deftheorem Def22 defines @ MSAFREE:def 22 :
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Symbol of (DTConMSA b2) st ex b4 being FinSequence st b3 ==> b4 holds
for b4 being OperSymbol of b1 holds
( b4 = @ b2,b3 iff [b4,the carrier of b1] = b3 );

definition
let c1 be non empty non void ManySortedSign ;
let c2 be non-empty MSAlgebra of c1;
let c3 be OperSymbol of c1;
let c4 be FinSequence;
assume E28: c4 in Args c3,c2 ;
func pi c3,c2,c4 -> Element of Union the Sorts of a2 equals :Def23: :: MSAFREE:def 23
(Den a3,a2) . a4;
coherence
(Den c3,c2) . c4 is Element of Union the Sorts of c2
proof end;
end;

:: deftheorem Def23 defines pi MSAFREE:def 23 :
for b1 being non empty non void ManySortedSign
for b2 being non-empty MSAlgebra of b1
for b3 being OperSymbol of b1
for b4 being FinSequence st b4 in Args b3,b2 holds
pi b3,b2,b4 = (Den b3,b2) . b4;

theorem Th17: :: MSAFREE:17
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds FreeGen b2 is free
proof end;

theorem Th18: :: MSAFREE:18
for b1 being non empty non void ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1 holds FreeMSA b2 is free
proof end;

registration
let c1 be non empty non void ManySortedSign ;
cluster strict non-empty free MSAlgebra of a1;
existence
ex b1 being non-empty MSAlgebra of c1 st
( b1 is free & b1 is strict )
proof end;
end;

registration
let c1 be non empty non void ManySortedSign ;
let c2 be free MSAlgebra of c1;
cluster free GeneratorSet of a2;
existence
ex b1 being GeneratorSet of c2 st b1 is free
by Def6;
end;

theorem Th19: :: MSAFREE:19
for b1 being non empty non void ManySortedSign
for b2 being non-empty MSAlgebra of b1 ex b3 being strict non-empty free MSAlgebra of b1ex b4 being ManySortedFunction of b3,b2 st b4 is_epimorphism b3,b2
proof end;

theorem Th20: :: MSAFREE:20
for b1 being non empty non void ManySortedSign
for b2 being strict non-empty MSAlgebra of b1 ex b3 being strict non-empty free MSAlgebra of b1ex b4 being ManySortedFunction of b3,b2 st
( b4 is_epimorphism b3,b2 & Image b4 = b2 )
proof end;