:: MSAFREE3 semantic presentation

registration
let c1 be non empty non void ManySortedSign ;
let c2 be non empty MSAlgebra of c1;
cluster Union the Sorts of a2 -> non empty ;
coherence
not Union the Sorts of c2 is empty
proof end;
end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be non empty MSAlgebra of c1;
mode Element of a2 is Element of Union the Sorts of a2;
end;

theorem Th1: :: MSAFREE3:1
for b1 being set
for b2 being Function st b1 c= dom b2 & b2 is one-to-one holds
b2 " (b2 .: b1) = b1
proof end;

theorem Th2: :: MSAFREE3:2
for b1 being set
for b2 being ManySortedSet of b1
for b3 being ManySortedFunction of b1 st b3 is "1-1" & b2 c= doms b3 holds
b3 "" (b3 .:.: b2) = b2
proof end;

definition
let c1 be non void Signature;
let c2 be ManySortedSet of the carrier of c1;
canceled;
func Free c1,c2 -> strict MSAlgebra of a1 means :Def2: :: MSAFREE3:def 2
ex b1 being MSSubset of (FreeMSA (a2 \/ (the carrier of a1 --> {0}))) st
( a3 = GenMSAlg b1 & b1 = (Reverse (a2 \/ (the carrier of a1 --> {0}))) "" a2 );
uniqueness
for b1, b2 being strict MSAlgebra of c1 st ex b3 being MSSubset of (FreeMSA (c2 \/ (the carrier of c1 --> {0}))) st
( b1 = GenMSAlg b3 & b3 = (Reverse (c2 \/ (the carrier of c1 --> {0}))) "" c2 ) & ex b3 being MSSubset of (FreeMSA (c2 \/ (the carrier of c1 --> {0}))) st
( b2 = GenMSAlg b3 & b3 = (Reverse (c2 \/ (the carrier of c1 --> {0}))) "" c2 ) holds
b1 = b2
;
existence
ex b1 being strict MSAlgebra of c1ex b2 being MSSubset of (FreeMSA (c2 \/ (the carrier of c1 --> {0}))) st
( b1 = GenMSAlg b2 & b2 = (Reverse (c2 \/ (the carrier of c1 --> {0}))) "" c2 )
proof end;
end;

:: deftheorem Def1 MSAFREE3:def 1 :
canceled;

:: deftheorem Def2 defines Free MSAFREE3:def 2 :
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1
for b3 being strict MSAlgebra of b1 holds
( b3 = Free b1,b2 iff ex b4 being MSSubset of (FreeMSA (b2 \/ (the carrier of b1 --> {0}))) st
( b3 = GenMSAlg b4 & b4 = (Reverse (b2 \/ (the carrier of b1 --> {0}))) "" b2 ) );

theorem Th3: :: MSAFREE3:3
for b1 being set
for b2 being non void Signature
for b3 being V3 ManySortedSet of the carrier of b2
for b4 being SortSymbol of b2 holds
( [b1,b4] in the carrier of (DTConMSA b3) iff b1 in b3 . b4 )
proof end;

theorem Th4: :: MSAFREE3:4
for b1 being set
for b2 being non void Signature
for b3 being V3 ManySortedSet of the carrier of b2
for b4 being ManySortedSet of the carrier of b2
for b5 being SortSymbol of b2 holds
( ( b1 in b4 . b5 & b1 in b3 . b5 ) iff root-tree [b1,b5] in ((Reverse b3) "" b4) . b5 )
proof end;

theorem Th5: :: MSAFREE3:5
for b1 being set
for b2 being non void Signature
for b3 being ManySortedSet of the carrier of b2
for b4 being SortSymbol of b2 st b1 in b3 . b4 holds
root-tree [b1,b4] in the Sorts of (Free b2,b3) . b4
proof end;

theorem Th6: :: MSAFREE3:6
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1
for b3 being OperSymbol of b1 st the_arity_of b3 = {} holds
root-tree [b3,the carrier of b1] in the Sorts of (Free b1,b2) . (the_result_sort_of b3)
proof end;

registration
let c1 be non void Signature;
let c2 be V4 ManySortedSet of the carrier of c1;
cluster Free a1,a2 -> strict non empty ;
coherence
not Free c1,c2 is empty
proof end;
end;

theorem Th7: :: MSAFREE3:7
for b1 being set
for b2 being non void Signature
for b3 being V3 ManySortedSet of the carrier of b2 holds
( b1 is Element of (FreeMSA b3) iff b1 is Term of b2,b3 )
proof end;

theorem Th8: :: MSAFREE3:8
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being SortSymbol of b1
for b4 being Term of b1,b2 holds
( b4 in the Sorts of (FreeMSA b2) . b3 iff the_sort_of b4 = b3 )
proof end;

theorem Th9: :: MSAFREE3:9
for b1 being non void Signature
for b2 being V4 ManySortedSet of the carrier of b1
for b3 being Element of (Free b1,b2) holds b3 is Term of b1,(b2 \/ (the carrier of b1 --> {0}))
proof end;

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V4 ManySortedSet of the carrier of c1;
cluster -> Relation-like Function-like Element of Union the Sorts of (Free a1,a2);
coherence
for b1 being Element of (Free c1,c2) holds
( b1 is Relation-like & b1 is Function-like )
by Th9;
end;

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V4 ManySortedSet of the carrier of c1;
cluster -> Relation-like Function-like finite DecoratedTree-like Element of Union the Sorts of (Free a1,a2);
coherence
for b1 being Element of (Free c1,c2) holds
( b1 is finite & b1 is DecoratedTree-like )
by Th9;
end;

registration
let c1 be non empty non void ManySortedSign ;
let c2 be V4 ManySortedSet of the carrier of c1;
cluster -> Relation-like Function-like finite DecoratedTree-like finite-branching Element of Union the Sorts of (Free a1,a2);
coherence
for b1 being Element of (Free c1,c2) holds b1 is finite-branching
;
end;

registration
cluster -> non empty set ;
coherence
for b1 being DecoratedTree holds not b1 is empty
proof end;
end;

definition
let c1 be ManySortedSign ;
let c2 be non empty Relation;
func c1 variables_in c2 -> ManySortedSet of the carrier of a1 means :Def3: :: MSAFREE3:def 3
for b1 being set st b1 in the carrier of a1 holds
a3 . b1 = { (b2 `1 ) where B is Element of rng a2 : b2 `2 = b1 } ;
existence
ex b1 being ManySortedSet of the carrier of c1 st
for b2 being set st b2 in the carrier of c1 holds
b1 . b2 = { (b3 `1 ) where B is Element of rng c2 : b3 `2 = b2 }
proof end;
uniqueness
for b1, b2 being ManySortedSet of the carrier of c1 st ( for b3 being set st b3 in the carrier of c1 holds
b1 . b3 = { (b4 `1 ) where B is Element of rng c2 : b4 `2 = b3 } ) & ( for b3 being set st b3 in the carrier of c1 holds
b2 . b3 = { (b4 `1 ) where B is Element of rng c2 : b4 `2 = b3 } ) holds
b1 = b2
proof end;
end;

:: deftheorem Def3 defines variables_in MSAFREE3:def 3 :
for b1 being ManySortedSign
for b2 being non empty Relation
for b3 being ManySortedSet of the carrier of b1 holds
( b3 = b1 variables_in b2 iff for b4 being set st b4 in the carrier of b1 holds
b3 . b4 = { (b5 `1 ) where B is Element of rng b2 : b5 `2 = b4 } );

definition
let c1 be ManySortedSign ;
let c2 be ManySortedSet of the carrier of c1;
let c3 be non empty Relation;
func c2 variables_in c3 -> ManySortedSubset of a2 equals :: MSAFREE3:def 4
a2 /\ (a1 variables_in a3);
coherence
c2 /\ (c1 variables_in c3) is ManySortedSubset of c2
proof end;
end;

:: deftheorem Def4 defines variables_in MSAFREE3:def 4 :
for b1 being ManySortedSign
for b2 being ManySortedSet of the carrier of b1
for b3 being non empty Relation holds b2 variables_in b3 = b2 /\ (b1 variables_in b3);

theorem Th10: :: MSAFREE3:10
for b1 being ManySortedSign
for b2 being ManySortedSet of the carrier of b1
for b3 being non empty Relation
for b4 being ManySortedSubset of b2 holds
( b4 = b2 variables_in b3 iff for b5 being set st b5 in the carrier of b1 holds
b4 . b5 = (b2 . b5) /\ { (b6 `1 ) where B is Element of rng b3 : b6 `2 = b5 } )
proof end;

theorem Th11: :: MSAFREE3:11
for b1 being ManySortedSign
for b2, b3 being set holds
( ( b2 in the carrier of b1 implies (b1 variables_in (root-tree [b3,b2])) . b2 = {b3} ) & ( for b4 being set st ( b4 <> b2 or not b2 in the carrier of b1 ) holds
(b1 variables_in (root-tree [b3,b2])) . b4 = {} ) )
proof end;

theorem Th12: :: MSAFREE3:12
for b1, b2 being set
for b3 being ManySortedSign
for b4 being set st b4 in the carrier of b3 holds
for b5 being DTree-yielding FinSequence holds
( b1 in (b3 variables_in ([b2,the carrier of b3] -tree b5)) . b4 iff ex b6 being DecoratedTree st
( b6 in rng b5 & b1 in (b3 variables_in b6) . b4 ) )
proof end;

theorem Th13: :: MSAFREE3:13
for b1 being ManySortedSign
for b2 being ManySortedSet of the carrier of b1
for b3, b4 being set holds
( ( b4 in b2 . b3 implies (b2 variables_in (root-tree [b4,b3])) . b3 = {b4} ) & ( for b5 being set st ( b5 <> b3 or not b4 in b2 . b3 ) holds
(b2 variables_in (root-tree [b4,b3])) . b5 = {} ) )
proof end;

theorem Th14: :: MSAFREE3:14
for b1, b2 being set
for b3 being ManySortedSign
for b4 being ManySortedSet of the carrier of b3
for b5 being set st b5 in the carrier of b3 holds
for b6 being DTree-yielding FinSequence holds
( b1 in (b4 variables_in ([b2,the carrier of b3] -tree b6)) . b5 iff ex b7 being DecoratedTree st
( b7 in rng b6 & b1 in (b4 variables_in b7) . b5 ) )
proof end;

theorem Th15: :: MSAFREE3:15
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Term of b1,b2 holds b1 variables_in b3 c= b2
proof end;

definition
let c1 be non void Signature;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be Term of c1,c2;
func variables_in c3 -> ManySortedSubset of a2 equals :: MSAFREE3:def 5
a1 variables_in a3;
correctness
coherence
c1 variables_in c3 is ManySortedSubset of c2
;
proof end;
end;

:: deftheorem Def5 defines variables_in MSAFREE3:def 5 :
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Term of b1,b2 holds variables_in b3 = b1 variables_in b3;

theorem Th16: :: MSAFREE3:16
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Term of b1,b2 holds variables_in b3 = b2 variables_in b3
proof end;

definition
let c1 be non void Signature;
let c2 be V3 ManySortedSet of the carrier of c1;
let c3 be ManySortedSet of the carrier of c1;
func c1 -Terms c3,c2 -> MSSubset of (FreeMSA a2) means :Def6: :: MSAFREE3:def 6
for b1 being SortSymbol of a1 holds a4 . b1 = { b2 where B is Term of a1,a2 : ( the_sort_of b2 = b1 & variables_in b2 c= a3 ) } ;
existence
ex b1 being MSSubset of (FreeMSA c2) st
for b2 being SortSymbol of c1 holds b1 . b2 = { b3 where B is Term of c1,c2 : ( the_sort_of b3 = b2 & variables_in b3 c= c3 ) }
proof end;
correctness
uniqueness
for b1, b2 being MSSubset of (FreeMSA c2) st ( for b3 being SortSymbol of c1 holds b1 . b3 = { b4 where B is Term of c1,c2 : ( the_sort_of b4 = b3 & variables_in b4 c= c3 ) } ) & ( for b3 being SortSymbol of c1 holds b2 . b3 = { b4 where B is Term of c1,c2 : ( the_sort_of b4 = b3 & variables_in b4 c= c3 ) } ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def6 defines -Terms MSAFREE3:def 6 :
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1
for b4 being MSSubset of (FreeMSA b2) holds
( b4 = b1 -Terms b3,b2 iff for b5 being SortSymbol of b1 holds b4 . b5 = { b6 where B is Term of b1,b2 : ( the_sort_of b6 = b5 & variables_in b6 c= b3 ) } );

theorem Th17: :: MSAFREE3:17
for b1 being set
for b2 being non void Signature
for b3 being V3 ManySortedSet of the carrier of b2
for b4 being ManySortedSet of the carrier of b2
for b5 being SortSymbol of b2 st b1 in (b2 -Terms b4,b3) . b5 holds
b1 is Term of b2,b3
proof end;

theorem Th18: :: MSAFREE3:18
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1
for b4 being Term of b1,b2
for b5 being SortSymbol of b1 st b4 in (b1 -Terms b3,b2) . b5 holds
( the_sort_of b4 = b5 & variables_in b4 c= b3 )
proof end;

theorem Th19: :: MSAFREE3:19
for b1 being set
for b2 being non void Signature
for b3 being V3 ManySortedSet of the carrier of b2
for b4 being ManySortedSet of the carrier of b2
for b5 being SortSymbol of b2 holds
( root-tree [b1,b5] in (b2 -Terms b4,b3) . b5 iff ( b1 in b4 . b5 & b1 in b3 . b5 ) )
proof end;

theorem Th20: :: MSAFREE3:20
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1
for b4 being OperSymbol of b1
for b5 being ArgumentSeq of Sym b4,b2 holds
( (Sym b4,b2) -tree b5 in (b1 -Terms b3,b2) . (the_result_sort_of b4) iff rng b5 c= Union (b1 -Terms b3,b2) )
proof end;

theorem Th21: :: MSAFREE3:21
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being MSSubset of (FreeMSA b2) holds
( b3 is opers_closed iff for b4 being OperSymbol of b1
for b5 being ArgumentSeq of Sym b4,b2 st rng b5 c= Union b3 holds
(Sym b4,b2) -tree b5 in b3 . (the_result_sort_of b4) )
proof end;

theorem Th22: :: MSAFREE3:22
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1 holds b1 -Terms b3,b2 is opers_closed
proof end;

theorem Th23: :: MSAFREE3:23
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1 holds (Reverse b2) "" b3 c= b1 -Terms b3,b2
proof end;

theorem Th24: :: MSAFREE3:24
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1
for b3 being Term of b1,(b2 \/ (the carrier of b1 --> {0}))
for b4 being SortSymbol of b1 st b3 in (b1 -Terms b2,(b2 \/ (the carrier of b1 --> {0}))) . b4 holds
b3 in the Sorts of (Free b1,b2) . b4
proof end;

theorem Th25: :: MSAFREE3:25
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1 holds the Sorts of (Free b1,b2) = b1 -Terms b2,(b2 \/ (the carrier of b1 --> {0}))
proof end;

theorem Th26: :: MSAFREE3:26
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1 holds (FreeMSA (b2 \/ (the carrier of b1 --> {0}))) | (b1 -Terms b2,(b2 \/ (the carrier of b1 --> {0}))) = Free b1,b2
proof end;

theorem Th27: :: MSAFREE3:27
for b1 being non void Signature
for b2, b3 being V3 ManySortedSet of the carrier of b1
for b4 being MSSubAlgebra of FreeMSA b2
for b5 being MSSubAlgebra of FreeMSA b3 st the Sorts of b4 = the Sorts of b5 holds
MSAlgebra(# the Sorts of b4,the Charact of b4 #) = MSAlgebra(# the Sorts of b5,the Charact of b5 #)
proof end;

theorem Th28: :: MSAFREE3:28
for b1 being non void Signature
for b2 being V4 ManySortedSet of the carrier of b1
for b3 being ManySortedSet of the carrier of b1
for b4 being Element of (Free b1,b2) holds b1 variables_in b4 c= b2
proof end;

theorem Th29: :: MSAFREE3:29
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Term of b1,b2 holds variables_in b3 c= b2
proof end;

theorem Th30: :: MSAFREE3:30
for b1 being non void Signature
for b2, b3 being V3 ManySortedSet of the carrier of b1
for b4 being Term of b1,b2
for b5 being Term of b1,b3 st b4 = b5 holds
the_sort_of b4 = the_sort_of b5
proof end;

theorem Th31: :: MSAFREE3:31
for b1 being non void Signature
for b2, b3 being V3 ManySortedSet of the carrier of b1
for b4 being Term of b1,b3 st variables_in b4 c= b2 holds
b4 is Term of b1,b2
proof end;

theorem Th32: :: MSAFREE3:32
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1 holds Free b1,b2 = FreeMSA b2
proof end;

theorem Th33: :: MSAFREE3:33
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Term of b1,b2
for b4 being Element of dom b3 holds variables_in (b3 | b4) c= variables_in b3
proof end;

theorem Th34: :: MSAFREE3:34
for b1 being non void Signature
for b2 being V4 ManySortedSet of the carrier of b1
for b3 being Element of (Free b1,b2)
for b4 being Element of dom b3 holds b3 | b4 is Element of (Free b1,b2)
proof end;

theorem Th35: :: MSAFREE3:35
for b1 being non void Signature
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being Term of b1,b2
for b4 being Element of rng b3 holds b4 = [(b4 `1 ),(b4 `2 )]
proof end;

theorem Th36: :: MSAFREE3:36
for b1 being set
for b2 being non void Signature
for b3 being V4 ManySortedSet of the carrier of b2
for b4 being Element of (Free b2,b3)
for b5 being SortSymbol of b2 holds
( ( b1 in (b2 variables_in b4) . b5 implies [b1,b5] in rng b4 ) & ( [b1,b5] in rng b4 implies ( b1 in (b2 variables_in b4) . b5 & b1 in b3 . b5 ) ) )
proof end;

theorem Th37: :: MSAFREE3:37
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1 st ( for b3 being SortSymbol of b1 st b2 . b3 = {} holds
ex b4 being OperSymbol of b1 st
( the_result_sort_of b4 = b3 & the_arity_of b4 = {} ) ) holds
Free b1,b2 is non-empty
proof end;

theorem Th38: :: MSAFREE3:38
for b1 being non empty non void ManySortedSign
for b2 being MSAlgebra of b1
for b3 being MSSubAlgebra of b2
for b4 being OperSymbol of b1 holds Args b4,b3 c= Args b4,b2
proof end;

theorem Th39: :: MSAFREE3:39
for b1 being non void Signature
for b2 being feasible MSAlgebra of b1
for b3 being MSSubAlgebra of b2 holds b3 is feasible
proof end;

registration
let c1 be non void Signature;
let c2 be feasible MSAlgebra of c1;
cluster -> feasible MSSubAlgebra of a2;
coherence
for b1 being MSSubAlgebra of c2 holds b1 is feasible
by Th39;
end;

theorem Th40: :: MSAFREE3:40
for b1 being non void Signature
for b2 being ManySortedSet of the carrier of b1 holds
( Free b1,b2 is feasible & Free b1,b2 is free )
proof end;

registration
let c1 be non void Signature;
let c2 be ManySortedSet of the carrier of c1;
cluster Free a1,a2 -> strict free feasible ;
coherence
( Free c1,c2 is feasible & Free c1,c2 is free )
by Th40;
end;