:: The Ring of {C}onway Numbers in {M}izar
:: by Karol P\kak
::
:: Received December 12, 2023
:: Copyright (c) 2023-2025 Association of Mizar Users


definition
let f be Function;
redefine attr f is Function-yielding means :Def1: :: SURREALR:def 1
rng f is functional ;
compatibility
( f is Function-yielding iff rng f is functional )
proof end;
end;

:: deftheorem Def1 defines Function-yielding SURREALR:def 1 :
for f being Function holds
( f is Function-yielding iff rng f is functional );

registration
cluster Relation-like Function-like Function-yielding Sequence-like c=-monotone for set ;
existence
ex b1 being Sequence st
( b1 is c=-monotone & b1 is Function-yielding )
proof end;
end;

registration
let f be c=-monotone Function;
let X be set ;
cluster f | X -> c=-monotone ;
coherence
f | X is c=-monotone
proof end;
end;

registration
let f be Function-yielding c=-monotone Sequence;
cluster union (rng f) -> Relation-like Function-like ;
coherence
( union (rng f) is Function-like & union (rng f) is Relation-like )
proof end;
end;

theorem Th1: :: SURREALR:1
for f being Function-yielding c=-monotone Sequence
for o being object st o in dom (union (rng f)) holds
ex A being Ordinal st
( A in dom f & o in dom (f . A) )
proof end;

theorem Th2: :: SURREALR:2
for f being Function-yielding c=-monotone Sequence
for A being Ordinal st A in dom f holds
( dom (f . A) c= dom (union (rng f)) & ( for o being object st o in dom (f . A) holds
(f . A) . o = (union (rng f)) . o ) )
proof end;

theorem Th3: :: SURREALR:3
for f being Function-yielding c=-monotone Sequence
for A being Ordinal
for X being set st ( for o being object st o in X holds
ex B being Ordinal st
( o in dom (f . B) & B in A ) ) holds
(union (rng (f | A))) .: X = (union (rng f)) .: X
proof end;

scheme :: SURREALR:sch 1
MonoFvSExists{ F1() -> Ordinal, F2( Ordinal) -> set , F3( object , Function-yielding c=-monotone Sequence) -> object } :
ex S being Function-yielding c=-monotone Sequence st
( dom S = succ F1() & ( for A being Ordinal st A in succ F1() holds
ex SA being ManySortedSet of F2(A) st
( S . A = SA & ( for o being object st o in F2(A) holds
SA . o = F3(o,(S | A)) ) ) ) )
provided
A1: for S being Function-yielding c=-monotone Sequence st ( for A being Ordinal st A in dom S holds
dom (S . A) = F2(A) ) holds
for A being Ordinal
for o being object st o in dom (S . A) holds
F3(o,(S | A)) = F3(o,S) and
A2: for A, B being Ordinal st A c= B holds
F2(A) c= F2(B)
proof end;

scheme :: SURREALR:sch 2
MonoFvSUniq{ F1() -> Ordinal, F2( Ordinal) -> set , F3() -> Function-yielding c=-monotone Sequence, F4() -> Function-yielding c=-monotone Sequence, F5( object , Function-yielding c=-monotone Sequence) -> object } :
F3() | F1() = F4() | F1()
provided
A1: ( F1() c= dom F3() & F1() c= dom F4() ) and
A2: for A being Ordinal st A in F1() holds
ex SA being ManySortedSet of F2(A) st
( F3() . A = SA & ( for o being object st o in F2(A) holds
SA . o = F5(o,(F3() | A)) ) ) and
A3: for A being Ordinal st A in F1() holds
ex SA being ManySortedSet of F2(A) st
( F4() . A = SA & ( for o being object st o in F2(A) holds
SA . o = F5(o,(F4() | A)) ) )
proof end;

definition
let A be Ordinal;
func No_opposite_op A -> ManySortedSet of Day A means :Def2: :: SURREALR:def 2
ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & it = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Day B st
( S . B = SB & ( for o being object st o in Day B holds
SB . o = [((union (rng (S | B))) .: (R_ o)),((union (rng (S | B))) .: (L_ o))] ) ) ) );
existence
ex b1 being ManySortedSet of Day A ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b1 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Day B st
( S . B = SB & ( for o being object st o in Day B holds
SB . o = [((union (rng (S | B))) .: (R_ o)),((union (rng (S | B))) .: (L_ o))] ) ) ) )
proof end;
uniqueness
for b1, b2 being ManySortedSet of Day A st ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b1 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Day B st
( S . B = SB & ( for o being object st o in Day B holds
SB . o = [((union (rng (S | B))) .: (R_ o)),((union (rng (S | B))) .: (L_ o))] ) ) ) ) & ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b2 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Day B st
( S . B = SB & ( for o being object st o in Day B holds
SB . o = [((union (rng (S | B))) .: (R_ o)),((union (rng (S | B))) .: (L_ o))] ) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def2 defines No_opposite_op SURREALR:def 2 :
for A being Ordinal
for b2 being ManySortedSet of Day A holds
( b2 = No_opposite_op A iff ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b2 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Day B st
( S . B = SB & ( for o being object st o in Day B holds
SB . o = [((union (rng (S | B))) .: (R_ o)),((union (rng (S | B))) .: (L_ o))] ) ) ) ) );

theorem Th4: :: SURREALR:4
for S being Function-yielding c=-monotone Sequence st ( for B being Ordinal st B in dom S holds
ex SB being ManySortedSet of Day B st
( S . B = SB & ( for o being object st o in Day B holds
SB . o = [((union (rng (S | B))) .: (R_ o)),((union (rng (S | B))) .: (L_ o))] ) ) ) holds
for A being Ordinal st A in dom S holds
No_opposite_op A = S . A
proof end;

theorem Th5: :: SURREALR:5
for A, B being Ordinal
for o being object
for f being Function-yielding c=-monotone Sequence st o in dom (f . B) & B in A holds
( o in dom (union (rng (f | A))) & (union (rng (f | A))) . o = (union (rng f)) . o )
proof end;

theorem Th6: :: SURREALR:6
for o being object
for f being Function-yielding c=-monotone Sequence
for A, B being Ordinal st o in dom (f . B) & B in A holds
(union (rng (f | A))) . o = (union (rng f)) . o
proof end;

definition
let x be Surreal;
func - x -> set equals :: SURREALR:def 3
(No_opposite_op (born x)) . x;
coherence
(No_opposite_op (born x)) . x is set
;
end;

:: deftheorem defines - SURREALR:def 3 :
for x being Surreal holds - x = (No_opposite_op (born x)) . x;

definition
let X be set ;
func -- X -> set means :Def4: :: SURREALR:def 4
for o being object holds
( o in it iff ex x being Surreal st
( x in X & o = - x ) );
existence
ex b1 being set st
for o being object holds
( o in b1 iff ex x being Surreal st
( x in X & o = - x ) )
proof end;
uniqueness
for b1, b2 being set st ( for o being object holds
( o in b1 iff ex x being Surreal st
( x in X & o = - x ) ) ) & ( for o being object holds
( o in b2 iff ex x being Surreal st
( x in X & o = - x ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def4 defines -- SURREALR:def 4 :
for X, b2 being set holds
( b2 = -- X iff for o being object holds
( o in b2 iff ex x being Surreal st
( x in X & o = - x ) ) );

theorem Th7: :: SURREALR:7
for x being Surreal holds - x = [(-- (R_ x)),(-- (L_ x))]
proof end;

Lm1: for D being Ordinal holds
( ( for x being Surreal st x in Day D holds
( - x is surreal & - x in Day D & ( for x1 being Surreal st x1 = - x holds
- x1 = x ) ) ) & ( for x, x1, y, y1 being Surreal st x in Day D & y in Day D & x1 = - x & y1 = - y holds
( x <= y iff y1 <= x1 ) ) )

proof end;

registration
let x be Surreal;
cluster - x -> surreal ;
coherence
- x is surreal
proof end;
end;

registration
let X be set ;
cluster -- X -> surreal-membered ;
coherence
-- X is surreal-membered
proof end;
end;

theorem Th8: :: SURREALR:8
for x being Surreal holds
( L_ (- x) = -- (R_ x) & R_ (- x) = -- (L_ x) )
proof end;

:: WP: Conway Ch.1 Th.4(ii)
theorem Th9: :: SURREALR:9
for x being Surreal holds - (- x) = x
proof end;

registration
let x be Surreal;
reduce - (- x) to x;
reducibility
- (- x) = x
by Th9;
end;

theorem Th10: :: SURREALR:10
for x, y being Surreal holds
( x <= y iff - y <= - x )
proof end;

theorem :: SURREALR:11
for x being Surreal
for D being Ordinal st x in Day D holds
- x in Day D by Lm1;

theorem Th12: :: SURREALR:12
for x being Surreal holds born x = born (- x)
proof end;

theorem Th13: :: SURREALR:13
for x being Surreal holds born_eq x = born_eq (- x)
proof end;

theorem :: SURREALR:14
for x, y being Surreal st x in born_eq_set y holds
- x in born_eq_set (- y)
proof end;

theorem Th15: :: SURREALR:15
for X being surreal-membered set holds -- (-- X) = X
proof end;

theorem Th16: :: SURREALR:16
for X being set holds card (-- X) c= card X
proof end;

theorem :: SURREALR:17
for X being surreal-membered set holds card X = card (-- X)
proof end;

Lm2: for X, Y being surreal-membered set st X <<= Y holds
-- Y <<= -- X

proof end;

theorem :: SURREALR:18
for X, Y being surreal-membered set holds
( X <<= Y iff -- Y <<= -- X )
proof end;

Lm3: for X, Y being surreal-membered set st X << Y holds
-- Y << -- X

proof end;

theorem :: SURREALR:19
for X, Y being surreal-membered set holds
( X << Y iff -- Y << -- X )
proof end;

theorem Th20: :: SURREALR:20
for X1, X2 being set holds -- (X1 \/ X2) = (-- X1) \/ (-- X2)
proof end;

theorem Th21: :: SURREALR:21
for x being Surreal holds {(- x)} = -- {x}
proof end;

theorem Th22: :: SURREALR:22
-- {} = {}
proof end;

theorem Th23: :: SURREALR:23
- 0_No = 0_No
proof end;

registration
reduce - 0_No to 0_No ;
reducibility
- 0_No = 0_No
by Th23;
end;

theorem :: SURREALR:24
for x being Surreal holds
( x == 0_No iff - x == 0_No ) by Th23, Th10;

definition
let A be Ordinal;
func Triangle A -> Subset of [:(Day A),(Day A):] means :Def5: :: SURREALR:def 5
for x, y being Surreal holds
( [x,y] in it iff (born x) (+) (born y) c= A );
existence
ex b1 being Subset of [:(Day A),(Day A):] st
for x, y being Surreal holds
( [x,y] in b1 iff (born x) (+) (born y) c= A )
proof end;
uniqueness
for b1, b2 being Subset of [:(Day A),(Day A):] st ( for x, y being Surreal holds
( [x,y] in b1 iff (born x) (+) (born y) c= A ) ) & ( for x, y being Surreal holds
( [x,y] in b2 iff (born x) (+) (born y) c= A ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def5 defines Triangle SURREALR:def 5 :
for A being Ordinal
for b2 being Subset of [:(Day A),(Day A):] holds
( b2 = Triangle A iff for x, y being Surreal holds
( [x,y] in b2 iff (born x) (+) (born y) c= A ) );

registration
let A be Ordinal;
cluster Triangle A -> non empty ;
coherence
not Triangle A is empty
proof end;
end;

theorem Th25: :: SURREALR:25
for A, B being Ordinal st A c= B holds
Triangle A c= Triangle B
proof end;

definition
let A be Ordinal;
func No_sum_op A -> ManySortedSet of Triangle A means :Def6: :: SURREALR:def 6
ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & it = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [((union (rng (S | B))) .: ([:(L_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(L_ (R_ x)):])),((union (rng (S | B))) .: ([:(R_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(R_ (R_ x)):]))] ) ) ) );
existence
ex b1 being ManySortedSet of Triangle A ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b1 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [((union (rng (S | B))) .: ([:(L_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(L_ (R_ x)):])),((union (rng (S | B))) .: ([:(R_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(R_ (R_ x)):]))] ) ) ) )
proof end;
uniqueness
for b1, b2 being ManySortedSet of Triangle A st ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b1 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [((union (rng (S | B))) .: ([:(L_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(L_ (R_ x)):])),((union (rng (S | B))) .: ([:(R_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(R_ (R_ x)):]))] ) ) ) ) & ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b2 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [((union (rng (S | B))) .: ([:(L_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(L_ (R_ x)):])),((union (rng (S | B))) .: ([:(R_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(R_ (R_ x)):]))] ) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def6 defines No_sum_op SURREALR:def 6 :
for A being Ordinal
for b2 being ManySortedSet of Triangle A holds
( b2 = No_sum_op A iff ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b2 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [((union (rng (S | B))) .: ([:(L_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(L_ (R_ x)):])),((union (rng (S | B))) .: ([:(R_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(R_ (R_ x)):]))] ) ) ) ) );

theorem Th26: :: SURREALR:26
for S being Function-yielding c=-monotone Sequence st ( for B being Ordinal st B in dom S holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [((union (rng (S | B))) .: ([:(L_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(L_ (R_ x)):])),((union (rng (S | B))) .: ([:(R_ (L_ x)),{(R_ x)}:] \/ [:{(L_ x)},(R_ (R_ x)):]))] ) ) ) holds
for A being Ordinal st A in dom S holds
No_sum_op A = S . A
proof end;

definition
let x, y be Surreal;
func x + y -> set equals :: SURREALR:def 7
(No_sum_op ((born x) (+) (born y))) . [x,y];
coherence
(No_sum_op ((born x) (+) (born y))) . [x,y] is set
;
end;

:: deftheorem defines + SURREALR:def 7 :
for x, y being Surreal holds x + y = (No_sum_op ((born x) (+) (born y))) . [x,y];

definition
let X, Y be set ;
func X ++ Y -> set means :Def8: :: SURREALR:def 8
for o being object holds
( o in it iff ex x, y being Surreal st
( x in X & y in Y & o = x + y ) );
existence
ex b1 being set st
for o being object holds
( o in b1 iff ex x, y being Surreal st
( x in X & y in Y & o = x + y ) )
proof end;
uniqueness
for b1, b2 being set st ( for o being object holds
( o in b1 iff ex x, y being Surreal st
( x in X & y in Y & o = x + y ) ) ) & ( for o being object holds
( o in b2 iff ex x, y being Surreal st
( x in X & y in Y & o = x + y ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def8 defines ++ SURREALR:def 8 :
for X, Y, b3 being set holds
( b3 = X ++ Y iff for o being object holds
( o in b3 iff ex x, y being Surreal st
( x in X & y in Y & o = x + y ) ) );

theorem Th27: :: SURREALR:27
for X being set holds X ++ {} = {}
proof end;

theorem Th28: :: SURREALR:28
for x, y being Surreal holds x + y = [(((L_ x) ++ {y}) \/ ({x} ++ (L_ y))),(((R_ x) ++ {y}) \/ ({x} ++ (R_ y)))]
proof end;

:: WP: Commutativity of Addition for Surreal Number, Conway Ch.1 Th.3 (ii)
theorem Th29: :: SURREALR:29
for x, y being Surreal holds x + y = y + x
proof end;

definition
let x, y be Surreal;
:: original: +
redefine func x + y -> set ;
commutativity
for x, y being Surreal holds x + y = y + x
by Th29;
end;

Lm4: for X, Y being set holds X ++ Y c= Y ++ X
proof end;

theorem Th30: :: SURREALR:30
for X, Y being set holds X ++ Y = Y ++ X
proof end;

definition
let X, Y be set ;
:: original: ++
redefine func X ++ Y -> set ;
commutativity
for X, Y being set holds X ++ Y = Y ++ X
by Th30;
end;

Lm5: for D being Ordinal holds
( ( for x, y being Surreal st (born x) (+) (born y) c= D holds
( x + y is surreal & x + y in Day ((born x) (+) (born y)) ) ) & ( for x, y, z, xz, yz being Surreal st (born x) (+) (born z) c= D & (born y) (+) (born z) c= D & xz = x + z & yz = y + z holds
( xz <= yz iff x <= y ) ) )

proof end;

registration
let x, y be Surreal;
cluster x + y -> surreal ;
coherence
x + y is surreal
by Lm5;
end;

definition
let x, y be Surreal;
func x - y -> Surreal equals :: SURREALR:def 9
x + (- y);
coherence
x + (- y) is Surreal
;
end;

:: deftheorem defines - SURREALR:def 9 :
for x, y being Surreal holds x - y = x + (- y);

theorem :: SURREALR:31
for x, y being Surreal holds born (x + y) c= (born x) (+) (born y)
proof end;

registration
let X, Y be set ;
cluster X ++ Y -> surreal-membered ;
coherence
X ++ Y is surreal-membered
proof end;
end;

:: WP: Transitive Law of Addition for Surreal Number, Conway Ch.1 Th.5
theorem Th32: :: SURREALR:32
for x, y, z being Surreal holds
( x <= y iff x + z <= y + z )
proof end;

theorem Th33: :: SURREALR:33
for X1, X2, Y being set holds (X1 \/ X2) ++ Y = (X1 ++ Y) \/ (X2 ++ Y)
proof end;

theorem :: SURREALR:34
for X, Y1, Y2 being set holds X ++ (Y1 \/ Y2) = (X ++ Y1) \/ (X ++ Y2) by Th33;

theorem :: SURREALR:35
for X1, X2, Y1, Y2 being set st X1 <=_ X2 & Y1 <=_ Y2 holds
X1 ++ Y1 <=_ X2 ++ Y2
proof end;

theorem Th36: :: SURREALR:36
for x, y being Surreal holds {x} ++ {y} = {(x + y)}
proof end;

:: WP: Associativity of Addition for Surreal Number, Conway Ch.1 Th.3(iii)
theorem Th37: :: SURREALR:37
for x, y, z being Surreal holds (x + y) + z = x + (y + z)
proof end;

:: WP: Additive Identity for Surreal Number, Conway Ch.1 Th.3(i)
theorem Th38: :: SURREALR:38
for x being Surreal holds x + 0_No = x
proof end;

registration
let x be Surreal;
reduce x + 0_No to x;
reducibility
x + 0_No = x
by Th38;
end;

:: WP: Property of The Aditive Inverse for Surreal Number, Conway Ch.1 Th.4(iii)
theorem Th39: :: SURREALR:39
for x being Surreal holds x - x == 0_No
proof end;

:: WP: Conway Ch.1 Th.4(i)
theorem Th40: :: SURREALR:40
for x, y being Surreal holds - (x + y) = (- x) + (- y)
proof end;

theorem Th41: :: SURREALR:41
for x, y, z being Surreal holds
( x + y <= z iff x <= z - y )
proof end;

theorem Th42: :: SURREALR:42
for x, y, z being Surreal holds
( x + y < z iff x < z - y )
proof end;

theorem Th43: :: SURREALR:43
for x, y, z, t being Surreal st x <= y & z <= t holds
x + z <= y + t
proof end;

theorem Th44: :: SURREALR:44
for x, y, z, t being Surreal st x <= y & z < t holds
x + z < y + t
proof end;

theorem :: SURREALR:45
for x, y being Surreal holds
( x < y iff 0_No < y - x )
proof end;

theorem :: SURREALR:46
for x, y being Surreal holds
( x < y iff x - y < 0_No )
proof end;

theorem :: SURREALR:47
for x, y being Surreal st x - y == 0_No holds
x == y
proof end;

definition
let x be object ;
assume A1: x is surreal ;
func -' x -> Surreal means :Def10: :: SURREALR:def 10
for x1 being Surreal st x1 = x holds
it = - x1;
existence
ex b1 being Surreal st
for x1 being Surreal st x1 = x holds
b1 = - x1
proof end;
uniqueness
for b1, b2 being Surreal st ( for x1 being Surreal st x1 = x holds
b1 = - x1 ) & ( for x1 being Surreal st x1 = x holds
b2 = - x1 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def10 defines -' SURREALR:def 10 :
for x being object st x is surreal holds
for b2 being Surreal holds
( b2 = -' x iff for x1 being Surreal st x1 = x holds
b2 = - x1 );

registration
let a be Surreal;
let x be object ;
identify - a with -' x when a = x;
compatibility
( a = x implies - a = -' x )
by Def10;
end;

definition
let x, y be object ;
assume A1: ( x is surreal & y is surreal ) ;
func x +' y -> Surreal means :Def11: :: SURREALR:def 11
for x1, y1 being Surreal st x1 = x & y1 = y holds
it = x1 + y1;
existence
ex b1 being Surreal st
for x1, y1 being Surreal st x1 = x & y1 = y holds
b1 = x1 + y1
proof end;
uniqueness
for b1, b2 being Surreal st ( for x1, y1 being Surreal st x1 = x & y1 = y holds
b1 = x1 + y1 ) & ( for x1, y1 being Surreal st x1 = x & y1 = y holds
b2 = x1 + y1 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def11 defines +' SURREALR:def 11 :
for x, y being object st x is surreal & y is surreal holds
for b3 being Surreal holds
( b3 = x +' y iff for x1, y1 being Surreal st x1 = x & y1 = y holds
b3 = x1 + y1 );

registration
let a, b be Surreal;
let x, y be object ;
identify a + b with x +' y when a = x, b = y;
compatibility
( a = x & b = y implies a + b = x +' y )
by Def11;
end;

definition
let A be Ordinal;
func No_mult_op A -> ManySortedSet of Triangle A means :Def12: :: SURREALR:def 12
ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & it = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xL,yL]))) where xL is Element of L_ (L_ x), yL is Element of L_ (R_ x) : ( xL in L_ (L_ x) & yL in L_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xR,yR]))) where xR is Element of R_ (L_ x), yR is Element of R_ (R_ x) : ( xR in R_ (L_ x) & yR in R_ (R_ x) ) } ),( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xL,yR]))) where xL is Element of L_ (L_ x), yR is Element of R_ (R_ x) : ( xL in L_ (L_ x) & yR in R_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xR,yL]))) where xR is Element of R_ (L_ x), yL is Element of L_ (R_ x) : ( xR in R_ (L_ x) & yL in L_ (R_ x) ) } )] ) ) ) );
existence
ex b1 being ManySortedSet of Triangle A ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b1 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xL,yL]))) where xL is Element of L_ (L_ x), yL is Element of L_ (R_ x) : ( xL in L_ (L_ x) & yL in L_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xR,yR]))) where xR is Element of R_ (L_ x), yR is Element of R_ (R_ x) : ( xR in R_ (L_ x) & yR in R_ (R_ x) ) } ),( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xL,yR]))) where xL is Element of L_ (L_ x), yR is Element of R_ (R_ x) : ( xL in L_ (L_ x) & yR in R_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xR,yL]))) where xR is Element of R_ (L_ x), yL is Element of L_ (R_ x) : ( xR in R_ (L_ x) & yL in L_ (R_ x) ) } )] ) ) ) )
proof end;
uniqueness
for b1, b2 being ManySortedSet of Triangle A st ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b1 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xL,yL]))) where xL is Element of L_ (L_ x), yL is Element of L_ (R_ x) : ( xL in L_ (L_ x) & yL in L_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xR,yR]))) where xR is Element of R_ (L_ x), yR is Element of R_ (R_ x) : ( xR in R_ (L_ x) & yR in R_ (R_ x) ) } ),( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xL,yR]))) where xL is Element of L_ (L_ x), yR is Element of R_ (R_ x) : ( xL in L_ (L_ x) & yR in R_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xR,yL]))) where xR is Element of R_ (L_ x), yL is Element of L_ (R_ x) : ( xR in R_ (L_ x) & yL in L_ (R_ x) ) } )] ) ) ) ) & ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b2 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xL,yL]))) where xL is Element of L_ (L_ x), yL is Element of L_ (R_ x) : ( xL in L_ (L_ x) & yL in L_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xR,yR]))) where xR is Element of R_ (L_ x), yR is Element of R_ (R_ x) : ( xR in R_ (L_ x) & yR in R_ (R_ x) ) } ),( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xL,yR]))) where xL is Element of L_ (L_ x), yR is Element of R_ (R_ x) : ( xL in L_ (L_ x) & yR in R_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xR,yL]))) where xR is Element of R_ (L_ x), yL is Element of L_ (R_ x) : ( xR in R_ (L_ x) & yL in L_ (R_ x) ) } )] ) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def12 defines No_mult_op SURREALR:def 12 :
for A being Ordinal
for b2 being ManySortedSet of Triangle A holds
( b2 = No_mult_op A iff ex S being Function-yielding c=-monotone Sequence st
( dom S = succ A & b2 = S . A & ( for B being Ordinal st B in succ A holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xL,yL]))) where xL is Element of L_ (L_ x), yL is Element of L_ (R_ x) : ( xL in L_ (L_ x) & yL in L_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xR,yR]))) where xR is Element of R_ (L_ x), yR is Element of R_ (R_ x) : ( xR in R_ (L_ x) & yR in R_ (R_ x) ) } ),( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xL,yR]))) where xL is Element of L_ (L_ x), yR is Element of R_ (R_ x) : ( xL in L_ (L_ x) & yR in R_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xR,yL]))) where xR is Element of R_ (L_ x), yL is Element of L_ (R_ x) : ( xR in R_ (L_ x) & yL in L_ (R_ x) ) } )] ) ) ) ) );

definition
let x, y be Surreal;
func x * y -> set equals :: SURREALR:def 13
(No_mult_op ((born x) (+) (born y))) . [x,y];
coherence
(No_mult_op ((born x) (+) (born y))) . [x,y] is set
;
end;

:: deftheorem defines * SURREALR:def 13 :
for x, y being Surreal holds x * y = (No_mult_op ((born x) (+) (born y))) . [x,y];

theorem Th48: :: SURREALR:48
for S being Function-yielding c=-monotone Sequence st ( for B being Ordinal st B in dom S holds
ex SB being ManySortedSet of Triangle B st
( S . B = SB & ( for x being object st x in Triangle B holds
SB . x = [( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xL,yL]))) where xL is Element of L_ (L_ x), yL is Element of L_ (R_ x) : ( xL in L_ (L_ x) & yL in L_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xR,yR]))) where xR is Element of R_ (L_ x), yR is Element of R_ (R_ x) : ( xR in R_ (L_ x) & yR in R_ (R_ x) ) } ),( { ((((union (rng (S | B))) . [xL,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yR])) +' (-' ((union (rng (S | B))) . [xL,yR]))) where xL is Element of L_ (L_ x), yR is Element of R_ (R_ x) : ( xL in L_ (L_ x) & yR in R_ (R_ x) ) } \/ { ((((union (rng (S | B))) . [xR,(R_ x)]) +' ((union (rng (S | B))) . [(L_ x),yL])) +' (-' ((union (rng (S | B))) . [xR,yL]))) where xR is Element of R_ (L_ x), yL is Element of L_ (R_ x) : ( xR in R_ (L_ x) & yL in L_ (R_ x) ) } )] ) ) ) holds
for A being Ordinal st A in dom S holds
No_mult_op A = S . A
proof end;

definition
let x, y be Surreal;
let X, Y be set ;
func comp (X,x,y,Y) -> set means :Def14: :: SURREALR:def 14
for o being object holds
( o in it iff ex x1, y1 being Surreal st
( o = ((x1 * y) +' (x * y1)) +' (-' (x1 * y1)) & x1 in X & y1 in Y ) );
existence
ex b1 being set st
for o being object holds
( o in b1 iff ex x1, y1 being Surreal st
( o = ((x1 * y) +' (x * y1)) +' (-' (x1 * y1)) & x1 in X & y1 in Y ) )
proof end;
uniqueness
for b1, b2 being set st ( for o being object holds
( o in b1 iff ex x1, y1 being Surreal st
( o = ((x1 * y) +' (x * y1)) +' (-' (x1 * y1)) & x1 in X & y1 in Y ) ) ) & ( for o being object holds
( o in b2 iff ex x1, y1 being Surreal st
( o = ((x1 * y) +' (x * y1)) +' (-' (x1 * y1)) & x1 in X & y1 in Y ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def14 defines comp SURREALR:def 14 :
for x, y being Surreal
for X, Y, b5 being set holds
( b5 = comp (X,x,y,Y) iff for o being object holds
( o in b5 iff ex x1, y1 being Surreal st
( o = ((x1 * y) +' (x * y1)) +' (-' (x1 * y1)) & x1 in X & y1 in Y ) ) );

theorem Th49: :: SURREALR:49
for x, y being Surreal
for X being set holds comp (X,x,y,{}) = {}
proof end;

theorem Th50: :: SURREALR:50
for x, y being Surreal holds x * y = [((comp ((L_ x),x,y,(L_ y))) \/ (comp ((R_ x),x,y,(R_ y)))),((comp ((L_ x),x,y,(R_ y))) \/ (comp ((R_ x),x,y,(L_ y))))]
proof end;

theorem Th51: :: SURREALR:51
( ( for x, y being Surreal holds x * y is Surreal ) & ( for x, y being Surreal holds x * y = y * x ) & ( for x1, x2, y, x1y, x2y being Surreal st x1 == x2 & x1y = x1 * y & x2y = x2 * y holds
x1y == x2y ) & ( for x1, x2, y1, y2, x1y2, x2y1, x1y1, x2y2 being Surreal st x1y1 = x1 * y1 & x1y2 = x1 * y2 & x2y1 = x2 * y1 & x2y2 = x2 * y2 & x1 < x2 & y1 < y2 holds
x1y2 + x2y1 < x1y1 + x2y2 ) )
proof end;

registration
let a, b be Surreal;
cluster a * b -> surreal ;
coherence
a * b is surreal
by Th51;
end;

:: WP: Commutativity of Multiplication for Surreal Number, Conway Ch.1 Th.7(iii)
definition
let a, b be Surreal;
:: original: *
redefine func a * b -> set ;
commutativity
for a, b being Surreal holds a * b = b * a
by Th51;
end;

registration
let x, y be Surreal;
let X, Y be set ;
cluster comp (X,x,y,Y) -> surreal-membered ;
coherence
comp (X,x,y,Y) is surreal-membered
proof end;
end;

definition
let x, y be Surreal;
let X, Y be set ;
redefine func comp (X,x,y,Y) means :Def15: :: SURREALR:def 15
for o being object holds
( o in it iff ex x1, y1 being Surreal st
( o = ((x1 * y) + (x * y1)) - (x1 * y1) & x1 in X & y1 in Y ) );
compatibility
for b1 being set holds
( b1 = comp (X,x,y,Y) iff for o being object holds
( o in b1 iff ex x1, y1 being Surreal st
( o = ((x1 * y) + (x * y1)) - (x1 * y1) & x1 in X & y1 in Y ) ) )
proof end;
end;

:: deftheorem Def15 defines comp SURREALR:def 15 :
for x, y being Surreal
for X, Y, b5 being set holds
( b5 = comp (X,x,y,Y) iff for o being object holds
( o in b5 iff ex x1, y1 being Surreal st
( o = ((x1 * y) + (x * y1)) - (x1 * y1) & x1 in X & y1 in Y ) ) );

theorem :: SURREALR:52
for x, y, z, t being Surreal holds comp ({z},x,y,{t}) = {(((z * y) + (x * t)) - (z * t))}
proof end;

Lm6: for x, y being Surreal
for X, Y being set holds comp (X,x,y,Y) c= comp (Y,y,x,X)

proof end;

theorem Th53: :: SURREALR:53
for x, y being Surreal
for X, Y being set holds comp (X,x,y,Y) = comp (Y,y,x,X)
proof end;

:: WP: Conway Ch.1 Th.8(i)
theorem :: SURREALR:54
for x1, x2, y being Surreal st x1 == x2 holds
x1 * y == x2 * y by Th51;

:: WP: Conway Ch.1 Th.8(iii)
theorem :: SURREALR:55
for x1, x2, y1, y2 being Surreal st x1 < x2 & y1 < y2 holds
(x1 * y2) + (x2 * y1) < (x1 * y1) + (x2 * y2) by Th51;

:: WP: Conway Ch.1 Th.7(i)
theorem Th56: :: SURREALR:56
for x being Surreal holds x * 0_No = 0_No
proof end;

:: WP: Multiplicative Identity for Surreal Number, Conway Ch.1 Th.7(ii)
theorem Th57: :: SURREALR:57
for x being Surreal holds x * 1_No = x
proof end;

registration
let x be Surreal;
reduce x * 0_No to 0_No ;
reducibility
x * 0_No = 0_No
by Th56;
reduce x * 1_No to x;
reducibility
x * 1_No = x
by Th57;
end;

Lm7: for x, y, z being Surreal
for X, Y, Z being surreal-membered set st ( X = L_ x or X = R_ x or X = {x} ) & ( Y = L_ y or Y = R_ y or Y = {y} ) & ( Z = L_ z or Z = R_ z or Z = {z} ) & ( X <> {x} or Y <> {y} or Z <> {z} ) holds
for x1, y1, z1 being Surreal st x1 in X & y1 in Y & z1 in Z holds
((born x1) (+) (born y1)) (+) (born z1) in ((born x) (+) (born y)) (+) (born z)

proof end;

Lm8: for x, y being Surreal holds - (x * y) = (- x) * y
proof end;

:: WP: Conway Ch.1 Th.7(in)
theorem Th58: :: SURREALR:58
for x, y being Surreal holds
( x * (- y) = - (x * y) & (- x) * y = - (x * y) & (- x) * (- y) = x * y )
proof end;

theorem Th59: :: SURREALR:59
for x, y being Surreal
for X, Y1, Y2 being set st Y1 c= Y2 holds
comp (X,x,y,Y1) c= comp (X,x,y,Y2)
proof end;

theorem Th60: :: SURREALR:60
for x, y being Surreal
for X, Y1, Y2 being set holds comp (X,x,y,(Y1 \/ Y2)) = (comp (X,x,y,Y1)) \/ (comp (X,x,y,Y2))
proof end;

theorem Th61: :: SURREALR:61
for X, Y being set st ( for x being Surreal st x in X holds
ex y being Surreal st
( y in Y & x == y ) ) holds
X <=_ Y
proof end;

theorem :: SURREALR:62
for X1, X2 being set st X1 <=_ X2 holds
-- X1 <=_ -- X2
proof end;

theorem :: SURREALR:63
for X1, X2 being set holds -- (X1 ++ X2) = (-- X1) ++ (-- X2)
proof end;

theorem :: SURREALR:64
for X being surreal-membered set holds X ++ {0_No} = X
proof end;

theorem Th65: :: SURREALR:65
for x, y being Surreal st x == y holds
- x == - y by Th10;

theorem :: SURREALR:66
for x1, x2, y1, y2 being Surreal st x1 == x2 & y1 == y2 holds
x1 + y1 == x2 + y2 by Th43;

:: WP: Distributivity of Multiplication Over Addition for Surreal Numbers, Conway Ch.1 Th.7(v)
theorem Th67: :: SURREALR:67
for x, y, z being Surreal holds x * (y + z) == (x * y) + (x * z)
proof end;

theorem Th68: :: SURREALR:68
for x, y being Surreal
for X1, X2, Y being set holds comp ((X1 \/ X2),x,y,Y) = (comp (X1,x,y,Y)) \/ (comp (X2,x,y,Y))
proof end;

:: WP: Associativity of Multiplication for Surreal Numbers, Conway Ch.1 Th.7(iii)
theorem :: SURREALR:69
for x, y, z being Surreal holds (x * y) * z == x * (y * z)
proof end;

theorem Th70: :: SURREALR:70
for x, y, z being Surreal st 0_No < x & y < z holds
y * x < z * x
proof end;

theorem :: SURREALR:71
for x, y, z being Surreal st x < 0_No & y < z holds
z * x < y * x
proof end;

Lm9: for x, y being Surreal st 0_No < x & 0_No < y holds
0_No < x * y

proof end;

:: WP: Conway Ch.1 Th.9
theorem Th72: :: SURREALR:72
for x, y being Surreal holds
( ( ( x < 0_No & y < 0_No ) or ( 0_No < x & 0_No < y ) ) iff 0_No < x * y )
proof end;

theorem :: SURREALR:73
for x, y, z being Surreal st 0_No < z & x * z < y * z holds
x < y
proof end;

theorem Th74: :: SURREALR:74
for x, y being Surreal holds
( ( ( x < 0_No & 0_No < y ) or ( 0_No < x & y < 0_No ) ) iff x * y < 0_No )
proof end;

theorem :: SURREALR:75
for x, y, z being Surreal st 0_No <= x & y <= z holds
y * x <= z * x
proof end;

theorem :: SURREALR:76
for x, y being Surreal holds (x + y) * (x + y) == ((x * x) + (y * y)) + ((x * y) + (y * x))
proof end;

theorem :: SURREALR:77
for x, y being Surreal holds
( x * y == 0_No iff ( x == 0_No or y == 0_No ) ) by Th72, Th74;