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.
( 105, 0, 3 ), ( 105, 35, 2 ), ( 105, 70, 1 ),
( 140, 0, 4 ), ( 140, 35, 3 ), ( 140, 70, 2 ), ( 140, 105, 1 ),
( 175, 0, 5 ), ( 175, 35, 4 ), ( 175, 70, 3 ), ( 175, 105, 2 ), ( 175, 140, 1 ),
( 210, 0, 6 ), ( 210, 35, 5 ), ( 210, 70, 4 ), ( 210, 105, 3 ), ( 210, 140, 2 ), ( 210, 175, 1 ),
( 245, 0, 7 ), ( 245, 35, 6 ), ( 245, 70, 5 ), ( 245, 105, 4 ), ( 245, 140, 3 ), ( 245, 175, 2 ), ( 245, 210, 1 ),
( 280, 0, 8 ), ( 280, 35, 7 ), ( 280, 70, 6 ), ( 280, 105, 5 ), ( 280, 140, 4 ), ( 280, 175, 3 ), ( 280, 210, 2 ), ( 280, 245, 1 ),
( 315, 0, 9 ), ( 315, 35, 8 ), ( 315, 70, 7 ), ( 315, 105, 6 ), ( 315, 140, 5 ), ( 315, 175, 4 ), ( 315, 210, 3 ), ( 315, 245, 2 ), ( 315, 280, 1 ),
( 350, 0, 10 ), ( 350, 35, 9 ), ( 350, 70, 8 ), ( 350, 105, 7 ), ( 350, 140, 6 ), ( 350, 175, 5 ), ( 350, 210, 4 ), ( 350, 245, 3 ), ( 350, 280, 2 ), ( 350, 315, 1 ),
( 385, 0, 11 ), ( 385, 35, 10 ), ( 385, 70, 9 ), ( 385, 105, 8 ), ( 385, 140, 7 ), ( 385, 175, 6 ), ( 385, 210, 5 ), ( 385, 245, 4 ), ( 385, 280, 3 ), ( 385, 315, 2 ), ( 385, 350, 1 ),
( 420, 0, 12 ), ( 420, 35, 11 ), ( 420, 70, 10 ), ( 420, 105, 9 ), ( 420, 140, 8 ), ( 420, 175, 7 ), ( 420, 210, 6 ), ( 420, 245, 5 ), ( 420, 280, 4 ), ( 420, 315, 3 ), ( 420, 350, 2 ), ( 420, 385, 1 ),
( 455, 0, 13 ), ( 455, 35, 12 ), ( 455, 70, 11 ), ( 455, 105, 10 ), ( 455, 140, 9 ), ( 455, 175, 8 ), ( 455, 210, 7 ), ( 455, 245, 6 ), ( 455, 280, 5 ), ( 455, 315, 4 ), ( 455, 350, 3 ), ( 455, 385, 2 ), ( 455, 420, 1 ),
( 490, 0, 14 ), ( 490, 35, 13 ), ( 490, 70, 12 ), ( 490, 105, 11 ), ( 490, 140, 10 ), ( 490, 175, 9 ), ( 490, 210, 8 ), ( 490, 245, 7 ), ( 490, 280, 6 ), ( 490, 315, 5 ), ( 490, 350, 4 ), ( 490, 385, 3 ), ( 490, 420, 2 ), ( 490, 455, 1 ),
...
}
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 "}"