Sum of Distinct Fibonacci Numbers (Some Proofs)
Sep. 9, 2021, 15:23:02
A couple of days ago, my friends and I worked together on an algorithm problem we found online. I proposed a potential solution but I didn't come up with a proper proof for it. Intuition says the theory is correct, but an actual proof for it requires multiple steps as dictated here.
The question is - "Given 2 positive integers,
My Solution
There are 3 steps to my solution:
1. Find the minimum number of distinct Fibonacci numbers
2. Find the maximum number of such Fibonacci numbers.
3. Check whether
Step 1
To find the minimum set of Fib numbers, I proposed the theory that "the smallest set of distinct Fibonacci numbers that sum to
Lemma 1: Every positive integers can be written as a sum of distinct Fib numbers.
There is already a theorem that indirectly proves this statement - the Zeckendorf's theorem, but it's better to prove it ourselves as the proof is simple to write and serves as a good refresher on "Proof by Induction" which we will use later for the statement above.
Base Case:
1 and 2 can be written as a sum of distinct Fib numbers (ie. they are Fib numbers themselves).
Induction Hypothesis:
Assume the statement is true for ALL positive number
Induction Case:
We know if
Let
Then by our induction hypothesis, we know
Lemma 2: The sum of the first distinct
This fact is easily proven by writing out each Fib number as the difference between 2 of its immediate larger Fib numbers. So,
Proof: The smallest set of distinct Fib numbers that sums to
Let's define a convenient function
Base Case:
Induction Hypothesis:
Assume the statement is true for ALL
Induction Case:
Let's define
Because we know from Lemma 2 that the sum of the first
So we can split
From our definition of
By the induction hypothesis, we know the minimum set of distinct Fib numbers for
Therefore, the smallest set must contain
Now with the proof in place, we can device a greedy algorithm that repeatedly takes the largest Fib number possible until we get a sum equal to
Step 2
Once we know the smallest set, we can try expanding it by breaking the numbers in this set into smaller numbers to obtain the maximum set.
An orderly way of achieving this is to start with the smallest number in the set and break it into numbers as small as possible. However, if breaking the current number results in duplicate Fib numbers being used, we would stop.
Lemma 3: All sets of distinct Fib numbers that sum to
Let's prove by contradiction. Assume we have a set of distinct Fib numbers
From Lemma 2 we know
However, by the definition of
The only valid next choices from this stage on are
In the end, there are only 2 possibilities: the last Fib number included is either
However, adding a
It's easy to see that if we apply this fact repeatedly on
Now that we know all valid sets that have a sum of
But how do we transform
It is worth noting that there is only one way to break a single Fib number - breaking
To break multiple numbers, we must follow certain rules to not introduce duplicates. During the process of breaking down a larger Fib number, and when the sequence of numbers being broken into, overlaps with a smaller Fib number, the breaking stops. Otherwise, we will certainly introduce duplicates. For example, let's assume
Therefore, we must break a Fib number as many times as permitted if the final sequence doesn't overlap with other Fib numbers.
Step 3
We check whether
Code
Min Set: Max Set: