:: RADIX_6 semantic presentation

Lemma1: for b1 being Nat st b1 >= 1 holds
b1 + 2 > 1
proof end;

theorem Th1: :: RADIX_6:1
for b1 being Nat st b1 >= 1 holds
for b2, b3 being Nat st b2 >= 1 & b3 >= 2 holds
SDDec (Fmin (b2 + b1),b2,b3) = SDDec (Fmin b2,b2,b3)
proof end;

theorem Th2: :: RADIX_6:2
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
SDDec (Fmin b1,b1,b2) > 0
proof end;

definition
let c1, c2, c3 be Nat;
let c4 be Tuple of (c2 + 2),(c3 -SD );
assume E3: c1 in Seg (c2 + 2) ;
func M0Digit c4,c1 -> Element of a3 -SD equals :Def1: :: RADIX_6:def 1
a4 . a1 if a1 >= a2
0 if a1 < a2
;
coherence
( ( c1 >= c2 implies c4 . c1 is Element of c3 -SD ) & ( c1 < c2 implies 0 is Element of c3 -SD ) )
proof end;
consistency
for b1 being Element of c3 -SD st c1 >= c2 & c1 < c2 holds
( b1 = c4 . c1 iff b1 = 0 )
;
end;

:: deftheorem Def1 defines M0Digit RADIX_6:def 1 :
for b1, b2, b3 being Nat
for b4 being Tuple of (b2 + 2),(b3 -SD ) st b1 in Seg (b2 + 2) holds
( ( b1 >= b2 implies M0Digit b4,b1 = b4 . b1 ) & ( b1 < b2 implies M0Digit b4,b1 = 0 ) );

definition
let c1, c2 be Nat;
let c3 be Tuple of (c1 + 2),(c2 -SD );
func M0 c3 -> Tuple of (a1 + 2),(a2 -SD ) means :Def2: :: RADIX_6:def 2
for b1 being Nat st b1 in Seg (a1 + 2) holds
DigA a4,b1 = M0Digit a3,b1;
existence
ex b1 being Tuple of (c1 + 2),(c2 -SD ) st
for b2 being Nat st b2 in Seg (c1 + 2) holds
DigA b1,b2 = M0Digit c3,b2
proof end;
uniqueness
for b1, b2 being Tuple of (c1 + 2),(c2 -SD ) st ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b1,b3 = M0Digit c3,b3 ) & ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b2,b3 = M0Digit c3,b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def2 defines M0 RADIX_6:def 2 :
for b1, b2 being Nat
for b3, b4 being Tuple of (b1 + 2),(b2 -SD ) holds
( b4 = M0 b3 iff for b5 being Nat st b5 in Seg (b1 + 2) holds
DigA b4,b5 = M0Digit b3,b5 );

definition
let c1, c2, c3 be Nat;
let c4 be Tuple of (c2 + 2),(c3 -SD );
assume that
E5: c3 >= 2 and
E6: c1 in Seg (c2 + 2) ;
func MmaxDigit c4,c1 -> Element of a3 -SD equals :Def3: :: RADIX_6:def 3
a4 . a1 if a1 >= a2
(Radix a3) - 1 if a1 < a2
;
coherence
( ( c1 >= c2 implies c4 . c1 is Element of c3 -SD ) & ( c1 < c2 implies (Radix c3) - 1 is Element of c3 -SD ) )
proof end;
consistency
for b1 being Element of c3 -SD st c1 >= c2 & c1 < c2 holds
( b1 = c4 . c1 iff b1 = (Radix c3) - 1 )
;
end;

:: deftheorem Def3 defines MmaxDigit RADIX_6:def 3 :
for b1, b2, b3 being Nat
for b4 being Tuple of (b2 + 2),(b3 -SD ) st b3 >= 2 & b1 in Seg (b2 + 2) holds
( ( b1 >= b2 implies MmaxDigit b4,b1 = b4 . b1 ) & ( b1 < b2 implies MmaxDigit b4,b1 = (Radix b3) - 1 ) );

definition
let c1, c2 be Nat;
let c3 be Tuple of (c1 + 2),(c2 -SD );
func Mmax c3 -> Tuple of (a1 + 2),(a2 -SD ) means :Def4: :: RADIX_6:def 4
for b1 being Nat st b1 in Seg (a1 + 2) holds
DigA a4,b1 = MmaxDigit a3,b1;
existence
ex b1 being Tuple of (c1 + 2),(c2 -SD ) st
for b2 being Nat st b2 in Seg (c1 + 2) holds
DigA b1,b2 = MmaxDigit c3,b2
proof end;
uniqueness
for b1, b2 being Tuple of (c1 + 2),(c2 -SD ) st ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b1,b3 = MmaxDigit c3,b3 ) & ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b2,b3 = MmaxDigit c3,b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def4 defines Mmax RADIX_6:def 4 :
for b1, b2 being Nat
for b3, b4 being Tuple of (b1 + 2),(b2 -SD ) holds
( b4 = Mmax b3 iff for b5 being Nat st b5 in Seg (b1 + 2) holds
DigA b4,b5 = MmaxDigit b3,b5 );

definition
let c1, c2, c3 be Nat;
let c4 be Tuple of (c2 + 2),(c3 -SD );
assume that
E7: c3 >= 2 and
E8: c1 in Seg (c2 + 2) ;
func MminDigit c4,c1 -> Element of a3 -SD equals :Def5: :: RADIX_6:def 5
a4 . a1 if a1 >= a2
(- (Radix a3)) + 1 if a1 < a2
;
coherence
( ( c1 >= c2 implies c4 . c1 is Element of c3 -SD ) & ( c1 < c2 implies (- (Radix c3)) + 1 is Element of c3 -SD ) )
proof end;
consistency
for b1 being Element of c3 -SD st c1 >= c2 & c1 < c2 holds
( b1 = c4 . c1 iff b1 = (- (Radix c3)) + 1 )
;
end;

:: deftheorem Def5 defines MminDigit RADIX_6:def 5 :
for b1, b2, b3 being Nat
for b4 being Tuple of (b2 + 2),(b3 -SD ) st b3 >= 2 & b1 in Seg (b2 + 2) holds
( ( b1 >= b2 implies MminDigit b4,b1 = b4 . b1 ) & ( b1 < b2 implies MminDigit b4,b1 = (- (Radix b3)) + 1 ) );

definition
let c1, c2 be Nat;
let c3 be Tuple of (c1 + 2),(c2 -SD );
func Mmin c3 -> Tuple of (a1 + 2),(a2 -SD ) means :Def6: :: RADIX_6:def 6
for b1 being Nat st b1 in Seg (a1 + 2) holds
DigA a4,b1 = MminDigit a3,b1;
existence
ex b1 being Tuple of (c1 + 2),(c2 -SD ) st
for b2 being Nat st b2 in Seg (c1 + 2) holds
DigA b1,b2 = MminDigit c3,b2
proof end;
uniqueness
for b1, b2 being Tuple of (c1 + 2),(c2 -SD ) st ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b1,b3 = MminDigit c3,b3 ) & ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b2,b3 = MminDigit c3,b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def6 defines Mmin RADIX_6:def 6 :
for b1, b2 being Nat
for b3, b4 being Tuple of (b1 + 2),(b2 -SD ) holds
( b4 = Mmin b3 iff for b5 being Nat st b5 in Seg (b1 + 2) holds
DigA b4,b5 = MminDigit b3,b5 );

theorem Th3: :: RADIX_6:3
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
for b3 being Tuple of (b1 + 2),(b2 -SD ) holds SDDec (Mmax b3) >= SDDec b3
proof end;

theorem Th4: :: RADIX_6:4
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
for b3 being Tuple of (b1 + 2),(b2 -SD ) holds SDDec b3 >= SDDec (Mmin b3)
proof end;

definition
let c1, c2 be Nat;
let c3 be Integer;
pred c3 needs_digits_of c1,c2 means :Def7: :: RADIX_6:def 7
( a3 < (Radix a2) |^ a1 & a3 >= (Radix a2) |^ (a1 -' 1) );
end;

:: deftheorem Def7 defines needs_digits_of RADIX_6:def 7 :
for b1, b2 being Nat
for b3 being Integer holds
( b3 needs_digits_of b1,b2 iff ( b3 < (Radix b2) |^ b1 & b3 >= (Radix b2) |^ (b1 -' 1) ) );

theorem Th5: :: RADIX_6:5
for b1, b2, b3, b4 being Nat st b4 in Seg b2 holds
DigA (DecSD b1,b2,b3),b4 >= 0
proof end;

theorem Th6: :: RADIX_6:6
for b1, b2, b3 being Nat st b1 >= 1 & b2 >= 2 & b3 needs_digits_of b1,b2 holds
DigA (DecSD b3,b1,b2),b1 > 0
proof end;

theorem Th7: :: RADIX_6:7
for b1, b2, b3 being Nat st b2 >= 1 & b3 >= 2 & b1 needs_digits_of b2,b3 holds
b1 >= SDDec (Fmin (b2 + 2),b2,b3)
proof end;

theorem Th8: :: RADIX_6:8
for b1, b2, b3 being Integer st b2 < b1 + b3 & b3 > 0 holds
ex b4 being Integer st
( - b3 < b1 - (b4 * b3) & b2 - (b4 * b3) < b3 )
proof end;

theorem Th9: :: RADIX_6:9
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
for b3 being Tuple of (b1 + 2),(b2 -SD ) holds (SDDec (Mmax b3)) + (SDDec (DecSD 0,(b1 + 2),b2)) = (SDDec (M0 b3)) + (SDDec (SDMax (b1 + 2),b1,b2))
proof end;

theorem Th10: :: RADIX_6:10
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
for b3 being Tuple of (b1 + 2),(b2 -SD ) holds SDDec (Mmax b3) < (SDDec (M0 b3)) + (SDDec (Fmin (b1 + 2),b1,b2))
proof end;

theorem Th11: :: RADIX_6:11
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
for b3 being Tuple of (b1 + 2),(b2 -SD ) holds (SDDec (Mmin b3)) + (SDDec (DecSD 0,(b1 + 2),b2)) = (SDDec (M0 b3)) + (SDDec (SDMin (b1 + 2),b1,b2))
proof end;

theorem Th12: :: RADIX_6:12
for b1, b2 being Nat
for b3 being Tuple of (b1 + 2),(b2 -SD ) st b1 >= 1 & b2 >= 2 holds
(SDDec (M0 b3)) + (SDDec (DecSD 0,(b1 + 2),b2)) = (SDDec (Mmin b3)) + (SDDec (SDMax (b1 + 2),b1,b2))
proof end;

theorem Th13: :: RADIX_6:13
for b1, b2 being Nat st b1 >= 1 & b2 >= 2 holds
for b3 being Tuple of (b1 + 2),(b2 -SD ) holds SDDec (M0 b3) < (SDDec (Mmin b3)) + (SDDec (Fmin (b1 + 2),b1,b2))
proof end;

theorem Th14: :: RADIX_6:14
for b1, b2, b3 being Nat
for b4 being Tuple of (b1 + 2),(b2 -SD ) st b1 >= 1 & b2 >= 2 & b3 needs_digits_of b1,b2 holds
ex b5 being Integer st
( - b3 < (SDDec (M0 b4)) - (b5 * b3) & (SDDec (Mmax b4)) - (b5 * b3) < b3 )
proof end;

theorem Th15: :: RADIX_6:15
for b1, b2, b3 being Nat
for b4 being Tuple of (b1 + 2),(b2 -SD ) st b1 >= 1 & b2 >= 2 & b3 needs_digits_of b1,b2 holds
ex b5 being Integer st
( - b3 < (SDDec (Mmin b4)) - (b5 * b3) & (SDDec (M0 b4)) - (b5 * b3) < b3 )
proof end;

theorem Th16: :: RADIX_6:16
for b1, b2 being Nat
for b3 being Tuple of (b1 + 2),(b2 -SD ) st b1 >= 1 & b2 >= 2 & not ( SDDec (M0 b3) <= SDDec b3 & SDDec b3 <= SDDec (Mmax b3) ) holds
( SDDec (Mmin b3) <= SDDec b3 & SDDec b3 < SDDec (M0 b3) )
proof end;

definition
let c1, c2, c3 be Nat;
let c4 be Tuple of (c2 + 2),(c3 -SD );
assume E21: c1 in Seg (c2 + 2) ;
func MmaskDigit c4,c1 -> Element of a3 -SD equals :Def8: :: RADIX_6:def 8
a4 . a1 if a1 < a2
0 if a1 >= a2
;
coherence
( ( c1 < c2 implies c4 . c1 is Element of c3 -SD ) & ( c1 >= c2 implies 0 is Element of c3 -SD ) )
proof end;
consistency
for b1 being Element of c3 -SD st c1 < c2 & c1 >= c2 holds
( b1 = c4 . c1 iff b1 = 0 )
;
end;

:: deftheorem Def8 defines MmaskDigit RADIX_6:def 8 :
for b1, b2, b3 being Nat
for b4 being Tuple of (b2 + 2),(b3 -SD ) st b1 in Seg (b2 + 2) holds
( ( b1 < b2 implies MmaskDigit b4,b1 = b4 . b1 ) & ( b1 >= b2 implies MmaskDigit b4,b1 = 0 ) );

definition
let c1, c2 be Nat;
let c3 be Tuple of (c1 + 2),(c2 -SD );
func Mmask c3 -> Tuple of (a1 + 2),(a2 -SD ) means :Def9: :: RADIX_6:def 9
for b1 being Nat st b1 in Seg (a1 + 2) holds
DigA a4,b1 = MmaskDigit a3,b1;
existence
ex b1 being Tuple of (c1 + 2),(c2 -SD ) st
for b2 being Nat st b2 in Seg (c1 + 2) holds
DigA b1,b2 = MmaskDigit c3,b2
proof end;
uniqueness
for b1, b2 being Tuple of (c1 + 2),(c2 -SD ) st ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b1,b3 = MmaskDigit c3,b3 ) & ( for b3 being Nat st b3 in Seg (c1 + 2) holds
DigA b2,b3 = MmaskDigit c3,b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def9 defines Mmask RADIX_6:def 9 :
for b1, b2 being Nat
for b3, b4 being Tuple of (b1 + 2),(b2 -SD ) holds
( b4 = Mmask b3 iff for b5 being Nat st b5 in Seg (b1 + 2) holds
DigA b4,b5 = MmaskDigit b3,b5 );

theorem Th17: :: RADIX_6:17
for b1, b2 being Nat
for b3 being Tuple of (b1 + 2),(b2 -SD ) st b1 >= 1 & b2 >= 2 holds
(SDDec (M0 b3)) + (SDDec (Mmask b3)) = (SDDec b3) + (SDDec (DecSD 0,(b1 + 2),b2))
proof end;

theorem Th18: :: RADIX_6:18
for b1, b2 being Nat
for b3 being Tuple of (b1 + 2),(b2 -SD ) st b1 >= 1 & b2 >= 2 & SDDec (Mmask b3) > 0 holds
SDDec b3 > SDDec (M0 b3)
proof end;

definition
let c1, c2, c3 be Nat;
assume E24: c3 >= 2 ;
func FSDMinDigit c2,c3,c1 -> Element of a3 -SD equals :Def10: :: RADIX_6:def 10
0 if a1 > a2
1 if a1 = a2
otherwise (- (Radix a3)) + 1;
coherence
( ( c1 > c2 implies 0 is Element of c3 -SD ) & ( c1 = c2 implies 1 is Element of c3 -SD ) & ( not c1 > c2 & not c1 = c2 implies (- (Radix c3)) + 1 is Element of c3 -SD ) )
proof end;
consistency
for b1 being Element of c3 -SD st c1 > c2 & c1 = c2 holds
( b1 = 0 iff b1 = 1 )
;
end;

:: deftheorem Def10 defines FSDMinDigit RADIX_6:def 10 :
for b1, b2, b3 being Nat st b3 >= 2 holds
( ( b1 > b2 implies FSDMinDigit b2,b3,b1 = 0 ) & ( b1 = b2 implies FSDMinDigit b2,b3,b1 = 1 ) & ( not b1 > b2 & not b1 = b2 implies FSDMinDigit b2,b3,b1 = (- (Radix b3)) + 1 ) );

definition
let c1, c2, c3 be Nat;
func FSDMin c1,c2,c3 -> Tuple of a1,(a3 -SD ) means :Def11: :: RADIX_6:def 11
for b1 being Nat st b1 in Seg a1 holds
DigA a4,b1 = FSDMinDigit a2,a3,b1;
existence
ex b1 being Tuple of c1,(c3 -SD ) st
for b2 being Nat st b2 in Seg c1 holds
DigA b1,b2 = FSDMinDigit c2,c3,b2
proof end;
uniqueness
for b1, b2 being Tuple of c1,(c3 -SD ) st ( for b3 being Nat st b3 in Seg c1 holds
DigA b1,b3 = FSDMinDigit c2,c3,b3 ) & ( for b3 being Nat st b3 in Seg c1 holds
DigA b2,b3 = FSDMinDigit c2,c3,b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def11 defines FSDMin RADIX_6:def 11 :
for b1, b2, b3 being Nat
for b4 being Tuple of b1,(b3 -SD ) holds
( b4 = FSDMin b1,b2,b3 iff for b5 being Nat st b5 in Seg b1 holds
DigA b4,b5 = FSDMinDigit b2,b3,b5 );

theorem Th19: :: RADIX_6:19
for b1 being Nat st b1 >= 1 holds
for b2, b3 being Nat st b2 in Seg b1 & b3 >= 2 holds
SDDec (FSDMin b1,b2,b3) = 1
proof end;

definition
let c1, c2, c3 be Nat;
let c4 be Tuple of (c2 + 2),(c3 -SD );
pred c4 is_Zero_over c1 means :Def12: :: RADIX_6:def 12
for b1 being Nat st b1 > a1 holds
DigA a4,b1 = 0;
end;

:: deftheorem Def12 defines is_Zero_over RADIX_6:def 12 :
for b1, b2, b3 being Nat
for b4 being Tuple of (b2 + 2),(b3 -SD ) holds
( b4 is_Zero_over b1 iff for b5 being Nat st b5 > b1 holds
DigA b4,b5 = 0 );

theorem Th20: :: RADIX_6:20
for b1 being Nat st b1 >= 1 holds
for b2, b3 being Nat
for b4 being Tuple of (b1 + 2),(b3 -SD ) st b3 >= 2 & b2 in Seg (b1 + 2) & Mmask b4 is_Zero_over b2 & DigA (Mmask b4),b2 > 0 holds
SDDec (Mmask b4) > 0
proof end;