interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / bootstrap / formal-oracles / lean / AienReceipt / Corpus.lean

59 lines · 4491 bytes Raw Blame History
1import AienReceipt.Layout
2namespace AienReceipt
3
4/-! Positive and negative corpus. The nonce function is a concrete stand-in; the theorems in
5`Theorems.lean` hold for every `nf`, the corpus only shows the rules fire on concrete records. -/
6
7def nf0 (v s : Nat) : Nat := v * 1000 + s
8
9def admittedR : Receipt :=
10 { pres := ⟨false, false, false⟩, decision := .admitted, tier := .seed0bQemu, sequence := 7,
11 nonce := nf0 5 7, observed := 0, status := .exited, exitCode := 0, rflags := ⟨true, false, true, true, false, true, true, true⟩, stage := 0, reason := 0, syscalls := 3, reads := 1, denials := 0, frames := 4, digests := [1,2,3,4,5,6,7],
12 verifier := 5, machineId := 0, generation := 0, contextId := 0 }
13
14def rejectedR : Receipt :=
15 { admittedR with decision := .rejected, status := .notRun, exitCode := 0, rflags := ⟨false, false, true, false, false, false, false, false⟩, stage := 3, reason := 18, syscalls := 0, reads := 0, denials := 0 }
16
17/-! Positive: each decision has a valid receipt. -/
18theorem pos_admitted_clean : validate nf0 admittedR = true := by decide
19theorem pos_rejected_at_stage : validate nf0 rejectedR = true := by decide
20theorem pos_loader_reason : validate nf0 { rejectedR with reason := 0x10a } = true := by decide
21theorem pos_present_flags :
22 validate nf0 { admittedR with pres := ⟨true, true, true⟩, machineId := 9, generation := 1, contextId := 2, observed := 99 } = true := by decide
23theorem pos_fault_admitted :
24 validate nf0 { admittedR with status := .fault, rflags := ⟨false, false, true, false, false, false, false, true⟩ } = true := by decide
25theorem pos_roundtrip : decode nf0 (encode rejectedR) = some rejectedR := decode_encode (by decide)
26
27/-! Negative: one receipt per violated rule, each refused. -/
28theorem neg_rejected_but_ran_status : validate nf0 { rejectedR with status := .exited } = false := by decide
29theorem neg_rejected_with_exit_status : validate nf0 { rejectedR with exitCode := 1 } = false := by decide
30theorem neg_rejected_with_syscalls : validate nf0 { rejectedR with syscalls := 1 } = false := by decide
31theorem neg_rejected_with_reads : validate nf0 { rejectedR with reads := 1 } = false := by decide
32theorem neg_rejected_with_denials : validate nf0 { rejectedR with denials := 1 } = false := by decide
33theorem neg_rejected_with_result_flag :
34 validate nf0 { rejectedR with rflags := ⟨true, false, true, false, false, false, false, false⟩ } = false := by decide
35theorem neg_rejected_without_stage : validate nf0 { rejectedR with stage := 0 } = false := by decide
36theorem neg_rejected_without_reason : validate nf0 { rejectedR with reason := 0 } = false := by decide
37theorem neg_stage_out_of_range : validate nf0 { rejectedR with stage := 10 } = false := by decide
38theorem neg_reason_out_of_range : validate nf0 { rejectedR with reason := 20 } = false := by decide
39theorem neg_admitted_with_reason : validate nf0 { admittedR with reason := 18 } = false := by decide
40theorem neg_admitted_with_stage : validate nf0 { admittedR with stage := 3 } = false := by decide
41theorem neg_canary_after_fault : validate nf0 { admittedR with status := .fault } = false := by decide
42theorem neg_canary_nonzero_exit : validate nf0 { admittedR with exitCode := 3 } = false := by decide
43theorem neg_absent_machine_nonzero : validate nf0 { admittedR with machineId := 1 } = false := by decide
44theorem neg_absent_context_nonzero : validate nf0 { admittedR with contextId := 1 } = false := by decide
45theorem neg_absent_generation_nonzero : validate nf0 { admittedR with generation := 1 } = false := by decide
46theorem neg_absent_time_nonzero : validate nf0 { admittedR with observed := 1 } = false := by decide
47theorem neg_bad_nonce : validate nf0 { admittedR with nonce := 0 } = false := by decide
48theorem neg_refused_after_encode : decode nf0 (encode { rejectedR with status := .exited }) = none :=
49 encode_invalid_refused neg_rejected_but_ran_status
50
51/-! Finding (CanaryFailed): the code accepts these. Recorded, not endorsed. -/
52theorem finding_canary_decision_with_exited_status :
53 validate nf0 { admittedR with decision := .canaryFailed } = true := by decide
54theorem finding_admitted_with_canary_failed_status :
55 validate nf0 { admittedR with status := .canaryFailed, rflags := ⟨false, false, true, false, false, false, false, true⟩ } = true := by decide
56theorem finding_destroyed_with_exited_status :
57 validate nf0 { admittedR with decision := .destroyed } = true := by decide
58
59end AienReceipt