The Program Is the Model
Auto-formalisation without AI for seL4 applications
Yan Liu (speaker) · Charlotte Fulham · Alex Potanin
Australian National University · Sapling, 4 December 2026
The model and the code are two artefacts, kept in step by hand.
On seL4 the kernel is proved, but assurance stops where the application’s components start to interact.
Re-derived after every change: the model cannot drift from what ships.
struct Frame {
len: uint16;
origin: uint8; // the NIC it came in on
data: uint8[2048];
}
Low MemoryRegion eth_outer_output(0x200000, 0x200000);
High MemoryRegion eth_inner_input(0x200000, 0x200000);
ProtectionDomain eth_outer(99, 79);
ProtectionDomain dd(150);
ProtectionDomain eth_inner(199, 78);
Chan o2d = eth_outer --> dd via eth_outer_output<Frame>;
Chan d2i = dd --> eth_inner via eth_inner_input<Frame>;
System = eth_outer ||| dd ||| eth_inner;
A network data diode: three components, two one-way channels.
A channel is a bounded buffer in shared memory.
--> is one-way: the diode's flow is a fact of two declarations.
import "include/eth.h" as eth;
evt poll: {
rx = eth.eth_poll();
kind = eth.eth_pkt_kind();
}
evt stage_forward:
frame = eth.eth_frame(ORIGIN_OUTER);
proc Drain() {
poll -> Skip;
[rx && kind == 1]
stage_forward -> o2d!frame -> Drain()
[] [rx && (kind == 2 || kind == 3)]
handle_ping -> Reply()
[] [rx && kind == 0] Drain()
default Skip;
}
/*@ ensures \result == 0 || \result == 1; */ bool eth_poll(void); /*@ ensures 0 <= \result <= 3; */ int64_t eth_pkt_kind(void); /*@ ensures \result.origin == origin; */ struct Frame eth_frame(uint8_t origin);
The loop states the orchestration once; reading and classifying a frame stays in C.
A contract says what the model needs of each function.
fire verify, step 1
Code verifiers prove the contracts: Frama-C WP, Viper.
fire verify, step 2
The model checker, verifyta, checks the queries.
Code called but not proved must be listed as assumed: here, the virtio-net driver.
Secrecy rests on the origin fixed by eth_frame's contract, proved on eth.c.
Same traffic under QEMU: behaves as the pure-C diode it replaces.
| Case study | Comp. | SLOC | Goals | Proof | States | Check |
|---|---|---|---|---|---|---|
| ping-pong (C) | 2 | 29 + 4 | 9 | 0.3 s | 35 | 0.09 s |
| ping-pong (Pancake) | 2 | 29 + 7 | 2† | 2.5 s | 35 | 0.09 s |
| timer | 1 | 31 + 100 | 47 | 1.8 s | 13 | 0.10 s |
| data diode | 3 | 119 + 489 | 110 | 3.1 s | 289,555 | 4.5 s |
| Ethernet bridge | 4 | 129 + 422 | 66 | 2.9 s | 50 M to 4.1 bn | 337 s to 8.9 h |
† contracts: Viper reports no goals.
Ethernet bridge · deadlock freedom · values a ring holds at most in the model
Next: data invariants, interleaving reductions proved safe.
Proved in Lean 4
Beneath: the proved seL4 kernel.
Trusted
No language model in the loop: the formal model is compiled from the program.
CoreFi calculus: arXiv:2611.40661 · Lean 4 mechanisation: github.com/fiducia-lang/fidus