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.
( 58, 0, 40 ), ( 58, 29, 20 ),
( 87, 0, 60 ), ( 87, 29, 40 ), ( 87, 58, 20 ),
( 116, 0, 80 ), ( 116, 29, 60 ), ( 116, 58, 40 ), ( 116, 87, 20 ),
( 145, 0, 100 ), ( 145, 29, 80 ), ( 145, 58, 60 ), ( 145, 87, 40 ), ( 145, 116, 20 ),
( 174, 0, 120 ), ( 174, 29, 100 ), ( 174, 58, 80 ), ( 174, 87, 60 ), ( 174, 116, 40 ), ( 174, 145, 20 ),
( 203, 0, 140 ), ( 203, 29, 120 ), ( 203, 58, 100 ), ( 203, 87, 80 ), ( 203, 116, 60 ), ( 203, 145, 40 ), ( 203, 174, 20 ),
( 232, 0, 160 ), ( 232, 29, 140 ), ( 232, 58, 120 ), ( 232, 87, 100 ), ( 232, 116, 80 ), ( 232, 145, 60 ), ( 232, 174, 40 ), ( 232, 203, 20 ),
( 261, 0, 180 ), ( 261, 29, 160 ), ( 261, 58, 140 ), ( 261, 87, 120 ), ( 261, 116, 100 ), ( 261, 145, 80 ), ( 261, 174, 60 ), ( 261, 203, 40 ), ( 261, 232, 20 ),
( 290, 0, 200 ), ( 290, 29, 180 ), ( 290, 58, 160 ), ( 290, 87, 140 ), ( 290, 116, 120 ), ( 290, 145, 100 ), ( 290, 174, 80 ), ( 290, 203, 60 ), ( 290, 232, 40 ), ( 290, 261, 20 ),
( 319, 0, 220 ), ( 319, 29, 200 ), ( 319, 58, 180 ), ( 319, 87, 160 ), ( 319, 116, 140 ), ( 319, 145, 120 ), ( 319, 174, 100 ), ( 319, 203, 80 ), ( 319, 232, 60 ), ( 319, 261, 40 ), ( 319, 290, 20 ),
( 348, 0, 240 ), ( 348, 29, 220 ), ( 348, 58, 200 ), ( 348, 87, 180 ), ( 348, 116, 160 ), ( 348, 145, 140 ), ( 348, 174, 120 ), ( 348, 203, 100 ), ( 348, 232, 80 ), ( 348, 261, 60 ), ( 348, 290, 40 ), ( 348, 319, 20 ),
( 377, 0, 260 ), ( 377, 29, 240 ), ( 377, 58, 220 ), ( 377, 87, 200 ), ( 377, 116, 180 ), ( 377, 145, 160 ), ( 377, 174, 140 ), ( 377, 203, 120 ), ( 377, 232, 100 ), ( 377, 261, 80 ), ( 377, 290, 60 ), ( 377, 319, 40 ), ( 377, 348, 20 ),
( 406, 0, 280 ), ( 406, 29, 260 ), ( 406, 58, 240 ), ( 406, 87, 220 ), ( 406, 116, 200 ), ( 406, 145, 180 ), ( 406, 174, 160 ), ( 406, 203, 140 ), ( 406, 232, 120 ), ( 406, 261, 100 ), ( 406, 290, 80 ), ( 406, 319, 60 ), ( 406, 348, 40 ), ( 406, 377, 20 ),
...
}
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 "}"