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.
( 40, 0, 22 ), ( 40, 20, 11 ),
( 60, 0, 33 ), ( 60, 20, 22 ), ( 60, 40, 11 ),
( 80, 0, 44 ), ( 80, 20, 33 ), ( 80, 40, 22 ), ( 80, 60, 11 ),
( 100, 0, 55 ), ( 100, 20, 44 ), ( 100, 40, 33 ), ( 100, 60, 22 ), ( 100, 80, 11 ),
( 120, 0, 66 ), ( 120, 20, 55 ), ( 120, 40, 44 ), ( 120, 60, 33 ), ( 120, 80, 22 ), ( 120, 100, 11 ),
( 140, 0, 77 ), ( 140, 20, 66 ), ( 140, 40, 55 ), ( 140, 60, 44 ), ( 140, 80, 33 ), ( 140, 100, 22 ), ( 140, 120, 11 ),
( 160, 0, 88 ), ( 160, 20, 77 ), ( 160, 40, 66 ), ( 160, 60, 55 ), ( 160, 80, 44 ), ( 160, 100, 33 ), ( 160, 120, 22 ), ( 160, 140, 11 ),
( 180, 0, 99 ), ( 180, 20, 88 ), ( 180, 40, 77 ), ( 180, 60, 66 ), ( 180, 80, 55 ), ( 180, 100, 44 ), ( 180, 120, 33 ), ( 180, 140, 22 ), ( 180, 160, 11 ),
( 200, 0, 110 ), ( 200, 20, 99 ), ( 200, 40, 88 ), ( 200, 60, 77 ), ( 200, 80, 66 ), ( 200, 100, 55 ), ( 200, 120, 44 ), ( 200, 140, 33 ), ( 200, 160, 22 ), ( 200, 180, 11 ),
( 220, 0, 121 ), ( 220, 20, 110 ), ( 220, 40, 99 ), ( 220, 60, 88 ), ( 220, 80, 77 ), ( 220, 100, 66 ), ( 220, 120, 55 ), ( 220, 140, 44 ), ( 220, 160, 33 ), ( 220, 180, 22 ), ( 220, 200, 11 ),
( 240, 0, 132 ), ( 240, 20, 121 ), ( 240, 40, 110 ), ( 240, 60, 99 ), ( 240, 80, 88 ), ( 240, 100, 77 ), ( 240, 120, 66 ), ( 240, 140, 55 ), ( 240, 160, 44 ), ( 240, 180, 33 ), ( 240, 200, 22 ), ( 240, 220, 11 ),
( 260, 0, 143 ), ( 260, 20, 132 ), ( 260, 40, 121 ), ( 260, 60, 110 ), ( 260, 80, 99 ), ( 260, 100, 88 ), ( 260, 120, 77 ), ( 260, 140, 66 ), ( 260, 160, 55 ), ( 260, 180, 44 ), ( 260, 200, 33 ), ( 260, 220, 22 ), ( 260, 240, 11 ),
( 280, 0, 154 ), ( 280, 20, 143 ), ( 280, 40, 132 ), ( 280, 60, 121 ), ( 280, 80, 110 ), ( 280, 100, 99 ), ( 280, 120, 88 ), ( 280, 140, 77 ), ( 280, 160, 66 ), ( 280, 180, 55 ), ( 280, 200, 44 ), ( 280, 220, 33 ), ( 280, 240, 22 ), ( 280, 260, 11 ),
...
}
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 "}"