Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-architecture-mv/blob/main/bootstrap/formal-oracles/lean/MutantReceiptModels.lean # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-architecture-mv / bootstrap / formal-oracles / lean / MutantReceiptModels.lean` 54 lines · 2473 bytes Raw Blame History 1 import AienReceipt.Corpus 2 /-! 3 # Deliberate mutants of `validate` (each must break one required rule) 4 5 WRONG on purpose. Each mutant model compiles; the matching claim file must not. 6 -/ 7 namespace AienReceipt 8 9 /-- MUTANT 1 (rejected_but_ran): a Rejected receipt is not required to have status NotRun. -/ 10 def decisionOkM1 (r : Receipt) : Bool := 11 match r.decision with 12 | .rejected => 13 r.stage != 0 && r.reason != 0 && r.exitCode == 0 && 14 r.syscalls == 0 && r.reads == 0 && r.denials == 0 && r.rflags.onlyReclaimed 15 | _ => r.stage == 0 && r.reason == 0 16 def validateM1 (nf : Nat → Nat → Nat) (r : Receipt) : Bool := 17 presenceOk r && codesOk r && decisionOkM1 r && canaryOk r && nonceOk nf r 18 19 /-- MUTANT 2 (rejected_without_reason): a Rejected receipt may have stage 0 or reason 0. -/ 20 def decisionOkM2 (r : Receipt) : Bool := 21 match r.decision with 22 | .rejected => 23 r.status == .notRun && r.exitCode == 0 && 24 r.syscalls == 0 && r.reads == 0 && r.denials == 0 && r.rflags.onlyReclaimed 25 | _ => r.stage == 0 && r.reason == 0 26 def validateM2 (nf : Nat → Nat → Nat) (r : Receipt) : Bool := 27 presenceOk r && codesOk r && decisionOkM2 r && canaryOk r && nonceOk nf r 28 29 /-- MUTANT 3 (non_rejected_with_rejection_fields): non-Rejected receipts are not checked. -/ 30 def decisionOkM3 (r : Receipt) : Bool := 31 match r.decision with 32 | .rejected => 33 r.stage != 0 && r.reason != 0 && r.status == .notRun && r.exitCode == 0 && 34 r.syscalls == 0 && r.reads == 0 && r.denials == 0 && r.rflags.onlyReclaimed 35 | _ => true 36 def validateM3 (nf : Nat → Nat → Nat) (r : Receipt) : Bool := 37 presenceOk r && codesOk r && decisionOkM3 r && canaryOk r && nonceOk nf r 38 39 /-- MUTANT 4 (canary_passed_without_clean_exit): the CANARY_PASSED rule is removed. -/ 40 def validateM4 (nf : Nat → Nat → Nat) (r : Receipt) : Bool := 41 presenceOk r && codesOk r && decisionOk r && nonceOk nf r 42 43 /-- MUTANT 5 (absent_flag_with_nonzero_value): the presence-flag rule is removed. -/ 44 def validateM5 (nf : Nat → Nat → Nat) (r : Receipt) : Bool := 45 codesOk r && decisionOk r && canaryOk r && nonceOk nf r 46 47 /-- witness: mutant 1 accepts a Rejected receipt that claims it exited... -/ 48 theorem m1_accepts_rejected_but_ran : 49 validateM1 nf0 { rejectedR with status := .exited } = true := by decide 50 /-- ...which the real model refuses -/ 51 theorem real_refuses_rejected_but_ran : 52 validate nf0 { rejectedR with status := .exited } = false := by decide 53 54 end AienReceipt