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.
( 42, 0, 27 ), ( 42, 14, 18 ), ( 42, 28, 9 ),
( 56, 0, 36 ), ( 56, 14, 27 ), ( 56, 28, 18 ), ( 56, 42, 9 ),
( 70, 0, 45 ), ( 70, 14, 36 ), ( 70, 28, 27 ), ( 70, 42, 18 ), ( 70, 56, 9 ),
( 84, 0, 54 ), ( 84, 14, 45 ), ( 84, 28, 36 ), ( 84, 42, 27 ), ( 84, 56, 18 ), ( 84, 70, 9 ),
( 98, 0, 63 ), ( 98, 14, 54 ), ( 98, 28, 45 ), ( 98, 42, 36 ), ( 98, 56, 27 ), ( 98, 70, 18 ), ( 98, 84, 9 ),
( 112, 0, 72 ), ( 112, 14, 63 ), ( 112, 28, 54 ), ( 112, 42, 45 ), ( 112, 56, 36 ), ( 112, 70, 27 ), ( 112, 84, 18 ), ( 112, 98, 9 ),
( 126, 0, 81 ), ( 126, 14, 72 ), ( 126, 28, 63 ), ( 126, 42, 54 ), ( 126, 56, 45 ), ( 126, 70, 36 ), ( 126, 84, 27 ), ( 126, 98, 18 ), ( 126, 112, 9 ),
( 140, 0, 90 ), ( 140, 14, 81 ), ( 140, 28, 72 ), ( 140, 42, 63 ), ( 140, 56, 54 ), ( 140, 70, 45 ), ( 140, 84, 36 ), ( 140, 98, 27 ), ( 140, 112, 18 ), ( 140, 126, 9 ),
( 154, 0, 99 ), ( 154, 14, 90 ), ( 154, 28, 81 ), ( 154, 42, 72 ), ( 154, 56, 63 ), ( 154, 70, 54 ), ( 154, 84, 45 ), ( 154, 98, 36 ), ( 154, 112, 27 ), ( 154, 126, 18 ), ( 154, 140, 9 ),
( 168, 0, 108 ), ( 168, 14, 99 ), ( 168, 28, 90 ), ( 168, 42, 81 ), ( 168, 56, 72 ), ( 168, 70, 63 ), ( 168, 84, 54 ), ( 168, 98, 45 ), ( 168, 112, 36 ), ( 168, 126, 27 ), ( 168, 140, 18 ), ( 168, 154, 9 ),
( 182, 0, 117 ), ( 182, 14, 108 ), ( 182, 28, 99 ), ( 182, 42, 90 ), ( 182, 56, 81 ), ( 182, 70, 72 ), ( 182, 84, 63 ), ( 182, 98, 54 ), ( 182, 112, 45 ), ( 182, 126, 36 ), ( 182, 140, 27 ), ( 182, 154, 18 ), ( 182, 168, 9 ),
( 196, 0, 126 ), ( 196, 14, 117 ), ( 196, 28, 108 ), ( 196, 42, 99 ), ( 196, 56, 90 ), ( 196, 70, 81 ), ( 196, 84, 72 ), ( 196, 98, 63 ), ( 196, 112, 54 ), ( 196, 126, 45 ), ( 196, 140, 36 ), ( 196, 154, 27 ), ( 196, 168, 18 ), ( 196, 182, 9 ),
...
}
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 "}"