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.
( 70, 0, 26 ), ( 70, 35, 13 ),
( 105, 0, 39 ), ( 105, 35, 26 ), ( 105, 70, 13 ),
( 140, 0, 52 ), ( 140, 35, 39 ), ( 140, 70, 26 ), ( 140, 105, 13 ),
( 175, 0, 65 ), ( 175, 35, 52 ), ( 175, 70, 39 ), ( 175, 105, 26 ), ( 175, 140, 13 ),
( 210, 0, 78 ), ( 210, 35, 65 ), ( 210, 70, 52 ), ( 210, 105, 39 ), ( 210, 140, 26 ), ( 210, 175, 13 ),
( 245, 0, 91 ), ( 245, 35, 78 ), ( 245, 70, 65 ), ( 245, 105, 52 ), ( 245, 140, 39 ), ( 245, 175, 26 ), ( 245, 210, 13 ),
( 280, 0, 104 ), ( 280, 35, 91 ), ( 280, 70, 78 ), ( 280, 105, 65 ), ( 280, 140, 52 ), ( 280, 175, 39 ), ( 280, 210, 26 ), ( 280, 245, 13 ),
( 315, 0, 117 ), ( 315, 35, 104 ), ( 315, 70, 91 ), ( 315, 105, 78 ), ( 315, 140, 65 ), ( 315, 175, 52 ), ( 315, 210, 39 ), ( 315, 245, 26 ), ( 315, 280, 13 ),
( 350, 0, 130 ), ( 350, 35, 117 ), ( 350, 70, 104 ), ( 350, 105, 91 ), ( 350, 140, 78 ), ( 350, 175, 65 ), ( 350, 210, 52 ), ( 350, 245, 39 ), ( 350, 280, 26 ), ( 350, 315, 13 ),
( 385, 0, 143 ), ( 385, 35, 130 ), ( 385, 70, 117 ), ( 385, 105, 104 ), ( 385, 140, 91 ), ( 385, 175, 78 ), ( 385, 210, 65 ), ( 385, 245, 52 ), ( 385, 280, 39 ), ( 385, 315, 26 ), ( 385, 350, 13 ),
( 420, 0, 156 ), ( 420, 35, 143 ), ( 420, 70, 130 ), ( 420, 105, 117 ), ( 420, 140, 104 ), ( 420, 175, 91 ), ( 420, 210, 78 ), ( 420, 245, 65 ), ( 420, 280, 52 ), ( 420, 315, 39 ), ( 420, 350, 26 ), ( 420, 385, 13 ),
( 455, 0, 169 ), ( 455, 35, 156 ), ( 455, 70, 143 ), ( 455, 105, 130 ), ( 455, 140, 117 ), ( 455, 175, 104 ), ( 455, 210, 91 ), ( 455, 245, 78 ), ( 455, 280, 65 ), ( 455, 315, 52 ), ( 455, 350, 39 ), ( 455, 385, 26 ), ( 455, 420, 13 ),
( 490, 0, 182 ), ( 490, 35, 169 ), ( 490, 70, 156 ), ( 490, 105, 143 ), ( 490, 140, 130 ), ( 490, 175, 117 ), ( 490, 210, 104 ), ( 490, 245, 91 ), ( 490, 280, 78 ), ( 490, 315, 65 ), ( 490, 350, 52 ), ( 490, 385, 39 ), ( 490, 420, 26 ), ( 490, 455, 13 ),
...
}
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 "}"