:: PRE_CIRC semantic presentation

scheme :: PRE_CIRC:sch 1
s1{ F1() -> non empty finite set , F2( set ) -> set , P1[ set ] } :
{ F2(b1) where B is Element of F1() : P1[b1] } is finite
proof end;

theorem Th1: :: PRE_CIRC:1
canceled;

theorem Th2: :: PRE_CIRC:2
for b1 being Function
for b2, b3 being set st dom b1 = {b2} & rng b1 = {b3} holds
b1 = {[b2,b3]}
proof end;

theorem Th3: :: PRE_CIRC:3
for b1, b2, b3 being Function st b1 c= b2 holds
b1 +* b3 c= b2 +* b3
proof end;

theorem Th4: :: PRE_CIRC:4
for b1, b2, b3 being Function st b1 c= b2 & dom b1 misses dom b3 holds
b1 c= b2 +* b3
proof end;

registration
cluster non empty finite natural-membered set ;
existence
ex b1 being set st
( b1 is finite & not b1 is empty & b1 is natural-membered )
proof end;
end;

notation
let c1 be non empty finite real-membered set ;
synonym max c1 for upper_bound c1;
end;

definition
let c1 be non empty finite real-membered set ;
redefine func max as max c1 -> real number means :Def1: :: PRE_CIRC:def 1
( a2 in a1 & ( for b1 being real number st b1 in a1 holds
b1 <= a2 ) );
compatibility
for b1 being real number holds
( b1 = max c1 iff ( b1 in c1 & ( for b2 being real number st b2 in c1 holds
b2 <= b1 ) ) )
proof end;
coherence
max c1 is real number
;
end;

:: deftheorem Def1 defines max PRE_CIRC:def 1 :
for b1 being non empty finite real-membered set
for b2 being real number holds
( b2 = max b1 iff ( b2 in b1 & ( for b3 being real number st b3 in b1 holds
b3 <= b2 ) ) );

registration
let c1 be non empty finite natural-membered set ;
cluster max a1 -> natural ;
coherence
max c1 is natural
proof end;
end;

theorem Th5: :: PRE_CIRC:5
for b1 being set
for b2 being ManySortedSet of b1 holds (b2 # ) . (<*> b1) = {{} }
proof end;

scheme :: PRE_CIRC:sch 2
s2{ F1() -> set , P1[ set ], F2( set ) -> set , F3( set ) -> set } :
ex b1 being ManySortedSet of F1() st
for b2 being Element of F1() st b2 in F1() holds
( ( P1[b2] implies b1 . b2 = F2(b2) ) & ( P1[b2] implies b1 . b2 = F3(b2) ) )
proof end;

definition
let c1 be set ;
let c2 be ManySortedSet of c1;
canceled;
attr a2 is locally-finite means :: PRE_CIRC:def 3
for b1 being set st b1 in a1 holds
a2 . b1 is finite;
end;

:: deftheorem Def2 PRE_CIRC:def 2 :
canceled;

:: deftheorem Def3 defines locally-finite PRE_CIRC:def 3 :
for b1 being set
for b2 being ManySortedSet of b1 holds
( b2 is locally-finite iff for b3 being set st b3 in b1 holds
b2 . b3 is finite );

registration
let c1 be set ;
cluster V2 locally-finite ManySortedSet of a1;
existence
ex b1 being ManySortedSet of c1 st
( b1 is non-empty & b1 is locally-finite )
proof end;
end;

definition
let c1, c2 be set ;
redefine func --> as c1 --> c2 -> ManySortedSet of a1;
coherence
c1 --> c2 is ManySortedSet of c1
proof end;
end;

definition
let c1 be set ;
let c2 be ManySortedSet of c1;
let c3 be Subset of c1;
redefine func | as c2 | c3 -> ManySortedSet of a3;
coherence
c2 | c3 is ManySortedSet of c3
proof end;
end;

registration
let c1 be non-empty Function;
let c2 be set ;
cluster a1 | a2 -> non-empty ;
coherence
c1 | c2 is non-empty
proof end;
end;

theorem Th6: :: PRE_CIRC:6
for b1 being non empty set
for b2 being V2 ManySortedSet of b1 holds not union (rng b2) is empty
proof end;

theorem Th7: :: PRE_CIRC:7
for b1 being set holds uncurry (b1 --> {} ) = {}
proof end;

theorem Th8: :: PRE_CIRC:8
for b1 being non empty set
for b2 being set
for b3 being V2 ManySortedSet of b1
for b4 being ManySortedFunction of b1 --> b2,b3 holds dom (commute b4) = b2
proof end;

scheme :: PRE_CIRC:sch 3
s3{ F1() -> non empty set , F2() -> Element of F1(), F3( Nat, Element of F1()) -> Element of F1() } :
( ex b1 being Function of NAT ,F1() st
( b1 . 0 = F2() & ( for b2 being Nat holds b1 . (b2 + 1) = F3(b2,(b1 . b2)) ) ) & ( for b1, b2 being Function of NAT ,F1() st b1 . 0 = F2() & ( for b3 being Nat holds b1 . (b3 + 1) = F3(b3,(b1 . b3)) ) & b2 . 0 = F2() & ( for b3 being Nat holds b2 . (b3 + 1) = F3(b3,(b2 . b3)) ) holds
b1 = b2 ) )
proof end;

scheme :: PRE_CIRC:sch 4
s4{ F1() -> non empty set , F2() -> Subset of F1(), F3() -> ManySortedSet of F2(), F4() -> ManySortedSet of F2(), F5( set ) -> set } :
ex b1 being ManySortedFunction of F3(),F4() st
for b2 being Element of F1() st b2 in F2() holds
b1 . b2 = F5(b2)
provided
E5: for b1 being Element of F1() st b1 in F2() holds
F5(b1) is Function of F3() . b1,F4() . b1
proof end;

registration
let c1 be non-empty Function;
let c2 be Function;
cluster a2 * a1 -> non-empty ;
coherence
c1 * c2 is non-empty
proof end;
end;

theorem Th9: :: PRE_CIRC:9
for b1 being set
for b2 being V2 ManySortedSet of b1
for b3 being Function
for b4 being Element of product b2 st dom b3 c= dom b2 & ( for b5 being set st b5 in dom b3 holds
b3 . b5 in b2 . b5 ) holds
b4 +* b3 is Element of product b2
proof end;

theorem Th10: :: PRE_CIRC:10
for b1, b2 being non empty set
for b3 being V2 ManySortedSet of b1
for b4 being ManySortedFunction of b1 --> b2,b3
for b5 being Element of b2 ex b6 being ManySortedSet of b1 st
( b6 = (commute b4) . b5 & b6 in b3 )
proof end;

theorem Th11: :: PRE_CIRC:11
for b1 being set
for b2 being ManySortedSet of b1
for b3, b4 being Function st b3 in product b2 holds
b3 * b4 in product (b2 * b4)
proof end;

theorem Th12: :: PRE_CIRC:12
for b1 being Nat
for b2 being set holds product (b1 |-> {b2}) = {(b1 |-> b2)}
proof end;

registration
let c1 be non empty set ;
cluster -> finite Element of FinTrees a1;
coherence
for b1 being Element of FinTrees c1 holds b1 is finite
proof end;
end;

registration
let c1 be finite DecoratedTree;
let c2 be Element of dom c1;
cluster a1 | a2 -> finite ;
coherence
c1 | c2 is finite
proof end;
end;

theorem Th13: :: PRE_CIRC:13
for b1 being finite Tree
for b2 being Element of b1 holds b1 | b2,{ b3 where B is Element of b1 : b2 is_a_prefix_of b3 } are_equipotent
proof end;

registration
let c1 be finite DecoratedTree;
let c2 be Element of dom c1;
let c3 be finite DecoratedTree;
cluster a1 with-replacement a2,a3 -> finite ;
coherence
c1 with-replacement c2,c3 is finite
proof end;
end;

theorem Th14: :: PRE_CIRC:14
for b1, b2 being finite Tree
for b3 being Element of b1 holds b1 with-replacement b3,b2 = { b4 where B is Element of b1 : not b3 is_a_prefix_of b4 } \/ { (b3 ^ b4) where B is Element of b2 : verum }
proof end;

theorem Th15: :: PRE_CIRC:15
for b1, b2 being finite Tree
for b3 being Element of b1
for b4 being FinSequence of NAT st b4 in b1 with-replacement b3,b2 & b3 is_a_prefix_of b4 holds
ex b5 being Element of b2 st b4 = b3 ^ b5
proof end;

theorem Th16: :: PRE_CIRC:16
for b1 being Tree-yielding FinSequence
for b2 being Nat st b2 + 1 in dom b1 holds
(tree b1) | <*b2*> = b1 . (b2 + 1)
proof end;

theorem Th17: :: PRE_CIRC:17
for b1 being DTree-yielding FinSequence
for b2 being Nat st b2 + 1 in dom b1 holds
<*b2*> in tree (doms b1)
proof end;

theorem Th18: :: PRE_CIRC:18
for b1, b2 being Tree-yielding FinSequence
for b3 being Nat st len b1 = len b2 & b3 + 1 in dom b1 & ( for b4 being Nat st b4 in dom b1 & b4 <> b3 + 1 holds
b1 . b4 = b2 . b4 ) holds
for b4 being Tree st b2 . (b3 + 1) = b4 holds
tree b2 = (tree b1) with-replacement <*b3*>,b4
proof end;

theorem Th19: :: PRE_CIRC:19
for b1, b2 being finite DecoratedTree
for b3 being set
for b4 being Nat
for b5 being DTree-yielding FinSequence st <*b4*> in dom b1 & b1 = b3 -tree b5 holds
ex b6 being DTree-yielding FinSequence st
( b1 with-replacement <*b4*>,b2 = b3 -tree b6 & len b6 = len b5 & b6 . (b4 + 1) = b2 & ( for b7 being Nat st b7 in dom b5 & b7 <> b4 + 1 holds
b6 . b7 = b5 . b7 ) )
proof end;

theorem Th20: :: PRE_CIRC:20
for b1 being finite Tree
for b2 being Element of b1 st b2 <> {} holds
card (b1 | b2) < card b1
proof end;

theorem Th21: :: PRE_CIRC:21
for b1 being Function holds Card b1 = Card (dom b1)
proof end;

theorem Th22: :: PRE_CIRC:22
for b1, b2 being finite Tree
for b3 being Element of b1 holds (card (b1 with-replacement b3,b2)) + (card (b1 | b3)) = (card b1) + (card b2)
proof end;

theorem Th23: :: PRE_CIRC:23
for b1, b2 being finite DecoratedTree
for b3 being Element of dom b1 holds (card (b1 with-replacement b3,b2)) + (card (b1 | b3)) = (card b1) + (card b2)
proof end;

registration
let c1 be set ;
cluster root-tree a1 -> finite ;
coherence
root-tree c1 is finite
proof end;
end;

theorem Th24: :: PRE_CIRC:24
for b1 being set holds card (root-tree b1) = 1
proof end;