:: CIRCUIT1 semantic presentation

definition
let c1 be non empty non void Circuit-like ManySortedSign ;
mode Circuit of a1 is locally-finite MSAlgebra of a1;
end;

definition
let c1 be non empty non void Circuit-like ManySortedSign ;
let c2 be non-empty Circuit of c1;
func Set-Constants c2 -> ManySortedSet of SortsWithConstants a1 means :Def1: :: CIRCUIT1:def 1
for b1 being Vertex of a1 st b1 in dom a3 holds
a3 . b1 in Constants a2,b1;
existence
ex b1 being ManySortedSet of SortsWithConstants c1 st
for b2 being Vertex of c1 st b2 in dom b1 holds
b1 . b2 in Constants c2,b2
proof end;
correctness
uniqueness
for b1, b2 being ManySortedSet of SortsWithConstants c1 st ( for b3 being Vertex of c1 st b3 in dom b1 holds
b1 . b3 in Constants c2,b3 ) & ( for b3 being Vertex of c1 st b3 in dom b2 holds
b2 . b3 in Constants c2,b3 ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def1 defines Set-Constants CIRCUIT1:def 1 :
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being ManySortedSet of SortsWithConstants b1 holds
( b3 = Set-Constants b2 iff for b4 being Vertex of b1 st b4 in dom b3 holds
b3 . b4 in Constants b2,b4 );

theorem Th1: :: CIRCUIT1:1
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being Vertex of b1
for b4 being Element of the Sorts of b2 . b3 st b3 in SortsWithConstants b1 & b4 in Constants b2,b3 holds
(Set-Constants b2) . b3 = b4
proof end;

definition
let c1 be non empty non void Circuit-like ManySortedSign ;
let c2 be Circuit of c1;
mode InputFuncs of a2 is ManySortedFunction of (InputVertices a1) --> NAT ,the Sorts of a2 | (InputVertices a1);
end;

theorem Th2: :: CIRCUIT1:2
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2
for b4 being Nat st b1 is with_input_V holds
(commute b3) . b4 is InputValues of b2
proof end;

definition
let c1 be non empty non void Circuit-like ManySortedSign ;
assume E3: c1 is with_input_V ;
let c2 be non-empty Circuit of c1;
let c3 be InputFuncs of c2;
let c4 be Nat;
func c4 -th_InputValues c3 -> InputValues of a2 equals :: CIRCUIT1:def 2
(commute a3) . a4;
coherence
(commute c3) . c4 is InputValues of c2
by E3, Th2;
correctness
;
end;

:: deftheorem Def2 defines -th_InputValues CIRCUIT1:def 2 :
for b1 being non empty non void Circuit-like ManySortedSign st b1 is with_input_V holds
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2
for b4 being Nat holds b4 -th_InputValues b3 = (commute b3) . b4;

definition
let c1 be non empty non void Circuit-like ManySortedSign ;
let c2 be Circuit of c1;
mode State of a2 is Element of product the Sorts of a2;
end;

theorem Th3: :: CIRCUIT1:3
canceled;

theorem Th4: :: CIRCUIT1:4
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2 holds dom b3 = the carrier of b1
proof end;

theorem Th5: :: CIRCUIT1:5
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2
for b4 being Vertex of b1 holds b3 . b4 in the Sorts of b2 . b4
proof end;

definition
let c1 be non empty non void Circuit-like ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be State of c2;
let c4 be OperSymbol of c1;
func c4 depends_on_in c3 -> Element of Args a4,a2 equals :: CIRCUIT1:def 3
a3 * (the_arity_of a4);
coherence
c3 * (the_arity_of c4) is Element of Args c4,c2
proof end;
correctness
;
end;

:: deftheorem Def3 defines depends_on_in CIRCUIT1:def 3 :
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2
for b4 being OperSymbol of b1 holds b4 depends_on_in b3 = b3 * (the_arity_of b4);

theorem Th6: :: CIRCUIT1:6
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3, b4 being Vertex of b1
for b5 being Element of the Sorts of (FreeEnv b2) . b3
for b6 being DTree-yielding FinSequence st b3 in InnerVertices b1 & b5 = [(action_at b3),the carrier of b1] -tree b6 holds
for b7 being Nat st b7 in dom b6 & b6 . b7 in the Sorts of (FreeEnv b2) . b4 holds
b4 = (the_arity_of (action_at b3)) /. b7
proof end;

registration
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty locally-finite MSAlgebra of c1;
let c3 be Vertex of c1;
cluster -> non empty Relation-like Function-like finite Element of the Sorts of (FreeEnv a2) . a3;
coherence
for b1 being Element of the Sorts of (FreeEnv c2) . c3 holds
( b1 is finite & not b1 is empty & b1 is Function-like & b1 is Relation-like )
proof end;
end;

registration
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty locally-finite MSAlgebra of c1;
let c3 be Vertex of c1;
cluster -> non empty Relation-like Function-like finite DecoratedTree-like Element of the Sorts of (FreeEnv a2) . a3;
coherence
for b1 being Element of the Sorts of (FreeEnv c2) . c3 holds b1 is DecoratedTree-like
proof end;
end;

theorem Th7: :: CIRCUIT1:7
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3, b4 being Vertex of b1
for b5 being Element of the Sorts of (FreeEnv b2) . b3
for b6 being Element of the Sorts of (FreeEnv b2) . b4
for b7 being DTree-yielding FinSequence
for b8 being Nat st b3 in (InnerVertices b1) \ (SortsWithConstants b1) & b5 = [(action_at b3),the carrier of b1] -tree b7 & b8 + 1 in dom b7 & b7 . (b8 + 1) in the Sorts of (FreeEnv b2) . b4 holds
b5 with-replacement <*b8*>,b6 in the Sorts of (FreeEnv b2) . b3
proof end;

theorem Th8: :: CIRCUIT1:8
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being Element of b1
for b4 being Element of the Sorts of (FreeEnv b2) . b3 st 1 < card b4 holds
ex b5 being OperSymbol of b1 st b4 . {} = [b5,the carrier of b1]
proof end;

theorem Th9: :: CIRCUIT1:9
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2
for b4 being OperSymbol of b1 holds (Den b4,b2) . (b4 depends_on_in b3) in the Sorts of b2 . (the_result_sort_of b4)
proof end;

theorem Th10: :: CIRCUIT1:10
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being Vertex of b1
for b4 being Element of the Sorts of (FreeEnv b2) . b3 st b4 . {} = [(action_at b3),the carrier of b1] holds
ex b5 being DTree-yielding FinSequence st b4 = [(action_at b3),the carrier of b1] -tree b5
proof end;

registration
let c1 be non empty non void monotonic ManySortedSign ;
let c2 be non-empty locally-finite MSAlgebra of c1;
let c3 be SortSymbol of c1;
cluster the Sorts of (FreeEnv a2) . a3 -> finite ;
coherence
the Sorts of (FreeEnv c2) . c3 is finite
proof end;
end;

defpred S1[ set ] means verum;

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty locally-finite MSAlgebra of c1;
let c3 be SortSymbol of c1;
func size c3,c2 -> natural number means :Def4: :: CIRCUIT1:def 4
ex b1 being non empty finite Subset of NAT st
( b1 = { (card b2) where B is Element of the Sorts of (FreeEnv a2) . a3 : verum } & a4 = max b1 );
existence
ex b1 being natural number ex b2 being non empty finite Subset of NAT st
( b2 = { (card b3) where B is Element of the Sorts of (FreeEnv c2) . c3 : verum } & b1 = max b2 )
proof end;
correctness
uniqueness
for b1, b2 being natural number st ex b3 being non empty finite Subset of NAT st
( b3 = { (card b4) where B is Element of the Sorts of (FreeEnv c2) . c3 : verum } & b1 = max b3 ) & ex b3 being non empty finite Subset of NAT st
( b3 = { (card b4) where B is Element of the Sorts of (FreeEnv c2) . c3 : verum } & b2 = max b3 ) holds
b1 = b2
;
;
end;

:: deftheorem Def4 defines size CIRCUIT1:def 4 :
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being SortSymbol of b1
for b4 being natural number holds
( b4 = size b3,b2 iff ex b5 being non empty finite Subset of NAT st
( b5 = { (card b6) where B is Element of the Sorts of (FreeEnv b2) . b3 : verum } & b4 = max b5 ) );

theorem Th11: :: CIRCUIT1:11
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being Element of b1 holds
( size b3,b2 = 1 iff b3 in (InputVertices b1) \/ (SortsWithConstants b1) )
proof end;

theorem Th12: :: CIRCUIT1:12
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3, b4 being Vertex of b1
for b5 being Element of the Sorts of (FreeEnv b2) . b3
for b6 being Element of the Sorts of (FreeEnv b2) . b4
for b7 being DTree-yielding FinSequence st b3 in (InnerVertices b1) \ (SortsWithConstants b1) & card b5 = size b3,b2 & b5 = [(action_at b3),the carrier of b1] -tree b7 & b6 in rng b7 holds
card b6 = size b4,b2
proof end;

theorem Th13: :: CIRCUIT1:13
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being Vertex of b1
for b4 being Element of the Sorts of (FreeEnv b2) . b3 st b3 in (InnerVertices b1) \ (SortsWithConstants b1) & card b4 = size b3,b2 holds
ex b5 being DTree-yielding FinSequence st b4 = [(action_at b3),the carrier of b1] -tree b5
proof end;

theorem Th14: :: CIRCUIT1:14
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being Vertex of b1
for b4 being Element of the Sorts of (FreeEnv b2) . b3 st b3 in (InnerVertices b1) \ (SortsWithConstants b1) & card b4 = size b3,b2 holds
ex b5 being OperSymbol of b1 st b4 . {} = [b5,the carrier of b1]
proof end;

definition
let c1 be non empty non void ManySortedSign ;
let c2 be non-empty locally-finite MSAlgebra of c1;
let c3 be SortSymbol of c1;
let c4 be Element of the Sorts of (FreeEnv c2) . c3;
func depth c4 -> Nat means :Def5: :: CIRCUIT1:def 5
ex b1 being Element of the Sorts of (FreeMSA the Sorts of a2) . a3 st
( a4 = b1 & a5 = depth b1 );
existence
ex b1 being Natex b2 being Element of the Sorts of (FreeMSA the Sorts of c2) . c3 st
( c4 = b2 & b1 = depth b2 )
proof end;
correctness
uniqueness
for b1, b2 being Nat st ex b3 being Element of the Sorts of (FreeMSA the Sorts of c2) . c3 st
( c4 = b3 & b1 = depth b3 ) & ex b3 being Element of the Sorts of (FreeMSA the Sorts of c2) . c3 st
( c4 = b3 & b2 = depth b3 ) holds
b1 = b2
;
;
end;

:: deftheorem Def5 defines depth CIRCUIT1:def 5 :
for b1 being non empty non void ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being SortSymbol of b1
for b4 being Element of the Sorts of (FreeEnv b2) . b3
for b5 being Nat holds
( b5 = depth b4 iff ex b6 being Element of the Sorts of (FreeMSA the Sorts of b2) . b3 st
( b4 = b6 & b5 = depth b6 ) );

theorem Th15: :: CIRCUIT1:15
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3, b4 being Element of b1 st b3 in InnerVertices b1 & b4 in rng (the_arity_of (action_at b3)) holds
size b4,b2 < size b3,b2
proof end;

theorem Th16: :: CIRCUIT1:16
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being SortSymbol of b1 holds size b3,b2 > 0
proof end;

theorem Th17: :: CIRCUIT1:17
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being Vertex of b1
for b4 being Element of the Sorts of (FreeEnv b2) . b3
for b5 being DTree-yielding FinSequence st b3 in InnerVertices b1 & b4 = [(action_at b3),the carrier of b1] -tree b5 & ( for b6 being Nat st b6 in dom b5 holds
ex b7 being Element of the Sorts of (FreeEnv b2) . ((the_arity_of (action_at b3)) /. b6) st
( b7 = b5 . b6 & card b7 = size ((the_arity_of (action_at b3)) /. b6),b2 ) ) holds
card b4 = size b3,b2
proof end;

definition
let c1 be non empty non void monotonic ManySortedSign ;
let c2 be non-empty locally-finite MSAlgebra of c1;
let c3 be SortSymbol of c1;
func depth c3,c2 -> natural number means :Def6: :: CIRCUIT1:def 6
ex b1 being non empty finite Subset of NAT st
( b1 = { (depth b2) where B is Element of the Sorts of (FreeEnv a2) . a3 : verum } & a4 = max b1 );
existence
ex b1 being natural number ex b2 being non empty finite Subset of NAT st
( b2 = { (depth b3) where B is Element of the Sorts of (FreeEnv c2) . c3 : verum } & b1 = max b2 )
proof end;
correctness
uniqueness
for b1, b2 being natural number st ex b3 being non empty finite Subset of NAT st
( b3 = { (depth b4) where B is Element of the Sorts of (FreeEnv c2) . c3 : verum } & b1 = max b3 ) & ex b3 being non empty finite Subset of NAT st
( b3 = { (depth b4) where B is Element of the Sorts of (FreeEnv c2) . c3 : verum } & b2 = max b3 ) holds
b1 = b2
;
;
end;

:: deftheorem Def6 defines depth CIRCUIT1:def 6 :
for b1 being non empty non void monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3 being SortSymbol of b1
for b4 being natural number holds
( b4 = depth b3,b2 iff ex b5 being non empty finite Subset of NAT st
( b5 = { (depth b6) where B is Element of the Sorts of (FreeEnv b2) . b3 : verum } & b4 = max b5 ) );

definition
let c1 be non empty finite non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
func depth c2 -> natural number means :Def7: :: CIRCUIT1:def 7
ex b1 being non empty finite Subset of NAT st
( b1 = { (depth b2,a2) where B is Element of a1 : b2 in the carrier of a1 } & a3 = max b1 );
existence
ex b1 being natural number ex b2 being non empty finite Subset of NAT st
( b2 = { (depth b3,c2) where B is Element of c1 : b3 in the carrier of c1 } & b1 = max b2 )
proof end;
uniqueness
for b1, b2 being natural number st ex b3 being non empty finite Subset of NAT st
( b3 = { (depth b4,c2) where B is Element of c1 : b4 in the carrier of c1 } & b1 = max b3 ) & ex b3 being non empty finite Subset of NAT st
( b3 = { (depth b4,c2) where B is Element of c1 : b4 in the carrier of c1 } & b2 = max b3 ) holds
b1 = b2
;
end;

:: deftheorem Def7 defines depth CIRCUIT1:def 7 :
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being natural number holds
( b3 = depth b2 iff ex b4 being non empty finite Subset of NAT st
( b4 = { (depth b5,b2) where B is Element of b1 : b5 in the carrier of b1 } & b3 = max b4 ) );

theorem Th18: :: CIRCUIT1:18
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being Vertex of b1 holds depth b3,b2 <= depth b2
proof end;

theorem Th19: :: CIRCUIT1:19
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being Vertex of b1 holds
( depth b3,b2 = 0 iff ( b3 in InputVertices b1 or b3 in SortsWithConstants b1 ) )
proof end;

theorem Th20: :: CIRCUIT1:20
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty locally-finite MSAlgebra of b1
for b3, b4 being SortSymbol of b1 st b3 in InnerVertices b1 & b4 in rng (the_arity_of (action_at b3)) holds
depth b4,b2 < depth b3,b2
proof end;