:: FSCIRC_1 semantic presentation

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

:: deftheorem Def1 defines BitSubtracterOutput FSCIRC_1:def 1 :
for b1, b2, b3 being set holds BitSubtracterOutput b1,b2,b3 = 2GatesCircOutput b1,b2,b3,'xor' ;

definition
let c1, c2, c3 be set ;
func BitSubtracterCirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of 2GatesCircStr a1,a2,a3,'xor' equals :: FSCIRC_1:def 2
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 Def2 defines BitSubtracterCirc FSCIRC_1:def 2 :
for b1, b2, b3 being set holds BitSubtracterCirc b1,b2,b3 = 2GatesCircuit b1,b2,b3,'xor' ;

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

:: deftheorem Def3 defines BorrowIStr FSCIRC_1:def 3 :
for b1, b2, b3 being set holds BorrowIStr b1,b2,b3 = ((1GateCircStr <*b1,b2*>,and2a ) +* (1GateCircStr <*b2,b3*>,and2 )) +* (1GateCircStr <*b1,b3*>,and2a );

definition
let c1, c2, c3 be set ;
func BorrowStr c1,c2,c3 -> non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign equals :: FSCIRC_1:def 4
(BorrowIStr a1,a2,a3) +* (1GateCircStr <*[<*a1,a2*>,and2a ],[<*a2,a3*>,and2 ],[<*a1,a3*>,and2a ]*>,or3 );
correctness
coherence
(BorrowIStr c1,c2,c3) +* (1GateCircStr <*[<*c1,c2*>,and2a ],[<*c2,c3*>,and2 ],[<*c1,c3*>,and2a ]*>,or3 ) is non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign
;
;
end;

:: deftheorem Def4 defines BorrowStr FSCIRC_1:def 4 :
for b1, b2, b3 being set holds BorrowStr b1,b2,b3 = (BorrowIStr b1,b2,b3) +* (1GateCircStr <*[<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ]*>,or3 );

definition
let c1, c2, c3 be set ;
func BorrowICirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of BorrowIStr a1,a2,a3 equals :: FSCIRC_1:def 5
((1GateCircuit a1,a2,and2a ) +* (1GateCircuit a2,a3,and2 )) +* (1GateCircuit a1,a3,and2a );
coherence
((1GateCircuit c1,c2,and2a ) +* (1GateCircuit c2,c3,and2 )) +* (1GateCircuit c1,c3,and2a ) is strict gate`2=den Boolean Circuit of BorrowIStr c1,c2,c3
;
end;

:: deftheorem Def5 defines BorrowICirc FSCIRC_1:def 5 :
for b1, b2, b3 being set holds BorrowICirc b1,b2,b3 = ((1GateCircuit b1,b2,and2a ) +* (1GateCircuit b2,b3,and2 )) +* (1GateCircuit b1,b3,and2a );

theorem Th1: :: FSCIRC_1:1
for b1, b2, b3 being set holds InnerVertices (BorrowStr b1,b2,b3) is Relation
proof end;

theorem Th2: :: FSCIRC_1:2
for b1, b2, b3 being non pair set holds not InputVertices (BorrowStr b1,b2,b3) is with_pair
proof end;

theorem Th3: :: FSCIRC_1:3
for b1, b2, b3 being set
for b4 being State of (BorrowICirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 holds
(Following b4) . [<*b1,b2*>,and2a ] = ('not' b5) '&' b6
proof end;

theorem Th4: :: FSCIRC_1:4
for b1, b2, b3 being set
for b4 being State of (BorrowICirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 holds
(Following b4) . [<*b2,b3*>,and2 ] = b5 '&' b6
proof end;

theorem Th5: :: FSCIRC_1:5
for b1, b2, b3 being set
for b4 being State of (BorrowICirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b3 holds
(Following b4) . [<*b1,b3*>,and2a ] = ('not' b5) '&' b6
proof end;

definition
let c1, c2, c3 be set ;
func BorrowOutput c1,c2,c3 -> Element of InnerVertices (BorrowStr a1,a2,a3) equals :: FSCIRC_1:def 6
[<*[<*a1,a2*>,and2a ],[<*a2,a3*>,and2 ],[<*a1,a3*>,and2a ]*>,or3 ];
coherence
[<*[<*c1,c2*>,and2a ],[<*c2,c3*>,and2 ],[<*c1,c3*>,and2a ]*>,or3 ] is Element of InnerVertices (BorrowStr c1,c2,c3)
proof end;
correctness
;
end;

:: deftheorem Def6 defines BorrowOutput FSCIRC_1:def 6 :
for b1, b2, b3 being set holds BorrowOutput b1,b2,b3 = [<*[<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ]*>,or3 ];

definition
let c1, c2, c3 be set ;
func BorrowCirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of BorrowStr a1,a2,a3 equals :: FSCIRC_1:def 7
(BorrowICirc a1,a2,a3) +* (1GateCircuit [<*a1,a2*>,and2a ],[<*a2,a3*>,and2 ],[<*a1,a3*>,and2a ],or3 );
coherence
(BorrowICirc c1,c2,c3) +* (1GateCircuit [<*c1,c2*>,and2a ],[<*c2,c3*>,and2 ],[<*c1,c3*>,and2a ],or3 ) is strict gate`2=den Boolean Circuit of BorrowStr c1,c2,c3
;
end;

:: deftheorem Def7 defines BorrowCirc FSCIRC_1:def 7 :
for b1, b2, b3 being set holds BorrowCirc b1,b2,b3 = (BorrowICirc b1,b2,b3) +* (1GateCircuit [<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ],or3 );

theorem Th6: :: FSCIRC_1:6
for b1, b2, b3 being set holds
( b1 in the carrier of (BorrowStr b1,b2,b3) & b2 in the carrier of (BorrowStr b1,b2,b3) & b3 in the carrier of (BorrowStr b1,b2,b3) )
proof end;

theorem Th7: :: FSCIRC_1:7
for b1, b2, b3 being set holds
( [<*b1,b2*>,and2a ] in InnerVertices (BorrowStr b1,b2,b3) & [<*b2,b3*>,and2 ] in InnerVertices (BorrowStr b1,b2,b3) & [<*b1,b3*>,and2a ] in InnerVertices (BorrowStr b1,b2,b3) )
proof end;

theorem Th8: :: FSCIRC_1:8
for b1, b2, b3 being non pair set holds
( b1 in InputVertices (BorrowStr b1,b2,b3) & b2 in InputVertices (BorrowStr b1,b2,b3) & b3 in InputVertices (BorrowStr b1,b2,b3) )
proof end;

theorem Th9: :: FSCIRC_1:9
for b1, b2, b3 being non pair set holds
( InputVertices (BorrowStr b1,b2,b3) = {b1,b2,b3} & InnerVertices (BorrowStr b1,b2,b3) = {[<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ]} \/ {(BorrowOutput b1,b2,b3)} )
proof end;

Lemma7: for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc 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*>,and2a ] = ('not' b5) '&' b6 & (Following b4) . [<*b2,b3*>,and2 ] = b6 '&' b7 & (Following b4) . [<*b1,b3*>,and2a ] = ('not' b5) '&' b7 )
proof end;

theorem Th10: :: FSCIRC_1:10
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 holds
(Following b4) . [<*b1,b2*>,and2a ] = ('not' b5) '&' b6
proof end;

theorem Th11: :: FSCIRC_1:11
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b2 & b6 = b4 . b3 holds
(Following b4) . [<*b2,b3*>,and2 ] = b5 '&' b6
proof end;

theorem Th12: :: FSCIRC_1:12
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b3 holds
(Following b4) . [<*b1,b3*>,and2a ] = ('not' b5) '&' b6
proof end;

theorem Th13: :: FSCIRC_1:13
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3)
for b5, b6, b7 being Element of BOOLEAN st b5 = b4 . [<*b1,b2*>,and2a ] & b6 = b4 . [<*b2,b3*>,and2 ] & b7 = b4 . [<*b1,b3*>,and2a ] holds
(Following b4) . (BorrowOutput b1,b2,b3) = (b5 'or' b6) 'or' b7
proof end;

Lemma9: for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc 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) . (BorrowOutput b1,b2,b3) = ((('not' b5) '&' b6) 'or' (b6 '&' b7)) 'or' (('not' b5) '&' b7) & (Following b4,2) . [<*b1,b2*>,and2a ] = ('not' b5) '&' b6 & (Following b4,2) . [<*b2,b3*>,and2 ] = b6 '&' b7 & (Following b4,2) . [<*b1,b3*>,and2a ] = ('not' b5) '&' b7 )
proof end;

theorem Th14: :: FSCIRC_1:14
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b2 holds
(Following b4,2) . [<*b1,b2*>,and2a ] = ('not' b5) '&' b6
proof end;

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

theorem Th16: :: FSCIRC_1:16
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3)
for b5, b6 being Element of BOOLEAN st b5 = b4 . b1 & b6 = b4 . b3 holds
(Following b4,2) . [<*b1,b3*>,and2a ] = ('not' b5) '&' b6
proof end;

theorem Th17: :: FSCIRC_1:17
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc 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) . (BorrowOutput b1,b2,b3) = ((('not' b5) '&' b6) 'or' (b6 '&' b7)) 'or' (('not' b5) '&' b7) by Lemma9;

theorem Th18: :: FSCIRC_1:18
for b1, b2, b3 being non pair set
for b4 being State of (BorrowCirc b1,b2,b3) holds Following b4,2 is stable
proof end;

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

:: deftheorem Def8 defines BitSubtracterWithBorrowStr FSCIRC_1:def 8 :
for b1, b2, b3 being set holds BitSubtracterWithBorrowStr b1,b2,b3 = (2GatesCircStr b1,b2,b3,'xor' ) +* (BorrowStr b1,b2,b3);

theorem Th19: :: FSCIRC_1:19
for b1, b2, b3 being non pair set holds InputVertices (BitSubtracterWithBorrowStr b1,b2,b3) = {b1,b2,b3}
proof end;

theorem Th20: :: FSCIRC_1:20
for b1, b2, b3 being non pair set holds InnerVertices (BitSubtracterWithBorrowStr b1,b2,b3) = ({[<*b1,b2*>,'xor' ],(2GatesCircOutput b1,b2,b3,'xor' )} \/ {[<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ]}) \/ {(BorrowOutput b1,b2,b3)}
proof end;

theorem Th21: :: FSCIRC_1:21
for b1, b2, b3 being set
for b4 being non empty ManySortedSign st b4 = BitSubtracterWithBorrowStr 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 BitSubtracterWithBorrowCirc c1,c2,c3 -> strict gate`2=den Boolean Circuit of BitSubtracterWithBorrowStr a1,a2,a3 equals :: FSCIRC_1:def 9
(BitSubtracterCirc a1,a2,a3) +* (BorrowCirc a1,a2,a3);
coherence
(BitSubtracterCirc c1,c2,c3) +* (BorrowCirc c1,c2,c3) is strict gate`2=den Boolean Circuit of BitSubtracterWithBorrowStr c1,c2,c3
;
end;

:: deftheorem Def9 defines BitSubtracterWithBorrowCirc FSCIRC_1:def 9 :
for b1, b2, b3 being set holds BitSubtracterWithBorrowCirc b1,b2,b3 = (BitSubtracterCirc b1,b2,b3) +* (BorrowCirc b1,b2,b3);

theorem Th22: :: FSCIRC_1:22
for b1, b2, b3 being set holds InnerVertices (BitSubtracterWithBorrowStr b1,b2,b3) is Relation
proof end;

theorem Th23: :: FSCIRC_1:23
for b1, b2, b3 being non pair set holds not InputVertices (BitSubtracterWithBorrowStr b1,b2,b3) is with_pair
proof end;

theorem Th24: :: FSCIRC_1:24
for b1, b2, b3 being set holds
( BitSubtracterOutput b1,b2,b3 in InnerVertices (BitSubtracterWithBorrowStr b1,b2,b3) & BorrowOutput b1,b2,b3 in InnerVertices (BitSubtracterWithBorrowStr b1,b2,b3) ) by FACIRC_1:21;

theorem Th25: :: FSCIRC_1:25
for b1, b2, b3 being non pair set
for b4 being State of (BitSubtracterWithBorrowCirc 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) . (BitSubtracterOutput b1,b2,b3) = (b5 'xor' b6) 'xor' b7 & (Following b4,2) . (BorrowOutput b1,b2,b3) = ((('not' b5) '&' b6) 'or' (b6 '&' b7)) 'or' (('not' b5) '&' b7) )
proof end;

theorem Th26: :: FSCIRC_1:26
for b1, b2, b3 being non pair set
for b4 being State of (BitSubtracterWithBorrowCirc b1,b2,b3) holds Following b4,2 is stable
proof end;