:: FSCIRC_2 semantic presentation

definition
let c1 be Nat;
let c2, c3 be FinSequence;
E1: ( 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) is unsplit & 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) is gate`1=arity & 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) is gate`2isBoolean & not 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) is void & not 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) is empty & 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) is strict ) ;
func c1 -BitSubtracterStr c2,c3 -> non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign means :Def1: :: FSCIRC_2:def 1
ex b1, b2 being ManySortedSet of NAT st
( a4 = b1 . a1 & b1 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b2 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b3 being Nat
for b4 being non empty ManySortedSign
for b5 being set st b4 = b1 . b3 & b5 = b2 . b3 holds
( b1 . (b3 + 1) = b4 +* (BitSubtracterWithBorrowStr (a2 . (b3 + 1)),(a3 . (b3 + 1)),b5) & b2 . (b3 + 1) = BorrowOutput (a2 . (b3 + 1)),(a3 . (b3 + 1)),b5 ) ) );
uniqueness
for b1, b2 being non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign st ex b3, b4 being ManySortedSet of NAT st
( b1 = b3 . c1 & b3 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b4 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b5 being Nat
for b6 being non empty ManySortedSign
for b7 being set st b6 = b3 . b5 & b7 = b4 . b5 holds
( b3 . (b5 + 1) = b6 +* (BitSubtracterWithBorrowStr (c2 . (b5 + 1)),(c3 . (b5 + 1)),b7) & b4 . (b5 + 1) = BorrowOutput (c2 . (b5 + 1)),(c3 . (b5 + 1)),b7 ) ) ) & ex b3, b4 being ManySortedSet of NAT st
( b2 = b3 . c1 & b3 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b4 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b5 being Nat
for b6 being non empty ManySortedSign
for b7 being set st b6 = b3 . b5 & b7 = b4 . b5 holds
( b3 . (b5 + 1) = b6 +* (BitSubtracterWithBorrowStr (c2 . (b5 + 1)),(c3 . (b5 + 1)),b7) & b4 . (b5 + 1) = BorrowOutput (c2 . (b5 + 1)),(c3 . (b5 + 1)),b7 ) ) ) holds
b1 = b2
proof end;
existence
ex b1 being non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign ex b2, b3 being ManySortedSet of NAT st
( b1 = b2 . c1 & b2 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b3 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b4 being Nat
for b5 being non empty ManySortedSign
for b6 being set st b5 = b2 . b4 & b6 = b3 . b4 holds
( b2 . (b4 + 1) = b5 +* (BitSubtracterWithBorrowStr (c2 . (b4 + 1)),(c3 . (b4 + 1)),b6) & b3 . (b4 + 1) = BorrowOutput (c2 . (b4 + 1)),(c3 . (b4 + 1)),b6 ) ) )
proof end;
end;

:: deftheorem Def1 defines -BitSubtracterStr FSCIRC_2:def 1 :
for b1 being Nat
for b2, b3 being FinSequence
for b4 being non empty strict non void unsplit gate`1=arity gate`2isBoolean ManySortedSign holds
( b4 = b1 -BitSubtracterStr b2,b3 iff ex b5, b6 being ManySortedSet of NAT st
( b4 = b5 . b1 & b5 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b6 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b7 being Nat
for b8 being non empty ManySortedSign
for b9 being set st b8 = b5 . b7 & b9 = b6 . b7 holds
( b5 . (b7 + 1) = b8 +* (BitSubtracterWithBorrowStr (b2 . (b7 + 1)),(b3 . (b7 + 1)),b9) & b6 . (b7 + 1) = BorrowOutput (b2 . (b7 + 1)),(b3 . (b7 + 1)),b9 ) ) ) );

definition
let c1 be Nat;
let c2, c3 be FinSequence;
func c1 -BitSubtracterCirc c2,c3 -> strict gate`2=den Boolean Circuit of a1 -BitSubtracterStr a2,a3 means :Def2: :: FSCIRC_2:def 2
ex b1, b2, b3 being ManySortedSet of NAT st
( a1 -BitSubtracterStr a2,a3 = b1 . a1 & a4 = b2 . a1 & b1 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b2 . 0 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b3 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b4 being Nat
for b5 being non empty ManySortedSign
for b6 being non-empty MSAlgebra of b5
for b7 being set st b5 = b1 . b4 & b6 = b2 . b4 & b7 = b3 . b4 holds
( b1 . (b4 + 1) = b5 +* (BitSubtracterWithBorrowStr (a2 . (b4 + 1)),(a3 . (b4 + 1)),b7) & b2 . (b4 + 1) = b6 +* (BitSubtracterWithBorrowCirc (a2 . (b4 + 1)),(a3 . (b4 + 1)),b7) & b3 . (b4 + 1) = BorrowOutput (a2 . (b4 + 1)),(a3 . (b4 + 1)),b7 ) ) );
uniqueness
for b1, b2 being strict gate`2=den Boolean Circuit of c1 -BitSubtracterStr c2,c3 st ex b3, b4, b5 being ManySortedSet of NAT st
( c1 -BitSubtracterStr c2,c3 = b3 . c1 & b1 = b4 . c1 & b3 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b4 . 0 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b5 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b6 being Nat
for b7 being non empty ManySortedSign
for b8 being non-empty MSAlgebra of b7
for b9 being set st b7 = b3 . b6 & b8 = b4 . b6 & b9 = b5 . b6 holds
( b3 . (b6 + 1) = b7 +* (BitSubtracterWithBorrowStr (c2 . (b6 + 1)),(c3 . (b6 + 1)),b9) & b4 . (b6 + 1) = b8 +* (BitSubtracterWithBorrowCirc (c2 . (b6 + 1)),(c3 . (b6 + 1)),b9) & b5 . (b6 + 1) = BorrowOutput (c2 . (b6 + 1)),(c3 . (b6 + 1)),b9 ) ) ) & ex b3, b4, b5 being ManySortedSet of NAT st
( c1 -BitSubtracterStr c2,c3 = b3 . c1 & b2 = b4 . c1 & b3 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b4 . 0 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b5 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b6 being Nat
for b7 being non empty ManySortedSign
for b8 being non-empty MSAlgebra of b7
for b9 being set st b7 = b3 . b6 & b8 = b4 . b6 & b9 = b5 . b6 holds
( b3 . (b6 + 1) = b7 +* (BitSubtracterWithBorrowStr (c2 . (b6 + 1)),(c3 . (b6 + 1)),b9) & b4 . (b6 + 1) = b8 +* (BitSubtracterWithBorrowCirc (c2 . (b6 + 1)),(c3 . (b6 + 1)),b9) & b5 . (b6 + 1) = BorrowOutput (c2 . (b6 + 1)),(c3 . (b6 + 1)),b9 ) ) ) holds
b1 = b2
proof end;
existence
ex b1 being strict gate`2=den Boolean Circuit of c1 -BitSubtracterStr c2,c3ex b2, b3, b4 being ManySortedSet of NAT st
( c1 -BitSubtracterStr c2,c3 = b2 . c1 & b1 = b3 . c1 & b2 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b3 . 0 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b4 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b5 being Nat
for b6 being non empty ManySortedSign
for b7 being non-empty MSAlgebra of b6
for b8 being set st b6 = b2 . b5 & b7 = b3 . b5 & b8 = b4 . b5 holds
( b2 . (b5 + 1) = b6 +* (BitSubtracterWithBorrowStr (c2 . (b5 + 1)),(c3 . (b5 + 1)),b8) & b3 . (b5 + 1) = b7 +* (BitSubtracterWithBorrowCirc (c2 . (b5 + 1)),(c3 . (b5 + 1)),b8) & b4 . (b5 + 1) = BorrowOutput (c2 . (b5 + 1)),(c3 . (b5 + 1)),b8 ) ) )
proof end;
end;

:: deftheorem Def2 defines -BitSubtracterCirc FSCIRC_2:def 2 :
for b1 being Nat
for b2, b3 being FinSequence
for b4 being strict gate`2=den Boolean Circuit of b1 -BitSubtracterStr b2,b3 holds
( b4 = b1 -BitSubtracterCirc b2,b3 iff ex b5, b6, b7 being ManySortedSet of NAT st
( b1 -BitSubtracterStr b2,b3 = b5 . b1 & b4 = b6 . b1 & b5 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b6 . 0 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b7 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b8 being Nat
for b9 being non empty ManySortedSign
for b10 being non-empty MSAlgebra of b9
for b11 being set st b9 = b5 . b8 & b10 = b6 . b8 & b11 = b7 . b8 holds
( b5 . (b8 + 1) = b9 +* (BitSubtracterWithBorrowStr (b2 . (b8 + 1)),(b3 . (b8 + 1)),b11) & b6 . (b8 + 1) = b10 +* (BitSubtracterWithBorrowCirc (b2 . (b8 + 1)),(b3 . (b8 + 1)),b11) & b7 . (b8 + 1) = BorrowOutput (b2 . (b8 + 1)),(b3 . (b8 + 1)),b11 ) ) ) );

definition
let c1 be Nat;
let c2, c3 be FinSequence;
set c4 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )];
func c1 -BitBorrowOutput c2,c3 -> Element of InnerVertices (a1 -BitSubtracterStr a2,a3) means :Def3: :: FSCIRC_2:def 3
ex b1 being ManySortedSet of NAT st
( a4 = b1 . a1 & b1 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b2 being Nat holds b1 . (b2 + 1) = BorrowOutput (a2 . (b2 + 1)),(a3 . (b2 + 1)),(b1 . b2) ) );
uniqueness
for b1, b2 being Element of InnerVertices (c1 -BitSubtracterStr c2,c3) st ex b3 being ManySortedSet of NAT st
( b1 = b3 . c1 & b3 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b4 being Nat holds b3 . (b4 + 1) = BorrowOutput (c2 . (b4 + 1)),(c3 . (b4 + 1)),(b3 . b4) ) ) & ex b3 being ManySortedSet of NAT st
( b2 = b3 . c1 & b3 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b4 being Nat holds b3 . (b4 + 1) = BorrowOutput (c2 . (b4 + 1)),(c3 . (b4 + 1)),(b3 . b4) ) ) holds
b1 = b2
proof end;
existence
ex b1 being Element of InnerVertices (c1 -BitSubtracterStr c2,c3)ex b2 being ManySortedSet of NAT st
( b1 = b2 . c1 & b2 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b3 being Nat holds b2 . (b3 + 1) = BorrowOutput (c2 . (b3 + 1)),(c3 . (b3 + 1)),(b2 . b3) ) )
proof end;
end;

:: deftheorem Def3 defines -BitBorrowOutput FSCIRC_2:def 3 :
for b1 being Nat
for b2, b3 being FinSequence
for b4 being Element of InnerVertices (b1 -BitSubtracterStr b2,b3) holds
( b4 = b1 -BitBorrowOutput b2,b3 iff ex b5 being ManySortedSet of NAT st
( b4 = b5 . b1 & b5 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b6 being Nat holds b5 . (b6 + 1) = BorrowOutput (b2 . (b6 + 1)),(b3 . (b6 + 1)),(b5 . b6) ) ) );

theorem Th1: :: FSCIRC_2:1
for b1, b2 being FinSequence
for b3, b4, b5 being ManySortedSet of NAT st b3 . 0 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b4 . 0 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & b5 . 0 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] & ( for b6 being Nat
for b7 being non empty ManySortedSign
for b8 being non-empty MSAlgebra of b7
for b9 being set st b7 = b3 . b6 & b8 = b4 . b6 & b9 = b5 . b6 holds
( b3 . (b6 + 1) = b7 +* (BitSubtracterWithBorrowStr (b1 . (b6 + 1)),(b2 . (b6 + 1)),b9) & b4 . (b6 + 1) = b8 +* (BitSubtracterWithBorrowCirc (b1 . (b6 + 1)),(b2 . (b6 + 1)),b9) & b5 . (b6 + 1) = BorrowOutput (b1 . (b6 + 1)),(b2 . (b6 + 1)),b9 ) ) holds
for b6 being Nat holds
( b6 -BitSubtracterStr b1,b2 = b3 . b6 & b6 -BitSubtracterCirc b1,b2 = b4 . b6 & b6 -BitBorrowOutput b1,b2 = b5 . b6 )
proof end;

theorem Th2: :: FSCIRC_2:2
for b1, b2 being FinSequence holds
( 0 -BitSubtracterStr b1,b2 = 1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & 0 -BitSubtracterCirc b1,b2 = 1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE ) & 0 -BitBorrowOutput b1,b2 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] )
proof end;

theorem Th3: :: FSCIRC_2:3
for b1, b2 being FinSequence
for b3 being set st b3 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] holds
( 1 -BitSubtracterStr b1,b2 = (1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE )) +* (BitSubtracterWithBorrowStr (b1 . 1),(b2 . 1),b3) & 1 -BitSubtracterCirc b1,b2 = (1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE )) +* (BitSubtracterWithBorrowCirc (b1 . 1),(b2 . 1),b3) & 1 -BitBorrowOutput b1,b2 = BorrowOutput (b1 . 1),(b2 . 1),b3 )
proof end;

theorem Th4: :: FSCIRC_2:4
for b1, b2, b3 being set st b3 = [<*> ,((0 -tuples_on BOOLEAN ) --> TRUE )] holds
( 1 -BitSubtracterStr <*b1*>,<*b2*> = (1GateCircStr <*> ,((0 -tuples_on BOOLEAN ) --> TRUE )) +* (BitSubtracterWithBorrowStr b1,b2,b3) & 1 -BitSubtracterCirc <*b1*>,<*b2*> = (1GateCircuit <*> ,((0 -tuples_on BOOLEAN ) --> TRUE )) +* (BitSubtracterWithBorrowCirc b1,b2,b3) & 1 -BitBorrowOutput <*b1*>,<*b2*> = BorrowOutput b1,b2,b3 )
proof end;

theorem Th5: :: FSCIRC_2:5
for b1 being Nat
for b2, b3 being FinSeqLen of b1
for b4, b5, b6, b7 being FinSequence holds
( b1 -BitSubtracterStr (b2 ^ b4),(b3 ^ b6) = b1 -BitSubtracterStr (b2 ^ b5),(b3 ^ b7) & b1 -BitSubtracterCirc (b2 ^ b4),(b3 ^ b6) = b1 -BitSubtracterCirc (b2 ^ b5),(b3 ^ b7) & b1 -BitBorrowOutput (b2 ^ b4),(b3 ^ b6) = b1 -BitBorrowOutput (b2 ^ b5),(b3 ^ b7) )
proof end;

theorem Th6: :: FSCIRC_2:6
for b1 being Nat
for b2, b3 being FinSeqLen of b1
for b4, b5 being set holds
( (b1 + 1) -BitSubtracterStr (b2 ^ <*b4*>),(b3 ^ <*b5*>) = (b1 -BitSubtracterStr b2,b3) +* (BitSubtracterWithBorrowStr b4,b5,(b1 -BitBorrowOutput b2,b3)) & (b1 + 1) -BitSubtracterCirc (b2 ^ <*b4*>),(b3 ^ <*b5*>) = (b1 -BitSubtracterCirc b2,b3) +* (BitSubtracterWithBorrowCirc b4,b5,(b1 -BitBorrowOutput b2,b3)) & (b1 + 1) -BitBorrowOutput (b2 ^ <*b4*>),(b3 ^ <*b5*>) = BorrowOutput b4,b5,(b1 -BitBorrowOutput b2,b3) )
proof end;

theorem Th7: :: FSCIRC_2:7
for b1 being Nat
for b2, b3 being FinSequence holds
( (b1 + 1) -BitSubtracterStr b2,b3 = (b1 -BitSubtracterStr b2,b3) +* (BitSubtracterWithBorrowStr (b2 . (b1 + 1)),(b3 . (b1 + 1)),(b1 -BitBorrowOutput b2,b3)) & (b1 + 1) -BitSubtracterCirc b2,b3 = (b1 -BitSubtracterCirc b2,b3) +* (BitSubtracterWithBorrowCirc (b2 . (b1 + 1)),(b3 . (b1 + 1)),(b1 -BitBorrowOutput b2,b3)) & (b1 + 1) -BitBorrowOutput b2,b3 = BorrowOutput (b2 . (b1 + 1)),(b3 . (b1 + 1)),(b1 -BitBorrowOutput b2,b3) )
proof end;

theorem Th8: :: FSCIRC_2:8
for b1, b2 being Nat st b1 <= b2 holds
for b3, b4 being FinSequence holds InnerVertices (b1 -BitSubtracterStr b3,b4) c= InnerVertices (b2 -BitSubtracterStr b3,b4)
proof end;

theorem Th9: :: FSCIRC_2:9
for b1 being Nat
for b2, b3 being FinSequence holds InnerVertices ((b1 + 1) -BitSubtracterStr b2,b3) = (InnerVertices (b1 -BitSubtracterStr b2,b3)) \/ (InnerVertices (BitSubtracterWithBorrowStr (b2 . (b1 + 1)),(b3 . (b1 + 1)),(b1 -BitBorrowOutput b2,b3)))
proof end;

definition
let c1, c2 be Nat;
assume E10: ( c1 >= 1 & c1 <= c2 ) ;
let c3, c4 be FinSequence;
func c1,c2 -BitSubtracterOutput c3,c4 -> Element of InnerVertices (a2 -BitSubtracterStr a3,a4) means :Def4: :: FSCIRC_2:def 4
ex b1 being Nat st
( a1 = b1 + 1 & a5 = BitSubtracterOutput (a3 . a1),(a4 . a1),(b1 -BitBorrowOutput a3,a4) );
uniqueness
for b1, b2 being Element of InnerVertices (c2 -BitSubtracterStr c3,c4) st ex b3 being Nat st
( c1 = b3 + 1 & b1 = BitSubtracterOutput (c3 . c1),(c4 . c1),(b3 -BitBorrowOutput c3,c4) ) & ex b3 being Nat st
( c1 = b3 + 1 & b2 = BitSubtracterOutput (c3 . c1),(c4 . c1),(b3 -BitBorrowOutput c3,c4) ) holds
b1 = b2
;
existence
ex b1 being Element of InnerVertices (c2 -BitSubtracterStr c3,c4)ex b2 being Nat st
( c1 = b2 + 1 & b1 = BitSubtracterOutput (c3 . c1),(c4 . c1),(b2 -BitBorrowOutput c3,c4) )
proof end;
end;

:: deftheorem Def4 defines -BitSubtracterOutput FSCIRC_2:def 4 :
for b1, b2 being Nat st b1 >= 1 & b1 <= b2 holds
for b3, b4 being FinSequence
for b5 being Element of InnerVertices (b2 -BitSubtracterStr b3,b4) holds
( b5 = b1,b2 -BitSubtracterOutput b3,b4 iff ex b6 being Nat st
( b1 = b6 + 1 & b5 = BitSubtracterOutput (b3 . b1),(b4 . b1),(b6 -BitBorrowOutput b3,b4) ) );

theorem Th10: :: FSCIRC_2:10
for b1, b2 being Nat st b2 < b1 holds
for b3, b4 being FinSequence holds (b2 + 1),b1 -BitSubtracterOutput b3,b4 = BitSubtracterOutput (b3 . (b2 + 1)),(b4 . (b2 + 1)),(b2 -BitBorrowOutput b3,b4)
proof end;

theorem Th11: :: FSCIRC_2:11
for b1 being Nat
for b2, b3 being FinSequence holds InnerVertices (b1 -BitSubtracterStr b2,b3) is Relation
proof end;

theorem Th12: :: FSCIRC_2:12
for b1, b2, b3 being set holds InnerVertices (BorrowIStr b1,b2,b3) = {[<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ]}
proof end;

theorem Th13: :: FSCIRC_2:13
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] holds
InputVertices (BorrowIStr b1,b2,b3) = {b1,b2,b3}
proof end;

theorem Th14: :: FSCIRC_2:14
for b1, b2, b3 being set holds InnerVertices (BorrowStr b1,b2,b3) = {[<*b1,b2*>,and2a ],[<*b2,b3*>,and2 ],[<*b1,b3*>,and2a ]} \/ {(BorrowOutput b1,b2,b3)}
proof end;

theorem Th15: :: FSCIRC_2:15
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] holds
InputVertices (BorrowStr b1,b2,b3) = {b1,b2,b3}
proof end;

theorem Th16: :: FSCIRC_2:16
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] & b3 <> [<*b1,b2*>,'xor' ] holds
InputVertices (BitSubtracterWithBorrowStr b1,b2,b3) = {b1,b2,b3}
proof end;

theorem Th17: :: FSCIRC_2:17
for b1, b2, b3 being 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;

registration
let c1 be Nat;
let c2, c3 be FinSequence;
cluster a1 -BitBorrowOutput a2,a3 -> pair ;
coherence
c1 -BitBorrowOutput c2,c3 is pair
proof end;
end;

theorem Th18: :: FSCIRC_2:18
for b1, b2 being FinSequence
for b3 being Nat holds
( ( (b3 -BitBorrowOutput b1,b2) `1 = <*> & (b3 -BitBorrowOutput b1,b2) `2 = (0 -tuples_on BOOLEAN ) --> TRUE & proj1 ((b3 -BitBorrowOutput b1,b2) `2 ) = 0 -tuples_on BOOLEAN ) or ( Card ((b3 -BitBorrowOutput b1,b2) `1 ) = 3 & (b3 -BitBorrowOutput b1,b2) `2 = or3 & proj1 ((b3 -BitBorrowOutput b1,b2) `2 ) = 3 -tuples_on BOOLEAN ) )
proof end;

theorem Th19: :: FSCIRC_2:19
for b1 being Nat
for b2, b3 being FinSequence
for b4 being set holds
( b1 -BitBorrowOutput b2,b3 <> [b4,and2 ] & b1 -BitBorrowOutput b2,b3 <> [b4,and2a ] & b1 -BitBorrowOutput b2,b3 <> [b4,'xor' ] )
proof end;

theorem Th20: :: FSCIRC_2:20
for b1, b2 being nonpair-yielding FinSequence
for b3 being Nat holds
( InputVertices ((b3 + 1) -BitSubtracterStr b1,b2) = (InputVertices (b3 -BitSubtracterStr b1,b2)) \/ ((InputVertices (BitSubtracterWithBorrowStr (b1 . (b3 + 1)),(b2 . (b3 + 1)),(b3 -BitBorrowOutput b1,b2))) \ {(b3 -BitBorrowOutput b1,b2)}) & InnerVertices (b3 -BitSubtracterStr b1,b2) is Relation & not InputVertices (b3 -BitSubtracterStr b1,b2) is with_pair )
proof end;

theorem Th21: :: FSCIRC_2:21
for b1 being Nat
for b2, b3 being nonpair-yielding FinSeqLen of b1 holds InputVertices (b1 -BitSubtracterStr b2,b3) = (rng b2) \/ (rng b3)
proof end;

Lemma20: for b1, b2, b3 being 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 Th22: :: FSCIRC_2:22
for b1, b2, b3 being 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;

Lemma22: for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] holds
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 Th23: :: FSCIRC_2:23
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] & b3 <> [<*b1,b2*>,'xor' ] holds
for b4 being State of (BorrowCirc b1,b2,b3) holds Following b4,2 is stable
proof end;

theorem Th24: :: FSCIRC_2:24
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] & b3 <> [<*b1,b2*>,'xor' ] holds
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 Th25: :: FSCIRC_2:25
for b1, b2, b3 being set st b1 <> [<*b2,b3*>,and2 ] & b2 <> [<*b1,b3*>,and2a ] & b3 <> [<*b1,b2*>,and2a ] & b3 <> [<*b1,b2*>,'xor' ] holds
for b4 being State of (BitSubtracterWithBorrowCirc b1,b2,b3) holds Following b4,2 is stable
proof end;

theorem Th26: :: FSCIRC_2:26
for b1 being Nat
for b2, b3 being nonpair-yielding FinSeqLen of b1
for b4 being State of (b1 -BitSubtracterCirc b2,b3) holds Following b4,(1 + (2 * b1)) is stable
proof end;