:: Preliminaries to Circuits, I
:: by Yatsuka Nakamura, Piotr Rudnicki, Andrzej Trybulec and Pauline N. Kawamoto
::
:: Copyright (c) 1994-2019 Association of Mizar Users

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

theorem :: PRE_CIRC:1
canceled;

::---------------------------------------------------------------------------
:: Many Sorted Sets and Functions
::---------------------------------------------------------------------------
::\$CT
theorem :: PRE_CIRC:2
for I being set
for MSS being ManySortedSet of I holds (MSS #) . (<*> I) =
proof end;

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

registration
let I be set ;
existence
ex b1 being ManySortedSet of I st
( b1 is V2() & b1 is V44() )
proof end;
end;

registration
let I be set ;
let M be ManySortedSet of I;
let A be Subset of I;
cluster M | A -> A -defined total for A -defined Function;
coherence
for b1 being A -defined Function st b1 = M | A holds
b1 is total
proof end;
end;

registration
let I be set ;
let M be ManySortedSet of I;
let A be Subset of I;
cluster M | A -> total ;
coherence
M | A is total
;
end;

registration
let M be non-empty Function;
let A be set ;
cluster M | A -> non-empty ;
coherence
M | A is non-empty
proof end;
end;

theorem Th2: :: PRE_CIRC:3
for I being non empty set
for B being V2() ManySortedSet of I holds not union (rng B) is empty
proof end;

theorem Th3: :: PRE_CIRC:4
for I being set holds uncurry () = {}
proof end;

theorem :: PRE_CIRC:5
for I being non empty set
for A being set
for B being V2() ManySortedSet of I
for F being ManySortedFunction of I --> A,B holds dom () = A
proof end;

scheme :: PRE_CIRC:sch 3
LambdaRecCorrD{ F1() -> non empty set , F2() -> Element of F1(), F3( Nat, Element of F1()) -> Element of F1() } :
( ex f being sequence of F1() st
( f . 0 = F2() & ( for i being Nat holds f . (i + 1) = F3(i,(f . i)) ) ) & ( for f1, f2 being sequence of F1() st f1 . 0 = F2() & ( for i being Nat holds f1 . (i + 1) = F3(i,(f1 . i)) ) & f2 . 0 = F2() & ( for i being Nat holds f2 . (i + 1) = F3(i,(f2 . i)) ) holds
f1 = f2 ) )
proof end;

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

theorem :: PRE_CIRC:6
for I being set
for f being V2() ManySortedSet of I
for g being Function
for s being Element of product f st dom g c= dom f & ( for x being set st x in dom g holds
g . x in f . x ) holds
s +* g is Element of product f
proof end;

theorem :: PRE_CIRC:7
for A, B being non empty set
for C being V2() ManySortedSet of A
for InpFs being ManySortedFunction of A --> B,C
for b being Element of B ex c being ManySortedSet of A st
( c = (commute InpFs) . b & c in C )
proof end;

theorem :: PRE_CIRC:8
for n being Nat
for a being set holds product (n |-> {a}) = {(n |-> a)}
proof end;

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

registration
let T be finite DecoratedTree;
let t be Element of dom T;
cluster T | t -> finite ;
coherence
T | t is finite
proof end;
end;

theorem Th8: :: PRE_CIRC:9
for T being finite Tree
for p being Element of T holds T | p, { t where t is Element of T : p is_a_prefix_of t } are_equipotent
proof end;

registration
let T be finite DecoratedTree-like Function;
let t be Element of dom T;
let T1 be finite DecoratedTree;
cluster T with-replacement (t,T1) -> finite ;
coherence
T with-replacement (t,T1) is finite
proof end;
end;

theorem Th9: :: PRE_CIRC:10
for T, T1 being finite Tree
for p being Element of T holds T with-replacement (p,T1) = { t where t is Element of T : not p is_a_prefix_of t } \/ { (p ^ t1) where t1 is Element of T1 : verum }
proof end;

theorem Th10: :: PRE_CIRC:11
for T, T1 being finite Tree
for p being Element of T
for f being FinSequence of NAT st f in T with-replacement (p,T1) & p is_a_prefix_of f holds
ex t1 being Element of T1 st f = p ^ t1
proof end;

theorem Th11: :: PRE_CIRC:12
for p being Tree-yielding FinSequence
for k being Element of NAT st k + 1 in dom p holds
(tree p) | <*k*> = p . (k + 1)
proof end;

theorem :: PRE_CIRC:13
for q being DTree-yielding FinSequence
for k being Nat st k + 1 in dom q holds
<*k*> in tree (doms q)
proof end;

theorem Th13: :: PRE_CIRC:14
for p, q being Tree-yielding FinSequence
for k being Element of NAT st len p = len q & k + 1 in dom p & ( for i being Nat st i in dom p & i <> k + 1 holds
p . i = q . i ) holds
for t being Tree st q . (k + 1) = t holds
tree q = (tree p) with-replacement (<*k*>,t)
proof end;

theorem :: PRE_CIRC:15
for e1, e2 being finite DecoratedTree
for x being set
for k being Element of NAT
for p being DTree-yielding FinSequence st <*k*> in dom e1 & e1 = x -tree p holds
ex q being DTree-yielding FinSequence st
( e1 with-replacement (<*k*>,e2) = x -tree q & len q = len p & q . (k + 1) = e2 & ( for i being Nat st i in dom p & i <> k + 1 holds
q . i = p . i ) )
proof end;

theorem :: PRE_CIRC:16
for T being finite Tree
for p being Element of T st p <> {} holds
card (T | p) < card T
proof end;

theorem Th16: :: PRE_CIRC:17
for T, T1 being finite Tree
for p being Element of T holds (card (T with-replacement (p,T1))) + (card (T | p)) = (card T) + (card T1)
proof end;

theorem :: PRE_CIRC:18
for T, T1 being finite DecoratedTree
for p being Element of dom T holds (card (T with-replacement (p,T1))) + (card (T | p)) = (card T) + (card T1)
proof end;

registration
let x be object ;
coherence
proof end;
end;

theorem :: PRE_CIRC:19
for x being set holds card () = 1
proof end;

:: from AMISTD_2
theorem Th19: :: PRE_CIRC:20
for F being non empty finite set holds (card F) - 1 = (card F) -' 1
proof end;

:: from AMISTD_2, 2006.03.26, A.T.
theorem :: PRE_CIRC:21
for f, g being Function holds
( dom f, dom g are_equipotent iff f,g are_equipotent )
proof end;

theorem :: PRE_CIRC:22
for f, g being finite Function st dom f misses dom g holds
card (f +* g) = (card f) + (card g)
proof end;

:: from SCMPDS_9. 2008.05.06, A.T.
theorem :: PRE_CIRC:23
for n being Nat holds { k where k is Nat : k > n } is infinite
proof end;

theorem Th23: :: PRE_CIRC:24
for D being finite set
for k being Nat st card D = k + 1 holds
ex x being Element of D ex C being Subset of D st
( D = C \/ {x} & card C = k )
proof end;

theorem Th24: :: PRE_CIRC:25
for D being finite set st card D = 1 holds
ex x being Element of D st D = {x}
proof end;

scheme :: PRE_CIRC:sch 5
MinValue{ F1() -> non empty finite set , F2( Element of F1()) -> Real } :
ex x being Element of F1() st
for y being Element of F1() holds F2(x) <= F2(y)
proof end;