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.
( 56, 0, 38 ), ( 56, 28, 19 ),
( 84, 0, 57 ), ( 84, 28, 38 ), ( 84, 56, 19 ),
( 112, 0, 76 ), ( 112, 28, 57 ), ( 112, 56, 38 ), ( 112, 84, 19 ),
( 140, 0, 95 ), ( 140, 28, 76 ), ( 140, 56, 57 ), ( 140, 84, 38 ), ( 140, 112, 19 ),
( 168, 0, 114 ), ( 168, 28, 95 ), ( 168, 56, 76 ), ( 168, 84, 57 ), ( 168, 112, 38 ), ( 168, 140, 19 ),
( 196, 0, 133 ), ( 196, 28, 114 ), ( 196, 56, 95 ), ( 196, 84, 76 ), ( 196, 112, 57 ), ( 196, 140, 38 ), ( 196, 168, 19 ),
( 224, 0, 152 ), ( 224, 28, 133 ), ( 224, 56, 114 ), ( 224, 84, 95 ), ( 224, 112, 76 ), ( 224, 140, 57 ), ( 224, 168, 38 ), ( 224, 196, 19 ),
( 252, 0, 171 ), ( 252, 28, 152 ), ( 252, 56, 133 ), ( 252, 84, 114 ), ( 252, 112, 95 ), ( 252, 140, 76 ), ( 252, 168, 57 ), ( 252, 196, 38 ), ( 252, 224, 19 ),
( 280, 0, 190 ), ( 280, 28, 171 ), ( 280, 56, 152 ), ( 280, 84, 133 ), ( 280, 112, 114 ), ( 280, 140, 95 ), ( 280, 168, 76 ), ( 280, 196, 57 ), ( 280, 224, 38 ), ( 280, 252, 19 ),
( 308, 0, 209 ), ( 308, 28, 190 ), ( 308, 56, 171 ), ( 308, 84, 152 ), ( 308, 112, 133 ), ( 308, 140, 114 ), ( 308, 168, 95 ), ( 308, 196, 76 ), ( 308, 224, 57 ), ( 308, 252, 38 ), ( 308, 280, 19 ),
( 336, 0, 228 ), ( 336, 28, 209 ), ( 336, 56, 190 ), ( 336, 84, 171 ), ( 336, 112, 152 ), ( 336, 140, 133 ), ( 336, 168, 114 ), ( 336, 196, 95 ), ( 336, 224, 76 ), ( 336, 252, 57 ), ( 336, 280, 38 ), ( 336, 308, 19 ),
( 364, 0, 247 ), ( 364, 28, 228 ), ( 364, 56, 209 ), ( 364, 84, 190 ), ( 364, 112, 171 ), ( 364, 140, 152 ), ( 364, 168, 133 ), ( 364, 196, 114 ), ( 364, 224, 95 ), ( 364, 252, 76 ), ( 364, 280, 57 ), ( 364, 308, 38 ), ( 364, 336, 19 ),
( 392, 0, 266 ), ( 392, 28, 247 ), ( 392, 56, 228 ), ( 392, 84, 209 ), ( 392, 112, 190 ), ( 392, 140, 171 ), ( 392, 168, 152 ), ( 392, 196, 133 ), ( 392, 224, 114 ), ( 392, 252, 95 ), ( 392, 280, 76 ), ( 392, 308, 57 ), ( 392, 336, 38 ), ( 392, 364, 19 ),
...
}
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 "}"