Verifying Exact Samplers for Continuous Distributions with a Discrete Program Logic
This paper introduces Continuous-Eris, a higher-order separation logic implemented in the Rocq proof assistant, to formally verify the correctness of exact sampling algorithms for continuous distributions like Gaussian and Laplace, addressing the security and accuracy limitations of floating-point approximations.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to bake a cake, but instead of using a standard measuring cup, you have to measure every ingredient by pouring water from a bucket into a tiny cup, one drop at a time. If you stop after 100 drops, you have an approximation of the amount. If you stop after 1,000, it's closer. But if you stop at any point, you've technically made a tiny mistake because you didn't get the exact amount.
In the world of computer science, this is exactly what happens when computers handle real numbers (like 3.14159...). They use "floating-point numbers," which are like those 100-drop approximations. For most things, this is fine. But for sensitive tasks—like protecting private data in medical studies or financial records—those tiny "rounding errors" can add up to big security leaks.
This paper introduces a new way to fix this problem. The authors built a tool called Continuous-Eris that helps programmers prove their code is doing exact sampling from continuous distributions (like picking a perfectly random number between 0 and 1) without ever making a rounding error.
Here is how they did it, using some creative analogies:
1. The Problem: The "Lazy" Chef
Usually, to get a random number between 0 and 1, a computer might try to generate the whole infinite sequence of digits (0.101101...) all at once. But that's impossible; you can't write down an infinite list.
Instead, the authors use a "lazy" approach. Imagine a chef who only peels an onion layer by layer, but only when you ask for it.
- The Code: The program
U(Uniform) doesn't generate the whole number immediately. It just creates an empty list. - The Request: When you ask for the first few digits (using a function called
GetBits), the program peels one layer (generates one random bit, 0 or 1). - The Magic: If you ask for more digits later, it peels another layer. It builds the number bit-by-bit, only as fast as you need it. This ensures you never have to deal with an infinite list, but you can get as precise an answer as you want.
2. The Challenge: Proving the Chef is Honest
The hard part isn't writing the code; it's proving that the lazy chef is actually picking numbers fairly.
- If the chef peels a layer, is it truly random?
- If you ask for 10 layers, is the resulting number truly distributed across the whole range?
- How do you prove this when the chef hasn't even finished peeling the onion yet?
Previous tools could only prove this for simple, discrete things (like rolling a die). They couldn't handle the "infinite onion" of continuous numbers, especially when the code was complex, used memory, and changed values on the fly.
3. The Solution: The "Infinite Tape" and "Time Receipts"
To solve this, the authors invented a new logic system (a set of rules for proving code correctness) that combines three clever tricks:
A. The "Pre-Drawn Tape" (Pre-sampling)
Imagine you are a magician. To prove your trick works, you secretly write down the entire sequence of cards you will pull from the deck before you even start the show.
In their logic, they use a "tape" that acts like this pre-written list. Even though the computer generates bits one by one, the proof assumes the whole infinite sequence of bits is already written down on a magical tape. This lets the mathematician reason about the "whole number" even though the program only sees "one bit at a time."
B. The "Time Receipt" (The Budget)
Here is the tricky part: A tape can't actually be infinite in a computer proof.
So, they use a concept called Time Receipts. Think of this as a "step budget."
- The logic says: "We are only going to watch the program run for 100 steps."
- Because the program only takes one step to generate one bit, if we only watch for 100 steps, we only need to know the first 100 bits on our magical tape.
- The "Time Receipt" is a token that says, "I have 100 steps left." Every time the program takes a step, you spend a receipt.
- This allows them to pretend the tape is infinite, because for any specific moment in the proof, they only need a finite number of bits, and they have a "receipt" to pay for them.
C. The "Error Credit" (The Safety Net)
Finally, they use Error Credits. Imagine you have a budget of "mistakes" you are allowed to make.
- If you want to prove the program is 99.9% correct, you spend 0.1% of your credit.
- The authors developed a way to "spend" these credits to prove that the probability of the program behaving incorrectly is vanishingly small.
- They figured out how to turn these discrete "mistake budgets" into a smooth, continuous math tool (using integrals) so they could prove the code works for the whole range of real numbers, not just specific points.
4. What They Actually Proved
Using this new system, the authors didn't just talk about theory; they built and verified actual code for:
- Uniform Distribution: Picking a random number between 0 and 1.
- Gaussian (Bell Curve): Picking a number that clusters around an average (like human heights).
- Laplace Distribution: A specific type of noise used in Differential Privacy (a method to share data without revealing individual secrets).
They proved that their code for these distributions is mathematically exact. If you use their code, you aren't getting a "close enough" floating-point number; you are getting a number that is guaranteed to follow the perfect mathematical rules, bit by bit.
The Bottom Line
The paper presents a new "rulebook" (Continuous-Eris) that allows programmers to write complex, lazy, exact sampling code and prove it is 100% correct. They did this by combining a "magical pre-written tape" with a "step-budget" system, allowing them to reason about infinite possibilities using finite, manageable steps. This is a major step forward for ensuring that privacy-preserving algorithms and other critical systems don't have hidden mathematical bugs caused by rounding errors.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.