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.
( 44, 0, 26 ), ( 44, 22, 13 ),
( 66, 0, 39 ), ( 66, 22, 26 ), ( 66, 44, 13 ),
( 88, 0, 52 ), ( 88, 22, 39 ), ( 88, 44, 26 ), ( 88, 66, 13 ),
( 110, 0, 65 ), ( 110, 22, 52 ), ( 110, 44, 39 ), ( 110, 66, 26 ), ( 110, 88, 13 ),
( 132, 0, 78 ), ( 132, 22, 65 ), ( 132, 44, 52 ), ( 132, 66, 39 ), ( 132, 88, 26 ), ( 132, 110, 13 ),
( 154, 0, 91 ), ( 154, 22, 78 ), ( 154, 44, 65 ), ( 154, 66, 52 ), ( 154, 88, 39 ), ( 154, 110, 26 ), ( 154, 132, 13 ),
( 176, 0, 104 ), ( 176, 22, 91 ), ( 176, 44, 78 ), ( 176, 66, 65 ), ( 176, 88, 52 ), ( 176, 110, 39 ), ( 176, 132, 26 ), ( 176, 154, 13 ),
( 198, 0, 117 ), ( 198, 22, 104 ), ( 198, 44, 91 ), ( 198, 66, 78 ), ( 198, 88, 65 ), ( 198, 110, 52 ), ( 198, 132, 39 ), ( 198, 154, 26 ), ( 198, 176, 13 ),
( 220, 0, 130 ), ( 220, 22, 117 ), ( 220, 44, 104 ), ( 220, 66, 91 ), ( 220, 88, 78 ), ( 220, 110, 65 ), ( 220, 132, 52 ), ( 220, 154, 39 ), ( 220, 176, 26 ), ( 220, 198, 13 ),
( 242, 0, 143 ), ( 242, 22, 130 ), ( 242, 44, 117 ), ( 242, 66, 104 ), ( 242, 88, 91 ), ( 242, 110, 78 ), ( 242, 132, 65 ), ( 242, 154, 52 ), ( 242, 176, 39 ), ( 242, 198, 26 ), ( 242, 220, 13 ),
( 264, 0, 156 ), ( 264, 22, 143 ), ( 264, 44, 130 ), ( 264, 66, 117 ), ( 264, 88, 104 ), ( 264, 110, 91 ), ( 264, 132, 78 ), ( 264, 154, 65 ), ( 264, 176, 52 ), ( 264, 198, 39 ), ( 264, 220, 26 ), ( 264, 242, 13 ),
( 286, 0, 169 ), ( 286, 22, 156 ), ( 286, 44, 143 ), ( 286, 66, 130 ), ( 286, 88, 117 ), ( 286, 110, 104 ), ( 286, 132, 91 ), ( 286, 154, 78 ), ( 286, 176, 65 ), ( 286, 198, 52 ), ( 286, 220, 39 ), ( 286, 242, 26 ), ( 286, 264, 13 ),
( 308, 0, 182 ), ( 308, 22, 169 ), ( 308, 44, 156 ), ( 308, 66, 143 ), ( 308, 88, 130 ), ( 308, 110, 117 ), ( 308, 132, 104 ), ( 308, 154, 91 ), ( 308, 176, 78 ), ( 308, 198, 65 ), ( 308, 220, 52 ), ( 308, 242, 39 ), ( 308, 264, 26 ), ( 308, 286, 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 "}"