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, 48 ), ( 70, 35, 24 ),
( 105, 0, 72 ), ( 105, 35, 48 ), ( 105, 70, 24 ),
( 140, 0, 96 ), ( 140, 35, 72 ), ( 140, 70, 48 ), ( 140, 105, 24 ),
( 175, 0, 120 ), ( 175, 35, 96 ), ( 175, 70, 72 ), ( 175, 105, 48 ), ( 175, 140, 24 ),
( 210, 0, 144 ), ( 210, 35, 120 ), ( 210, 70, 96 ), ( 210, 105, 72 ), ( 210, 140, 48 ), ( 210, 175, 24 ),
( 245, 0, 168 ), ( 245, 35, 144 ), ( 245, 70, 120 ), ( 245, 105, 96 ), ( 245, 140, 72 ), ( 245, 175, 48 ), ( 245, 210, 24 ),
( 280, 0, 192 ), ( 280, 35, 168 ), ( 280, 70, 144 ), ( 280, 105, 120 ), ( 280, 140, 96 ), ( 280, 175, 72 ), ( 280, 210, 48 ), ( 280, 245, 24 ),
( 315, 0, 216 ), ( 315, 35, 192 ), ( 315, 70, 168 ), ( 315, 105, 144 ), ( 315, 140, 120 ), ( 315, 175, 96 ), ( 315, 210, 72 ), ( 315, 245, 48 ), ( 315, 280, 24 ),
( 350, 0, 240 ), ( 350, 35, 216 ), ( 350, 70, 192 ), ( 350, 105, 168 ), ( 350, 140, 144 ), ( 350, 175, 120 ), ( 350, 210, 96 ), ( 350, 245, 72 ), ( 350, 280, 48 ), ( 350, 315, 24 ),
( 385, 0, 264 ), ( 385, 35, 240 ), ( 385, 70, 216 ), ( 385, 105, 192 ), ( 385, 140, 168 ), ( 385, 175, 144 ), ( 385, 210, 120 ), ( 385, 245, 96 ), ( 385, 280, 72 ), ( 385, 315, 48 ), ( 385, 350, 24 ),
( 420, 0, 288 ), ( 420, 35, 264 ), ( 420, 70, 240 ), ( 420, 105, 216 ), ( 420, 140, 192 ), ( 420, 175, 168 ), ( 420, 210, 144 ), ( 420, 245, 120 ), ( 420, 280, 96 ), ( 420, 315, 72 ), ( 420, 350, 48 ), ( 420, 385, 24 ),
( 455, 0, 312 ), ( 455, 35, 288 ), ( 455, 70, 264 ), ( 455, 105, 240 ), ( 455, 140, 216 ), ( 455, 175, 192 ), ( 455, 210, 168 ), ( 455, 245, 144 ), ( 455, 280, 120 ), ( 455, 315, 96 ), ( 455, 350, 72 ), ( 455, 385, 48 ), ( 455, 420, 24 ),
( 490, 0, 336 ), ( 490, 35, 312 ), ( 490, 70, 288 ), ( 490, 105, 264 ), ( 490, 140, 240 ), ( 490, 175, 216 ), ( 490, 210, 192 ), ( 490, 245, 168 ), ( 490, 280, 144 ), ( 490, 315, 120 ), ( 490, 350, 96 ), ( 490, 385, 72 ), ( 490, 420, 48 ), ( 490, 455, 24 ),
...
}
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 "}"