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.
( 52, 0, 22 ), ( 52, 26, 11 ),
( 78, 0, 33 ), ( 78, 26, 22 ), ( 78, 52, 11 ),
( 104, 0, 44 ), ( 104, 26, 33 ), ( 104, 52, 22 ), ( 104, 78, 11 ),
( 130, 0, 55 ), ( 130, 26, 44 ), ( 130, 52, 33 ), ( 130, 78, 22 ), ( 130, 104, 11 ),
( 156, 0, 66 ), ( 156, 26, 55 ), ( 156, 52, 44 ), ( 156, 78, 33 ), ( 156, 104, 22 ), ( 156, 130, 11 ),
( 182, 0, 77 ), ( 182, 26, 66 ), ( 182, 52, 55 ), ( 182, 78, 44 ), ( 182, 104, 33 ), ( 182, 130, 22 ), ( 182, 156, 11 ),
( 208, 0, 88 ), ( 208, 26, 77 ), ( 208, 52, 66 ), ( 208, 78, 55 ), ( 208, 104, 44 ), ( 208, 130, 33 ), ( 208, 156, 22 ), ( 208, 182, 11 ),
( 234, 0, 99 ), ( 234, 26, 88 ), ( 234, 52, 77 ), ( 234, 78, 66 ), ( 234, 104, 55 ), ( 234, 130, 44 ), ( 234, 156, 33 ), ( 234, 182, 22 ), ( 234, 208, 11 ),
( 260, 0, 110 ), ( 260, 26, 99 ), ( 260, 52, 88 ), ( 260, 78, 77 ), ( 260, 104, 66 ), ( 260, 130, 55 ), ( 260, 156, 44 ), ( 260, 182, 33 ), ( 260, 208, 22 ), ( 260, 234, 11 ),
( 286, 0, 121 ), ( 286, 26, 110 ), ( 286, 52, 99 ), ( 286, 78, 88 ), ( 286, 104, 77 ), ( 286, 130, 66 ), ( 286, 156, 55 ), ( 286, 182, 44 ), ( 286, 208, 33 ), ( 286, 234, 22 ), ( 286, 260, 11 ),
( 312, 0, 132 ), ( 312, 26, 121 ), ( 312, 52, 110 ), ( 312, 78, 99 ), ( 312, 104, 88 ), ( 312, 130, 77 ), ( 312, 156, 66 ), ( 312, 182, 55 ), ( 312, 208, 44 ), ( 312, 234, 33 ), ( 312, 260, 22 ), ( 312, 286, 11 ),
( 338, 0, 143 ), ( 338, 26, 132 ), ( 338, 52, 121 ), ( 338, 78, 110 ), ( 338, 104, 99 ), ( 338, 130, 88 ), ( 338, 156, 77 ), ( 338, 182, 66 ), ( 338, 208, 55 ), ( 338, 234, 44 ), ( 338, 260, 33 ), ( 338, 286, 22 ), ( 338, 312, 11 ),
( 364, 0, 154 ), ( 364, 26, 143 ), ( 364, 52, 132 ), ( 364, 78, 121 ), ( 364, 104, 110 ), ( 364, 130, 99 ), ( 364, 156, 88 ), ( 364, 182, 77 ), ( 364, 208, 66 ), ( 364, 234, 55 ), ( 364, 260, 44 ), ( 364, 286, 33 ), ( 364, 312, 22 ), ( 364, 338, 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 "}"