:: BINARI_3 semantic presentation

theorem Th1: :: BINARI_3:1
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN holds Absval b2 < 2 to_power b1
proof end;

theorem Th2: :: BINARI_3:2
for b1 being non empty Nat
for b2, b3 being Tuple of b1,BOOLEAN st Absval b2 = Absval b3 holds
b2 = b3
proof end;

theorem Th3: :: BINARI_3:3
for b1, b2 being FinSequence st Rev b1 = Rev b2 holds
b1 = b2
proof end;

theorem Th4: :: BINARI_3:4
for b1 being Nat holds 0* (b1 + 1) = (0* b1) ^ <*0*>
proof end;

theorem Th5: :: BINARI_3:5
for b1 being Nat holds 0* b1 in BOOLEAN *
proof end;

theorem Th6: :: BINARI_3:6
for b1 being Nat
for b2 being Tuple of b1,BOOLEAN st b2 = 0* b1 holds
'not' b2 = b1 |-> 1
proof end;

theorem Th7: :: BINARI_3:7
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN st b2 = 0* b1 holds
Absval b2 = 0
proof end;

theorem Th8: :: BINARI_3:8
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN st b2 = 0* b1 holds
Absval ('not' b2) = (2 to_power b1) - 1
proof end;

theorem Th9: :: BINARI_3:9
for b1 being Nat holds Rev (0* b1) = 0* b1
proof end;

theorem Th10: :: BINARI_3:10
for b1 being Nat
for b2 being Tuple of b1,BOOLEAN st b2 = 0* b1 holds
Rev ('not' b2) = 'not' b2
proof end;

theorem Th11: :: BINARI_3:11
Bin1 1 = <*TRUE *>
proof end;

theorem Th12: :: BINARI_3:12
for b1 being non empty Nat holds Absval (Bin1 b1) = 1
proof end;

theorem Th13: :: BINARI_3:13
for b1, b2 being Element of BOOLEAN holds
( ( not b1 'or' b2 = TRUE or b1 = TRUE or b2 = TRUE ) & ( ( b1 = TRUE or b2 = TRUE ) implies b1 'or' b2 = TRUE ) & ( b1 'or' b2 = FALSE implies ( b1 = FALSE & b2 = FALSE ) ) & ( b1 = FALSE & b2 = FALSE implies b1 'or' b2 = FALSE ) )
proof end;

theorem Th14: :: BINARI_3:14
for b1, b2 being Element of BOOLEAN holds
( add_ovfl <*b1*>,<*b2*> = TRUE iff ( b1 = TRUE & b2 = TRUE ) )
proof end;

theorem Th15: :: BINARI_3:15
'not' <*FALSE *> = <*TRUE *>
proof end;

theorem Th16: :: BINARI_3:16
'not' <*TRUE *> = <*FALSE *>
proof end;

theorem Th17: :: BINARI_3:17
<*FALSE *> + <*FALSE *> = <*FALSE *>
proof end;

theorem Th18: :: BINARI_3:18
( <*FALSE *> + <*TRUE *> = <*TRUE *> & <*TRUE *> + <*FALSE *> = <*TRUE *> )
proof end;

theorem Th19: :: BINARI_3:19
<*TRUE *> + <*TRUE *> = <*FALSE *>
proof end;

theorem Th20: :: BINARI_3:20
for b1 being non empty Nat
for b2, b3 being Tuple of b1,BOOLEAN st b2 /. b1 = TRUE & (carry b2,(Bin1 b1)) /. b1 = TRUE holds
for b4 being non empty Nat st b4 <> 1 & b4 <= b1 holds
( b2 /. b4 = TRUE & (carry b2,(Bin1 b1)) /. b4 = TRUE )
proof end;

theorem Th21: :: BINARI_3:21
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN st b2 /. b1 = TRUE & (carry b2,(Bin1 b1)) /. b1 = TRUE holds
carry b2,(Bin1 b1) = 'not' (Bin1 b1)
proof end;

theorem Th22: :: BINARI_3:22
for b1 being non empty Nat
for b2, b3 being Tuple of b1,BOOLEAN st b3 = 0* b1 & b2 /. b1 = TRUE & (carry b2,(Bin1 b1)) /. b1 = TRUE holds
b2 = 'not' b3
proof end;

theorem Th23: :: BINARI_3:23
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN st b2 = 0* b1 holds
carry ('not' b2),(Bin1 b1) = 'not' (Bin1 b1)
proof end;

theorem Th24: :: BINARI_3:24
for b1 being non empty Nat
for b2, b3 being Tuple of b1,BOOLEAN st b3 = 0* b1 holds
( add_ovfl b2,(Bin1 b1) = TRUE iff b2 = 'not' b3 )
proof end;

theorem Th25: :: BINARI_3:25
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN st b2 = 0* b1 holds
('not' b2) + (Bin1 b1) = b2
proof end;

definition
let c1, c2 be Nat;
func c1 -BinarySequence c2 -> Tuple of a1,BOOLEAN means :Def1: :: BINARI_3:def 1
for b1 being Nat st b1 in Seg a1 holds
a3 /. b1 = IFEQ ((a2 div (2 to_power (b1 -' 1))) mod 2),0,FALSE ,TRUE ;
existence
ex b1 being Tuple of c1,BOOLEAN st
for b2 being Nat st b2 in Seg c1 holds
b1 /. b2 = IFEQ ((c2 div (2 to_power (b2 -' 1))) mod 2),0,FALSE ,TRUE
proof end;
uniqueness
for b1, b2 being Tuple of c1,BOOLEAN st ( for b3 being Nat st b3 in Seg c1 holds
b1 /. b3 = IFEQ ((c2 div (2 to_power (b3 -' 1))) mod 2),0,FALSE ,TRUE ) & ( for b3 being Nat st b3 in Seg c1 holds
b2 /. b3 = IFEQ ((c2 div (2 to_power (b3 -' 1))) mod 2),0,FALSE ,TRUE ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines -BinarySequence BINARI_3:def 1 :
for b1, b2 being Nat
for b3 being Tuple of b1,BOOLEAN holds
( b3 = b1 -BinarySequence b2 iff for b4 being Nat st b4 in Seg b1 holds
b3 /. b4 = IFEQ ((b2 div (2 to_power (b4 -' 1))) mod 2),0,FALSE ,TRUE );

theorem Th26: :: BINARI_3:26
for b1 being Nat holds b1 -BinarySequence 0 = 0* b1
proof end;

theorem Th27: :: BINARI_3:27
for b1, b2 being Nat st b2 < 2 to_power b1 holds
((b1 + 1) -BinarySequence b2) . (b1 + 1) = FALSE
proof end;

theorem Th28: :: BINARI_3:28
for b1 being non empty Nat
for b2 being Nat st b2 < 2 to_power b1 holds
(b1 + 1) -BinarySequence b2 = (b1 -BinarySequence b2) ^ <*FALSE *>
proof end;

Lemma23: for b1 being non empty Nat holds (b1 + 1) -BinarySequence (2 to_power b1) = (0* b1) ^ <*TRUE *>
proof end;

Lemma24: for b1 being non empty Nat
for b2 being Nat st 2 to_power b1 <= b2 & b2 < 2 to_power (b1 + 1) holds
((b1 + 1) -BinarySequence b2) . (b1 + 1) = TRUE
proof end;

Lemma25: for b1 being non empty Nat
for b2 being Nat st 2 to_power b1 <= b2 & b2 < 2 to_power (b1 + 1) holds
(b1 + 1) -BinarySequence b2 = (b1 -BinarySequence (b2 -' (2 to_power b1))) ^ <*TRUE *>
proof end;

Lemma26: for b1 being non empty Nat
for b2 being Nat st b2 < 2 to_power b1 holds
for b3 being Tuple of b1,BOOLEAN st b3 = 0* b1 holds
( b1 -BinarySequence b2 = 'not' b3 iff b2 = (2 to_power b1) - 1 )
proof end;

theorem Th29: :: BINARI_3:29
for b1 being Nat holds (b1 + 1) -BinarySequence (2 to_power b1) = (0* b1) ^ <*1*>
proof end;

theorem Th30: :: BINARI_3:30
for b1 being non empty Nat
for b2 being Nat st 2 to_power b1 <= b2 & b2 < 2 to_power (b1 + 1) holds
((b1 + 1) -BinarySequence b2) . (b1 + 1) = TRUE by Lemma24;

theorem Th31: :: BINARI_3:31
for b1 being non empty Nat
for b2 being Nat st 2 to_power b1 <= b2 & b2 < 2 to_power (b1 + 1) holds
(b1 + 1) -BinarySequence b2 = (b1 -BinarySequence (b2 -' (2 to_power b1))) ^ <*TRUE *> by Lemma25;

theorem Th32: :: BINARI_3:32
for b1 being non empty Nat
for b2 being Nat st b2 < 2 to_power b1 holds
for b3 being Tuple of b1,BOOLEAN st b3 = 0* b1 holds
( b1 -BinarySequence b2 = 'not' b3 iff b2 = (2 to_power b1) - 1 ) by Lemma26;

theorem Th33: :: BINARI_3:33
for b1 being non empty Nat
for b2 being Nat st b2 + 1 < 2 to_power b1 holds
add_ovfl (b1 -BinarySequence b2),(Bin1 b1) = FALSE
proof end;

theorem Th34: :: BINARI_3:34
for b1 being non empty Nat
for b2 being Nat st b2 + 1 < 2 to_power b1 holds
b1 -BinarySequence (b2 + 1) = (b1 -BinarySequence b2) + (Bin1 b1)
proof end;

theorem Th35: :: BINARI_3:35
for b1, b2 being Nat holds (b1 + 1) -BinarySequence b2 = <*(b2 mod 2)*> ^ (b1 -BinarySequence (b2 div 2))
proof end;

theorem Th36: :: BINARI_3:36
for b1 being non empty Nat
for b2 being Nat st b2 < 2 to_power b1 holds
Absval (b1 -BinarySequence b2) = b2
proof end;

theorem Th37: :: BINARI_3:37
for b1 being non empty Nat
for b2 being Tuple of b1,BOOLEAN holds b1 -BinarySequence (Absval b2) = b2
proof end;