:: CIRCUIT2 semantic presentation

Lemma1: for b1 being set holds not b1 in b1
;

theorem Th1: :: CIRCUIT2:1
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being V3 ManySortedSet of the carrier of b1
for b3 being ManySortedFunction of (FreeMSA b2),(FreeMSA b2)
for b4 being Function-yielding Function
for b5 being SortSymbol of b1
for b6 being DTree-yielding FinSequence
for b7 being Element of the Sorts of (FreeMSA b2) . b5 st b5 in InnerVertices b1 & b7 = [(action_at b5),the carrier of b1] -tree b6 & b3 is_homomorphism FreeMSA b2, FreeMSA b2 & b4 = b3 * (the_arity_of (action_at b5)) holds
ex b8 being DTree-yielding FinSequence st
( b8 = b4 .. b6 & (b3 . b5) . b7 = [(action_at b5),the carrier of b1] -tree b8 )
proof end;

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be State of c2;
let c4 be InputValues of c2;
redefine func +* as c3 +* c4 -> State of a2;
coherence
c3 +* c4 is State of c2
proof end;
end;

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be InputValues of c2;
func Fix_inp c3 -> ManySortedFunction of FreeGen the Sorts of a2,the Sorts of (FreeEnv a2) means :Def1: :: CIRCUIT2:def 1
for b1 being Vertex of a1 holds
( ( b1 in InputVertices a1 implies a4 . b1 = (FreeGen b1,the Sorts of a2) --> (root-tree [(a3 . b1),b1]) ) & ( b1 in SortsWithConstants a1 implies a4 . b1 = (FreeGen b1,the Sorts of a2) --> (root-tree [(action_at b1),the carrier of a1]) ) & ( b1 in (InnerVertices a1) \ (SortsWithConstants a1) implies a4 . b1 = id (FreeGen b1,the Sorts of a2) ) );
existence
ex b1 being ManySortedFunction of FreeGen the Sorts of c2,the Sorts of (FreeEnv c2) st
for b2 being Vertex of c1 holds
( ( b2 in InputVertices c1 implies b1 . b2 = (FreeGen b2,the Sorts of c2) --> (root-tree [(c3 . b2),b2]) ) & ( b2 in SortsWithConstants c1 implies b1 . b2 = (FreeGen b2,the Sorts of c2) --> (root-tree [(action_at b2),the carrier of c1]) ) & ( b2 in (InnerVertices c1) \ (SortsWithConstants c1) implies b1 . b2 = id (FreeGen b2,the Sorts of c2) ) )
proof end;
uniqueness
for b1, b2 being ManySortedFunction of FreeGen the Sorts of c2,the Sorts of (FreeEnv c2) st ( for b3 being Vertex of c1 holds
( ( b3 in InputVertices c1 implies b1 . b3 = (FreeGen b3,the Sorts of c2) --> (root-tree [(c3 . b3),b3]) ) & ( b3 in SortsWithConstants c1 implies b1 . b3 = (FreeGen b3,the Sorts of c2) --> (root-tree [(action_at b3),the carrier of c1]) ) & ( b3 in (InnerVertices c1) \ (SortsWithConstants c1) implies b1 . b3 = id (FreeGen b3,the Sorts of c2) ) ) ) & ( for b3 being Vertex of c1 holds
( ( b3 in InputVertices c1 implies b2 . b3 = (FreeGen b3,the Sorts of c2) --> (root-tree [(c3 . b3),b3]) ) & ( b3 in SortsWithConstants c1 implies b2 . b3 = (FreeGen b3,the Sorts of c2) --> (root-tree [(action_at b3),the carrier of c1]) ) & ( b3 in (InnerVertices c1) \ (SortsWithConstants c1) implies b2 . b3 = id (FreeGen b3,the Sorts of c2) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines Fix_inp CIRCUIT2:def 1 :
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being ManySortedFunction of FreeGen the Sorts of b2,the Sorts of (FreeEnv b2) holds
( b4 = Fix_inp b3 iff for b5 being Vertex of b1 holds
( ( b5 in InputVertices b1 implies b4 . b5 = (FreeGen b5,the Sorts of b2) --> (root-tree [(b3 . b5),b5]) ) & ( b5 in SortsWithConstants b1 implies b4 . b5 = (FreeGen b5,the Sorts of b2) --> (root-tree [(action_at b5),the carrier of b1]) ) & ( b5 in (InnerVertices b1) \ (SortsWithConstants b1) implies b4 . b5 = id (FreeGen b5,the Sorts of b2) ) ) );

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be InputValues of c2;
func Fix_inp_ext c3 -> ManySortedFunction of (FreeEnv a2),(FreeEnv a2) means :Def2: :: CIRCUIT2:def 2
( a4 is_homomorphism FreeEnv a2, FreeEnv a2 & Fix_inp a3 c= a4 );
existence
ex b1 being ManySortedFunction of (FreeEnv c2),(FreeEnv c2) st
( b1 is_homomorphism FreeEnv c2, FreeEnv c2 & Fix_inp c3 c= b1 )
proof end;
uniqueness
for b1, b2 being ManySortedFunction of (FreeEnv c2),(FreeEnv c2) st b1 is_homomorphism FreeEnv c2, FreeEnv c2 & Fix_inp c3 c= b1 & b2 is_homomorphism FreeEnv c2, FreeEnv c2 & Fix_inp c3 c= b2 holds
b1 = b2
proof end;
end;

:: deftheorem Def2 defines Fix_inp_ext CIRCUIT2:def 2 :
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being ManySortedFunction of (FreeEnv b2),(FreeEnv b2) holds
( b4 = Fix_inp_ext b3 iff ( b4 is_homomorphism FreeEnv b2, FreeEnv b2 & Fix_inp b3 c= b4 ) );

theorem Th2: :: CIRCUIT2:2
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being Vertex of b1
for b5 being Element of the Sorts of (FreeEnv b2) . b4
for b6 being set st b4 in (InnerVertices b1) \ (SortsWithConstants b1) & b5 = root-tree [b6,b4] holds
((Fix_inp_ext b3) . b4) . b5 = b5
proof end;

theorem Th3: :: CIRCUIT2:3
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being Vertex of b1
for b5 being Element of the Sorts of b2 . b4 st b4 in InputVertices b1 holds
((Fix_inp_ext b3) . b4) . (root-tree [b5,b4]) = root-tree [(b3 . b4),b4]
proof end;

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

theorem Th5: :: CIRCUIT2:5
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being Vertex of b1
for b5 being Element of the Sorts of (FreeEnv b2) . b4 st b4 in SortsWithConstants b1 holds
((Fix_inp_ext b3) . b4) . b5 = root-tree [(action_at b4),the carrier of b1]
proof end;

theorem Th6: :: CIRCUIT2:6
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being Vertex of b1
for b5, b6 being Element of the Sorts of (FreeEnv b2) . b4
for b7, b8 being DecoratedTree st b7 = b5 & b8 = b6 & b6 = ((Fix_inp_ext b3) . b4) . b5 holds
dom b7 = dom b8
proof end;

theorem Th7: :: CIRCUIT2:7
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputValues of b2
for b4 being Vertex of b1
for b5, b6 being Element of the Sorts of (FreeEnv b2) . b4 st b6 = ((Fix_inp_ext b3) . b4) . b5 holds
card b5 = card b6
proof end;

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be Vertex of c1;
let c4 be InputValues of c2;
E11: FreeEnv c2 = FreeMSA the Sorts of c2 by MSAFREE2:def 8;
func IGTree c3,c4 -> Element of the Sorts of (FreeEnv a2) . a3 means :Def3: :: CIRCUIT2:def 3
ex b1 being Element of the Sorts of (FreeEnv a2) . a3 st
( card b1 = size a3,a2 & a5 = ((Fix_inp_ext a4) . a3) . b1 );
existence
ex b1, b2 being Element of the Sorts of (FreeEnv c2) . c3 st
( card b2 = size c3,c2 & b1 = ((Fix_inp_ext c4) . c3) . b2 )
proof end;
uniqueness
for b1, b2 being Element of the Sorts of (FreeEnv c2) . c3 st ex b3 being Element of the Sorts of (FreeEnv c2) . c3 st
( card b3 = size c3,c2 & b1 = ((Fix_inp_ext c4) . c3) . b3 ) & ex b3 being Element of the Sorts of (FreeEnv c2) . c3 st
( card b3 = size c3,c2 & b2 = ((Fix_inp_ext c4) . c3) . b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def3 defines IGTree CIRCUIT2:def 3 :
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 InputValues of b2
for b5 being Element of the Sorts of (FreeEnv b2) . b3 holds
( b5 = IGTree b3,b4 iff ex b6 being Element of the Sorts of (FreeEnv b2) . b3 st
( card b6 = size b3,b2 & b5 = ((Fix_inp_ext b4) . b3) . b6 ) );

theorem Th8: :: CIRCUIT2:8
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 InputValues of b2 holds IGTree b3,b4 = ((Fix_inp_ext b4) . b3) . (IGTree b3,b4)
proof end;

theorem Th9: :: CIRCUIT2:9
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 InputValues of b2
for b5 being DTree-yielding FinSequence st b3 in InnerVertices b1 & dom b5 = dom (the_arity_of (action_at b3)) & ( for b6 being Nat st b6 in dom b5 holds
b5 . b6 = IGTree ((the_arity_of (action_at b3)) /. b6),b4 ) holds
IGTree b3,b4 = [(action_at b3),the carrier of b1] -tree b5
proof end;

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be Vertex of c1;
let c4 be InputValues of c2;
func IGValue c3,c4 -> Element of the Sorts of a2 . a3 equals :: CIRCUIT2:def 4
((Eval a2) . a3) . (IGTree a3,a4);
coherence
((Eval c2) . c3) . (IGTree c3,c4) is Element of the Sorts of c2 . c3
;
end;

:: deftheorem Def4 defines IGValue CIRCUIT2:def 4 :
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 InputValues of b2 holds IGValue b3,b4 = ((Eval b2) . b3) . (IGTree b3,b4);

theorem Th10: :: CIRCUIT2: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 InputValues of b2 st b3 in InputVertices b1 holds
IGValue b3,b4 = b4 . b3
proof end;

theorem Th11: :: CIRCUIT2:11
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 InputValues of b2 st b3 in SortsWithConstants b1 holds
IGValue b3,b4 = (Set-Constants b2) . b3
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;
func Following c3 -> State of a2 means :Def5: :: CIRCUIT2:def 5
for b1 being Vertex of a1 holds
( ( b1 in InputVertices a1 implies a4 . b1 = a3 . b1 ) & ( b1 in InnerVertices a1 implies a4 . b1 = (Den (action_at b1),a2) . ((action_at b1) depends_on_in a3) ) );
existence
ex b1 being State of c2 st
for b2 being Vertex of c1 holds
( ( b2 in InputVertices c1 implies b1 . b2 = c3 . b2 ) & ( b2 in InnerVertices c1 implies b1 . b2 = (Den (action_at b2),c2) . ((action_at b2) depends_on_in c3) ) )
proof end;
uniqueness
for b1, b2 being State of c2 st ( for b3 being Vertex of c1 holds
( ( b3 in InputVertices c1 implies b1 . b3 = c3 . b3 ) & ( b3 in InnerVertices c1 implies b1 . b3 = (Den (action_at b3),c2) . ((action_at b3) depends_on_in c3) ) ) ) & ( for b3 being Vertex of c1 holds
( ( b3 in InputVertices c1 implies b2 . b3 = c3 . b3 ) & ( b3 in InnerVertices c1 implies b2 . b3 = (Den (action_at b3),c2) . ((action_at b3) depends_on_in c3) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def5 defines Following CIRCUIT2:def 5 :
for b1 being non empty non void Circuit-like ManySortedSign
for b2 being non-empty Circuit of b1
for b3, b4 being State of b2 holds
( b4 = Following b3 iff for b5 being Vertex of b1 holds
( ( b5 in InputVertices b1 implies b4 . b5 = b3 . b5 ) & ( b5 in InnerVertices b1 implies b4 . b5 = (Den (action_at b5),b2) . ((action_at b5) depends_on_in b3) ) ) );

theorem Th12: :: CIRCUIT2:12
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2
for b4 being InputValues of b2 st b4 c= b3 holds
b4 c= Following b3
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;
attr a3 is stable means :Def6: :: CIRCUIT2:def 6
a3 = Following a3;
end;

:: deftheorem Def6 defines stable CIRCUIT2:def 6 :
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
( b3 is stable iff b3 = Following b3 );

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be State of c2;
let c4 be InputValues of c2;
func Following c3,c4 -> State of a2 equals :: CIRCUIT2:def 7
Following (a3 +* a4);
coherence
Following (c3 +* c4) is State of c2
;
end;

:: deftheorem Def7 defines Following CIRCUIT2:def 7 :
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2
for b4 being InputValues of b2 holds Following b3,b4 = Following (b3 +* b4);

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be InputFuncs of c2;
let c4 be State of c2;
func InitialComp c4,c3 -> State of a2 equals :: CIRCUIT2:def 8
(a4 +* (0 -th_InputValues a3)) +* (Set-Constants a2);
coherence
(c4 +* (0 -th_InputValues c3)) +* (Set-Constants c2) is State of c2
proof end;
end;

:: deftheorem Def8 defines InitialComp CIRCUIT2:def 8 :
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2
for b4 being State of b2 holds InitialComp b4,b3 = (b4 +* (0 -th_InputValues b3)) +* (Set-Constants b2);

definition
let c1 be non empty non void Circuit-like monotonic ManySortedSign ;
let c2 be non-empty Circuit of c1;
let c3 be InputFuncs of c2;
let c4 be State of c2;
func Computation c4,c3 -> Function of NAT , product the Sorts of a2 means :Def9: :: CIRCUIT2:def 9
( a5 . 0 = InitialComp a4,a3 & ( for b1 being Nat holds a5 . (b1 + 1) = Following (a5 . b1),((b1 + 1) -th_InputValues a3) ) );
correctness
existence
ex b1 being Function of NAT , product the Sorts of c2 st
( b1 . 0 = InitialComp c4,c3 & ( for b2 being Nat holds b1 . (b2 + 1) = Following (b1 . b2),((b2 + 1) -th_InputValues c3) ) )
;
uniqueness
for b1, b2 being Function of NAT , product the Sorts of c2 st b1 . 0 = InitialComp c4,c3 & ( for b3 being Nat holds b1 . (b3 + 1) = Following (b1 . b3),((b3 + 1) -th_InputValues c3) ) & b2 . 0 = InitialComp c4,c3 & ( for b3 being Nat holds b2 . (b3 + 1) = Following (b2 . b3),((b3 + 1) -th_InputValues c3) ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def9 defines Computation CIRCUIT2:def 9 :
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2
for b4 being State of b2
for b5 being Function of NAT , product the Sorts of b2 holds
( b5 = Computation b4,b3 iff ( b5 . 0 = InitialComp b4,b3 & ( for b6 being Nat holds b5 . (b6 + 1) = Following (b5 . b6),((b6 + 1) -th_InputValues b3) ) ) );

theorem Th13: :: CIRCUIT2:13
for b1 being non empty non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being State of b2
for b4 being InputValues of b2
for b5 being Nat st ( for b6 being Vertex of b1 st depth b6,b2 <= b5 holds
b3 . b6 = IGValue b6,b4 ) holds
for b6 being Vertex of b1 st depth b6,b2 <= b5 + 1 holds
(Following b3) . b6 = IGValue b6,b4
proof end;

theorem Th14: :: CIRCUIT2:14
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2 st commute b3 is constant & not InputVertices b1 is empty holds
for b4 being State of b2
for b5 being InputValues of b2 st b5 = (commute b3) . 0 holds
for b6 being Nat holds b5 c= (Computation b4,b3) . b6
proof end;

theorem Th15: :: CIRCUIT2:15
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2
for b4 being State of b2
for b5 being Nat st commute b3 is constant & not InputVertices b1 is empty & (Computation b4,b3) . b5 is stable holds
for b6 being Nat st b5 <= b6 holds
(Computation b4,b3) . b5 = (Computation b4,b3) . b6
proof end;

theorem Th16: :: CIRCUIT2:16
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2 st commute b3 is constant & not InputVertices b1 is empty holds
for b4 being State of b2
for b5 being InputValues of b2 st b5 = (commute b3) . 0 holds
for b6 being Nat
for b7 being Vertex of b1 st depth b7,b2 <= b6 holds
((Computation b4,b3) . b6) . b7 = IGValue b7,b5
proof end;

theorem Th17: :: CIRCUIT2:17
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2
for b4 being InputValues of b2 st commute b3 is constant & not InputVertices b1 is empty & b4 = (commute b3) . 0 holds
for b5 being State of b2
for b6 being Vertex of b1
for b7 being Element of NAT st b7 = depth b2 holds
((Computation b5,b3) . b7) . b6 = IGValue b6,b4
proof end;

theorem Th18: :: CIRCUIT2:18
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2 st commute b3 is constant & not InputVertices b1 is empty holds
for b4 being State of b2
for b5 being Element of NAT st b5 = depth b2 holds
(Computation b4,b3) . b5 is stable
proof end;

theorem Th19: :: CIRCUIT2:19
for b1 being non empty finite non void Circuit-like monotonic ManySortedSign
for b2 being non-empty Circuit of b1
for b3 being InputFuncs of b2 st commute b3 is constant & not InputVertices b1 is empty holds
for b4, b5 being State of b2 holds (Computation b4,b3) . (depth b2) = (Computation b5,b3) . (depth b2)
proof end;