One way to define a rational number (a-b)/c is to define it as the (infinite) set of all 3-tuples of natural numbers (a1, b1, c1) for which (a-b)/c = (a1-b1)/c1 (b is needed for negative numbers).
Klick on a 3-tuple to see how it may be defined as a set.
( 48, 0, 27 ), ( 48, 16, 18 ), ( 48, 32, 9 ),
( 64, 0, 36 ), ( 64, 16, 27 ), ( 64, 32, 18 ), ( 64, 48, 9 ),
( 80, 0, 45 ), ( 80, 16, 36 ), ( 80, 32, 27 ), ( 80, 48, 18 ), ( 80, 64, 9 ),
( 96, 0, 54 ), ( 96, 16, 45 ), ( 96, 32, 36 ), ( 96, 48, 27 ), ( 96, 64, 18 ), ( 96, 80, 9 ),
( 112, 0, 63 ), ( 112, 16, 54 ), ( 112, 32, 45 ), ( 112, 48, 36 ), ( 112, 64, 27 ), ( 112, 80, 18 ), ( 112, 96, 9 ),
( 128, 0, 72 ), ( 128, 16, 63 ), ( 128, 32, 54 ), ( 128, 48, 45 ), ( 128, 64, 36 ), ( 128, 80, 27 ), ( 128, 96, 18 ), ( 128, 112, 9 ),
( 144, 0, 81 ), ( 144, 16, 72 ), ( 144, 32, 63 ), ( 144, 48, 54 ), ( 144, 64, 45 ), ( 144, 80, 36 ), ( 144, 96, 27 ), ( 144, 112, 18 ), ( 144, 128, 9 ),
( 160, 0, 90 ), ( 160, 16, 81 ), ( 160, 32, 72 ), ( 160, 48, 63 ), ( 160, 64, 54 ), ( 160, 80, 45 ), ( 160, 96, 36 ), ( 160, 112, 27 ), ( 160, 128, 18 ), ( 160, 144, 9 ),
( 176, 0, 99 ), ( 176, 16, 90 ), ( 176, 32, 81 ), ( 176, 48, 72 ), ( 176, 64, 63 ), ( 176, 80, 54 ), ( 176, 96, 45 ), ( 176, 112, 36 ), ( 176, 128, 27 ), ( 176, 144, 18 ), ( 176, 160, 9 ),
( 192, 0, 108 ), ( 192, 16, 99 ), ( 192, 32, 90 ), ( 192, 48, 81 ), ( 192, 64, 72 ), ( 192, 80, 63 ), ( 192, 96, 54 ), ( 192, 112, 45 ), ( 192, 128, 36 ), ( 192, 144, 27 ), ( 192, 160, 18 ), ( 192, 176, 9 ),
( 208, 0, 117 ), ( 208, 16, 108 ), ( 208, 32, 99 ), ( 208, 48, 90 ), ( 208, 64, 81 ), ( 208, 80, 72 ), ( 208, 96, 63 ), ( 208, 112, 54 ), ( 208, 128, 45 ), ( 208, 144, 36 ), ( 208, 160, 27 ), ( 208, 176, 18 ), ( 208, 192, 9 ),
( 224, 0, 126 ), ( 224, 16, 117 ), ( 224, 32, 108 ), ( 224, 48, 99 ), ( 224, 64, 90 ), ( 224, 80, 81 ), ( 224, 96, 72 ), ( 224, 112, 63 ), ( 224, 128, 54 ), ( 224, 144, 45 ), ( 224, 160, 36 ), ( 224, 176, 27 ), ( 224, 192, 18 ), ( 224, 208, 9 ),
...
}
The equation (a-b)/c = (a1-b1)/c1 is equivalent to a·c1 + b1·c = a1·c + b·c1 - so only addition and multiplication of natural numbers are needed to define the rational numbers.
For rational numbers Q, Q1 as defined above, Q < Q1 is defined as a·c1 + b1·c < a1·c + b·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.
Q + Q1 is defined as (a2-b2)/c2, where a2 = a·c1 + a1·c, b2 = b·c1 + b1·c, c2 = c·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.
Be aware that (a2-b2)/c2 is simply a notation for the set determined by a2, b2 and c2 here - not an expression using subtraction and division.
The definition for Q + Q1 above simply is a transformation of the expression (a-b)/c + (a1-b1)/c1.
Assuming that a,c is minimal for a positive rational number a/c or (a-0)/c, we can enumerate all members of the set by doing this:
Let n be 1 Repeat: For all n1 from 0 to n-1: Let a1 be n·a Let b1 be n1·a Let c1 be (n-n1)·c Enumerate (a1,b1,c1) Increase n by 1
The enumeration as Python function with a limiting parameter k which will cause the function to enumerate (k·(k+1))/2 elements of a/c:
def print_rational_number(a,c,k): print str(a)+'/'+str(c)+' = ('+str(a)+'-0)/'+str(c)+' = {' for n in range(1,k+1): for n1 in range(n): a1=n*a b1=n1*a c1=(n-n1)*c print '( '+str(a1)+', '+str(b1)+', '+str(c1)+' ),' print print "..." print "}"