let n be non empty Nat; :: thesis: for k being Nat st 2 to_power n <= k & k < 2 to_power (n + 1) holds
(n + 1) -BinarySequence k = (n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>
let k be Nat; :: thesis: ( 2 to_power n <= k & k < 2 to_power (n + 1) implies (n + 1) -BinarySequence k = (n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *> )
assume that
A1:
2 to_power n <= k
and
A2:
k < 2 to_power (n + 1)
; :: thesis: (n + 1) -BinarySequence k = (n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>
now let i be
Nat;
:: thesis: ( i in Seg (n + 1) implies ((n + 1) -BinarySequence k) . i = ((n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>) . i )assume A3:
i in Seg (n + 1)
;
:: thesis: ((n + 1) -BinarySequence k) . i = ((n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>) . ithen
i in Seg (len ((n + 1) -BinarySequence k))
by FINSEQ_1:def 18;
then A4:
i in dom ((n + 1) -BinarySequence k)
by FINSEQ_1:def 3;
reconsider z =
i as
Nat ;
now per cases
( i in Seg n or i = n + 1 )
by A3, FINSEQ_2:8;
suppose A5:
i in Seg n
;
:: thesis: ((n + 1) -BinarySequence k) . i = ((n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>) . ithen
i in Seg (len (n -BinarySequence (k -' (2 to_power n))))
by FINSEQ_1:def 18;
then A6:
i in dom (n -BinarySequence (k -' (2 to_power n)))
by FINSEQ_1:def 3;
2
to_power (i -' 1) > 0
by POWER:39;
then A7:
0 + 1
<= 2
to_power (i -' 1)
by NAT_1:13;
A8:
( 1
<= i &
i <= n )
by A5, FINSEQ_1:3;
2
* (2 to_power (i -' 1)) =
(2 to_power (i -' 1)) * (2 to_power 1)
by POWER:30
.=
2
to_power ((i -' 1) + 1)
by POWER:32
.=
2
to_power ((i - 1) + 1)
by A8, XREAL_1:235
.=
2
to_power i
;
then A9:
2
* (2 to_power (z -' 1)) divides 2
to_power n
by A8, NAT_2:13;
thus ((n + 1) -BinarySequence k) . i =
((n + 1) -BinarySequence k) /. i
by A4, PARTFUN1:def 8
.=
IFEQ ((k div (2 to_power (i -' 1))) mod 2),
0 ,
FALSE ,
TRUE
by A3, Def1
.=
(n -BinarySequence (k -' (2 to_power n))) /. i
by A5, A10, Def1
.=
(n -BinarySequence (k -' (2 to_power n))) . i
by A6, PARTFUN1:def 8
.=
((n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>) . i
by A6, FINSEQ_1:def 7
;
:: thesis: verum end; end; end; hence
((n + 1) -BinarySequence k) . i = ((n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>) . i
;
:: thesis: verum end;
hence
(n + 1) -BinarySequence k = (n -BinarySequence (k -' (2 to_power n))) ^ <*TRUE *>
by FINSEQ_2:139; :: thesis: verum