Fiducia Sapling Talk

Fiducia

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

1The workflow
2The example
3Results
1.1

Without auto-formalisation

The model and the code are two artefacts, kept in step by hand.

  1. The model is abstracted by hand from the code and the design documents.
  2. It drifts. Once the code moves on, what was verified is no longer what ships, and nothing says so.

On seL4 the kernel is proved, but assurance stops where the application’s components start to interact.

the code the model v1 v2 v3 what ships changes changes model of v1 verified by hand still true?
1.2

One program, two readings

the Fiducia compiler, fic
properties *.q system program *.fis component programs *.fi foreign code, contracts *.c *.pnk dashed: written by the developer everything else is generated parse, validate flatten Ccfg VERIFICATION BACKEND lower UPPAAL model verifyta with the contracts, proved by Frama-C WP and Viper pass, or a counterexample lower generated C bootable image linked with the foreign code by MicroKit's own build tool COMPILATION BACKEND one graph, read twice

Re-derived after every change: the model cannot drift from what ships.

2.1

The system program

datadiode.fis · excerpt
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.

2.2

Orchestration in Fiducia, computation in FFI (e.g., C)

eth_outer.fi · include/eth.h
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.

2.3

fire: build, run, verify

live demo
$ fire build demo/datadiode/ # a bootable seL4 MicroKit image
$ fire run demo/datadiode/ # boot it under QEMU
$ fire verify demo/datadiode/ # prove the contracts, check the model

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.

3.1

What holds on the diode's model

spec/datadiode.q
Never stuck
A[] not deadlock
A frame crosses
E<> dd.L2  ·  E<> eth_inner.Deliver
No lost wake-up
A[] not (!dd.awake && q_o2d.length > 0 && !pend_o2d)
Secrecy
A[] not (eth_outer.frame.origin == ORIGIN_INNER || dd.f.origin == ORIGIN_INNER || (exists (i : int[0, 2]) q_o2d_val[i].origin == ORIGIN_INNER))

Secrecy rests on the origin fixed by eth_frame's contract, proved on eth.c.

110goals proved by WP, 3.1 s
289,555states explored, 4.5 s
7queries, all hold

Same traffic under QEMU: behaves as the pure-C diode it replaces.

3.2

Four case studies

SLOC: Fiducia + foreign
Case studyComp.SLOCGoalsProofStatesCheck
ping-pong (C)229 + 490.3 s350.09 s
ping-pong (Pancake)229 + 72†2.5 s350.09 s
timer131 + 100471.8 s130.10 s
data diode3119 + 4891103.1 s289,5554.5 s
Ethernet bridge4129 + 422662.9 s50 M to 4.1 bn337 s to 8.9 h
  • All boot under QEMU; contracts proved, queries hold.
  • Ping-pong in C and in Pancake emit the same model, character for character.

† contracts: Viper reports no goals.

3.3

Model size follows the interaction, not the code

Ethernet bridge · deadlock freedom · values a ring holds at most in the model

cap 150,032,709337 s · 4.6 GiB
× 4.3
cap 2215,342,4871,544 s · 19.6 GiB
× 19
cap 3, as emitted4,106,491,7058.9 h · 351 GiB
  • Diode: 489 lines of C, 289,555 states. Bridge: 422 lines, billions.
  • Contracts keep the code out; queues and device input remain.
  • A queue of capacity N holds any sequence up to N, and four queues multiply.

Next: data invariants, interleaving reductions proved safe.

3.4

What is proved, what is trusted

Proved in Lean 4

  • The channel runtime's model implements CoreFi's channel rules; no lost wake-up.
  • Its index arithmetic matches our Rust, via Aeneas.
  • The compiler’s intermediate graph is bisimilar to CoreFi’s semantics.

Beneath: the proved seL4 kernel.

Trusted

  • fic and MicroKit.
  • Frama-C WP, Viper, UPPAAL.
  • Each contract's author, human or AI.
  • Assumed code: the virtio-net driver.

The program is the model

  1. Separate the concerns. Communication in Fiducia; computation in C or Pancake.
  2. One program, two readings. The image and the model cannot drift apart.
  3. Contracts are the abstraction. Proved on the code, lifted into the model.
fiducia-lang.github.io

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