← Latest papers
💻 computer science

Contextual Refinement of Higher-Order Concurrent Probabilistic Programs (Extended Version)

This paper introduces Foxtrot, the first higher-order separation logic that enables the mechanized proof of contextual refinement for higher-order concurrent probabilistic programs with local state by integrating advanced concurrency and probabilistic reasoning principles, including a novel reliance on the axiom of choice within the Iris framework.

Original authors: Kwing Hei Li, Alejandro Aguirre, Joseph Tassarotti, Lars Birkedal

Published 2026-04-20
📖 7 min read🧠 Deep dive

Original authors: Kwing Hei Li, Alejandro Aguirre, Joseph Tassarotti, Lars Birkedal

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

The Big Picture: A High-Stakes Game of "Copycat"

Imagine you are a quality control inspector for a software factory. You have two machines:

  1. Machine A (The Implementation): A complex, messy machine that uses random dice rolls and has multiple workers (threads) running at the same time, sometimes getting in each other's way.
  2. Machine B (The Specification): A simple, perfect machine that does exactly what the customer wants to happen, with no mess or randomness.

Your job is to prove that Machine A is safe to use. You need to show that no matter how you try to trick Machine A (by changing the order of workers or the dice rolls), it will never produce a result that Machine B couldn't also produce. In computer science, this is called proving Contextual Refinement.

The problem? When you mix randomness (dice rolls) with concurrency (multiple workers racing), the math gets incredibly messy. It's like trying to predict the outcome of a card game where the deck is being shuffled by three different people simultaneously, and the cards themselves are slightly sticky.

Enter Foxtrot.


What is Foxtrot?

Foxtrot is a new set of rules (a "logic") invented by the authors to help inspectors prove that Machine A is just as good as Machine B, even when things are chaotic. Think of Foxtrot as a super-powered magnifying glass that can see through the chaos of randomness and multitasking to find the hidden order.

Before Foxtrot, we had tools to check simple programs or programs with just randomness, or just multitasking. But we didn't have a tool that could handle all three at once:

  1. High-Order: Functions that can pass other functions around (like a manager hiring a subcontractor who hires another subcontractor).
  2. Concurrency: Multiple threads running at once.
  3. Probability: Randomness and chance.

The Three Magic Tricks of Foxtrot

To solve this messy problem, Foxtrot uses three clever "tricks" (reasoning principles). Here is how they work, using analogies:

1. The "Presampling Tape" (The Crystal Ball)

Imagine you are trying to prove that two people rolling dice will get the same result.

  • The Problem: In a concurrent program, Thread A rolls a die, then Thread B rolls a die. You can't just say "Thread A's roll equals Thread B's roll" because they happen at different times.
  • The Foxtrot Trick: Foxtrot introduces a "Presampling Tape." Think of this as a magical roll of film. Before the game even starts, Foxtrot secretly writes down all the dice rolls that will happen on this tape.
  • How it helps: When Thread A needs a number, Foxtrot says, "Don't roll yet! Just look at the tape and take the next number." This allows the inspector to line up the dice rolls from the messy machine (Machine A) with the perfect machine (Machine B) before they actually happen, making it easy to compare them.

2. The "Error Credit" (The Budget for Mistakes)

Sometimes, you can't prove two machines are exactly the same. Maybe Machine A has a 0.0001% chance of doing something weird that Machine B never does.

  • The Problem: In strict math, even a tiny chance of failure means the proof fails.
  • The Foxtrot Trick: Foxtrot gives you "Error Credits." Imagine you have a budget of "mistakes" you are allowed to make. You can say, "I will prove these machines are the same, provided I am allowed a tiny error budget of 0.0001."
  • The Magic: Foxtrot has a rule called "Induction by Error Amplification." It's like a magic trick where you can take a tiny error budget, use it to prove a step, and then get more error budget back. If you can keep doing this forever, you prove that the total error is effectively zero. It's like proving you can walk across a tightrope by taking steps so small that the wobble disappears.

3. The "Fragmented Coupling" (The Rejection Sampler)

Some programs work by "rejection sampling." Imagine you want a number between 1 and 10, but you only have a die that rolls 1 to 100. You roll the die; if it's 1-10, you keep it. If it's 11-100, you throw it away and roll again.

  • The Problem: This creates a loop. You might roll 50 times before you get a "keep." How do you prove this loop is safe?
  • The Foxtrot Trick: Foxtrot uses "Fragmented Coupling." Instead of trying to match every single roll, it matches the successful rolls. It says, "If the messy machine accepts a number, the perfect machine must also accept a number." If the messy machine rejects a number (rolls 11-100), the perfect machine doesn't have to do anything. It's like a bouncer at a club: if the messy machine lets someone in, the perfect club must also let them in. If the messy machine turns someone away, the perfect club doesn't care.

Why is this a Big Deal? (The "Axiom of Choice" Twist)

The paper mentions a very technical challenge: proving that Foxtrot works requires using a version of the Axiom of Choice.

The Analogy:
Imagine you have a infinite number of boxes, and inside each box is a different way to organize a team of workers. To prove your logic works, you have to pick one specific way to organize the workers for every possible scenario.

  • In normal math, you can just say "Pick one."
  • In the world of computer logic (specifically the Iris framework used here), you usually can't just "pick" things arbitrarily because it breaks the rules of the system.
  • The Breakthrough: The authors figured out a way to use this "picking" rule (Axiom of Choice) safely within their specific system. This is like finding a secret backdoor that lets you organize the infinite boxes without breaking the laws of physics. This is what makes Foxtrot's underlying math so strong and new.

Real-World Examples They Tested

The authors didn't just write theory; they tested Foxtrot on real-world problems:

  1. The Adversarial Coin: A coin flipper that is being hacked by an enemy who can change the coin's weight while it's being flipped. Foxtrot proved that even with the hacker, the coin still behaves like a fair coin.
  2. Sodium (Cryptography): A famous security library. They proved that a specific function used to generate random numbers for encryption is safe to use, even if other parts of the program are running at the same time. This is crucial because if random number generation fails, your encryption fails.

Summary

Foxtrot is a new, powerful tool for software engineers and mathematicians. It allows them to prove that complex, chaotic, random, multi-threaded programs are safe and correct.

  • Old way: "I hope this works, but I can't prove it because the math is too hard."
  • Foxtrot way: "I can prove it works, even with the chaos, by using magical tapes to predict the future, a budget for tiny mistakes, and a way to match up the good outcomes."

All of this has been checked by a computer (the Rocq proof assistant), so we know the rules are 100% solid. It's a giant leap forward for making secure, reliable software in a world where randomness and multitasking are everywhere.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →