Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 1 of 3

Canonical digits and injections from a square

Resolve positional ambiguity, prove canonical expansions exist uniquely, and encode two real numbers without mistaking an injection for a bijection.

Loading your saved responses…

Try the optional starting-point checks and targeted refreshers. You can continue directly into this lesson.

Try

Can two numbers between zero and one be stored in the digits of a single number? Start with binary notation, where the first fractional place is worth 1/2, the second 1/4, the third 1/8, and so on. Take x=1/2 and y=1/4. Write their expansions with trailing zeros, and place x’s digits in odd positions and y’s digits in even positions.

Position within each input123Later positions
x=1/2100All zero
y=1/4010All zero
Output pair of digits100100All zero
Output place values for this pair1/2, 1/41/8, 1/161/32, 1/64Successive halves

The output is binary 0.1001000… with all remaining digits zero, equal to 1/2+1/16=9/16. Circle the odd output positions and recover x; circle the even positions and recover y. This table suggests a reversible encoding, but it is not yet a proof for arbitrary real inputs.

There is a trap: 1/2 also equals binary 0.011111…. Indeed the sum of 1/4+1/8+1/16+⋯ is 1/2. If we use that expansion instead while keeping y’s expansion, the output becomes 0.0011101010…, a different number. Its value is 1/16 plus the sum of the odd-position terms starting at position 3, namely 1/16+1/6=11/48. One input pair must not be assigned two outputs. We need an explicit convention before defining the map.

Predict

Our convention is to exclude digit streams that are eventually all maximal digits. In binary, exclude a stream that becomes all ones after some position. In decimal, exclude one that becomes all nines. Trailing zeros are allowed. “Eventually” includes streams with a long nonconstant beginning: the issue is the infinite tail, not the first few digits.

Predict which representations are canonical: decimal 0.249999…, decimal 0.250000…, and binary 0.010101…. The first is excluded; the second and third are allowed. A repeating pattern that contains infinitely many zeros is not eventually one. The interval is [0,1), so binary 0.111111… represents an excluded endpoint, not a permissible input.

Now predict whether every canonical binary output can be split into two canonical inputs. Consider 0.101010…. Its full stream contains infinitely many zeros. Its odd-position stream, however, contains only ones. Canonicality of a full stream does not imply canonicality of its two subsequences. We will use this distinction to disprove surjectivity.

Experiment

On paper encode x=1/4 and y=3/4. Keep four digits of each, mark the output positions, and convert the result to a fraction. Then exchange x and y. Does the encoding preserve the order of the pair?

Check both ordered pairs

The first pair has input streams 0100… and 1100…, producing 01110000…=7/16. Exchanging the inputs produces 10110000…=11/16. The odd/even assignment is part of the definition, so swapping the inputs generally changes the output. These finite terminating examples use canonical streams.

For a nonterminating example, split binary 0.101010… into odd and even positions. The two subsequences have values 1 and 0, so the first is outside [0,1). Do not “repair” it to a different input expansion and assume the output stays unchanged. The proposed map always uses the canonical expansion of each permitted input.

If you write only m digits of each input, you determine only 2m output digits. Filling the rest with zeros produces a lower approximation. The omitted binary tail is less than 2 raised to the power −2m for a canonical output. This is a numerical error bound, not proof that two infinite digit strings agree.

Understand

Fix an integer base b≥2. A digit is an integer from 0 through b−1. A stream of digits d₁,d₂,… represents the sum of dₙb^(−n) over positive integers n. Its partial sums increase and are bounded above by the geometric series with every digit b−1, whose value is 1. Thus the series exists. We call a stream canonical when it is not eventually b−1.

Existence. For x in [0,1), begin with remainder r₀=x. At each step set dₙ=floor(brₙ₋₁) and rₙ=brₙ₋₁−dₙ. Since each remainder lies in [0,1), each digit lies from 0 to b−1 and the new remainder again lies in [0,1). Repeated substitution gives

x = d₁/b + d₂/b² + ⋯ + dₙ/bⁿ + rₙ/bⁿ.

The last term is nonnegative and less than b^(−n), so the digit series converges to x. If the digits from some position N onward were all b−1, the same tail identity would give r at position N−1 equal to the geometric sum (b−1)/b+(b−1)/b²+⋯=1. This contradicts the remainder bound. The algorithm therefore produces a canonical expansion, including for zero, whose digits are all zero.

Uniqueness and the precise ambiguity. Suppose two distinct expansions have equal values and first differ at position k. Call the smaller digit there aₖ and the larger cₖ. Their difference contributes at least b^(−k). Every later digit difference together can cancel at most

(b−1) times the sum of b^(−j) for j greater than k, which equals b^(−k).

Consequently the first digit difference must be exactly one. Moreover, cancellation must be maximal at every later position: the stream with smaller kth digit has only b−1 afterward, and the other has only zeros afterward. A strict deficit in even one tail term would make full cancellation impossible. Thus the only ambiguity is a terminating expansion versus its maximal-tail alternative. Two canonical expansions cannot have this ambiguity, establishing uniqueness.

The injection. Expand x and y canonically in binary as a₁,a₂,… and b₁,b₂,…, then define I(x,y) by the stream a₁,b₁,a₂,b₂,…. Each input has infinitely many zero digits, so the output does too. Its value is below 1: the all-one sum is 1 and at least one positive term is missing. It is nonnegative and canonical, hence is a valid member of [0,1).

If I(x,y)=I(u,v), uniqueness makes their entire canonical output streams identical. Reading odd positions gives identical canonical streams for x and u, hence x=u; reading even positions gives y=v. This proves injectivity. It is not enough to say that the first few displayed digits can be decoded.

The image is smaller than the codomain. The number 2/3 has canonical binary expansion 0.101010…, by a geometric sum with first term 1/2 and ratio 1/4. Its odd subsequence is all ones, so no permitted input pair can encode it. More generally, an output is in the image exactly when both odd and even subsequences are not eventually one. Necessity follows from construction and uniqueness. Conversely, two such subsequences each represent a number below one and are its canonical expansion; interleaving those numbers reproduces the output. This proves both directions of the image description.

Apply

Try a changed base. Group each pair of binary digits into a single base-four digit eₙ=2aₙ+bₙ. The pairs 00, 01, 10, 11 become 0, 1, 2, 3. An eventual tail of threes would force both inputs eventually one, which is impossible. Uniqueness in base four now recovers each eₙ, and division by two recovers its ordered pair of bits. This is another injection, not automatically a surjection. For instance a constant base-four stream of twos would demand an all-one first input.

For a different domain, allow an arbitrary infinite binary stream and encode its digits directly as base-four digits 0 and 1. At the first disagreement k, the leading difference is 4^(−k), while the entire later tail difference is at most 4^(−k)/3. A positive gap remains, so no two streams have equal outputs. This stricter tail bound needs no canonical restriction on the input streams. State the input domain whenever using this alternative: a stream space and the real interval with chosen representations are related but are not interchangeable definitions.

Check a finite-prefix boundary

If the input prefixes are 11 and 00, the output prefix is 1010, with value 5/8. All encoded outputs sharing that prefix lie in [5/8,11/16). The upper endpoint would require an all-one output tail, so it is excluded. Further zeros and ones can still change the value within the interval; a finite table cannot establish uniqueness of infinite expansions.

Continue

The practice asks for proofs of the expansion algorithm, the ambiguity classification and the injection, as well as an exact description of failed decoding. Keep existence, uniqueness, injectivity and surjectivity as separate claims. A map from the interval into its square is easy to construct by sending x to the ordered pair (x,0); it is injective too. Turning these two injections into a bijection requires a separate two-injection theorem and its proof. That is the next mathematical step, not a conclusion already established by unrestricted digit splitting.

Apply · explain · revise

Practice and reasoning

Drafts save locally as you type. Reveal worked solutions when useful; the site remembers that exposure. Automatic matches check the requested answer, while written arguments require review against the rubric.

For an integer base b≥2 and x∈[0,1), set r₀=x, dₙ=floor(brₙ₋₁), rₙ=brₙ₋₁−dₙ. Prove the digit bounds, remainder identity, convergence to x, and the fact that the digit sequence is not eventually b−1. Then compute the canonical binary expansion of 5/8.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Two distinct base-b digit sequences represent the same number. At their first differing position k assume aₖ<cₖ. Prove their digits differ there by exactly one, the a-tail after k consists entirely of b−1, and the c-tail entirely of zeros. Deduce uniqueness under the convention not eventually b−1. Check 0.23000…=0.22999… in base ten.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Define I(x,y) by alternating the canonical binary digits of x and y, placing x in odd positions. Prove this produces a canonical expansion of a number in [0,1) and proves I injective. Compute I(3/4,1/4). Explain why choosing arbitrary expansions instead would not define a unique procedure.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Prove that 2/3 is not in the image of the canonical interleaving map, even though it is in [0,1). Characterize the image exactly using the odd and even subsequences of the canonical output digits. Test 1/3 as a second excluded point.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

A table contains only the first m binary digits of each of two inputs. Prove an error bound for the value obtained by interleaving those prefixes and filling remaining positions with zeros. Explain why agreement of finite prefixes cannot establish equality of the original inputs or prove global injectivity. For m=2 and prefixes 10 and 01, compute the truncated output and an interval enclosing every possible output.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Encode each pair of canonical binary input streams by the base-four stream eₙ=2aₙ+bₙ. Prove this also injects [0,1)² into [0,1), without asserting surjectivity. Then consider encoding a single unrestricted binary stream using base-four digits only 0 and 1. Show directly that a first differing digit cannot be canceled by its tail, even for eventual-one binary streams.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Reflect and continue

Before marking this lesson complete, explain one key idea without the worked solution and identify a condition that matters. Marking complete records participation, not independent mastery.