interplane.Get Omega
Read in your language

mailhand

mailhand: agents look after a person's email in seeded Omega. Maildir + MIME parsing, JSONL CLI and MCP, rule triage, policy-gated sending, hash-chained audit. Free (Apache-2.0).

Brought by drakestapleton

branch main Branches Tags History

mailhand / proofs / README.md

116 lines · 5435 bytes Raw Blame History Source

Mailhand proofs

Mailhand.lean is a plain Lean 4 file (core library only: no Mathlib, no unfinished proofs, no axiom declarations, no native_decide). It proves facts about two small models. It does not prove anything about the compiled Omega program itself: the models are hand-written from the algorithm description in the task brief, and src/mime.om did not exist yet when they were written, so the match between model and code has to be checked by reading the code against the model below.

How to check

From the repository root, with a Lean 4 toolchain (4.35.0 was used for the recorded check):

lean proofs/Mailhand.lean; echo exit=$?

Expected: exit=0 and these axiom lines (only Lean's standard axioms):

'Mailhand.B64.decode_length' depends on axioms: [propext, Classical.choice, Quot.sound]
'Mailhand.B64.decode_bound' depends on axioms: [propext, Classical.choice, Quot.sound]
'Mailhand.Chain.chain_unique' depends on axioms: [propext, Classical.choice, Quot.sound]
'Mailhand.Chain.single_change_detected' depends on axioms: [propext, Classical.choice, Quot.sound]
'Mailhand.Chain.truncation_verifies' depends on axioms: [propext]
'Mailhand.B64.lenient_breaks_bound' depends on axioms: [propext]
'Mailhand.Chain.needs_injective' does not depend on any axioms
'Mailhand.Chain.needs_fixed_length' does not depend on any axioms

Toolchain: Lean 4.35.0 (~/.elan/bin/lean --version).

Part 1: base64 decoder

Model (Mailhand.B64.decode)

The input is a list of bytes. The model produces the decoded bytes, not just a count:

Proved

Not proved

Part 2: hash-chain audit log

Model (Mailhand.Chain)

A log is a list of records (body, stored). Verification starts with prev = genesis. For each record it requires stored = H(prev ++ body) and then sets prev := stored. The head is the last stored value, or genesis if the log is empty.

H stands for SHA-256. Each theorem that needs facts about H takes them as hypotheses. They are not added as axioms:

  1. H is injective (no two inputs give the same output). This is an idealisation of collision resistance. Real SHA-256 does have collisions; they are only believed infeasible to find. So these results hold only as far as that belief holds.
  2. All outputs of H have the same length (SHA-256: 32 bytes). Without this, prev ++ body could be split at a different point. needs_fixed_length gives a concrete injective H with varying output length where two different logs share a head.

Proved

Truncation is NOT detected by verification alone

truncation_verifies proves that dropping the last record of a log that verifies gives a log that still verifies (prefix_verifies is the general statement for any prefix). Removing trailing records is therefore detected only by comparing the head with a head value kept somewhere else (outside the log). Nothing in this file proves the truncated head differs from the original head. That needs the kept head and a comparison step, neither of which is modelled.

Not proved