:: FACIRC_1 semantic presentation

definition
let c1 be set ;
attr a1 is pair means :Def1: :: FACIRC_1:def 1
ex b1, b2 being set st a1 = [b1,b2];
end;

:: deftheorem Def1 defines pair FACIRC_1:def 1 :
for b1 being set holds
( b1 is pair iff ex b2, b3 being set st b1 = [b2,b3] );

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

registration
let c1, c2 be set ;
cluster [a1,a2] -> pair ;
coherence
[c1,c2] is pair
proof end;
end;

registration
cluster non empty pair set ;
existence
ex b1 being set st b1 is pair
proof end;
cluster non pair set ;
existence
not for b1 being set holds b1 is pair
proof end;
end;

registration
cluster -> non pair Element of NAT ;
coherence
for b1 being Nat holds not b1 is pair
proof end;
end;

definition
let c1 be set ;
attr a1 is with_pair means :Def2: :: FACIRC_1:def 2
ex b1 being pair set st b1 in a1;
end;

:: deftheorem Def2 defines with_pair FACIRC_1:def 2 :
for b1 being set holds
( b1 is with_pair iff ex b2 being pair set st b2 in b1 );

notation
let c1 be set ;
antonym without_pairs c1 for with_pair c1;
end;

registration
cluster empty -> without_pairs set ;
coherence
for b1 being set st b1 is empty holds
not b1 is with_pair
proof end;
let c1 be non pair set ;
cluster {a1} -> without_pairs ;
coherence
not {c1} is with_pair
proof end;
let c2 be non pair set ;
cluster {a1,a2} -> without_pairs ;
coherence
not {c1,c2} is with_pair
proof end;
let c3 be non pair set ;
cluster {a1,a2,a3} -> without_pairs ;
coherence
not {c1,c2,c3} is with_pair
proof end;
end;

registration
cluster non empty without_pairs set ;
existence
not for b1 being non empty set holds b1 is with_pair
proof end;
end;

registration
let c1, c2 be without_pairs set ;
cluster a1 \/ a2 -> without_pairs ;
coherence
not c1 \/ c2 is with_pair
proof end;
end;

registration
let c1 be without_pairs set ;
let c2 be set ;
cluster a1 \ a2 -> without_pairs ;
coherence
not c1 \ c2 is with_pair
proof end;
cluster a1 /\ a2 -> without_pairs ;
coherence
not c1 /\ c2 is with_pair
proof end;
cluster a2 /\ a1 -> without_pairs ;
coherence
not c2 /\ c1 is with_pair
;
end;

registration
let c1 be pair set ;
cluster {a1} -> Relation-like ;
coherence
{c1} is Relation-like
proof end;
let c2 be pair set ;
cluster {a1,a2} -> Relation-like ;
coherence
{c1,c2} is Relation-like
proof end;
let c3 be pair set ;
cluster {a1,a2,a3} -> Relation-like ;
coherence
{c1,c2,c3} is Relation-like
proof end;
end;

registration
cluster Relation-like without_pairs -> empty without_pairs set ;
coherence
for b1 being set st not b1 is with_pair & b1 is Relation-like holds
b1 is empty
proof end;
end;

definition
let c1 be Function;
attr a1 is nonpair-yielding means :: FACIRC_1:def 3
for b1 being set st b1 in dom a1 holds
not a1 . b1 is pair;
end;

:: deftheorem Def3 defines nonpair-yielding FACIRC_1:def 3 :
for b1 being Function holds
( b1 is nonpair-yielding iff for b2 being set st b2 in dom b1 holds
not b1 . b2 is pair );

registration
let c1 be non pair set ;
cluster <*a1*> -> nonpair-yielding ;
coherence
<*c1*> is nonpair-yielding
proof end;
let c2 be non pair set ;
cluster <*a1,a2*> -> nonpair-yielding ;
coherence
<*c1,c2*> is nonpair-yielding
proof end;
let c3 be non pair set ;
cluster <*a1,a2,a3*> -> nonpair-yielding ;
coherence
<*c1,c2,c3*> is nonpair-yielding
proof end;
end;

theorem Th1: :: FACIRC_1:1
for b1 being Function st b1 is nonpair-yielding holds
not rng b1 is with_pair
proof end;

registration
let c1 be Nat;
cluster one-to-one nonpair-yielding FinSeqLen of a1;
existence
ex b1 being FinSeqLen of c1 st
( b1 is one-to-one & b1 is nonpair-yielding )
proof end;
end;

registration
cluster one-to-one nonpair-yielding set ;
existence
ex b1 being FinSequence st
( b1 is one-to-one & b1 is nonpair-yielding )
proof end;
end;

registration
let c1 be nonpair-yielding Function;
cluster rng a1 -> without_pairs ;
coherence
not rng c1 is with_pair
by Th1;
end;

theorem Th2: :: FACIRC_1:2
for b1, b2 being non empty ManySortedSign st b1 tolerates b2 & InnerVertices b1 is Relation & InnerVertices b2 is Relation holds
InnerVertices (b1 +* b2) is Relation
proof end;

theorem Th3: :: FACIRC_1:3
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign st InnerVertices b1 is Relation & InnerVertices b2 is Relation holds
InnerVertices (b1 +* b2) is Relation
proof end;

theorem Th4: :: FACIRC_1:4
for b1, b2 being non empty ManySortedSign st b1 tolerates b2 & InnerVertices b2 misses InputVertices b1 holds
( InputVertices b1 c= InputVertices (b1 +* b2) & InputVertices (b1 +* b2) = (InputVertices b1) \/ ((InputVertices b2) \ (InnerVertices b1)) )
proof end;

theorem Th5: :: FACIRC_1:5
for b1, b2 being set st not b1 is with_pair & b2 is Relation holds
b1 misses b2
proof end;

theorem Th6: :: FACIRC_1:6
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign st not InputVertices b1 is with_pair & InnerVertices b2 is Relation holds
( InputVertices b1 c= InputVertices (b1 +* b2) & InputVertices (b1 +* b2) = (InputVertices b1) \/ ((InputVertices b2) \ (InnerVertices b1)) )
proof end;

theorem Th7: :: FACIRC_1:7
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign st not InputVertices b1 is with_pair & InnerVertices b1 is Relation & not InputVertices b2 is with_pair & InnerVertices b2 is Relation holds
InputVertices (b1 +* b2) = (InputVertices b1) \/ (InputVertices b2)
proof end;

theorem Th8: :: FACIRC_1:8
for b1, b2 being non empty ManySortedSign st b1 tolerates b2 & not InputVertices b1 is with_pair & not InputVertices b2 is with_pair holds
not InputVertices (b1 +* b2) is with_pair
proof end;

theorem Th9: :: FACIRC_1:9
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign st not InputVertices b1 is with_pair & not InputVertices b2 is with_pair holds
not InputVertices (b1 +* b2) is with_pair
proof end;

scheme :: FACIRC_1:sch 1
s1{ F1( set , set ) -> Element of BOOLEAN } :
ex b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = F1(b2,b3)
proof end;

scheme :: FACIRC_1:sch 2
s2{ F1( set , set ) -> Element of BOOLEAN } :
for b1, b2 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4 being Element of BOOLEAN holds b1 . <*b3,b4*> = F1(b3,b4) ) & ( for b3, b4 being Element of BOOLEAN holds b2 . <*b3,b4*> = F1(b3,b4) ) holds
b1 = b2
proof end;

scheme :: FACIRC_1:sch 3
s3{ F1( set , set ) -> Element of BOOLEAN } :
( ex b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = F1(b2,b3) & ( for b1, b2 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4 being Element of BOOLEAN holds b1 . <*b3,b4*> = F1(b3,b4) ) & ( for b3, b4 being Element of BOOLEAN holds b2 . <*b3,b4*> = F1(b3,b4) ) holds
b1 = b2 ) )
proof end;

scheme :: FACIRC_1:sch 4
s4{ F1( set , set , set ) -> Element of BOOLEAN } :
ex b1 being Function of 3 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3, b4 being Element of BOOLEAN holds b1 . <*b2,b3,b4*> = F1(b2,b3,b4)
proof end;

scheme :: FACIRC_1:sch 5
s5{ F1( set , set , set ) -> Element of BOOLEAN } :
for b1, b2 being Function of 3 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4, b5 being Element of BOOLEAN holds b1 . <*b3,b4,b5*> = F1(b3,b4,b5) ) & ( for b3, b4, b5 being Element of BOOLEAN holds b2 . <*b3,b4,b5*> = F1(b3,b4,b5) ) holds
b1 = b2
proof end;

scheme :: FACIRC_1:sch 6
s6{ F1( set , set , set ) -> Element of BOOLEAN } :
( ex b1 being Function of 3 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3, b4 being Element of BOOLEAN holds b1 . <*b2,b3,b4*> = F1(b2,b3,b4) & ( for b1, b2 being Function of 3 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4, b5 being Element of BOOLEAN holds b1 . <*b3,b4,b5*> = F1(b3,b4,b5) ) & ( for b3, b4, b5 being Element of BOOLEAN holds b2 . <*b3,b4,b5*> = F1(b3,b4,b5) ) holds
b1 = b2 ) )
proof end;

definition
func 'xor' -> Function of 2 -tuples_on BOOLEAN , BOOLEAN means :Def4: :: FACIRC_1:def 4
for b1, b2 being Element of BOOLEAN holds a1 . <*b1,b2*> = b1 'xor' b2;
correctness
existence
ex b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = b2 'xor' b3
;
uniqueness
for b1, b2 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4 being Element of BOOLEAN holds b1 . <*b3,b4*> = b3 'xor' b4 ) & ( for b3, b4 being Element of BOOLEAN holds b2 . <*b3,b4*> = b3 'xor' b4 ) holds
b1 = b2
;
proof end;
func 'or' -> Function of 2 -tuples_on BOOLEAN , BOOLEAN means :Def5: :: FACIRC_1:def 5
for b1, b2 being Element of BOOLEAN holds a1 . <*b1,b2*> = b1 'or' b2;
correctness
existence
ex b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = b2 'or' b3
;
uniqueness
for b1, b2 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4 being Element of BOOLEAN holds b1 . <*b3,b4*> = b3 'or' b4 ) & ( for b3, b4 being Element of BOOLEAN holds b2 . <*b3,b4*> = b3 'or' b4 ) holds
b1 = b2
;
proof end;
func '&' -> Function of 2 -tuples_on BOOLEAN , BOOLEAN means :Def6: :: FACIRC_1:def 6
for b1, b2 being Element of BOOLEAN holds a1 . <*b1,b2*> = b1 '&' b2;
correctness
existence
ex b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = b2 '&' b3
;
uniqueness
for b1, b2 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4 being Element of BOOLEAN holds b1 . <*b3,b4*> = b3 '&' b4 ) & ( for b3, b4 being Element of BOOLEAN holds b2 . <*b3,b4*> = b3 '&' b4 ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def4 defines 'xor' FACIRC_1:def 4 :
for b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds
( b1 = 'xor' iff for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = b2 'xor' b3 );

:: deftheorem Def5 defines 'or' FACIRC_1:def 5 :
for b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds
( b1 = 'or' iff for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = b2 'or' b3 );

:: deftheorem Def6 defines '&' FACIRC_1:def 6 :
for b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds
( b1 = '&' iff for b2, b3 being Element of BOOLEAN holds b1 . <*b2,b3*> = b2 '&' b3 );

definition
func or3 -> Function of 3 -tuples_on BOOLEAN , BOOLEAN means :Def7: :: FACIRC_1:def 7
for b1, b2, b3 being Element of BOOLEAN holds a1 . <*b1,b2,b3*> = (b1 'or' b2) 'or' b3;
correctness
existence
ex b1 being Function of 3 -tuples_on BOOLEAN , BOOLEAN st
for b2, b3, b4 being Element of BOOLEAN holds b1 . <*b2,b3,b4*> = (b2 'or' b3) 'or' b4
;
uniqueness
for b1, b2 being Function of 3 -tuples_on BOOLEAN , BOOLEAN st ( for b3, b4, b5 being Element of BOOLEAN holds b1 . <*b3,b4,b5*> = (b3 'or' b4) 'or' b5 ) & ( for b3, b4, b5 being Element of BOOLEAN holds b2 . <*b3,b4,b5*> = (b3 'or' b4) 'or' b5 ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def7 defines or3 FACIRC_1:def 7 :
for b1 being Function of 3 -tuples_on BOOLEAN , BOOLEAN holds
( b1 = or3 iff for b2, b3, b4 being Element of BOOLEAN holds b1 . <*b2,b3,b4*> = (b2 'or' b3) 'or' b4 );

definition
let c1 be set ;
redefine func <* as <*c1*> -> FinSeqLen of 1;
coherence
<*c1*> is FinSeqLen of 1
proof end;
let c2 be set ;
redefine func <* as <*c1,c2*> -> FinSeqLen of 2;
coherence
<*c1,c2*> is FinSeqLen of 2
proof end;
let c3 be set ;
redefine func <* as <*c1,c2,c3*> -> FinSeqLen of 3;
coherence
<*c1,c2,c3*> is FinSeqLen of 3
proof end;
end;

definition
let c1, c2 be Nat;
let c3 be FinSeqLen of c1;
let c4 be FinSeqLen of c2;
redefine func ^ as c3 ^ c4 -> FinSeqLen of a1 + a2;
coherence
c3 ^ c4 is FinSeqLen of c1 + c2
proof end;
end;

E16: now
let c1 be non empty non void ManySortedSign ;
let c2 be Gate of c1;
not the OperSymbols of c1 is empty by MSUALG_1:def 5;
hence c2 in the OperSymbols of c1 ;
end;

theorem Th10: :: FACIRC_1:10
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 Gate of b1 holds (Following b3) . (the_result_sort_of b4) = (Den b4,b2) . (b3 * (the_arity_of 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 Nat;
func Following c3,c4 -> State of a2 means :Def8: :: FACIRC_1:def 8
ex b1 being Function of NAT , product the Sorts of a2 st
( a5 = b1 . a4 & b1 . 0 = a3 & ( for b2 being Nat holds b1 . (b2 + 1) = Following (b1 . b2) ) );
correctness
existence
ex b1 being State of c2ex b2 being Function of NAT , product the Sorts of c2 st
( b1 = b2 . c4 & b2 . 0 = c3 & ( for b3 being Nat holds b2 . (b3 + 1) = Following (b2 . b3) ) )
;
uniqueness
for b1, b2 being State of c2 st ex b3 being Function of NAT , product the Sorts of c2 st
( b1 = b3 . c4 & b3 . 0 = c3 & ( for b4 being Nat holds b3 . (b4 + 1) = Following (b3 . b4) ) ) & ex b3 being Function of NAT , product the Sorts of c2 st
( b2 = b3 . c4 & b3 . 0 = c3 & ( for b4 being Nat holds b3 . (b4 + 1) = Following (b3 . b4) ) ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def8 defines Following FACIRC_1:def 8 :
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 Nat
for b5 being State of b2 holds
( b5 = Following b3,b4 iff ex b6 being Function of NAT , product the Sorts of b2 st
( b5 = b6 . b4 & b6 . 0 = b3 & ( for b7 being Nat holds b6 . (b7 + 1) = Following (b6 . b7) ) ) );

theorem Th11: :: FACIRC_1:11
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 Following b3,0 = b3
proof end;

theorem Th12: :: FACIRC_1:12
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 Nat holds Following b3,(b4 + 1) = Following (Following b3,b4)
proof end;

theorem Th13: :: FACIRC_1:13
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, b5 being Nat holds Following b3,(b4 + b5) = Following (Following b3,b4),b5
proof end;

theorem Th14: :: FACIRC_1:14
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 Following b3,1 = Following b3
proof end;

theorem Th15: :: FACIRC_1:15
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 Following b3,2 = Following (Following b3)
proof end;

theorem Th16: :: FACIRC_1:16
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 Nat holds Following b3,(b4 + 1) = Following (Following b3),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 set ;
pred c3 is_stable_at c4 means :Def9: :: FACIRC_1:def 9
for b1 being Nat holds (Following a3,b1) . a4 = a3 . a4;
end;

:: deftheorem Def9 defines is_stable_at FACIRC_1:def 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 set holds
( b3 is_stable_at b4 iff for b5 being Nat holds (Following b3,b5) . b4 = b3 . b4 );

theorem Th17: :: FACIRC_1:17
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 set st b3 is_stable_at b4 holds
for b5 being Nat holds Following b3,b5 is_stable_at b4
proof end;

theorem Th18: :: FACIRC_1:18
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 set st b4 in InputVertices b1 holds
b3 is_stable_at b4
proof end;

theorem Th19: :: FACIRC_1:19
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 Gate of b1 st ( for b5 being set st b5 in rng (the_arity_of b4) holds
b3 is_stable_at b5 ) holds
Following b3 is_stable_at the_result_sort_of b4
proof end;

theorem Th20: :: FACIRC_1:20
for b1, b2 being non empty ManySortedSign
for b3 being Vertex of b1 holds
( b3 in the carrier of (b1 +* b2) & b3 in the carrier of (b2 +* b1) )
proof end;

theorem Th21: :: FACIRC_1:21
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign
for b3 being set st b3 in InnerVertices b1 holds
( b3 in InnerVertices (b1 +* b2) & b3 in InnerVertices (b2 +* b1) )
proof end;

theorem Th22: :: FACIRC_1:22
for b1, b2 being non empty ManySortedSign
for b3 being set st b3 in InnerVertices b2 holds
b3 in InnerVertices (b1 +* b2)
proof end;

theorem Th23: :: FACIRC_1:23
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign holds b1 +* b2 = b2 +* b1
proof end;

theorem Th24: :: FACIRC_1:24
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2 holds b3 +* b4 = b4 +* b3
proof end;

theorem Th25: :: FACIRC_1:25
for b1, b2, b3 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
for b4 being Boolean Circuit of b1
for b5 being Boolean Circuit of b2
for b6 being Boolean Circuit of b3 holds (b4 +* b5) +* b6 = b4 +* (b5 +* b6)
proof end;

theorem Th26: :: FACIRC_1:26
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
for b3 being non-empty gate`2=den Boolean Circuit of b1
for b4 being non-empty gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4) holds
( b5 | the carrier of b1 is State of b3 & b5 | the carrier of b2 is State of b4 )
proof end;

theorem Th27: :: FACIRC_1:27
for b1, b2 being non empty unsplit gate`1=arity ManySortedSign holds InnerVertices (b1 +* b2) = (InnerVertices b1) \/ (InnerVertices b2)
proof end;

theorem Th28: :: FACIRC_1:28
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st InnerVertices b2 misses InputVertices b1 holds
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4)
for b6 being State of b3 st b6 = b5 | the carrier of b1 holds
(Following b5) | the carrier of b1 = Following b6
proof end;

theorem Th29: :: FACIRC_1:29
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st InnerVertices b1 misses InputVertices b2 holds
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4)
for b6 being State of b4 st b6 = b5 | the carrier of b2 holds
(Following b5) | the carrier of b2 = Following b6
proof end;

theorem Th30: :: FACIRC_1:30
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st InnerVertices b2 misses InputVertices b1 holds
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4)
for b6 being State of b3 st b6 = b5 | the carrier of b1 holds
for b7 being Nat holds (Following b5,b7) | the carrier of b1 = Following b6,b7
proof end;

theorem Th31: :: FACIRC_1:31
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st InnerVertices b1 misses InputVertices b2 holds
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4)
for b6 being State of b4 st b6 = b5 | the carrier of b2 holds
for b7 being Nat holds (Following b5,b7) | the carrier of b2 = Following b6,b7
proof end;

theorem Th32: :: FACIRC_1:32
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st InnerVertices b2 misses InputVertices b1 holds
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4)
for b6 being State of b3 st b6 = b5 | the carrier of b1 holds
for b7 being set st b7 in the carrier of b1 holds
for b8 being Nat holds (Following b5,b8) . b7 = (Following b6,b8) . b7
proof end;

theorem Th33: :: FACIRC_1:33
for b1, b2 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st InnerVertices b1 misses InputVertices b2 holds
for b3 being gate`2=den Boolean Circuit of b1
for b4 being gate`2=den Boolean Circuit of b2
for b5 being State of (b3 +* b4)
for b6 being State of b4 st b6 = b5 | the carrier of b2 holds
for b7 being set st b7 in the carrier of b2 holds
for b8 being Nat holds (Following b5,b8) . b7 = (Following b6,b8) . b7
proof end;

registration
let c1 be non empty non void gate`2=den ManySortedSign ;
let c2 be Gate of c1;
cluster a2 `2 -> Relation-like Function-like ;
coherence
( c2 `2 is Function-like & c2 `2 is Relation-like )
proof end;
end;

theorem Th34: :: FACIRC_1:34
for b1 being non empty non void Circuit-like gate`2=den ManySortedSign
for b2 being non-empty Circuit of b1 st b2 is gate`2=den holds
for b3 being State of b2
for b4 being Gate of b1 holds (Following b3) . (the_result_sort_of b4) = (b4 `2 ) . (b3 * (the_arity_of b4))
proof end;

theorem Th35: :: FACIRC_1:35
for b1 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
for b2 being non-empty gate`2=den Boolean Circuit of b1
for b3 being State of b2
for b4 being FinSequence
for b5 being Function st [b4,b5] in the OperSymbols of b1 holds
(Following b3) . [b4,b5] = b5 . (b3 * b4)
proof end;

theorem Th36: :: FACIRC_1:36
for b1 being non empty non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
for b2 being non-empty gate`2=den Boolean Circuit of b1
for b3 being State of b2
for b4 being FinSequence
for b5 being Function st [b4,b5] in the OperSymbols of b1 & ( for b6 being set st b6 in rng b4 holds
b3 is_stable_at b6 ) holds
Following b3 is_stable_at [b4,b5]
proof end;

theorem Th37: :: FACIRC_1:37
for b1 being non empty unsplit ManySortedSign holds InnerVertices b1 = the OperSymbols of b1
proof end;

theorem Th38: :: FACIRC_1:38
for b1 being set
for b2 being FinSequence holds InnerVertices (1GateCircStr b2,b1) is Relation
proof end;

theorem Th39: :: FACIRC_1:39
for b1 being set
for b2 being nonpair-yielding FinSequence holds not InputVertices (1GateCircStr b2,b1) is with_pair
proof end;

theorem Th40: :: FACIRC_1:40
for b1, b2, b3 being set holds InputVertices (1GateCircStr <*b2,b3*>,b1) = {b2,b3}
proof end;

theorem Th41: :: FACIRC_1:41
for b1 being set
for b2, b3 being non pair set holds not InputVertices (1GateCircStr <*b2,b3*>,b1) is with_pair
proof end;

theorem Th42: :: FACIRC_1:42
for b1, b2, b3, b4 being set holds InputVertices (1GateCircStr <*b2,b3,b4*>,b1) = {b2,b3,b4}
proof end;

theorem Th43: :: FACIRC_1:43
for b1, b2, b3 being set holds
( b1 in the carrier of (1GateCircStr <*b1,b2*>,b3) & b2 in the carrier of (1GateCircStr <*b1,b2*>,b3) & [<*b1,b2*>,b3] in the carrier of (1GateCircStr <*b1,b2*>,b3) )
proof end;

theorem Th44: :: FACIRC_1:44
for b1, b2, b3, b4 being set holds
( b1 in the carrier of (1GateCircStr <*b1,b2,b3*>,b4) & b2 in the carrier of (1GateCircStr <*b1,b2,b3*>,b4) & b3 in the carrier of (1GateCircStr <*b1,b2,b3*>,b4) )
proof end;

theorem Th45: :: FACIRC_1:45
for b1, b2 being set
for b3 being FinSequence holds
( b2 in the carrier of (1GateCircStr b3,b1,b2) & ( for b4 being set st b4 in rng b3 holds
b4 in the carrier of (1GateCircStr b3,b1,b2) ) )
proof end;

theorem Th46: :: FACIRC_1:46
for b1, b2 being set
for b3 being FinSequence holds
( 1GateCircStr b3,b1,b2 is gate`1=arity & 1GateCircStr b3,b1,b2 is Circuit-like )
proof end;

theorem Th47: :: FACIRC_1:47
for b1 being FinSequence
for b2 being set holds [b1,b2] in InnerVertices (1GateCircStr b1,b2)
proof end;

definition
let c1, c2 be set ;
let c3 be Function of 2 -tuples_on BOOLEAN , BOOLEAN ;
func 1GateCircuit c1,c2,c3 -> strict gate`2=den Boolean Circuit of 1GateCircStr <*a1,a2*>,a3 equals :: FACIRC_1:def 10
1GateCircuit <*a1,a2*>,a3;
coherence
1GateCircuit <*c1,c2*>,c3 is strict gate`2=den Boolean Circuit of 1GateCircStr <*c1,c2*>,c3
by CIRCCOMB:69;
end;

:: deftheorem Def10 defines 1GateCircuit FACIRC_1:def 10 :
for b1, b2 being set
for b3 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds 1GateCircuit b1,b2,b3 = 1GateCircuit <*b1,b2*>,b3;

theorem Th48: :: FACIRC_1:48
for b1, b2 being set
for b3 being non empty finite set
for b4 being Function of 2 -tuples_on b3,b3
for b5 being State of (1GateCircuit <*b1,b2*>,b4) holds
( (Following b5) . [<*b1,b2*>,b4] = b4 . <*(b5 . b1),(b5 . b2)*> & (Following b5) . b1 = b5 . b1 & (Following b5) . b2 = b5 . b2 )
proof end;

theorem Th49: :: FACIRC_1:49
for b1, b2 being set
for b3 being non empty finite set
for b4 being Function of 2 -tuples_on b3,b3
for b5 being State of (1GateCircuit <*b1,b2*>,b4) holds Following b5 is stable
proof end;

theorem Th50: :: FACIRC_1:50
for b1, b2 being set
for b3 being Function of 2 -tuples_on BOOLEAN , BOOLEAN
for b4 being State of (1GateCircuit b1,b2,b3) holds
( (Following b4) . [<*b1,b2*>,b3] = b3 . <*(b4 . b1),(b4 . b2)*> & (Following b4) . b1 = b4 . b1 & (Following b4) . b2 = b4 . b2 ) by Th48;

theorem Th51: :: FACIRC_1:51
for b1, b2 being set
for b3 being Function of 2 -tuples_on BOOLEAN , BOOLEAN
for b4 being State of (1GateCircuit b1,b2,b3) holds Following b4 is stable by Th49;

definition
let c1, c2, c3 be set ;
let c4 be Function of 3 -tuples_on BOOLEAN , BOOLEAN ;
func 1GateCircuit c1,c2,c3,c4 -> strict gate`2=den Boolean Circuit of 1GateCircStr <*a1,a2,a3*>,a4 equals :: FACIRC_1:def 11
1GateCircuit <*a1,a2,a3*>,a4;
coherence
1GateCircuit <*c1,c2,c3*>,c4 is strict gate`2=den Boolean Circuit of 1GateCircStr <*c1,c2,c3*>,c4
by CIRCCOMB:69;
end;

:: deftheorem Def11 defines 1GateCircuit FACIRC_1:def 11 :
for b1, b2, b3 being set
for b4 being Function of 3 -tuples_on BOOLEAN , BOOLEAN holds 1GateCircuit b1,b2,b3,b4 = 1GateCircuit <*b1,b2,b3*>,b4;

theorem Th52: :: FACIRC_1:52
for b1, b2, b3 being set
for b4 being non empty finite set
for b5 being Function of 3 -tuples_on b4,b4
for b6 being State of (1GateCircuit <*b1,b2,b3*>,b5) holds
( (Following b6) . [<*b1,b2,b3*>,b5] = b5 . <*(b6 . b1),(b6 . b2),(b6 . b3)*> & (Following b6) . b1 = b6 . b1 & (Following b6) . b2 = b6 . b2 & (Following b6) . b3 = b6 . b3 )
proof end;

theorem Th53: :: FACIRC_1:53
for b1, b2, b3 being set
for b4 being non empty finite set
for b5 being Function of 3 -tuples_on b4,b4
for b6 being State of (1GateCircuit <*b1,b2,b3*>,b5) holds Following b6 is stable
proof end;

theorem Th54: :: FACIRC_1:54
for b1, b2, b3 being set
for b4 being Function of 3 -tuples_on BOOLEAN , BOOLEAN
for b5 being State of (1GateCircuit b1,b2,b3,b4) holds
( (Following b5) . [<*b1,b2,b3*>,b4] = b4 . <*(b5 . b1),(b5 . b2),(b5 . b3)*> & (Following b5) . b1 = b5 . b1 & (Following b5) . b2 = b5 . b2 & (Following b5) . b3 = b5 . b3 ) by Th52;

theorem Th55: :: FACIRC_1:55
for b1, b2, b3 being set
for b4 being Function of 3 -tuples_on BOOLEAN , BOOLEAN
for b5 being State of (1GateCircuit b1,b2,b3,b4) holds Following b5 is stable by Th53;

definition
let c1, c2, c3 be set ;
let c4 be Function of 2 -tuples_on BOOLEAN , BOOLEAN ;
func 2GatesCircStr c1,c2,c3,c4 -> non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign equals :: FACIRC_1:def 12
(1GateCircStr <*a1,a2*>,a4) +* (1GateCircStr <*[<*a1,a2*>,a4],a3*>,a4);
correctness
coherence
(1GateCircStr <*c1,c2*>,c4) +* (1GateCircStr <*[<*c1,c2*>,c4],c3*>,c4) is non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
;
;
end;

:: deftheorem Def12 defines 2GatesCircStr FACIRC_1:def 12 :
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds 2GatesCircStr b1,b2,b3,b4 = (1GateCircStr <*b1,b2*>,b4) +* (1GateCircStr <*[<*b1,b2*>,b4],b3*>,b4);

definition
let c1, c2, c3 be set ;
let c4 be Function of 2 -tuples_on BOOLEAN , BOOLEAN ;
func 2GatesCircOutput c1,c2,c3,c4 -> Element of InnerVertices (2GatesCircStr a1,a2,a3,a4) equals :: FACIRC_1:def 13
[<*[<*a1,a2*>,a4],a3*>,a4];
coherence
[<*[<*c1,c2*>,c4],c3*>,c4] is Element of InnerVertices (2GatesCircStr c1,c2,c3,c4)
proof end;
correctness
;
end;

:: deftheorem Def13 defines 2GatesCircOutput FACIRC_1:def 13 :
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds 2GatesCircOutput b1,b2,b3,b4 = [<*[<*b1,b2*>,b4],b3*>,b4];

registration
let c1, c2, c3 be set ;
let c4 be Function of 2 -tuples_on BOOLEAN , BOOLEAN ;
cluster 2GatesCircOutput a1,a2,a3,a4 -> non empty pair ;
coherence
2GatesCircOutput c1,c2,c3,c4 is pair
;
end;

theorem Th56: :: FACIRC_1:56
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds InnerVertices (2GatesCircStr b1,b2,b3,b4) = {[<*b1,b2*>,b4],(2GatesCircOutput b1,b2,b3,b4)}
proof end;

theorem Th57: :: FACIRC_1:57
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN st b1 <> [<*b2,b3*>,b4] holds
InputVertices (2GatesCircStr b2,b3,b1,b4) = {b2,b3,b1}
proof end;

definition
let c1, c2, c3 be set ;
let c4 be Function of 2 -tuples_on BOOLEAN , BOOLEAN ;
func 2GatesCircuit c1,c2,c3,c4 -> strict gate`2=den Boolean Circuit of 2GatesCircStr a1,a2,a3,a4 equals :: FACIRC_1:def 14
(1GateCircuit a1,a2,a4) +* (1GateCircuit [<*a1,a2*>,a4],a3,a4);
coherence
(1GateCircuit c1,c2,c4) +* (1GateCircuit [<*c1,c2*>,c4],c3,c4) is strict gate`2=den Boolean Circuit of 2GatesCircStr c1,c2,c3,c4
;
end;

:: deftheorem Def14 defines 2GatesCircuit FACIRC_1:def 14 :
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds 2GatesCircuit b1,b2,b3,b4 = (1GateCircuit b1,b2,b4) +* (1GateCircuit [<*b1,b2*>,b4],b3,b4);

theorem Th58: :: FACIRC_1:58
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds InnerVertices (2GatesCircStr b1,b2,b3,b4) is Relation
proof end;

theorem Th59: :: FACIRC_1:59
for b1 being Function of 2 -tuples_on BOOLEAN , BOOLEAN
for b2, b3, b4 being non pair set holds not InputVertices (2GatesCircStr b2,b3,b4,b1) is with_pair
proof end;

theorem Th60: :: FACIRC_1:60
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds
( b1 in the carrier of (2GatesCircStr b1,b2,b3,b4) & b2 in the carrier of (2GatesCircStr b1,b2,b3,b4) & b3 in the carrier of (2GatesCircStr b1,b2,b3,b4) )
proof end;

theorem Th61: :: FACIRC_1:61
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN holds
( [<*b1,b2*>,b4] in the carrier of (2GatesCircStr b1,b2,b3,b4) & [<*[<*b1,b2*>,b4],b3*>,b4] in the carrier of (2GatesCircStr b1,b2,b3,b4) )
proof end;

definition
let c1 be non empty non void unsplit ManySortedSign ;
let c2 be Boolean Circuit of c1;
let c3 be State of c2;
let c4 be Vertex of c1;
redefine func . as c3 . c4 -> Element of BOOLEAN ;
coherence
c3 . c4 is Element of BOOLEAN
proof end;
end;

Lemma60: for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN
for b5 being State of (2GatesCircuit b2,b3,b1,b4) st b1 <> [<*b2,b3*>,b4] holds
( (Following b5) . (2GatesCircOutput b2,b3,b1,b4) = b4 . <*(b5 . [<*b2,b3*>,b4]),(b5 . b1)*> & (Following b5) . [<*b2,b3*>,b4] = b4 . <*(b5 . b2),(b5 . b3)*> & (Following b5) . b2 = b5 . b2 & (Following b5) . b3 = b5 . b3 & (Following b5) . b1 = b5 . b1 )
proof end;

theorem Th62: :: FACIRC_1:62
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN
for b5 being State of (2GatesCircuit b2,b3,b1,b4) st b1 <> [<*b2,b3*>,b4] holds
( (Following b5,2) . (2GatesCircOutput b2,b3,b1,b4) = b4 . <*(b4 . <*(b5 . b2),(b5 . b3)*>),(b5 . b1)*> & (Following b5,2) . [<*b2,b3*>,b4] = b4 . <*(b5 . b2),(b5 . b3)*> & (Following b5,2) . b2 = b5 . b2 & (Following b5,2) . b3 = b5 . b3 & (Following b5,2) . b1 = b5 . b1 )
proof end;

theorem Th63: :: FACIRC_1:63
for b1, b2, b3 being set
for b4 being Function of 2 -tuples_on BOOLEAN , BOOLEAN
for b5 being State of (2GatesCircuit b2,b3,b1,b4) st b1 <> [<*b2,b3*>,b4] holds
Following b5,2 is stable
proof end;

theorem Th64: :: FACIRC_1:64
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,'xor' ] holds
for b4 being State of (2GatesCircuit b2,b3,b1,'xor' )
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 & b7 = b4 . b1 holds
(Following b4,2) . (2GatesCircOutput b2,b3,b1,'xor' ) = (b5 'xor' b6) 'xor' b7
proof end;

theorem Th65: :: FACIRC_1:65
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,'or' ] holds
for b4 being State of (2GatesCircuit b2,b3,b1,'or' )
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 & b7 = b4 . b1 holds
(Following b4,2) . (2GatesCircOutput b2,b3,b1,'or' ) = (b5 'or' b6) 'or' b7
proof end;

theorem Th66: :: FACIRC_1:66
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,'&' ] holds
for b4 being State of (2GatesCircuit b2,b3,b1,'&' )
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 & b7 = b4 . b1 holds
(Following b4,2) . (2GatesCircOutput b2,b3,b1,'&' ) = (b5 '&' b6) '&' b7
proof end;

definition
let c1, c2, c3 be set ;
func BitAdderOutput c1,c2,c3 -> Element of InnerVertices (2GatesCircStr a1,a2,a3,'xor' ) equals :: FACIRC_1:def 15
2GatesCircOutput a1,a2,a3,'xor' ;
coherence
2GatesCircOutput c1,c2,c3,'xor' is Element of InnerVertices (2GatesCircStr c1,c2,c3,'xor' )
;
end;

:: deftheorem Def15 defines BitAdderOutput FACIRC_1:def 15 :
for b1, b2, b3 being set holds BitAdderOutput b1,b2,b3 = 2GatesCircOutput b1,b2,b3,'xor' ;

definition
let c1, c2, c3 be set ;
func BitAdderCirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of 2GatesCircStr a1,a2,a3,'xor' equals :: FACIRC_1:def 16
2GatesCircuit a1,a2,a3,'xor' ;
coherence
2GatesCircuit c1,c2,c3,'xor' is strict gate`2=den Boolean Circuit of 2GatesCircStr c1,c2,c3,'xor'
;
end;

:: deftheorem Def16 defines BitAdderCirc FACIRC_1:def 16 :
for b1, b2, b3 being set holds BitAdderCirc b1,b2,b3 = 2GatesCircuit b1,b2,b3,'xor' ;

definition
let c1, c2, c3 be set ;
func MajorityIStr c1,c2,c3 -> non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign equals :: FACIRC_1:def 17
((1GateCircStr <*a1,a2*>,'&' ) +* (1GateCircStr <*a2,a3*>,'&' )) +* (1GateCircStr <*a3,a1*>,'&' );
correctness
coherence
((1GateCircStr <*c1,c2*>,'&' ) +* (1GateCircStr <*c2,c3*>,'&' )) +* (1GateCircStr <*c3,c1*>,'&' ) is non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
;
;
end;

:: deftheorem Def17 defines MajorityIStr FACIRC_1:def 17 :
for b1, b2, b3 being set holds MajorityIStr b1,b2,b3 = ((1GateCircStr <*b1,b2*>,'&' ) +* (1GateCircStr <*b2,b3*>,'&' )) +* (1GateCircStr <*b3,b1*>,'&' );

definition
let c1, c2, c3 be set ;
func MajorityStr c1,c2,c3 -> non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign equals :: FACIRC_1:def 18
(MajorityIStr a1,a2,a3) +* (1GateCircStr <*[<*a1,a2*>,'&' ],[<*a2,a3*>,'&' ],[<*a3,a1*>,'&' ]*>,or3 );
correctness
coherence
(MajorityIStr c1,c2,c3) +* (1GateCircStr <*[<*c1,c2*>,'&' ],[<*c2,c3*>,'&' ],[<*c3,c1*>,'&' ]*>,or3 ) is non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
;
;
end;

:: deftheorem Def18 defines MajorityStr FACIRC_1:def 18 :
for b1, b2, b3 being set holds MajorityStr b1,b2,b3 = (MajorityIStr b1,b2,b3) +* (1GateCircStr <*[<*b1,b2*>,'&' ],[<*b2,b3*>,'&' ],[<*b3,b1*>,'&' ]*>,or3 );

definition
let c1, c2, c3 be set ;
func MajorityICirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of MajorityIStr a1,a2,a3 equals :: FACIRC_1:def 19
((1GateCircuit a1,a2,'&' ) +* (1GateCircuit a2,a3,'&' )) +* (1GateCircuit a3,a1,'&' );
coherence
((1GateCircuit c1,c2,'&' ) +* (1GateCircuit c2,c3,'&' )) +* (1GateCircuit c3,c1,'&' ) is strict gate`2=den Boolean Circuit of MajorityIStr c1,c2,c3
;
end;

:: deftheorem Def19 defines MajorityICirc FACIRC_1:def 19 :
for b1, b2, b3 being set holds MajorityICirc b1,b2,b3 = ((1GateCircuit b1,b2,'&' ) +* (1GateCircuit b2,b3,'&' )) +* (1GateCircuit b3,b1,'&' );

theorem Th67: :: FACIRC_1:67
for b1, b2, b3 being set holds InnerVertices (MajorityStr b1,b2,b3) is Relation
proof end;

theorem Th68: :: FACIRC_1:68
for b1, b2, b3 being non pair set holds not InputVertices (MajorityStr b1,b2,b3) is with_pair
proof end;

theorem Th69: :: FACIRC_1:69
for b1, b2, b3 being set
for b4 being State of (MajorityICirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 holds
(Following b4) . [<*b1,b2*>,'&' ] = b5 '&' b6
proof end;

theorem Th70: :: FACIRC_1:70
for b1, b2, b3 being set
for b4 being State of (MajorityICirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 holds
(Following b4) . [<*b2,b3*>,'&' ] = b5 '&' b6
proof end;

theorem Th71: :: FACIRC_1:71
for b1, b2, b3 being set
for b4 being State of (MajorityICirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b3 & b6 = b4 . b1 holds
(Following b4) . [<*b3,b1*>,'&' ] = b5 '&' b6
proof end;

definition
let c1, c2, c3 be set ;
func MajorityOutput c1,c2,c3 -> Element of InnerVertices (MajorityStr a1,a2,a3) equals :: FACIRC_1:def 20
[<*[<*a1,a2*>,'&' ],[<*a2,a3*>,'&' ],[<*a3,a1*>,'&' ]*>,or3 ];
coherence
[<*[<*c1,c2*>,'&' ],[<*c2,c3*>,'&' ],[<*c3,c1*>,'&' ]*>,or3 ] is Element of InnerVertices (MajorityStr c1,c2,c3)
proof end;
correctness
;
end;

:: deftheorem Def20 defines MajorityOutput FACIRC_1:def 20 :
for b1, b2, b3 being set holds MajorityOutput b1,b2,b3 = [<*[<*b1,b2*>,'&' ],[<*b2,b3*>,'&' ],[<*b3,b1*>,'&' ]*>,or3 ];

definition
let c1, c2, c3 be set ;
func MajorityCirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of MajorityStr a1,a2,a3 equals :: FACIRC_1:def 21
(MajorityICirc a1,a2,a3) +* (1GateCircuit [<*a1,a2*>,'&' ],[<*a2,a3*>,'&' ],[<*a3,a1*>,'&' ],or3 );
coherence
(MajorityICirc c1,c2,c3) +* (1GateCircuit [<*c1,c2*>,'&' ],[<*c2,c3*>,'&' ],[<*c3,c1*>,'&' ],or3 ) is strict gate`2=den Boolean Circuit of MajorityStr c1,c2,c3
;
end;

:: deftheorem Def21 defines MajorityCirc FACIRC_1:def 21 :
for b1, b2, b3 being set holds MajorityCirc b1,b2,b3 = (MajorityICirc b1,b2,b3) +* (1GateCircuit [<*b1,b2*>,'&' ],[<*b2,b3*>,'&' ],[<*b3,b1*>,'&' ],or3 );

theorem Th72: :: FACIRC_1:72
for b1, b2, b3 being set holds
( b1 in the carrier of (MajorityStr b1,b2,b3) & b2 in the carrier of (MajorityStr b1,b2,b3) & b3 in the carrier of (MajorityStr b1,b2,b3) )
proof end;

theorem Th73: :: FACIRC_1:73
for b1, b2, b3 being set holds
( [<*b1,b2*>,'&' ] in InnerVertices (MajorityStr b1,b2,b3) & [<*b2,b3*>,'&' ] in InnerVertices (MajorityStr b1,b2,b3) & [<*b3,b1*>,'&' ] in InnerVertices (MajorityStr b1,b2,b3) )
proof end;

theorem Th74: :: FACIRC_1:74
for b1, b2, b3 being non pair set holds
( b1 in InputVertices (MajorityStr b1,b2,b3) & b2 in InputVertices (MajorityStr b1,b2,b3) & b3 in InputVertices (MajorityStr b1,b2,b3) )
proof end;

theorem Th75: :: FACIRC_1:75
for b1, b2, b3 being non pair set holds
( InputVertices (MajorityStr b1,b2,b3) = {b1,b2,b3} & InnerVertices (MajorityStr b1,b2,b3) = {[<*b1,b2*>,'&' ],[<*b2,b3*>,'&' ],[<*b3,b1*>,'&' ]} \/ {(MajorityOutput b1,b2,b3)} )
proof end;

Lemma70: for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 & b7 = b4 . b3 holds
( (Following b4) . [<*b1,b2*>,'&' ] = b5 '&' b6 & (Following b4) . [<*b2,b3*>,'&' ] = b6 '&' b7 & (Following b4) . [<*b3,b1*>,'&' ] = b7 '&' b5 )
proof end;

theorem Th76: :: FACIRC_1:76
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 holds
(Following b4) . [<*b1,b2*>,'&' ] = b5 '&' b6
proof end;

theorem Th77: :: FACIRC_1:77
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 holds
(Following b4) . [<*b2,b3*>,'&' ] = b5 '&' b6
proof end;

theorem Th78: :: FACIRC_1:78
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b3 holds
(Following b4) . [<*b3,b1*>,'&' ] = b6 '&' b5
proof end;

theorem Th79: :: FACIRC_1:79
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . [<*b1,b2*>,'&' ] & b6 = b4 . [<*b2,b3*>,'&' ] & b7 = b4 . [<*b3,b1*>,'&' ] holds
(Following b4) . (MajorityOutput b1,b2,b3) = (b5 'or' b6) 'or' b7
proof end;

Lemma72: for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 & b7 = b4 . b3 holds
( (Following b4,2) . (MajorityOutput b1,b2,b3) = ((b5 '&' b6) 'or' (b6 '&' b7)) 'or' (b7 '&' b5) & (Following b4,2) . [<*b1,b2*>,'&' ] = b5 '&' b6 & (Following b4,2) . [<*b2,b3*>,'&' ] = b6 '&' b7 & (Following b4,2) . [<*b3,b1*>,'&' ] = b7 '&' b5 )
proof end;

theorem Th80: :: FACIRC_1:80
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 holds
(Following b4,2) . [<*b1,b2*>,'&' ] = b5 '&' b6
proof end;

theorem Th81: :: FACIRC_1:81
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 holds
(Following b4,2) . [<*b2,b3*>,'&' ] = b5 '&' b6
proof end;

theorem Th82: :: FACIRC_1:82
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b3 holds
(Following b4,2) . [<*b3,b1*>,'&' ] = b6 '&' b5
proof end;

theorem Th83: :: FACIRC_1:83
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3)
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 & b7 = b4 . b3 holds
(Following b4,2) . (MajorityOutput b1,b2,b3) = ((b5 '&' b6) 'or' (b6 '&' b7)) 'or' (b7 '&' b5) by Lemma72;

theorem Th84: :: FACIRC_1:84
for b1, b2, b3 being non pair set
for b4 being State of (MajorityCirc b1,b2,b3) holds Following b4,2 is stable
proof end;

definition
let c1, c2, c3 be set ;
func BitAdderWithOverflowStr c1,c2,c3 -> non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign equals :: FACIRC_1:def 22
(2GatesCircStr a1,a2,a3,'xor' ) +* (MajorityStr a1,a2,a3);
coherence
(2GatesCircStr c1,c2,c3,'xor' ) +* (MajorityStr c1,c2,c3) is non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
;
end;

:: deftheorem Def22 defines BitAdderWithOverflowStr FACIRC_1:def 22 :
for b1, b2, b3 being set holds BitAdderWithOverflowStr b1,b2,b3 = (2GatesCircStr b1,b2,b3,'xor' ) +* (MajorityStr b1,b2,b3);

theorem Th85: :: FACIRC_1:85
for b1, b2, b3 being non pair set holds InputVertices (BitAdderWithOverflowStr b1,b2,b3) = {b1,b2,b3}
proof end;

theorem Th86: :: FACIRC_1:86
for b1, b2, b3 being non pair set holds InnerVertices (BitAdderWithOverflowStr b1,b2,b3) = ({[<*b1,b2*>,'xor' ],(2GatesCircOutput b1,b2,b3,'xor' )} \/ {[<*b1,b2*>,'&' ],[<*b2,b3*>,'&' ],[<*b3,b1*>,'&' ]}) \/ {(MajorityOutput b1,b2,b3)}
proof end;

theorem Th87: :: FACIRC_1:87
for b1, b2, b3 being set
for b4 being non empty ManySortedSign st b4 = BitAdderWithOverflowStr b1,b2,b3 holds
( b1 in the carrier of b4 & b2 in the carrier of b4 & b3 in the carrier of b4 )
proof end;

definition
let c1, c2, c3 be set ;
func BitAdderWithOverflowCirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of BitAdderWithOverflowStr a1,a2,a3 equals :: FACIRC_1:def 23
(BitAdderCirc a1,a2,a3) +* (MajorityCirc a1,a2,a3);
coherence
(BitAdderCirc c1,c2,c3) +* (MajorityCirc c1,c2,c3) is strict gate`2=den Boolean Circuit of BitAdderWithOverflowStr c1,c2,c3
;
end;

:: deftheorem Def23 defines BitAdderWithOverflowCirc FACIRC_1:def 23 :
for b1, b2, b3 being set holds BitAdderWithOverflowCirc b1,b2,b3 = (BitAdderCirc b1,b2,b3) +* (MajorityCirc b1,b2,b3);

theorem Th88: :: FACIRC_1:88
for b1, b2, b3 being set holds InnerVertices (BitAdderWithOverflowStr b1,b2,b3) is Relation
proof end;

theorem Th89: :: FACIRC_1:89
for b1, b2, b3 being non pair set holds not InputVertices (BitAdderWithOverflowStr b1,b2,b3) is with_pair
proof end;

theorem Th90: :: FACIRC_1:90
for b1, b2, b3 being set holds
( BitAdderOutput b1,b2,b3 in InnerVertices (BitAdderWithOverflowStr b1,b2,b3) & MajorityOutput b1,b2,b3 in InnerVertices (BitAdderWithOverflowStr b1,b2,b3) ) by Th21;

theorem Th91: :: FACIRC_1:91
for b1, b2, b3 being non pair set
for b4 being State of (BitAdderWithOverflowCirc b1,b2,b3)
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 & b7 = b4 . b3 holds
( (Following b4,2) . (BitAdderOutput b1,b2,b3) = (b5 'xor' b6) 'xor' b7 & (Following b4,2) . (MajorityOutput b1,b2,b3) = ((b5 '&' b6) 'or' (b6 '&' b7)) 'or' (b7 '&' b5) )
proof end;

theorem Th92: :: FACIRC_1:92
for b1, b2, b3 being non pair set
for b4 being State of (BitAdderWithOverflowCirc b1,b2,b3) holds Following b4,2 is stable
proof end;