:: BINARI_4 semantic presentation
theorem E1: :: BINARI_4:1
for b
1 being
Nat holds
( b
1 > 0 implies b
1 * 2
>= b
1 + 1 )
theorem E2: :: BINARI_4:2
proof
defpred S
1[
Nat] means 2
to_power a
1 >= a
1;
E3:
S
1[0]
;
E4:
for b
1 being
Nat holds
( S
1[b
1] implies S
1[b
1 + 1] )
proof
let c
1 be
Nat;
assume E5:
2
to_power c
1 >= c
1
;
now
per cases
not ( not c
1 = 0 & not c
1 > 0 )
;
suppose E6:
c
1 = 0
;
end;
suppose E6:
c
1 > 0
;
end;
end;
end;
hence
S
1[c
1 + 1]
;
end;
thus
for b
1 being
Nat holds
S
1[b
1]
from NAT_1:sch 1(E3, E4);
end;
theorem :: BINARI_4:3
theorem E3: :: BINARI_4:4
for b
1, b
2, b
3 being
Nat holds
not ( b
3 <= b
1 & b
1 <= b
2 & not b
3 = b
1 & not ( b
3 + 1
<= b
1 & b
1 <= b
2 ) )
proof
let c
1, c
2 be
Nat;
defpred S
1[
Nat] means not ( a
1 <= c
1 & c
1 <= c
2 & not a
1 = c
1 & not ( a
1 + 1
<= c
1 & c
1 <= c
2 ) );
E4:
S
1[0]
by NAT_1:38;
E5:
for b
1 being
Nat holds
( S
1[b
1] implies S
1[b
1 + 1] )
proof
let c
3 be
Nat;
assume
not ( c
3 <= c
1 & c
1 <= c
2 & not c
3 = c
1 & not ( c
3 + 1
<= c
1 & c
1 <= c
2 ) )
;
assume that
E6:
c
3 + 1
<= c
1
and
E7:
c
1 <= c
2
;
not ( not c
3 + 1
= c
1 & not c
3 + 1
< c
1 )
by E6, XREAL_1:1;
hence
not ( not c
3 + 1
= c
1 & not (
(c3 + 1) + 1
<= c
1 & c
1 <= c
2 ) )
by E7, NAT_1:38;
end;
thus
for b
1 being
Nat holds
S
1[b
1]
from NAT_1:sch 1(E4, E5);
end;
theorem E4: :: BINARI_4:5
proof
let c
1 be non
empty Nat;
let c
2, c
3 be
Tuple of c
1,
BOOLEAN ;
assume E5:
( c
2 = 0* c
1 & c
3 = 0* c
1 )
;
len (carry c2,c3) = c
1
by FINSEQ_2:109;
then
1
<= len (carry c2,c3)
by NAT_1:39;
then E6:
(carry c2,c3) . 1 =
(carry c2,c3) /. 1
by FINSEQ_4:24
.=
0
by BINARITH:def 5, MARGREL1:36
;
E7:
for b
1 being
Nat holds
( ( b
1 <= c
1 ) implies ( not 1
< b
1 or
(carry c2,c3) . b
1 = 0 ) )
proof
let c
4 be
Nat;
assume E8:
( 1
< c
4 & c
4 <= c
1 )
;
reconsider c
5 = c
4 - 1 as
Nat by E8, INT_1:18;
c
5 + 1
= c
4
;
then E9:
( 1
<= c
5 & c
5 < c
1 & c
4 = c
5 + 1 )
by E8, NAT_1:38;
then E10:
( c
5 in Seg c
1 & c
5 <= len c
2 & c
5 <= len c
3 )
by FINSEQ_1:3, FINSEQ_2:109;
len (0* c1) =
len (c1 |-> 0)
by EUCLID:def 4
.=
c
1
by FINSEQ_2:69
;
then E11: c
2 /. c
5 =
(0* c1) . c
5
by E5, E9, FINSEQ_4:24
.=
(c1 |-> 0) . c
5
by EUCLID:def 4
.=
FALSE
by E10, FINSEQ_2:70, MARGREL1:36
;
len (carry c2,c3) = c
1
by FINSEQ_2:109;
then (carry c2,c3) . c
4 =
(carry c2,c3) /. c
4
by E8, FINSEQ_4:24
.=
((FALSE '&' FALSE ) 'or' (FALSE '&' ((carry c2,c3) /. c5))) 'or' (FALSE '&' ((carry c2,c3) /. c5))
by E5, E9, E11, BINARITH:def 5
.=
(FALSE 'or' (FALSE '&' ((carry c2,c3) /. c5))) 'or' (FALSE '&' ((carry c2,c3) /. c5))
by MARGREL1:49
.=
(FALSE 'or' FALSE ) 'or' (FALSE '&' ((carry c2,c3) /. c5))
by MARGREL1:49
.=
(FALSE 'or' FALSE ) 'or' FALSE
by MARGREL1:49
.=
FALSE 'or' FALSE
by BINARITH:7
.=
FALSE
by BINARITH:7
;
hence
(carry c2,c3) . c
4 = 0
by MARGREL1:36;
end;
for b
1 being
Nat holds
( b
1 in Seg c
1 implies
(carry c2,c3) . b
1 = (0* c1) . b
1 )
hence
carry c
2,c
3 = 0* c
1
by E5, FINSEQ_2:139;
end;
theorem :: BINARI_4:6
proof
let c
1 be non
empty Nat;
let c
2, c
3 be
Tuple of c
1,
BOOLEAN ;
assume E5:
( c
2 = 0* c
1 & c
3 = 0* c
1 )
;
for b
1 being
Nat holds
( b
1 in Seg c
1 implies
(c2 + c3) . b
1 = (0* c1) . b
1 )
proof
let c
4 be
Nat;
assume E6:
c
4 in Seg c
1
;
E7:
(0* c1) . c
4 =
(c1 |-> 0) . c
4
by EUCLID:def 4
.=
FALSE
by E6, FINSEQ_2:70, MARGREL1:36
;
(
len c
2 = c
1 &
len c
3 = c
1 &
len (carry c2,c3) = c
1 &
len (c2 + c3) = c
1 )
by FINSEQ_2:109;
then E8:
( 1
<= c
4 & c
4 <= len c
2 & c
4 <= len (carry c2,c3) & c
4 <= len (c2 + c3) )
by E6, FINSEQ_1:3;
then E9:
c
3 /. c
4 = FALSE
by E5, E7, FINSEQ_4:24;
E10:
(carry c2,c3) /. c
4 =
(carry c2,c3) . c
4
by E8, FINSEQ_4:24
.=
FALSE
by E5, E7, E4
;
(c2 + c3) . c
4 =
(c2 + c3) /. c
4
by E8, FINSEQ_4:24
.=
(FALSE 'xor' FALSE ) 'xor' FALSE
by E5, E6, E9, E10, BINARITH:def 8
.=
FALSE 'xor' FALSE
by BINARITH:14
.=
FALSE
by BINARITH:14
;
hence
(c2 + c3) . c
4 = (0* c1) . c
4
by E7;
end;
hence
c
2 + c
3 = 0* c
1
by E5, FINSEQ_2:139;
end;
theorem :: BINARI_4:7
theorem E5: :: BINARI_4:8
for b
1, b
2, b
3 being
Nat holds
( b
1 + b
2 <= b
3 - 1 implies ( b
1 < b
3 & b
2 < b
3 ) )
theorem E6: :: BINARI_4:9
for b
1, b
2, b
3 being
Integer holds
( ( b
1 <= b
2 + b
3 ) implies ( not b
2 < 0 or not b
3 < 0 or ( b
1 < b
2 & b
1 < b
3 ) ) )
theorem E7: :: BINARI_4:10
proof
let c
1 be non
empty Nat;
let c
2, c
3 be
Nat;
assume E8:
c
2 + c
3 <= (2 to_power c1) - 1
;
set c
4 = c
1 -BinarySequence c
2;
set c
5 = c
1 -BinarySequence c
3;
assume E9:
add_ovfl (c1 -BinarySequence c2),
(c1 -BinarySequence c3) <> FALSE
;
E10:
( c
2 < 2
to_power c
1 & c
3 < 2
to_power c
1 )
by E8, E5;
E11:
IFEQ (add_ovfl (c1 -BinarySequence c2),(c1 -BinarySequence c3)),
FALSE ,0,
(2 to_power c1) = 2
to_power c
1
by E9, CQC_LANG:def 1;
E12:
(Absval ((c1 -BinarySequence c2) + (c1 -BinarySequence c3))) + (IFEQ (add_ovfl (c1 -BinarySequence c2),(c1 -BinarySequence c3)),FALSE ,0,(2 to_power c1)) =
(Absval (c1 -BinarySequence c2)) + (Absval (c1 -BinarySequence c3))
by BINARITH:47
.=
c
2 + (Absval (c1 -BinarySequence c3))
by E10, BINARI_3:36
.=
c
2 + c
3
by E10, BINARI_3:36
;
E13:
2
to_power c
1 > (2 to_power c1) - 1
by XREAL_1:148;
(Absval ((c1 -BinarySequence c2) + (c1 -BinarySequence c3))) + (2 to_power c1) >= 2
to_power c
1
by NAT_1:29;
hence
not verum
by E8, E11, E12, E13, XREAL_1:2;
end;
theorem E8: :: BINARI_4:11
theorem E9: :: BINARI_4:12
proof
defpred S
1[
Nat] means for b
1 being
Tuple of a
1,
BOOLEAN holds
( b
1 /. a
1 = TRUE implies
Absval b
1 >= 2
to_power (a1 -' 1) );
E10:
S
1[1]
E11:
for b
1 being non
empty Nat holds
( S
1[b
1] implies S
1[b
1 + 1] )
proof
let c
1 be non
empty Nat;
assume
S
1[c
1]
;
let c
2 be
Tuple of
(c1 + 1),
BOOLEAN ;
assume E12:
c
2 /. (c1 + 1) = TRUE
;
consider c
3 being
Tuple of c
1,
BOOLEAN , c
4 being
Element of
BOOLEAN such that
E13:
c
2 = c
3 ^ <*c4*>
by FINSEQ_2:137;
E14:
c
1 + 1
>= 1
by NAT_1:29;
then
(c1 + 1) - 1
>= 1
- 1
by XREAL_1:11;
then E15:
(c1 + 1) -' 1
= c
1
by BINARITH:def 3;
len c
2 = c
1 + 1
by FINSEQ_2:109;
then E16: c
2 /. (c1 + 1) =
(c3 ^ <*c4*>) . (c1 + 1)
by E13, E14, FINSEQ_4:24
.=
c
4
by FINSEQ_2:136
;
Absval c
2 =
(Absval c3) + (IFEQ c4,FALSE ,0,(2 to_power c1))
by E13, BINARITH:46
.=
(Absval c3) + (2 to_power c1)
by E12, E16, CQC_LANG:def 1, MARGREL1:38
;
hence
Absval c
2 >= 2
to_power ((c1 + 1) -' 1)
by E15, NAT_1:29;
end;
thus
for b
1 being non
empty Nat holds
S
1[b
1]
from BINARITH:sch 1(E10, E11);
end;
theorem E10: :: BINARI_4:13
proof
let c
1 be non
empty Nat;
let c
2, c
3 be
Nat;
assume E11:
c
2 + c
3 <= (2 to_power (c1 -' 1)) - 1
;
set c
4 = c
1 -BinarySequence c
2;
set c
5 = c
1 -BinarySequence c
3;
set c
6 =
FALSE ;
set c
7 =
TRUE ;
assume
not
(carry (c1 -BinarySequence c2),(c1 -BinarySequence c3)) /. c
1 = FALSE
;
then E12:
(carry (c1 -BinarySequence c2),(c1 -BinarySequence c3)) /. c
1 = TRUE
by MARGREL1:39;
E13:
( c
2 < 2
to_power (c1 -' 1) & c
3 < 2
to_power (c1 -' 1) )
by E11, E5;
1
<= c
1
by NAT_1:39;
then E14:
c
1 in Seg c
1
by FINSEQ_1:3;
then E15:
(c1 -BinarySequence c2) /. c
1 =
IFEQ ((c2 div (2 to_power (c1 -' 1))) mod 2),0,
FALSE ,
TRUE
by BINARI_3:def 1
.=
IFEQ (0 mod 2),0,
FALSE ,
TRUE
by E13, JORDAN4:5
.=
IFEQ 0,0,
FALSE ,
TRUE
by GR_CY_1:6
.=
FALSE
by CQC_LANG:def 1
;
E16:
(c1 -BinarySequence c3) /. c
1 =
IFEQ ((c3 div (2 to_power (c1 -' 1))) mod 2),0,
FALSE ,
TRUE
by E14, BINARI_3:def 1
.=
IFEQ (0 mod 2),0,
FALSE ,
TRUE
by E13, JORDAN4:5
.=
IFEQ 0,0,
FALSE ,
TRUE
by GR_CY_1:6
.=
FALSE
by CQC_LANG:def 1
;
c
1 >= 1
by NAT_1:39;
then
c
1 - 1
>= 1
- 1
by XREAL_1:11;
then
c
1 -' 1
= c
1 - 1
by BINARITH:def 3;
then
c
1 -' 1
< c
1
by XREAL_1:148;
then
2
to_power (c1 -' 1) < 2
to_power c
1
by POWER:44;
then
(2 to_power (c1 -' 1)) - 1
< (2 to_power c1) - 1
by REAL_1:92;
then E17:
c
2 + c
3 <= (2 to_power c1) - 1
by E11, XREAL_1:2;
((c1 -BinarySequence c2) + (c1 -BinarySequence c3)) /. c
1 =
(FALSE 'xor' FALSE ) 'xor' TRUE
by E12, E14, E15, E16, BINARITH:def 8
.=
FALSE 'xor' TRUE
by BINARITH:14
.=
TRUE
by BINARITH:14
;
then E18:
Absval ((c1 -BinarySequence c2) + (c1 -BinarySequence c3)) >= 2
to_power (c1 -' 1)
by E9;
(2 to_power (c1 -' 1)) - 1
< 2
to_power (c1 -' 1)
by XREAL_1:148;
then
c
2 + c
3 < 2
to_power (c1 -' 1)
by E11, XREAL_1:2;
hence
not verum
by E17, E18, E8;
end;
theorem E11: :: BINARI_4:14
proof
let c
1, c
2 be
Nat;
let c
3 be non
empty Nat;
assume E12:
c
1 + c
2 <= (2 to_power (c3 -' 1)) - 1
;
set c
4 = c
3 -BinarySequence c
1;
set c
5 = c
3 -BinarySequence c
2;
set c
6 =
FALSE ;
set c
7 =
TRUE ;
E13:
( c
1 < 2
to_power (c3 -' 1) & c
2 < 2
to_power (c3 -' 1) )
by E12, E5;
1
<= c
3
by NAT_1:39;
then E14:
c
3 in Seg c
3
by FINSEQ_1:3;
then E15:
(c3 -BinarySequence c1) /. c
3 =
IFEQ ((c1 div (2 to_power (c3 -' 1))) mod 2),0,
FALSE ,
TRUE
by BINARI_3:def 1
.=
IFEQ (0 mod 2),0,
FALSE ,
TRUE
by E13, JORDAN4:5
.=
IFEQ 0,0,
FALSE ,
TRUE
by GR_CY_1:6
.=
FALSE
by CQC_LANG:def 1
;
(c3 -BinarySequence c2) /. c
3 =
IFEQ ((c2 div (2 to_power (c3 -' 1))) mod 2),0,
FALSE ,
TRUE
by E14, BINARI_3:def 1
.=
IFEQ (0 mod 2),0,
FALSE ,
TRUE
by E13, JORDAN4:5
.=
IFEQ 0,0,
FALSE ,
TRUE
by GR_CY_1:6
.=
FALSE
by CQC_LANG:def 1
;
then ((c3 -BinarySequence c1) + (c3 -BinarySequence c2)) /. c
3 =
(FALSE 'xor' FALSE ) 'xor' ((carry (c3 -BinarySequence c1),(c3 -BinarySequence c2)) /. c3)
by E14, E15, BINARITH:def 8
.=
FALSE 'xor' ((carry (c3 -BinarySequence c1),(c3 -BinarySequence c2)) /. c3)
by BINARITH:14
.=
(carry (c3 -BinarySequence c1),(c3 -BinarySequence c2)) /. c
3
by BINARITH:14
.=
FALSE
by E12, E10
;
then E16:
Intval ((c3 -BinarySequence c1) + (c3 -BinarySequence c2)) = Absval ((c3 -BinarySequence c1) + (c3 -BinarySequence c2))
by BINARI_2:def 3;
c
3 >= 1
by NAT_1:39;
then
c
3 - 1
>= 1
- 1
by XREAL_1:11;
then
c
3 -' 1
= c
3 - 1
by BINARITH:def 3;
then
c
3 -' 1
< c
3
by XREAL_1:148;
then
2
to_power (c3 -' 1) < 2
to_power c
3
by POWER:44;
then
(2 to_power (c3 -' 1)) - 1
< (2 to_power c3) - 1
by REAL_1:92;
then
c
1 + c
2 <= (2 to_power c3) - 1
by E12, XREAL_1:2;
hence
Intval ((c3 -BinarySequence c1) + (c3 -BinarySequence c2)) = c
1 + c
2
by E16, E8;
end;
theorem E12: :: BINARI_4:15
theorem :: BINARI_4:16
theorem E13: :: BINARI_4:17
theorem :: BINARI_4:18
theorem :: BINARI_4:19
proof
let c
1 be non
empty Nat;
let c
2, c
3 be
Tuple of c
1,
BOOLEAN ;
assume E14:
( c
2 = 0* c
1 & c
3 = 0* c
1 )
;
E15:
( 1
<= c
1 &
len c
2 = c
1 )
by FINSEQ_2:109, NAT_1:39;
then E16:
c
1 in Seg c
1
by FINSEQ_1:3;
c
2 /. c
1 =
(0* c1) . c
1
by E14, E15, FINSEQ_4:24
.=
(c1 |-> 0) . c
1
by EUCLID:def 4
.=
FALSE
by E16, FINSEQ_2:70, MARGREL1:36
;
then add_ovfl c
2,c
3 =
((FALSE '&' FALSE ) 'or' (FALSE '&' ((carry c2,c3) /. c1))) 'or' (FALSE '&' ((carry c2,c3) /. c1))
by E14, BINARITH:def 9
.=
(FALSE 'or' (FALSE '&' ((carry c2,c3) /. c1))) 'or' (FALSE '&' ((carry c2,c3) /. c1))
by MARGREL1:49
.=
(FALSE 'or' FALSE ) 'or' (FALSE '&' ((carry c2,c3) /. c1))
by MARGREL1:49
.=
(FALSE 'or' FALSE ) 'or' FALSE
by MARGREL1:49
.=
FALSE 'or' FALSE
by BINARITH:7
.=
FALSE
by BINARITH:7
;
hence
c
2,c
3 are_summable
by BINARITH:def 10;
end;
theorem E14: :: BINARI_4:20
:: deftheorem E15 defines MajP BINARI_4:def 1 :
theorem :: BINARI_4:21
for b
1, b
2, b
3 being
Nat holds
( b
1 >= b
2 implies
MajP b
3,b
1 >= MajP b
3,b
2 )
theorem E16: :: BINARI_4:22
for b
1, b
2, b
3 being
Nat holds
( b
1 >= b
2 implies
MajP b
1,b
3 >= MajP b
2,b
3 )
theorem :: BINARI_4:23
for b
1 being
Nat holds
( b
1 >= 1 implies
MajP b
1,1
= b
1 )
theorem E17: :: BINARI_4:24
theorem :: BINARI_4:25
:: deftheorem E18 defines 2sComplement BINARI_4:def 2 :