From c6895dcfda0dda254b2307917a424ffef0ed9a66 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Wed, 25 Nov 2026 09:50:49 +0000 Subject: [PATCH 1/3] Check heap permission and bounded-span laws across proof kernels --- .github/workflows/atoma.yml | 2 + scripts/atoma-heap-proof-gate.sh | 69 ++++++++ .../atoma/consumer/agda/HeapOwnership.agda | 149 ++++++++++++++++++ .../consumer/agda/HeapOwnershipCubical.agda | 23 +++ .../atoma/consumer/coq/HeapOwnership.v | 83 ++++++++++ .../atoma/consumer/lean4/HeapOwnership.lean | 83 ++++++++++ 6 files changed, 409 insertions(+) create mode 100644 scripts/atoma-heap-proof-gate.sh create mode 100644 verification/atoma/consumer/agda/HeapOwnership.agda create mode 100644 verification/atoma/consumer/agda/HeapOwnershipCubical.agda create mode 100644 verification/atoma/consumer/coq/HeapOwnership.v create mode 100644 verification/atoma/consumer/lean4/HeapOwnership.lean diff --git a/.github/workflows/atoma.yml b/.github/workflows/atoma.yml index 0be16fe..343ade4 100644 --- a/.github/workflows/atoma.yml +++ b/.github/workflows/atoma.yml @@ -92,6 +92,8 @@ jobs: run: bash scripts/atoma-registry-proof-gate.sh - name: Borrowed wrapper theory and cleanup control run: bash scripts/atoma-wrapper-proof-gate.sh + - name: Heap permissions and bounded-span theory + run: bash scripts/atoma-heap-proof-gate.sh - name: Preserve canonical repository map for review run: | bash scripts/gen-repo-map.sh . diff --git a/scripts/atoma-heap-proof-gate.sh b/scripts/atoma-heap-proof-gate.sh new file mode 100644 index 0000000..7511350 --- /dev/null +++ b/scripts/atoma-heap-proof-gate.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +set -euo pipefail +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +parent="$root/build/scalar-proof-evidence/heap" +mkdir -p "$parent" +out=$(mktemp -d "$parent/run.XXXXXXXX") +work=$(mktemp -d) +echo INCOMPLETE > "$out/result.txt" +trap 'status=$?; if ((status)); then echo FAIL > "$out/result.txt"; tail -n 45 "$out"/*.txt >&2; fi; rm -rf "$work"' EXIT +sources=(verification/atoma/consumer/agda/HeapOwnership.agda + verification/atoma/consumer/agda/HeapOwnershipCubical.agda + verification/atoma/consumer/lean4/HeapOwnership.lean + verification/atoma/consumer/coq/HeapOwnership.v scripts/atoma-heap-proof-gate.sh) +(cd "$root"; sha256sum "${sources[@]}") > "$out/source-inputs.sha256" +for source in "${sources[@]:0:4}"; do cp "$root/$source" "$work/"; cmp "$root/$source" "$work/$(basename "$source")"; done +(cd "$root"; sha256sum -c "$out/source-inputs.sha256") > "$out/snapshot-recheck.txt" +cd "$work" +sha256sum HeapOwnership.agda HeapOwnershipCubical.agda HeapOwnership.lean HeapOwnership.v > "$out/checked-inputs.sha256" +agda --safe --without-K --cubical-compatible --double-check --warning=error HeapOwnership.agda > "$out/agda.txt" 2>&1 +lean HeapOwnership.lean > "$out/lean.txt" 2>&1 +awk ' +BEGIN { + split("releaseBorrowedRefused releaseRetainedRefused writeBorrowedRefused failedPreserves borrowReturnCell borrowPreservesBytes releaseRemovesOwned releaseFramesOther acquireLiveRefused spanLength", required, " ") + for (i in required) names[required[i]]=1 +} +{ + found=0 + for (n in names) { + expected="\047HeapOwnership." n "\047 does not depend on any axioms" + if ($0 == expected && names[n] == 1) {names[n]=2; found=1; count++} + } + if (!found) exit 1 +} +END {if (count != 10) exit 1}' "$out/lean.txt" +coqc -q HeapOwnership.v > "$out/coq.txt" 2>&1 +[[ $(grep -c '^Closed under the global context$' "$out/coq.txt") == 10 ]] +if grep -q '^Axioms:' "$out/coq.txt"; then echo 'FAIL: heap proof axioms' >&2; exit 1; fi +coqchk -silent -Q . '' HeapOwnership > "$out/coqchk.txt" 2>&1 +agda --safe --cubical --double-check --warning=error HeapOwnershipCubical.agda > "$out/cubical.txt" 2>&1 + +# These mutate the actual operational definitions; unrelated compiler failures +# are not accepted as evidence that the intended mathematical obligation failed. +sed -e 's/module HeapOwnership where/module HeapOwnershipMutant where/' \ + -e 's/cell-step release (live bytes retained (suc readers)) = nothing/cell-step release (live bytes retained (suc readers)) = just vacant/' \ + HeapOwnership.agda > HeapOwnershipMutant.agda +if agda --safe --without-K --cubical-compatible --double-check --warning=error HeapOwnershipMutant.agda > "$out/reject-borrowed-release.txt" 2>&1; then + echo 'FAIL: freeing borrowed region accepted' >&2; exit 1 +fi +grep -q '!=' "$out/reject-borrowed-release.txt" +sed -e 's/module HeapOwnership where/module HeapOwnershipCorrupt where/' \ + -e 's/cell-step borrow-read (live bytes retained readers) = just (live bytes retained (suc readers))/cell-step borrow-read (live bytes retained readers) = just (live (zero ∷ bytes) retained (suc readers))/' \ + HeapOwnership.agda > HeapOwnershipCorrupt.agda +if agda --safe --without-K --cubical-compatible --double-check --warning=error HeapOwnershipCorrupt.agda > "$out/reject-borrow-corruption.txt" 2>&1; then + echo 'FAIL: borrow byte corruption accepted' >&2; exit 1 +fi +grep -q '!=' "$out/reject-borrow-corruption.txt" +sed 's/| Release, Live _ 0 0 => Some Vacant/| Release, Live _ 0 _ => Some Vacant/' HeapOwnership.v > HeapOwnershipBad.v +if coqc -q HeapOwnershipBad.v > "$out/reject-coq-release.txt" 2>&1; then + echo 'FAIL: Coq borrowed release mutation accepted' >&2; exit 1 +fi +grep -q 'Unable to unify' "$out/reject-coq-release.txt" +sha256sum -c "$out/checked-inputs.sha256" > "$out/checked-input-recheck.txt" +(cd "$root"; sha256sum -c "$out/source-inputs.sha256") > "$out/source-recheck.txt" +cp HeapOwnership.agda HeapOwnershipCubical.agda HeapOwnership.lean HeapOwnership.v HeapOwnership.vo "$out/" +{ agda --version; lean --version; coqc --version; } > "$out/versions.txt" +for tool in agda lean coqc coqchk; do sha256sum "$(command -v "$tool")"; done > "$out/tools.sha256" +echo PASS > "$out/result.txt" +echo 'HEAP THEORY PASS: region updates, borrow/release and span laws; native pointer and authority correspondence remain premises' diff --git a/verification/atoma/consumer/agda/HeapOwnership.agda b/verification/atoma/consumer/agda/HeapOwnership.agda new file mode 100644 index 0000000..5c6d562 --- /dev/null +++ b/verification/atoma/consumer/agda/HeapOwnership.agda @@ -0,0 +1,149 @@ +-- SPDX-License-Identifier: MPL-2.0 +{-# OPTIONS --safe --without-K --cubical-compatible #-} +module HeapOwnership where +open import Agda.Builtin.Nat +open import Agda.Builtin.Bool +open import Agda.Builtin.List +open import Agda.Builtin.Maybe +open import Agda.Builtin.Equality + +-- This is a ghost region/permission protocol, not a native pointer validator. +-- A caller must possess authority for its region; raw aliases and the mapping +-- from machine addresses to these region identities remain external premises. +data Allocation : Set where + vacant : Allocation + live : (bytes : List Nat) (retained readers : Nat) → Allocation + +data Operation : Set where + acquire write-bytes : List Nat → Operation + retain drop-retention borrow-read return-read release : Operation + +cell-step : Operation → Allocation → Maybe Allocation +cell-step (acquire bytes) vacant = just (live bytes zero zero) +cell-step (acquire bytes) (live old retained readers) = nothing +cell-step retain (live bytes retained readers) = just (live bytes (suc retained) readers) +cell-step drop-retention (live bytes (suc retained) readers) = just (live bytes retained readers) +cell-step borrow-read (live bytes retained readers) = just (live bytes retained (suc readers)) +cell-step return-read (live bytes retained (suc readers)) = just (live bytes retained readers) +cell-step release (live bytes retained (suc readers)) = nothing +cell-step release (live bytes (suc retained) zero) = nothing +cell-step release (live bytes zero zero) = just vacant +cell-step (write-bytes bytes) (live old retained zero) = just (live bytes retained zero) +cell-step (write-bytes bytes) (live old retained (suc readers)) = nothing +cell-step _ _ = nothing + +Heap : Set +Heap = Nat → Allocation + +replace : Heap → Nat → Allocation → Heap +replace h zero value zero = value +replace h zero value (suc key) = h (suc key) +replace h (suc addr) value zero = h zero +replace h (suc addr) value (suc key) = replace (λ n → h (suc n)) addr value key + +record Result : Set where + constructor result + field + succeeded : Bool + store : Heap +open Result public + +run : Operation → Heap → Nat → Result +run op h addr with cell-step op (h addr) +... | nothing = result false h +... | just value = result true (replace h addr value) + +read-bytes : Allocation → Maybe (List Nat) +read-bytes vacant = nothing +read-bytes (live bytes _ _) = just bytes + +then-cell : Operation → Operation → Allocation → Maybe Allocation +then-cell first second cell with cell-step first cell +... | nothing = nothing +... | just next = cell-step second next +bytes-after : Operation → Allocation → Maybe (List Nat) +bytes-after op cell with cell-step op cell +... | nothing = nothing +... | just next = read-bytes next + +data Empty : Set where +absurd : {A : Set} → Empty → A +absurd () +cong : {A B : Set} {x y : A} → (f : A → B) → x ≡ y → f x ≡ f y +cong f refl = refl + +replace-hit : (h : Heap) (addr : Nat) (value : Allocation) → replace h addr value addr ≡ value +replace-hit h zero value = refl +replace-hit h (suc addr) value = replace-hit (λ n → h (suc n)) addr value + +replace-frame : (h : Heap) (addr key : Nat) (value : Allocation) → + (key ≡ addr → Empty) → replace h addr value key ≡ h key +replace-frame h zero zero value neq = absurd (neq refl) +replace-frame h zero (suc key) value neq = refl +replace-frame h (suc addr) zero value neq = refl +replace-frame h (suc addr) (suc key) value neq = + replace-frame (λ n → h (suc n)) addr key value (λ eq → neq (cong suc eq)) + +release-borrowed-refused : ∀ bytes retained readers → + cell-step release (live bytes retained (suc readers)) ≡ nothing +release-borrowed-refused bytes retained readers = refl + +release-retained-refused : ∀ bytes retained readers → + cell-step release (live bytes (suc retained) readers) ≡ nothing +release-retained-refused bytes retained zero = refl +release-retained-refused bytes retained (suc readers) = refl + +write-borrowed-refused : ∀ bytes old retained readers → + cell-step (write-bytes bytes) (live old retained (suc readers)) ≡ nothing +write-borrowed-refused bytes old retained readers = refl + +failed-preserves : ∀ op h addr key → cell-step op (h addr) ≡ nothing → + store (run op h addr) key ≡ h key +failed-preserves op h addr key refused rewrite refused = refl + +borrow-return-cell : ∀ bytes retained readers → + then-cell borrow-read return-read (live bytes retained readers) ≡ just (live bytes retained readers) +borrow-return-cell bytes retained readers = refl + +borrow-preserves-bytes : ∀ bytes retained readers → + bytes-after borrow-read (live bytes retained readers) ≡ read-bytes (live bytes retained readers) +borrow-preserves-bytes bytes retained readers = refl + +release-removes-owned : ∀ h addr bytes → h addr ≡ live bytes zero zero → + store (run release h addr) addr ≡ vacant +release-removes-owned h addr bytes owned rewrite owned = replace-hit h addr vacant + +release-frames-other : ∀ h addr key bytes → h addr ≡ live bytes zero zero → + (key ≡ addr → Empty) → store (run release h addr) key ≡ h key +release-frames-other h addr key bytes owned neq rewrite owned = replace-frame h addr key vacant neq + +acquire-live-refused : ∀ bytes old retained readers → + cell-step (acquire bytes) (live old retained readers) ≡ nothing +acquire-live-refused bytes old retained readers = refl + +length : {A : Set} → List A → Nat +length [] = zero +length (_ ∷ xs) = suc (length xs) +take : {A : Set} → Nat → List A → List A +take zero xs = [] +take (suc n) [] = [] +take (suc n) (x ∷ xs) = x ∷ take n xs +drop : {A : Set} → Nat → List A → List A +drop zero xs = xs +drop (suc n) [] = [] +drop (suc n) (_ ∷ xs) = drop n xs +data _≤_ : Nat → Nat → Set where + z≤n : ∀ {n} → zero ≤ n + s≤s : ∀ {m n} → m ≤ n → suc m ≤ suc n + +-- Machine-usize/address representability is an additional native premise. +borrowed-span : Nat → Nat → List Nat → List Nat +borrowed-span offset count bytes = take count (drop offset bytes) + +span-length : ∀ offset count bytes → offset + count ≤ length bytes → + length (borrowed-span offset count bytes) ≡ count +span-length zero zero bytes fits = refl +span-length zero (suc count) [] () +span-length zero (suc count) (b ∷ bytes) (s≤s fits) = cong suc (span-length zero count bytes fits) +span-length (suc offset) count [] () +span-length (suc offset) count (b ∷ bytes) (s≤s fits) = span-length offset count bytes fits diff --git a/verification/atoma/consumer/agda/HeapOwnershipCubical.agda b/verification/atoma/consumer/agda/HeapOwnershipCubical.agda new file mode 100644 index 0000000..e8fa96c --- /dev/null +++ b/verification/atoma/consumer/agda/HeapOwnershipCubical.agda @@ -0,0 +1,23 @@ +-- SPDX-License-Identifier: MPL-2.0 +{-# OPTIONS --safe --cubical #-} +module HeapOwnershipCubical where +import HeapOwnership as H +open import Agda.Builtin.Nat +open import Agda.Builtin.Maybe +open import Agda.Builtin.Equality +open import Agda.Builtin.Cubical.Path using (PathP) + +toPath : {A : Set} {x y : A} → x ≡ y → PathP (λ _ → A) x y +toPath {x = x} refl _ = x + +release-borrowed-path : ∀ bytes retained readers → + PathP (λ _ → Maybe H.Allocation) (H.cell-step H.release (H.live bytes retained (suc readers))) nothing +release-borrowed-path bytes retained readers = toPath (H.release-borrowed-refused bytes retained readers) + +release-owned-path : ∀ h addr bytes → h addr ≡ H.live bytes zero zero → + PathP (λ _ → H.Allocation) (H.store (H.run H.release h addr) addr) H.vacant +release-owned-path h addr bytes owned = toPath (H.release-removes-owned h addr bytes owned) + +span-length-path : ∀ offset count bytes → H._≤_ (offset + count) (H.length bytes) → + PathP (λ _ → Nat) (H.length (H.borrowed-span offset count bytes)) count +span-length-path offset count bytes fits = toPath (H.span-length offset count bytes fits) diff --git a/verification/atoma/consumer/coq/HeapOwnership.v b/verification/atoma/consumer/coq/HeapOwnership.v new file mode 100644 index 0000000..a0ff247 --- /dev/null +++ b/verification/atoma/consumer/coq/HeapOwnership.v @@ -0,0 +1,83 @@ +(* SPDX-License-Identifier: MPL-2.0 *) +(* Ghost permissions. Native pointer/region correspondence and authority are premises. *) +From Coq Require Import List Arith Bool Lia. +Import ListNotations. + +Inductive allocation := Vacant | Live (bytes : list nat) (retained readers : nat). +Inductive operation := Acquire (bytes : list nat) | Retain | DropRetention | + BorrowRead | ReturnRead | Release | WriteBytes (bytes : list nat). +Definition cell_step (op : operation) (cell : allocation) : option allocation := + match op, cell with + | Acquire bytes, Vacant => Some (Live bytes 0 0) + | Retain, Live bytes retained readers => Some (Live bytes (S retained) readers) + | DropRetention, Live bytes (S retained) readers => Some (Live bytes retained readers) + | BorrowRead, Live bytes retained readers => Some (Live bytes retained (S readers)) + | ReturnRead, Live bytes retained (S readers) => Some (Live bytes retained readers) + | Release, Live _ 0 0 => Some Vacant + | WriteBytes bytes, Live _ retained 0 => Some (Live bytes retained 0) + | _, _ => None + end. +Definition heap := nat -> allocation. +Definition replace (h : heap) (addr : nat) (value : allocation) : heap := + fun key => if Nat.eq_dec key addr then value else h key. +Definition run (op : operation) (h : heap) (addr : nat) : bool * heap := + match cell_step op (h addr) with + | None => (false,h) + | Some value => (true,replace h addr value) + end. +Definition read_bytes (cell : allocation) : option (list nat) := + match cell with Vacant => None | Live bytes _ _ => Some bytes end. +Definition then_cell (first second : operation) (cell : allocation) := + match cell_step first cell with None => None | Some next => cell_step second next end. +Definition bytes_after (op : operation) (cell : allocation) := + match cell_step op cell with None => None | Some next => read_bytes next end. + +Theorem release_borrowed_refused : forall bytes retained readers, + cell_step Release (Live bytes retained (S readers)) = None. +Proof. intros; destruct retained; reflexivity. Qed. +Theorem release_retained_refused : forall bytes retained readers, + cell_step Release (Live bytes (S retained) readers) = None. +Proof. reflexivity. Qed. +Theorem write_borrowed_refused : forall bytes old retained readers, + cell_step (WriteBytes bytes) (Live old retained (S readers)) = None. +Proof. reflexivity. Qed. +Theorem failed_preserves : forall op h addr key, + cell_step op (h addr) = None -> snd (run op h addr) key = h key. +Proof. intros op h addr key H; unfold run; now rewrite H. Qed. +Theorem borrow_return_cell : forall bytes retained readers, + then_cell BorrowRead ReturnRead (Live bytes retained readers) = Some (Live bytes retained readers). +Proof. reflexivity. Qed. +Theorem borrow_preserves_bytes : forall bytes retained readers, + bytes_after BorrowRead (Live bytes retained readers) = read_bytes (Live bytes retained readers). +Proof. reflexivity. Qed. +Theorem release_removes_owned : forall h addr bytes, + h addr = Live bytes 0 0 -> snd (run Release h addr) addr = Vacant. +Proof. intros h addr bytes H; unfold run; rewrite H; simpl; unfold replace. + destruct (Nat.eq_dec addr addr); [reflexivity|contradiction]. Qed. +Theorem release_frames_other : forall h addr key bytes, + h addr = Live bytes 0 0 -> key <> addr -> snd (run Release h addr) key = h key. +Proof. intros h addr key bytes H Hneq; unfold run; rewrite H; simpl; unfold replace. + destruct (Nat.eq_dec key addr); [contradiction|reflexivity]. Qed. +Theorem acquire_live_refused : forall bytes old retained readers, + cell_step (Acquire bytes) (Live old retained readers) = None. +Proof. reflexivity. Qed. + +Definition span_fits (offset count : nat) (bytes : list nat) : bool := + offset + count <=? List.length bytes. +Definition borrowed_span (offset count : nat) (bytes : list nat) := + firstn count (skipn offset bytes). +Theorem span_length : forall offset count bytes, + span_fits offset count bytes = true -> List.length (borrowed_span offset count bytes) = count. +Proof. intros offset count bytes H; unfold span_fits in H; apply Nat.leb_le in H. + unfold borrowed_span; rewrite firstn_length, skipn_length; apply Nat.min_l; lia. Qed. + +Print Assumptions release_borrowed_refused. +Print Assumptions release_retained_refused. +Print Assumptions write_borrowed_refused. +Print Assumptions failed_preserves. +Print Assumptions borrow_return_cell. +Print Assumptions borrow_preserves_bytes. +Print Assumptions release_removes_owned. +Print Assumptions release_frames_other. +Print Assumptions acquire_live_refused. +Print Assumptions span_length. diff --git a/verification/atoma/consumer/lean4/HeapOwnership.lean b/verification/atoma/consumer/lean4/HeapOwnership.lean new file mode 100644 index 0000000..6457767 --- /dev/null +++ b/verification/atoma/consumer/lean4/HeapOwnership.lean @@ -0,0 +1,83 @@ +-- SPDX-License-Identifier: MPL-2.0 +import Init.Data.List.Nat.TakeDrop +namespace HeapOwnership +-- Ghost protocol only; it does not validate or confer authority over raw pointers. +inductive Allocation where + | vacant + | live (bytes : List Nat) (retained readers : Nat) +inductive Operation where + | acquire (bytes : List Nat) + | retain | dropRetention | borrowRead | returnRead | release + | writeBytes (bytes : List Nat) +open Allocation Operation +def cellStep : Operation → Allocation → Option Allocation + | acquire bytes, vacant => some (live bytes 0 0) + | retain, live bytes retained readers => some (live bytes (retained+1) readers) + | dropRetention, live bytes (retained+1) readers => some (live bytes retained readers) + | borrowRead, live bytes retained readers => some (live bytes retained (readers+1)) + | returnRead, live bytes retained (readers+1) => some (live bytes retained readers) + | release, live _ 0 0 => some vacant + | writeBytes bytes, live _ retained 0 => some (live bytes retained 0) + | _, _ => none +abbrev Heap := Nat → Allocation +def replace (h : Heap) (addr : Nat) (value : Allocation) : Heap := + fun key => if key = addr then value else h key +def run (op : Operation) (h : Heap) (addr : Nat) : Bool × Heap := + match cellStep op (h addr) with + | none => (false,h) + | some value => (true,replace h addr value) +def readBytes : Allocation → Option (List Nat) + | vacant => none + | live bytes _ _ => some bytes +def thenCell (first second : Operation) (cell : Allocation) : Option Allocation := + match cellStep first cell with + | none => none + | some next => cellStep second next +def bytesAfter (op : Operation) (cell : Allocation) : Option (List Nat) := + match cellStep op cell with + | none => none + | some next => readBytes next + +theorem releaseBorrowedRefused (bytes : List Nat) (retained readers : Nat) : + cellStep release (live bytes retained (readers+1)) = none := by + cases retained <;> rfl +theorem releaseRetainedRefused (bytes : List Nat) (retained readers : Nat) : + cellStep release (live bytes (retained+1) readers) = none := rfl +theorem writeBorrowedRefused (bytes old : List Nat) (retained readers : Nat) : + cellStep (writeBytes bytes) (live old retained (readers+1)) = none := rfl +theorem failedPreserves (op : Operation) (h : Heap) (addr key : Nat) + (refused : cellStep op (h addr) = none) : (run op h addr).2 key = h key := by + simp only [run, refused] +theorem borrowReturnCell (bytes : List Nat) (retained readers : Nat) : + thenCell borrowRead returnRead (live bytes retained readers) = some (live bytes retained readers) := rfl +theorem borrowPreservesBytes (bytes : List Nat) (retained readers : Nat) : + bytesAfter borrowRead (live bytes retained readers) = readBytes (live bytes retained readers) := rfl +theorem releaseRemovesOwned (h : Heap) (addr : Nat) (bytes : List Nat) + (owned : h addr = live bytes 0 0) : (run release h addr).2 addr = vacant := by + simp only [run, owned, cellStep, replace, if_pos rfl] +theorem releaseFramesOther (h : Heap) (addr key : Nat) (bytes : List Nat) + (owned : h addr = live bytes 0 0) (other : key ≠ addr) : (run release h addr).2 key = h key := by + simp only [run, owned, cellStep, replace, if_neg other] +theorem acquireLiveRefused (bytes old : List Nat) (retained readers : Nat) : + cellStep (acquire bytes) (live old retained readers) = none := rfl + +def borrowedSpan (offset count : Nat) (bytes : List Nat) : List Nat := + (bytes.drop offset).take count +theorem spanLength (offset count : Nat) (bytes : List Nat) + (fits : offset+count ≤ bytes.length) : (borrowedSpan offset count bytes).length = count := by + rw [borrowedSpan, List.length_take, List.length_drop] + apply Nat.min_eq_left + apply Nat.le_sub_of_add_le + simpa only [Nat.add_comm] using fits + +#print axioms releaseBorrowedRefused +#print axioms releaseRetainedRefused +#print axioms writeBorrowedRefused +#print axioms failedPreserves +#print axioms borrowReturnCell +#print axioms borrowPreservesBytes +#print axioms releaseRemovesOwned +#print axioms releaseFramesOther +#print axioms acquireLiveRefused +#print axioms spanLength +end HeapOwnership From e81ffb12c098eb257a52251821995f39f82214bf Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Wed, 25 Nov 2026 10:02:06 +0000 Subject: [PATCH 2/3] Bind public entry and retained-lifetime effects to original Zig source --- .github/workflows/atoma.yml | 66 +++++- docs/decisions/ATOMA-HEAP-BOUNDARY.adoc | 77 +++++++ docs/plan/ULTRAPLAN.adoc | 14 +- docs/status/PROOF-STATUS.adoc | 22 +- docs/status/ROADMAP.adoc | 36 +-- scripts/atoma-consumer-heap-gate.sh | 46 ++++ scripts/atoma-public-header-capsule.sh | 62 +++++ scripts/atoma-public-header-source-gate.sh | 69 ++++++ scripts/atoma-registry-lifetime-capsule.sh | 63 +++++ .../atoma-registry-lifetime-source-gate.sh | 67 ++++++ scripts/atoma-source-profile-replay.sh | 23 +- tests/consumer-heap/proven.pin | 1 + tests/consumer-heap/uaa.pin | 1 + .../atoma/consumer/agda/HeapOwnership.agda | 1 + .../consumer/coq/HeaderBoundaryContext.v | 12 + .../atoma/consumer/coq/HeaderBoundarySource.v | 218 ++++++++++++++++++ .../consumer/coq/RegistryLifetimeSource.v | 171 ++++++++++++++ 17 files changed, 918 insertions(+), 31 deletions(-) create mode 100644 docs/decisions/ATOMA-HEAP-BOUNDARY.adoc create mode 100644 scripts/atoma-consumer-heap-gate.sh create mode 100644 scripts/atoma-public-header-capsule.sh create mode 100644 scripts/atoma-public-header-source-gate.sh create mode 100644 scripts/atoma-registry-lifetime-capsule.sh create mode 100644 scripts/atoma-registry-lifetime-source-gate.sh create mode 100644 tests/consumer-heap/proven.pin create mode 100644 tests/consumer-heap/uaa.pin create mode 100644 verification/atoma/consumer/coq/HeaderBoundaryContext.v create mode 100644 verification/atoma/consumer/coq/HeaderBoundarySource.v create mode 100644 verification/atoma/consumer/coq/RegistryLifetimeSource.v diff --git a/.github/workflows/atoma.yml b/.github/workflows/atoma.yml index 343ade4..eab722f 100644 --- a/.github/workflows/atoma.yml +++ b/.github/workflows/atoma.yml @@ -105,8 +105,55 @@ jobs: path: build/scalar-proof-evidence/ if-no-files-found: error - soundness: - name: Atoma soundness gate + heap_source: + name: Public boundary and lifetime source + runs-on: ubuntu-24.04 + timeout-minutes: 25 + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Provision independent Coq checker + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends coq=8.18.0+dfsg-1build2 + - name: Actual public header entry + run: bash scripts/atoma-public-header-source-gate.sh + - name: Actual registry destruction and retained regions + if: success() || failure() + run: bash scripts/atoma-registry-lifetime-source-gate.sh + - uses: actions/upload-artifact@v7.0.2 + if: always() + with: + name: heap-source-evidence-${{ github.sha }} + path: build/heap-source-evidence/ + if-no-files-found: error + + heap_consumers: + name: Heap lifetime consumer replay + needs: [scalar, heap_source] + runs-on: ubuntu-24.04 + timeout-minutes: 45 + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Provision pinned proof tools + run: bash scripts/atoma-ci-toolchain.sh + - name: Provision independent replay tools + run: bash scripts/atoma-ci-replay-toolchain.sh + - name: Fresh native consumers and source-bound lifetime replay + run: bash scripts/atoma-consumer-heap-gate.sh + - uses: actions/upload-artifact@v7.0.2 + if: always() + with: + name: heap-consumer-evidence-${{ github.sha }} + path: build/atoma-evidence/heap-consumers/ + if-no-files-found: error + retention-days: 30 + + core_soundness: + name: Existing source and replay gates needs: [scalar, word_source, wrapper_source] runs-on: ubuntu-24.04 timeout-minutes: 45 @@ -131,6 +178,21 @@ jobs: if-no-files-found: error retention-days: 30 + soundness: + name: Atoma soundness gate + needs: [core_soundness, heap_consumers] + if: ${{ always() }} + runs-on: ubuntu-24.04 + timeout-minutes: 2 + steps: + - name: Require both existing and heap-boundary qualification + env: + CORE_RESULT: ${{ needs.core_soundness.result }} + HEAP_RESULT: ${{ needs.heap_consumers.result }} + run: | + test "$CORE_RESULT" = success + test "$HEAP_RESULT" = success + gate: name: CI/gate needs: [soundness] diff --git a/docs/decisions/ATOMA-HEAP-BOUNDARY.adoc b/docs/decisions/ATOMA-HEAP-BOUNDARY.adoc new file mode 100644 index 0000000..6eb646c --- /dev/null +++ b/docs/decisions/ATOMA-HEAP-BOUNDARY.adoc @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: CC-BY-SA-4.0 += Heap permissions and actual public boundaries +:revdate: 2026-11-25 + +== Shared contract + +The region store maps a logical region identity to vacant storage or a live byte +snapshot with retained-reference and active-reader counts. Acquisition requires +vacancy; release requires zero retained references and readers. Borrow/return +preserves bytes; a write during an active read borrow is refused by the protocol. +These counts are ghost obligations, not new fields or runtime checks in either +consumer ABI. A caller cannot obtain allocation authority merely by constructing +a Nat region identity or wrapping a copyable pointer in a linear type. + +Compatible Agda, Lean, Coq/coqchk and full Cubical check the scoped laws. The +independent hand re-proofs remain BRIDGE-PENDING. No proof-witness grade or +cross-kernel transport is inferred from successful compilation alone. + +== Proven public entry + +The profile admits the original complete core.zig and main_refc.zig modules. +Reviewed, fixed byte prefixes and suffixes close the surrounding declarations, +imports, result layout, status constants and error storage. The original public +entry body and exported forwarder are parsed between those contexts; the source +cannot select its own context. This is intentionally restrictive: a change +outside the admitted body must be reviewed and re-qualified. + +The interpretation covers null refusal before backend invocation, exact +pointer-to-slice span forwarding, backend status mapping and the thread-local +error effect. The actual header_refc.zig source is separately admitted. A native +dispatch double observes the unchanged public function; the real Idris-backed +export is still exercised independently. Those evidence categories remain +distinct. + +The caller owes live readable memory, pointer-to-region correspondence, physical +separation where required, usize/address representability and synchronous input +lifetime. Non-nullness is not a bound or liveness proof. Backend heap effects +remain in the semantics; preservation requires an explicit frame premise. + +== UAA retained lifetimes + +Registration retains callback/code and optional context references across calls. +Multiple slots referencing one region contribute multiple retentions. Removing +one registration releases only that registration's obligations. Idle destroy +releases the registry allocation and detaches its registrations; it does not +destroy callback/context allocations. + +The source interpretation derives the actual null/busy/free sequence from the +closed registry module. Source-facing theorems require a live mapped allocation; +idle free additionally requires ownership authority and accounted retentions. +A distinct logical region is only physically separate under the explicit +native correspondence premise. No stale pointer is dereferenced in tests. + +The existing raw-alias counterexample remains part of qualification. Serialized +access, valid retained callback/context lifetimes, input readability and normal, +frame-preserving callback return remain obligations of native callers. + +== Required evidence and remaining work + +The required soundness context depends on both the existing replay campaign and +the new heap/public-boundary campaign. Both use fresh pinned consumers and +native checks, original-source capsules, ECHIDNA results, regenerated Coq audits, +coqchk and input-hash rechecks. Missing, failed or skipped qualification cannot +produce a successful soundness context. Operational proof mutations, native +source mutants and zero-exit compiler diagnostics must be refused. + +Exact-head results are recorded in +https://github.com/hyperpolymath/atoma/pull/34[the implementation PR], alongside +https://github.com/hyperpolymath/proven/pull/249[Proven] and +https://github.com/hyperpolymath/unified-api-adapter/pull/25[UAA]. +The presence of this decision is not a qualification receipt. + +Receipts remain INCOMPLETE. General Zig parsing/compiler refinement, native +allocation authority, arbitrary-pointer validity, concurrent/non-local effects, +foreign-call contracts and cross-kernel statement transport are not discharged +by this bounded slice. Checked generation handles would be a separate, +versioned Idris2 ABI decision; this work preserves the current ABI. diff --git a/docs/plan/ULTRAPLAN.adoc b/docs/plan/ULTRAPLAN.adoc index 8846f85..ab23b49 100644 --- a/docs/plan/ULTRAPLAN.adoc +++ b/docs/plan/ULTRAPLAN.adoc @@ -1,7 +1,7 @@ // SPDX-License-Identifier: CC-BY-SA-4.0 // SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell = Atoma — soundness-first plan to v1 -:revdate: 2026-11-24 +:revdate: 2026-11-25 :toc: Atoma is experimental. The release objective is a useful verifier for an @@ -57,8 +57,11 @@ Whole-boundary receipts remain INCOMPLETE. This milestone precedes v1; it does not discharge memory, state, compiler refinement or the full checker chain. #28 merged on 2026-11-24 after its required soundness and CI checks passed; consumer source checking and its evidence are -in #30. Next, prove the full-word decoder relation and the registry state/effect -contract before extending source interpretation to calls, memory or ownership. +in #30. The full-word decoder, registry state kernel and conditional wrapper +profiles followed in #31–#33. The raw-alias counterexample is now explicit. +The next bounded extension, #34, connects heap/borrow obligations to Proven's +public entry and UAA's retained registration/destruction effects. Its source +and native receipts remain subject to exact-head qualification. All applicable rows must pass on the release commit. They are conjunctive gates, not a readiness percentage. @@ -110,8 +113,9 @@ Re-estimate after R1, with compiler/formal-methods expertise available. R1 progress: the source-bound u8 function now has a generated Coq model theorem and a real ECHIDNA/coqchk path with adversarial replay controls. -This closes a narrow replay experiment, not R1: the alias counterexample, -typed-subset expansion and source-to-model refinement argument remain open. +The alias counterexample and conditional wrapper framing are now checked by +the #33 campaign. R1 is still partial: typed-subset expansion and the +source-to-model refinement argument remain open. Do those before expanding features or shortening the v1 estimate. See `docs/audit/2026-11-07-source-replay.adoc`. diff --git a/docs/status/PROOF-STATUS.adoc b/docs/status/PROOF-STATUS.adoc index 80ba08b..1074deb 100644 --- a/docs/status/PROOF-STATUS.adoc +++ b/docs/status/PROOF-STATUS.adoc @@ -84,17 +84,33 @@ The manifests in `verification/proofs/` declare exact checked/quarantined scope. See link:../plan/ULTRAPLAN.adoc[the stable task register] and link:../audit/2026-11-07-soundness-sprint.adoc[the repair evidence]. -== Source-binding milestone (under qualification) +== Source-binding and conditional wrapper milestones The decoder/import and registry-kernel source capsules passed their independent Coq interpretation, assumption audits, coqchk and rejecting source mutations in https://github.com/hyperpolymath/atoma/actions/runs/45527831101[run 45527831101] at head 1cc383c1ff2e747cb96d13a49638326ee75823f7. Registry compatible Agda, -Lean and full Cubical witnesses passed in the same run. Combined consumer and -ECHIDNA qualification was still pending when this entry was prepared. +Lean and full Cubical witnesses passed in the same run. Subsequent complete +qualification, including the actual wrapper call/scan profiles, passed at +head 6823ff07297ca015a2461c00adc2ee2215633d1a in +https://github.com/hyperpolymath/atoma/actions/runs/45580361419[run 45580361419]. +Downloaded evidence includes fresh native consumers, verified ECHIDNA results, +independent regenerated audits and coqchk; all 31 wrapper replay files matched +their evidence hashes. Native ownership and foreign-call premises remain open. The existing proof-policy claims table and grades above are not promoted by these observations. Cross-kernel statement correspondence is BRIDGE-PENDING. See link:../decisions/ATOMA-BOUNDARY-SOURCE.adoc[the source-profile decision] for the exact interpretation, compiler, wrapper and ownership boundaries. +== Heap/public-boundary extension + +PR #34 adds a ghost region/permission protocol, original public header-entry +interpretation and source-bound registry destruction/retention effects. +Compatible Agda, Lean, Coq/coqchk, full Cubical, rejecting operational mutations +and fresh native consumer campaigns are required. The exact PR head and its +artifacts own the execution status; implementation alone is not a pass. +The policy claims table is not promoted by these additions. +See link:../decisions/ATOMA-HEAP-BOUNDARY.adoc[scope and native correspondence +premises]. All hand re-proof correspondence remains BRIDGE-PENDING. + diff --git a/docs/status/ROADMAP.adoc b/docs/status/ROADMAP.adoc index 41f1ee2..81f8771 100644 --- a/docs/status/ROADMAP.adoc +++ b/docs/status/ROADMAP.adoc @@ -1,7 +1,7 @@ // SPDX-License-Identifier: CC-BY-SA-4.0 // Copyright (c) Jonathan D.A. Jewell = Atoma roadmap -:revdate: 2026-11-24 +:revdate: 2026-11-25 The active link:../plan/ULTRAPLAN.adoc[v1 plan] owns milestone acceptance and estimates. Atoma is experimental. There is no overall readiness percentage. @@ -39,25 +39,27 @@ The scalar MVP merged in PR #30 at `c59fe78fceeaf284c0beab96300c9ad392150598`. The next theory slice has checked universal decoder models in strict safe Agda, full safe Cubical, Lean and Coq/coqchk; see link:../theory/UNIVERSAL-DECODER.adoc[the statements, hosted evidence and limits]. -These independent models do not yet establish cross-model correspondence or -prove the real decoder source. UAA PR #22 separately checks its total Idris2 -state contract and existing native campaign, with ownership/lifetime assumptions -explicit. Its source refinement and Agda/Lean/Coq state witnesses remain open. +PR #32 subsequently bound the actual decoder/import and registry-kernel source. +PR #33 added the original wrapper call/scan profiles and an explicit raw-alias +counterexample. Its complete hosted campaign passed at head +`6823ff07297ca015a2461c00adc2ee2215633d1a` in +https://github.com/hyperpolymath/atoma/actions/runs/45580361419[run 45580361419], +including fresh Proven/UAA native checks and independent ECHIDNA/Coq replay. +Cross-kernel correspondence and native pointer/lifetime premises remain open. -* Proven: prove decoder acceptance iff the entire 64-bit word is a canonical - byte encoding, then bind the actual raw-word decoder source and its encoder - dependency. Immediate tagged words are not allocated objects; pointer-carrier - correspondence and later buffer leases remain separate obligations. -* UAA: prove state-preserving refusals, selected callback/context identity, - busy-state framing and restoration after a normally returning callback. - State the serialized access and borrowed-lifetime preconditions explicitly. -* Extend checked source interpretation to these operations, with an explicit - memory/alias counterexample before admitting pointer-bearing effects. The - ECHIDNA/coqchk path does not establish general Zig/compiler refinement. +* Proven: qualify the actual public pointer-to-slice entry against bounded + borrowed spans, null refusal and backend effects. Immediate tagged words are + not allocated objects; pointer-carrier correspondence remains separate. +* UAA: qualify retained callback/context lifetimes, shared registrations, + unregister and idle/busy destruction against the actual Zig declarations. +* The shared heap/permission protocol and both source-bound pilot extensions are + implemented by PR #34; its exact head must pass the full required campaign. + See link:../decisions/ATOMA-HEAP-BOUNDARY.adoc[acceptance and remaining premises]. * Second-language transfer spike before choosing the full sibling sequence. -Store, loops, permissions, compiler refinement and the complete required -kernel chain remain open. A passing scoped gate is not production readiness. +General store/loop/permission refinement, native allocation authority, compiler +refinement and the complete required kernel chain remain open. A passing scoped +gate is not production readiness. == Dogfooding status diff --git a/scripts/atoma-consumer-heap-gate.sh b/scripts/atoma-consumer-heap-gate.sh new file mode 100644 index 0000000..701836c --- /dev/null +++ b/scripts/atoma-consumer-heap-gate.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +set -euo pipefail +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +parent="$root/build/atoma-evidence/heap-consumers" +mkdir -p "$parent" +out=$(mktemp -d "$parent/run.XXXXXXXX") +work=$(mktemp -d) +echo INCOMPLETE > "$out/result.txt" +trap 'status=$?; if ((status)); then echo FAIL > "$out/result.txt"; fi; rm -rf "$work"' EXIT +for profile in public-header registry-lifetime; do + if [[ $profile == public-header ]]; then + repo=proven; pin=proven.pin + source=ffi/zig/src/core.zig; dependency=ffi/zig/src/main_refc.zig + else + repo=unified-api-adapter; pin=uaa.pin + source=src/interface/ffi/src/registry.zig; dependency=src/interface/ffi/src/registry_state.zig + fi + revision=$(cat "$root/tests/consumer-heap/$pin") + [[ $revision =~ ^[0-9a-f]{40}$ ]] + checkout="$work/$repo" + git init -q "$checkout" + git -C "$checkout" remote add origin "https://github.com/hyperpolymath/$repo.git" + git -C "$checkout" fetch -q --depth 1 origin "$revision" + git -C "$checkout" checkout -q --detach FETCH_HEAD + [[ $(git -C "$checkout" rev-parse HEAD) == "$revision" ]] + git -C "$checkout" diff --exit-code "$revision" -- + mkdir "$out/$profile" + echo "$revision" > "$out/$profile/revision.txt" + if [[ $profile == public-header ]]; then + EVIDENCE_DIR="$out/$profile/native" bash "$checkout/scripts/test-header-bridge.sh" + for marker in result.txt ownership/result.txt ownership-controls/result.txt boundary/result.txt boundary-controls/result.txt; do + [[ $(cat "$out/$profile/native/$marker") == PASS ]] + done + else + for slice in ownership ownership-controls lifetime lifetime-controls; do + EVIDENCE_DIR="$out/$profile/$slice" bash "$checkout/scripts/check-registry-$slice.sh" + [[ $(cat "$out/$profile/$slice/result.txt") == PASS ]] + done + fi + git -C "$checkout" diff --exit-code "$revision" -- > "$out/$profile/native-recheck.txt" + bash "$root/scripts/atoma-source-profile-replay.sh" "$profile" "$checkout/$source" "$checkout/$dependency" "$out/$profile/replay" + git -C "$checkout" diff --exit-code "$revision" -- > "$out/$profile/replay-recheck.txt" +done +echo PASS > "$out/result.txt" +echo 'HEAP CONSUMERS PASS: actual public entry and registry lifetime profiles; native authority and lifetime correspondence remain premises' diff --git a/scripts/atoma-public-header-capsule.sh b/scripts/atoma-public-header-capsule.sh new file mode 100644 index 0000000..61a8f1c --- /dev/null +++ b/scripts/atoma-public-header-capsule.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +set -euo pipefail +[[ $# == 3 ]] +for source in "$@"; do [[ -f $source && $(wc -c < "$source") -le 65536 ]]; done +cat <<'COQ' +From Coq Require Import List Bool Arith ZArith. +Require Import HeaderBoundarySource WrapperSource HeapOwnership. +Import ListNotations. +Open Scope nat_scope. +COQ +bytes() { + printf 'Definition %s : list nat := ' "$1" + od -An -v -tu1 "$2" | awk 'BEGIN {printf "["} {for(i=1;i<=NF;i++) {if(n++) printf ";"; printf "%s",$i}} END {print "]."}' +} +bytes core_bytes "$1" +bytes export_bytes "$2" +bytes backend_bytes "$3" +cat <<'COQ' +Lemma entry_accepted : HeaderBoundarySource.check core_bytes export_bytes = true. +Proof. vm_compute. reflexivity. Qed. +Lemma backend_accepted : WrapperSource.check_header backend_bytes = true. +Proof. vm_compute. reflexivity. Qed. +Theorem source_null_checked : forall h addr offset count tls backend, + exists p, HeaderBoundarySource.parse_core core_bytes = Some p /\ + HeaderBoundarySource.check_export export_bytes = true /\ + HeaderBoundarySource.run p false h addr offset count tls backend = + Some (HeaderBoundarySource.Observe (-1)%Z false h tls []). +Proof. intros; eapply HeaderBoundarySource.source_null; exact entry_accepted. Qed. +Theorem source_normal_checked : forall h addr offset count tls backend bytes retained readers, + h addr = HeapOwnership.Live bytes retained (S readers) -> + HeapOwnership.span_fits offset count bytes = true -> + HeaderBoundarySource.backend_frames addr backend -> + exists p, HeaderBoundarySource.parse_core core_bytes = Some p /\ + HeaderBoundarySource.check_export export_bytes = true /\ + exists observed, HeaderBoundarySource.run p true h addr offset count tls backend = Some observed /\ + HeaderBoundarySource.calls observed = [HeapOwnership.borrowed_span offset count bytes] /\ + HeaderBoundarySource.final_heap observed addr = h addr /\ + HeapOwnership.cell_step HeapOwnership.ReturnRead (HeaderBoundarySource.final_heap observed addr) = + Some (HeapOwnership.Live bytes retained readers). +Proof. intros; eapply HeaderBoundarySource.source_normal; eauto using entry_accepted. Qed. +Theorem source_result_checked : forall h addr offset count tls effect bytes retained readers step foreign, + h addr = HeapOwnership.Live bytes retained (S readers) -> + HeapOwnership.span_fits offset count bytes = true -> + Forall (fun b => b < 256) (HeapOwnership.borrowed_span offset count bytes) -> + (forall s b, b < 256 -> foreign (WrapperSource.encode s) b = Some (WrapperSource.encode (step s b))) -> + exists p, HeaderBoundarySource.parse_core core_bytes = Some p /\ + HeaderBoundarySource.check_export export_bytes = true /\ + exists observed, HeaderBoundarySource.run p true h addr offset count tls + (HeaderBoundarySource.interpreted_backend foreign effect) = Some observed /\ + HeaderBoundarySource.status observed = 0%Z /\ HeaderBoundarySource.value observed = + WrapperSource.fold step false (HeapOwnership.borrowed_span offset count bytes). +Proof. + intros; eapply HeaderBoundarySource.source_fold; + eauto using entry_accepted, backend_accepted. + unfold HeaderBoundarySource.implements_scan, HeaderBoundarySource.interpreted_backend; reflexivity. +Qed. +Print Assumptions source_null_checked. +Print Assumptions source_normal_checked. +Print Assumptions source_result_checked. +Print Assumptions backend_accepted. +COQ diff --git a/scripts/atoma-public-header-source-gate.sh b/scripts/atoma-public-header-source-gate.sh new file mode 100644 index 0000000..ae128e5 --- /dev/null +++ b/scripts/atoma-public-header-source-gate.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +set -euo pipefail +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +out="$root/build/heap-source-evidence/public-header" +mkdir -p "$out" +echo INCOMPLETE > "$out/result.txt" +work=$(mktemp -d) +trap 'status=$?; if ((status)); then echo FAIL > "$out/result.txt"; tail -n 40 "$out"/*.txt >&2; fi; rm -rf "$work"' EXIT +libraries=(ScalarSource RegistrySource WrapperSource HeapOwnership HeaderBoundaryContext HeaderBoundarySource) +revision=$(cat "$root/tests/consumer-heap/proven.pin") +[[ $revision =~ ^[0-9a-f]{40}$ ]] +echo "$revision" > "$out/revision.txt" +sha256sum "$root/scripts/atoma-public-header-source-gate.sh" "$root/scripts/atoma-public-header-capsule.sh" \ + "$root/tests/consumer-heap/proven.pin" > "$out/inputs.sha256" +for library in "${libraries[@]}"; do + sha256sum "$root/verification/atoma/consumer/coq/$library.v" >> "$out/inputs.sha256" + cp "$root/verification/atoma/consumer/coq/$library.v" "$work/" + cmp "$root/verification/atoma/consumer/coq/$library.v" "$work/$library.v" +done +for source in core main_refc header_refc; do + curl --proto '=https' --proto-redir '=https' --connect-timeout 20 --max-time 120 -fsSL --retry 1 \ + "https://raw.githubusercontent.com/hyperpolymath/proven/$revision/ffi/zig/src/$source.zig" -o "$work/$source.zig" +done +sha256sum -c "$out/inputs.sha256" > "$out/snapshot-recheck.txt" +cd "$work" +bash "$root/scripts/atoma-public-header-capsule.sh" core.zig main_refc.zig header_refc.zig > AtomaProof.v +sha256sum ./*.v ./*.zig > "$out/checked-inputs.sha256" +for library in "${libraries[@]}"; do coqc -q "$library.v" > "$out/$library.txt" 2>&1; done +[[ $(grep -c '^Closed under the global context$' "$out/HeaderBoundarySource.txt") == 5 ]] +coqc -q AtomaProof.v > "$out/capsule.txt" 2>&1 +[[ $(grep -c '^Closed under the global context$' "$out/capsule.txt") == 4 ]] +if grep -q '^Axioms:' "$out/capsule.txt" "$out/HeaderBoundarySource.txt"; then echo 'FAIL public header assumptions' >&2; exit 1; fi +coqchk -silent -Q . '' "${libraries[@]}" AtomaProof > "$out/coqchk.txt" 2>&1 +reject() { + local name=$1 core=core.zig exports=main_refc.zig backend=header_refc.zig + case "$2" in core) core=mutant.zig ;; export) exports=mutant.zig ;; backend) backend=mutant.zig ;; *) exit 2 ;; esac + bash "$root/scripts/atoma-public-header-capsule.sh" "$core" "$exports" "$backend" > Bad.v + if coqc -q Bad.v > "$out/reject-$name.txt" 2>&1; then echo "FAIL $name source accepted" >&2; exit 1; fi + grep -q 'Unable to unify' "$out/reject-$name.txt" +} +for mutation in slice null_status error_class null_order name context_status; do + case "$mutation" in + slice) sed '/^pub fn headerHasCrlf/,/^}/s/p\[0\.\.len\]/p[1..len]/' core.zig ;; + null_status) sed '/^pub fn headerHasCrlf/,/^}/s/status = PROVEN_ERR_NULL_POINTER/status = PROVEN_OK/' core.zig ;; + error_class) sed '/^pub fn headerHasCrlf/,/^}/s/) -99 else -7/) -7 else -99/' core.zig ;; + null_order) awk '{print} /^pub fn headerHasCrlf/ {print " if (ptr == null) _ = header_backend.detect(&.{}) catch false;"}' core.zig ;; + name) sed 's/pub fn headerHasCrlf(/pub fn headerChanged(/' core.zig ;; + context_status) sed 's/const PROVEN_ERR_NULL_POINTER: c_int = -1;/const PROVEN_ERR_NULL_POINTER: c_int = -2;/' core.zig ;; + esac > mutant.zig + if cmp -s core.zig mutant.zig; then echo 'FAIL unchanged public-entry mutant' >&2; exit 1; fi + reject "$mutation" core +done +for mutation in forwarding import; do + case "$mutation" in + forwarding) sed '/^pub export fn proven_header_has_crlf/,/^}/s/, ptr, len)/, ptr, 0)/' main_refc.zig ;; + import) sed 's/header_refc.zig/header_unavailable.zig/' main_refc.zig ;; + esac > mutant.zig + if cmp -s main_refc.zig mutant.zig; then echo 'FAIL unchanged public-export mutant' >&2; exit 1; fi + reject "$mutation" export +done +sed 's/next > 1/next > 2/' header_refc.zig > mutant.zig +if cmp -s header_refc.zig mutant.zig; then echo 'FAIL unchanged backend mutant' >&2; exit 1; fi +reject backend backend +sha256sum -c "$out/checked-inputs.sha256" > "$out/checked-input-recheck.txt" +sha256sum -c "$out/inputs.sha256" > "$out/input-recheck.txt" +cp ./*.v ./*.vo core.zig main_refc.zig header_refc.zig "$out/" +echo PASS > "$out/result.txt" +echo 'PUBLIC HEADER SOURCE PASS: closed original entry/export and checked backend; readable live region and compiler premises remain' diff --git a/scripts/atoma-registry-lifetime-capsule.sh b/scripts/atoma-registry-lifetime-capsule.sh new file mode 100644 index 0000000..1b8dc2a --- /dev/null +++ b/scripts/atoma-registry-lifetime-capsule.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +set -euo pipefail +[[ $# == 3 ]] +for source in "$@"; do [[ -f $source && $(wc -c < "$source") -le 65536 ]]; done +cat <<'COQ' +From Coq Require Import List Bool String. +Require Import ScalarSource RegistrySource WrapperSource HeapOwnership RegistryLifetimeSource. +Import ListNotations. +Open Scope string_scope. +Open Scope nat_scope. +COQ +bytes() { + printf 'Definition %s : list nat := ' "$1" + od -An -v -tu1 "$2" | awk 'BEGIN {printf "["} {for(i=1;i<=NF;i++) {if(n++) printf ";"; printf "%s",$i}} END {print "]."}' +} +bytes registry_bytes "$1" +bytes dependency_bytes "$2" +bytes protocol_bytes "$3" +cat <<'COQ' +Lemma source_accepted : RegistryLifetimeSource.check registry_bytes = true. +Proof. vm_compute. reflexivity. Qed. +Lemma dependency_accepted : RegistrySource.check dependency_bytes = true. +Proof. vm_compute. reflexivity. Qed. +Definition protocol_exports_known : bool := + match ScalarSource.lex (List.length protocol_bytes) protocol_bytes with + | Some ("pub" :: "fn" :: "known" :: _) => true + | _ => false end. +Lemma protocol_accepted : protocol_exports_known = true /\ + ScalarSource.parse protocol_bytes = Some (ScalarSource.inclusive_range 1 9). +Proof. vm_compute. split; reflexivity. Qed. +Theorem source_idle_release : exists p, RegistryLifetimeSource.parse registry_bytes = Some p /\ + forall s h addr payload, + RegistrySource.active s = false -> h addr = HeapOwnership.Live payload 0 0 -> RegistryLifetimeSource.accounted s h -> + RegistryLifetimeSource.status (RegistryLifetimeSource.destroy_run p true s h addr) = 0 /\ + forall key, RegistryLifetimeSource.store (RegistryLifetimeSource.destroy_run p true s h addr) key = + RegistryLifetimeSource.detach s (snd (HeapOwnership.run HeapOwnership.Release h addr)) key. +Proof. apply RegistryLifetimeSource.source_idle_release; exact source_accepted. Qed. +Theorem source_busy_preserves : exists p, RegistryLifetimeSource.parse registry_bytes = Some p /\ + forall s h addr payload retained readers, + h addr = HeapOwnership.Live payload retained readers -> RegistrySource.active s = true -> + RegistryLifetimeSource.destroy_run p true s h addr = RegistryLifetimeSource.Destroyed 6 h (Some s). +Proof. apply RegistryLifetimeSource.source_busy_preserves; exact source_accepted. Qed. +Theorem source_other_allocation_live : exists p, RegistryLifetimeSource.parse registry_bytes = Some p /\ + forall s h addr key registry_payload payload retained readers, + h addr = HeapOwnership.Live registry_payload 0 0 -> + RegistrySource.active s = false -> key <> addr -> RegistryLifetimeSource.accounted s h -> + h key = HeapOwnership.Live payload retained readers -> + exists remaining, RegistryLifetimeSource.store (RegistryLifetimeSource.destroy_run p true s h addr) key = + HeapOwnership.Live payload remaining readers /\ remaining + RegistryLifetimeSource.retentions s key = retained. +Proof. apply RegistryLifetimeSource.source_other_allocation_live; exact source_accepted. Qed. +Theorem source_detaches_registrations : exists p, RegistryLifetimeSource.parse registry_bytes = Some p /\ + forall s h addr payload, h addr = HeapOwnership.Live payload 0 0 -> + RegistryLifetimeSource.accounted s h -> RegistrySource.active s = false -> + RegistryLifetimeSource.registration (RegistryLifetimeSource.destroy_run p true s h addr) = None. +Proof. apply RegistryLifetimeSource.source_detaches_registrations; exact source_accepted. Qed. +Print Assumptions source_idle_release. +Print Assumptions source_busy_preserves. +Print Assumptions source_other_allocation_live. +Print Assumptions source_detaches_registrations. +Print Assumptions dependency_accepted. +Print Assumptions protocol_accepted. +COQ diff --git a/scripts/atoma-registry-lifetime-source-gate.sh b/scripts/atoma-registry-lifetime-source-gate.sh new file mode 100644 index 0000000..f2bb71b --- /dev/null +++ b/scripts/atoma-registry-lifetime-source-gate.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +set -euo pipefail +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +parent="$root/build/heap-source-evidence/registry" +mkdir -p "$parent" +out=$(mktemp -d "$parent/run.XXXXXXXX") +work=$(mktemp -d) +echo INCOMPLETE > "$out/result.txt" +trap 'status=$?; if ((status)); then echo FAIL > "$out/result.txt"; tail -n 40 "$out"/*.txt >&2; fi; rm -rf "$work"' EXIT +libraries=(ScalarSource RegistrySource WrapperSource HeapOwnership RegistryLifetimeSource) +sources=(scripts/atoma-registry-lifetime-source-gate.sh scripts/atoma-registry-lifetime-capsule.sh tests/consumer-heap/uaa.pin) +for library in "${libraries[@]}"; do sources+=("verification/atoma/consumer/coq/$library.v"); done +(cd "$root"; sha256sum "${sources[@]}") > "$out/source-inputs.sha256" +for library in "${libraries[@]}"; do + cp "$root/verification/atoma/consumer/coq/$library.v" "$work/" + cmp "$root/verification/atoma/consumer/coq/$library.v" "$work/$library.v" +done +revision=$(cat "$root/tests/consumer-heap/uaa.pin") +[[ $revision =~ ^[0-9a-f]{40}$ ]] +printf '%s\n' "$revision" > "$out/revision.txt" +for source in registry registry_state protocol_tag; do + curl --proto '=https' --proto-redir '=https' --connect-timeout 20 --max-time 120 -fsSL --retry 1 \ + "https://raw.githubusercontent.com/hyperpolymath/unified-api-adapter/$revision/src/interface/ffi/src/$source.zig" -o "$work/$source.zig" +done +(cd "$root"; sha256sum -c "$out/source-inputs.sha256") > "$out/snapshot-recheck.txt" +cd "$work" +sha256sum ./*.v ./*.zig > "$out/checked-inputs.sha256" +for library in "${libraries[@]}"; do + printf 'LIFETIME SOURCE: compiling %s\n' "$library" + coqc -q "$library.v" > "$out/$library.txt" 2>&1 +done +[[ $(grep -c '^Closed under the global context$' "$out/RegistryLifetimeSource.txt") == 4 ]] +bash "$root/scripts/atoma-registry-lifetime-capsule.sh" registry.zig registry_state.zig protocol_tag.zig > AtomaProof.v +coqc -q AtomaProof.v > "$out/capsule.txt" 2>&1 +[[ $(grep -c '^Closed under the global context$' "$out/capsule.txt") == 6 ]] +if grep -q '^Axioms:' "$out/capsule.txt"; then echo 'FAIL: lifetime capsule axioms' >&2; exit 1; fi +coqchk -silent -Q . '' "${libraries[@]}" AtomaProof > "$out/coqchk.txt" 2>&1 +for mutation in remove-busy reorder-busy free-context clear-instead-free; do + case "$mutation" in + remove-busy) + sed '/pub export fn uaa_registry_destroy/,/^}/ { /if (registry.active) return 6;/d; }' registry.zig > mutant.zig ;; + reorder-busy) + awk '/pub export fn uaa_registry_destroy/ {inside=1} + inside && /if \(registry.active\) return 6;/ {next} + {print} + inside && /std.heap.c_allocator.destroy\(registry\);/ {print " if (registry.active) return 6;"} + inside && /^}/ {inside=0}' registry.zig > mutant.zig ;; + free-context) + sed 's/std.heap.c_allocator.destroy(registry);/std.heap.c_allocator.destroy(registry.rest.?.context);/' registry.zig > mutant.zig ;; + clear-instead-free) + sed 's/std.heap.c_allocator.destroy(registry);/registry.* = .{};/' registry.zig > mutant.zig ;; + esac + if cmp -s registry.zig mutant.zig; then echo "FAIL unchanged $mutation mutant" >&2; exit 1; fi + bash "$root/scripts/atoma-registry-lifetime-capsule.sh" mutant.zig registry_state.zig protocol_tag.zig > Bad.v + if coqc -q Bad.v > "$out/reject-$mutation.txt" 2>&1; then + echo "FAIL $mutation accepted" >&2; exit 1 + fi + grep -q 'Unable to unify' "$out/reject-$mutation.txt" + cp mutant.zig "$out/$mutation.zig" +done +sha256sum -c "$out/checked-inputs.sha256" > "$out/checked-input-recheck.txt" +(cd "$root"; sha256sum -c "$out/source-inputs.sha256") > "$out/source-recheck.txt" +cp registry.zig registry_state.zig protocol_tag.zig AtomaProof.v AtomaProof.vo "$out/" +sha256sum AtomaProof.v AtomaProof.vo > "$out/capsule.sha256" +echo PASS > "$out/result.txt" +echo 'REGISTRY LIFETIME SOURCE PASS: parsed destroy guards and allocator effect; native pointer, caller authority and ghost-accounting premises remain' diff --git a/scripts/atoma-source-profile-replay.sh b/scripts/atoma-source-profile-replay.sh index 0e5cca9..e2a5381 100644 --- a/scripts/atoma-source-profile-replay.sh +++ b/scripts/atoma-source-profile-replay.sh @@ -22,16 +22,28 @@ case "$profile" in libraries=(ScalarSource RegistrySource) reports=1 ;; - registry-wrapper|header-wrapper) + registry-wrapper|header-wrapper|registry-lifetime) import_path=$(realpath "$3") cp "$import_path" "$out/dependency.zig" libraries=(ScalarSource RegistrySource WrapperSource) reports=1 - if [[ $profile == registry-wrapper ]]; then + if [[ $profile == registry-wrapper || $profile == registry-lifetime ]]; then protocol_path=$(dirname "$source_path")/protocol_tag.zig cp "$protocol_path" "$out/protocol_tag.zig" reports=3 fi + if [[ $profile == registry-lifetime ]]; then + libraries+=(HeapOwnership RegistryLifetimeSource) + reports=6 + fi + ;; + public-header) + import_path=$(realpath "$3") + cp "$import_path" "$out/dependency.zig" + backend_path=$(dirname "$source_path")/header_refc.zig + cp "$backend_path" "$out/backend.zig" + libraries=(ScalarSource RegistrySource WrapperSource HeapOwnership HeaderBoundaryContext HeaderBoundarySource) + reports=4 ;; *) fail 'unsupported source profile' ;; esac @@ -44,6 +56,8 @@ capsule() { registry) bash "$root/scripts/atoma-registry-capsule.sh" "$out/source.zig" ;; registry-wrapper) bash "$root/scripts/atoma-wrapper-capsule.sh" registry "$out/source.zig" "$out/dependency.zig" "$out/protocol_tag.zig" ;; header-wrapper) bash "$root/scripts/atoma-wrapper-capsule.sh" header "$out/source.zig" "$out/dependency.zig" - ;; + registry-lifetime) bash "$root/scripts/atoma-registry-lifetime-capsule.sh" "$out/source.zig" "$out/dependency.zig" "$out/protocol_tag.zig" ;; + public-header) bash "$root/scripts/atoma-public-header-capsule.sh" "$out/source.zig" "$out/dependency.zig" "$out/backend.zig" ;; esac } capsule > "$out/AtomaProof.v" @@ -69,8 +83,9 @@ timeout -k 5 180 coqc -q Audit.v > assumptions.txt 2>&1 if grep -q '^Axioms:' assumptions.txt; then fail 'audit reported axioms'; fi cmp -s source.zig "$source_path" || fail 'source changed during replay' if [[ $profile == decoder ]]; then cmp -s encoder.zig "$import_path" || fail 'import changed'; fi -if [[ $profile == *-wrapper ]]; then cmp -s dependency.zig "$import_path" || fail 'wrapper dependency changed'; fi -if [[ $profile == registry-wrapper ]]; then cmp -s protocol_tag.zig "$protocol_path" || fail 'protocol dependency changed'; fi +if [[ $profile == *-wrapper || $profile == registry-lifetime || $profile == public-header ]]; then cmp -s dependency.zig "$import_path" || fail 'entry dependency changed'; fi +if [[ $profile == registry-wrapper || $profile == registry-lifetime ]]; then cmp -s protocol_tag.zig "$protocol_path" || fail 'protocol dependency changed'; fi +if [[ $profile == public-header ]]; then cmp -s backend.zig "$backend_path" || fail 'header backend changed'; fi for library in "${libraries[@]}"; do cmp -s "$library.v" "$root/verification/atoma/consumer/coq/$library.v" || fail 'checker changed' done diff --git a/tests/consumer-heap/proven.pin b/tests/consumer-heap/proven.pin new file mode 100644 index 0000000..0aa76d0 --- /dev/null +++ b/tests/consumer-heap/proven.pin @@ -0,0 +1 @@ +24bc1fbed4f250be32b9aa3cb27d130fe75cfcd3 diff --git a/tests/consumer-heap/uaa.pin b/tests/consumer-heap/uaa.pin new file mode 100644 index 0000000..9996619 --- /dev/null +++ b/tests/consumer-heap/uaa.pin @@ -0,0 +1 @@ +3738d5467908374f13546a9744093bdaf5cbb63a diff --git a/verification/atoma/consumer/agda/HeapOwnership.agda b/verification/atoma/consumer/agda/HeapOwnership.agda index 5c6d562..eed78c7 100644 --- a/verification/atoma/consumer/agda/HeapOwnership.agda +++ b/verification/atoma/consumer/agda/HeapOwnership.agda @@ -132,6 +132,7 @@ drop : {A : Set} → Nat → List A → List A drop zero xs = xs drop (suc n) [] = [] drop (suc n) (_ ∷ xs) = drop n xs +infix 4 _≤_ data _≤_ : Nat → Nat → Set where z≤n : ∀ {n} → zero ≤ n s≤s : ∀ {m n} → m ≤ n → suc m ≤ suc n diff --git a/verification/atoma/consumer/coq/HeaderBoundaryContext.v b/verification/atoma/consumer/coq/HeaderBoundaryContext.v new file mode 100644 index 0000000..9d4d376 --- /dev/null +++ b/verification/atoma/consumer/coq/HeaderBoundaryContext.v @@ -0,0 +1,12 @@ +(* SPDX-License-Identifier: MPL-2.0 *) +(* Reviewed closed context at Proven d5eb0bf66538c15d8ed88ced95edf7c2b70cbc81. + Full original modules are admitted; only the designated function bodies are + interpreted. Constants, result layout, imports, setError and every surrounding + declaration/test are byte-fixed, including the final newline. Other legacy + exports acquire no safety theorem merely because their bytes are retained. *) +From Coq Require Import List. +Import ListNotations. +Definition core_prefix : list nat := [47;47;32;83;80;68;88;45;76;105;99;101;110;115;101;45;73;100;101;110;116;105;102;105;101;114;58;32;77;80;76;45;50;46;48;10;47;47;32;80;82;79;86;69;78;32;70;70;73;32;73;109;112;108;101;109;101;110;116;97;116;105;111;110;10;47;47;10;47;47;32;84;104;105;115;32;109;111;100;117;108;101;32;105;109;112;108;101;109;101;110;116;115;32;116;104;101;32;67;45;99;111;109;112;97;116;105;98;108;101;32;70;70;73;32;100;101;99;108;97;114;101;100;32;105;110;32;115;114;99;47;97;98;105;47;70;111;114;101;105;103;110;46;105;100;114;10;47;47;32;65;108;108;32;116;121;112;101;115;32;97;110;100;32;108;97;121;111;117;116;115;32;109;117;115;116;32;109;97;116;99;104;32;116;104;101;32;73;100;114;105;115;50;32;65;66;73;32;100;101;102;105;110;105;116;105;111;110;115;46;10;47;47;10;10;99;111;110;115;116;32;115;116;100;32;61;32;64;105;109;112;111;114;116;40;34;115;116;100;34;41;59;10;99;111;110;115;116;32;108;105;102;101;99;121;99;108;101;32;61;32;64;105;109;112;111;114;116;40;34;108;105;102;101;99;121;99;108;101;34;41;59;10;10;47;47;32;86;101;114;115;105;111;110;32;105;110;102;111;114;109;97;116;105;111;110;32;40;107;101;101;112;32;105;110;32;115;121;110;99;32;119;105;116;104;32;112;114;111;106;101;99;116;41;10;99;111;110;115;116;32;86;69;82;83;73;79;78;32;61;32;34;48;46;49;46;48;34;59;10;99;111;110;115;116;32;66;85;73;76;68;95;73;78;70;79;32;61;32;34;80;82;79;86;69;78;32;98;117;105;108;116;32;119;105;116;104;32;90;105;103;32;34;32;43;43;32;64;105;109;112;111;114;116;40;34;98;117;105;108;116;105;110;34;41;46;122;105;103;95;118;101;114;115;105;111;110;95;115;116;114;105;110;103;59;10;10;47;47;47;32;84;104;114;101;97;100;45;108;111;99;97;108;32;101;114;114;111;114;32;115;116;111;114;97;103;101;10;116;104;114;101;97;100;108;111;99;97;108;32;118;97;114;32;108;97;115;116;95;101;114;114;111;114;58;32;63;91;58;48;93;99;111;110;115;116;32;117;56;32;61;32;110;117;108;108;59;10;10;47;47;47;32;83;101;116;32;116;104;101;32;108;97;115;116;32;101;114;114;111;114;32;109;101;115;115;97;103;101;10;102;110;32;115;101;116;69;114;114;111;114;40;99;111;109;112;116;105;109;101;32;109;115;103;58;32;91;58;48;93;99;111;110;115;116;32;117;56;41;32;118;111;105;100;32;123;10;32;32;32;32;108;97;115;116;95;101;114;114;111;114;32;61;32;109;115;103;59;10;125;10;10;47;47;47;32;67;108;101;97;114;32;116;104;101;32;108;97;115;116;32;101;114;114;111;114;10;102;110;32;99;108;101;97;114;69;114;114;111;114;40;41;32;118;111;105;100;32;123;10;32;32;32;32;108;97;115;116;95;101;114;114;111;114;32;61;32;110;117;108;108;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;67;111;114;101;32;84;121;112;101;115;32;40;109;117;115;116;32;109;97;116;99;104;32;115;114;99;47;97;98;105;47;84;121;112;101;115;46;105;100;114;41;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;82;101;115;117;108;116;32;99;111;100;101;115;32;40;109;117;115;116;32;109;97;116;99;104;32;73;100;114;105;115;50;32;82;101;115;117;108;116;32;116;121;112;101;41;10;112;117;98;32;99;111;110;115;116;32;82;101;115;117;108;116;32;61;32;101;110;117;109;40;99;95;105;110;116;41;32;123;10;32;32;32;32;111;107;32;61;32;48;44;10;32;32;32;32;64;34;101;114;114;111;114;34;32;61;32;49;44;10;32;32;32;32;105;110;118;97;108;105;100;95;112;97;114;97;109;32;61;32;50;44;10;32;32;32;32;111;117;116;95;111;102;95;109;101;109;111;114;121;32;61;32;51;44;10;32;32;32;32;110;117;108;108;95;112;111;105;110;116;101;114;32;61;32;52;44;10;125;59;10;10;47;47;47;32;76;105;98;114;97;114;121;32;104;97;110;100;108;101;46;32;32;67;32;99;111;110;115;117;109;101;114;115;32;114;101;99;101;105;118;101;32;111;110;108;121;32;97;32;112;111;105;110;116;101;114;44;32;115;111;32;67;32;99;111;100;101;32;116;114;101;97;116;115;32;105;116;10;47;47;47;32;97;115;32;111;112;97;113;117;101;46;32;32;90;105;103;32;99;111;100;101;32;97;99;99;101;115;115;101;115;32;102;105;101;108;100;115;32;100;105;114;101;99;116;108;121;32;118;105;97;32;116;104;101;32;112;111;105;110;116;101;114;46;10;112;117;98;32;99;111;110;115;116;32;72;97;110;100;108;101;32;61;32;115;116;114;117;99;116;32;123;10;32;32;32;32;97;108;108;111;99;97;116;111;114;58;32;115;116;100;46;109;101;109;46;65;108;108;111;99;97;116;111;114;44;10;32;32;32;32;105;110;105;116;105;97;108;105;122;101;100;58;32;98;111;111;108;44;10;125;59;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;76;105;98;114;97;114;121;32;76;105;102;101;99;121;99;108;101;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;73;110;105;116;105;97;108;105;122;101;32;116;104;101;32;108;105;98;114;97;114;121;10;47;47;47;32;82;101;116;117;114;110;115;32;97;32;104;97;110;100;108;101;44;32;111;114;32;110;117;108;108;32;111;110;32;102;97;105;108;117;114;101;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;104;97;110;100;108;101;95;99;114;101;97;116;101;40;41;32;63;42;72;97;110;100;108;101;32;123;10;32;32;32;32;99;111;110;115;116;32;97;108;108;111;99;97;116;111;114;32;61;32;115;116;100;46;104;101;97;112;46;99;95;97;108;108;111;99;97;116;111;114;59;10;10;32;32;32;32;99;111;110;115;116;32;104;97;110;100;108;101;32;61;32;97;108;108;111;99;97;116;111;114;46;99;114;101;97;116;101;40;72;97;110;100;108;101;41;32;99;97;116;99;104;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;70;97;105;108;101;100;32;116;111;32;97;108;108;111;99;97;116;101;32;104;97;110;100;108;101;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;110;117;108;108;59;10;32;32;32;32;125;59;10;10;32;32;32;32;47;47;32;73;110;105;116;105;97;108;105;122;101;32;104;97;110;100;108;101;10;32;32;32;32;104;97;110;100;108;101;46;42;32;61;32;46;123;10;32;32;32;32;32;32;32;32;46;97;108;108;111;99;97;116;111;114;32;61;32;97;108;108;111;99;97;116;111;114;44;10;32;32;32;32;32;32;32;32;46;105;110;105;116;105;97;108;105;122;101;100;32;61;32;116;114;117;101;44;10;32;32;32;32;125;59;10;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;32;32;32;32;114;101;116;117;114;110;32;104;97;110;100;108;101;59;10;125;10;10;47;47;47;32;67;97;110;111;110;105;99;97;108;32;110;111;45;97;114;103;117;109;101;110;116;32;108;105;102;101;99;121;99;108;101;32;65;66;73;46;32;80;111;108;105;99;121;32;105;115;32;105;109;112;108;101;109;101;110;116;101;100;32;105;110;32;73;100;114;105;115;46;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;105;110;105;116;40;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;105;51;50;32;123;10;32;32;32;32;114;101;116;117;114;110;32;108;105;102;101;99;121;99;108;101;46;105;110;105;116;40;41;59;10;125;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;100;101;105;110;105;116;40;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;118;111;105;100;32;123;10;32;32;32;32;108;105;102;101;99;121;99;108;101;46;100;101;105;110;105;116;40;41;59;10;125;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;105;115;95;105;110;105;116;105;97;108;105;122;101;100;40;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;98;111;111;108;32;123;10;32;32;32;32;114;101;116;117;114;110;32;108;105;102;101;99;121;99;108;101;46;105;115;73;110;105;116;105;97;108;105;122;101;100;40;41;59;10;125;10;47;47;47;32;70;114;101;101;32;116;104;101;32;108;105;98;114;97;114;121;32;104;97;110;100;108;101;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;102;114;101;101;40;104;97;110;100;108;101;58;32;63;42;72;97;110;100;108;101;41;32;118;111;105;100;32;123;10;32;32;32;32;99;111;110;115;116;32;104;32;61;32;104;97;110;100;108;101;32;111;114;101;108;115;101;32;114;101;116;117;114;110;59;10;32;32;32;32;99;111;110;115;116;32;97;108;108;111;99;97;116;111;114;32;61;32;104;46;97;108;108;111;99;97;116;111;114;59;10;10;32;32;32;32;47;47;32;67;108;101;97;110;32;117;112;32;114;101;115;111;117;114;99;101;115;10;32;32;32;32;104;46;105;110;105;116;105;97;108;105;122;101;100;32;61;32;102;97;108;115;101;59;10;10;32;32;32;32;97;108;108;111;99;97;116;111;114;46;100;101;115;116;114;111;121;40;104;41;59;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;125;10;10;47;47;47;32;82;101;116;117;114;110;32;116;104;101;32;108;105;98;114;97;114;121;32;118;101;114;115;105;111;110;32;116;114;105;112;108;101;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;118;101;114;115;105;111;110;95;109;97;106;111;114;40;41;32;117;51;50;32;123;10;32;32;32;32;114;101;116;117;114;110;32;49;59;10;125;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;118;101;114;115;105;111;110;95;109;105;110;111;114;40;41;32;117;51;50;32;123;10;32;32;32;32;114;101;116;117;114;110;32;49;59;10;125;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;118;101;114;115;105;111;110;95;112;97;116;99;104;40;41;32;117;51;50;32;123;10;32;32;32;32;114;101;116;117;114;110;32;48;59;10;125;10;10;47;47;47;32;82;101;116;117;114;110;32;116;104;101;32;70;70;73;32;65;66;73;32;118;101;114;115;105;111;110;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;102;102;105;95;97;98;105;95;118;101;114;115;105;111;110;40;41;32;117;51;50;32;123;10;32;32;32;32;114;101;116;117;114;110;32;50;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;67;111;114;101;32;79;112;101;114;97;116;105;111;110;115;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;80;114;111;99;101;115;115;32;100;97;116;97;32;40;101;120;97;109;112;108;101;32;111;112;101;114;97;116;105;111;110;41;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;112;114;111;99;101;115;115;40;104;97;110;100;108;101;58;32;63;42;72;97;110;100;108;101;44;32;105;110;112;117;116;58;32;117;51;50;41;32;82;101;115;117;108;116;32;123;10;32;32;32;32;99;111;110;115;116;32;104;32;61;32;104;97;110;100;108;101;32;111;114;101;108;115;101;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;78;117;108;108;32;104;97;110;100;108;101;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;110;117;108;108;95;112;111;105;110;116;101;114;59;10;32;32;32;32;125;59;10;10;32;32;32;32;105;102;32;40;33;104;46;105;110;105;116;105;97;108;105;122;101;100;41;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;72;97;110;100;108;101;32;110;111;116;32;105;110;105;116;105;97;108;105;122;101;100;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;64;34;101;114;114;111;114;34;59;10;32;32;32;32;125;10;10;32;32;32;32;47;47;32;69;120;97;109;112;108;101;32;112;114;111;99;101;115;115;105;110;103;32;108;111;103;105;99;10;32;32;32;32;95;32;61;32;105;110;112;117;116;59;10;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;32;32;32;32;114;101;116;117;114;110;32;46;111;107;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;83;116;114;105;110;103;32;79;112;101;114;97;116;105;111;110;115;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;71;101;116;32;97;32;115;116;114;105;110;103;32;114;101;115;117;108;116;32;40;101;120;97;109;112;108;101;41;10;47;47;47;32;67;97;108;108;101;114;32;109;117;115;116;32;102;114;101;101;32;116;104;101;32;114;101;116;117;114;110;101;100;32;115;116;114;105;110;103;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;103;101;116;95;115;116;114;105;110;103;40;104;97;110;100;108;101;58;32;63;42;72;97;110;100;108;101;41;32;63;91;42;58;48;93;99;111;110;115;116;32;117;56;32;123;10;32;32;32;32;99;111;110;115;116;32;104;32;61;32;104;97;110;100;108;101;32;111;114;101;108;115;101;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;78;117;108;108;32;104;97;110;100;108;101;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;110;117;108;108;59;10;32;32;32;32;125;59;10;10;32;32;32;32;105;102;32;40;33;104;46;105;110;105;116;105;97;108;105;122;101;100;41;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;72;97;110;100;108;101;32;110;111;116;32;105;110;105;116;105;97;108;105;122;101;100;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;110;117;108;108;59;10;32;32;32;32;125;10;10;32;32;32;32;47;47;32;69;120;97;109;112;108;101;58;32;97;108;108;111;99;97;116;101;32;97;110;100;32;114;101;116;117;114;110;32;97;32;115;116;114;105;110;103;10;32;32;32;32;99;111;110;115;116;32;114;101;115;117;108;116;32;61;32;104;46;97;108;108;111;99;97;116;111;114;46;100;117;112;101;90;40;117;56;44;32;34;69;120;97;109;112;108;101;32;114;101;115;117;108;116;34;41;32;99;97;116;99;104;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;70;97;105;108;101;100;32;116;111;32;97;108;108;111;99;97;116;101;32;115;116;114;105;110;103;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;110;117;108;108;59;10;32;32;32;32;125;59;10;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;32;32;32;32;114;101;116;117;114;110;32;114;101;115;117;108;116;46;112;116;114;59;10;125;10;10;47;47;47;32;70;114;101;101;32;97;32;115;116;114;105;110;103;32;97;108;108;111;99;97;116;101;100;32;98;121;32;116;104;101;32;108;105;98;114;97;114;121;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;102;114;101;101;95;115;116;114;105;110;103;40;115;116;114;58;32;63;91;42;58;48;93;99;111;110;115;116;32;117;56;41;32;118;111;105;100;32;123;10;32;32;32;32;99;111;110;115;116;32;115;32;61;32;115;116;114;32;111;114;101;108;115;101;32;114;101;116;117;114;110;59;10;32;32;32;32;99;111;110;115;116;32;97;108;108;111;99;97;116;111;114;32;61;32;115;116;100;46;104;101;97;112;46;99;95;97;108;108;111;99;97;116;111;114;59;10;10;32;32;32;32;99;111;110;115;116;32;115;108;105;99;101;32;61;32;115;116;100;46;109;101;109;46;115;112;97;110;40;115;41;59;10;32;32;32;32;97;108;108;111;99;97;116;111;114;46;102;114;101;101;40;115;108;105;99;101;41;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;65;114;114;97;121;47;66;117;102;102;101;114;32;79;112;101;114;97;116;105;111;110;115;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;80;114;111;99;101;115;115;32;97;110;32;97;114;114;97;121;32;111;102;32;100;97;116;97;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;112;114;111;99;101;115;115;95;97;114;114;97;121;40;10;32;32;32;32;104;97;110;100;108;101;58;32;63;42;72;97;110;100;108;101;44;10;32;32;32;32;98;117;102;102;101;114;58;32;63;91;42;93;99;111;110;115;116;32;117;56;44;10;32;32;32;32;108;101;110;58;32;117;51;50;44;10;41;32;82;101;115;117;108;116;32;123;10;32;32;32;32;99;111;110;115;116;32;104;32;61;32;104;97;110;100;108;101;32;111;114;101;108;115;101;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;78;117;108;108;32;104;97;110;100;108;101;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;110;117;108;108;95;112;111;105;110;116;101;114;59;10;32;32;32;32;125;59;10;10;32;32;32;32;99;111;110;115;116;32;98;117;102;32;61;32;98;117;102;102;101;114;32;111;114;101;108;115;101;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;78;117;108;108;32;98;117;102;102;101;114;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;110;117;108;108;95;112;111;105;110;116;101;114;59;10;32;32;32;32;125;59;10;10;32;32;32;32;105;102;32;40;33;104;46;105;110;105;116;105;97;108;105;122;101;100;41;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;72;97;110;100;108;101;32;110;111;116;32;105;110;105;116;105;97;108;105;122;101;100;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;64;34;101;114;114;111;114;34;59;10;32;32;32;32;125;10;10;32;32;32;32;47;47;32;65;99;99;101;115;115;32;116;104;101;32;98;117;102;102;101;114;10;32;32;32;32;99;111;110;115;116;32;100;97;116;97;32;61;32;98;117;102;91;48;46;46;108;101;110;93;59;10;32;32;32;32;95;32;61;32;100;97;116;97;59;10;10;32;32;32;32;47;47;32;80;114;111;99;101;115;115;32;100;97;116;97;32;104;101;114;101;10;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;32;32;32;32;114;101;116;117;114;110;32;46;111;107;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;69;114;114;111;114;32;72;97;110;100;108;105;110;103;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;71;101;116;32;116;104;101;32;108;97;115;116;32;101;114;114;111;114;32;109;101;115;115;97;103;101;10;47;47;47;32;82;101;116;117;114;110;115;32;110;117;108;108;32;105;102;32;110;111;32;101;114;114;111;114;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;108;97;115;116;95;101;114;114;111;114;40;41;32;63;91;42;58;48;93;99;111;110;115;116;32;117;56;32;123;10;32;32;32;32;99;111;110;115;116;32;101;114;114;32;61;32;108;97;115;116;95;101;114;114;111;114;32;111;114;101;108;115;101;32;114;101;116;117;114;110;32;110;117;108;108;59;10;10;32;32;32;32;47;47;32;66;111;114;114;111;119;101;100;32;115;116;97;116;105;99;32;115;116;111;114;97;103;101;59;32;99;97;108;108;101;114;115;32;109;117;115;116;32;110;111;116;32;102;114;101;101;32;116;104;105;115;32;112;111;105;110;116;101;114;46;10;32;32;32;32;114;101;116;117;114;110;32;101;114;114;46;112;116;114;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;86;101;114;115;105;111;110;32;73;110;102;111;114;109;97;116;105;111;110;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;71;101;116;32;116;104;101;32;108;105;98;114;97;114;121;32;118;101;114;115;105;111;110;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;118;101;114;115;105;111;110;40;41;32;91;42;58;48;93;99;111;110;115;116;32;117;56;32;123;10;32;32;32;32;114;101;116;117;114;110;32;86;69;82;83;73;79;78;46;112;116;114;59;10;125;10;10;47;47;47;32;71;101;116;32;98;117;105;108;100;32;105;110;102;111;114;109;97;116;105;111;110;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;98;117;105;108;100;95;105;110;102;111;40;41;32;91;42;58;48;93;99;111;110;115;116;32;117;56;32;123;10;32;32;32;32;114;101;116;117;114;110;32;66;85;73;76;68;95;73;78;70;79;46;112;116;114;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;67;97;108;108;98;97;99;107;32;83;117;112;112;111;114;116;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;67;97;108;108;98;97;99;107;32;102;117;110;99;116;105;111;110;32;116;121;112;101;32;40;67;32;65;66;73;41;10;112;117;98;32;99;111;110;115;116;32;67;97;108;108;98;97;99;107;32;61;32;42;99;111;110;115;116;32;102;110;32;40;117;54;52;44;32;117;51;50;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;117;51;50;59;10;10;47;47;47;32;82;101;103;105;115;116;101;114;32;97;32;99;97;108;108;98;97;99;107;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;114;101;103;105;115;116;101;114;95;99;97;108;108;98;97;99;107;40;10;32;32;32;32;104;97;110;100;108;101;58;32;63;42;72;97;110;100;108;101;44;10;32;32;32;32;99;97;108;108;98;97;99;107;58;32;63;67;97;108;108;98;97;99;107;44;10;41;32;82;101;115;117;108;116;32;123;10;32;32;32;32;99;111;110;115;116;32;104;32;61;32;104;97;110;100;108;101;32;111;114;101;108;115;101;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;78;117;108;108;32;104;97;110;100;108;101;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;110;117;108;108;95;112;111;105;110;116;101;114;59;10;32;32;32;32;125;59;10;10;32;32;32;32;99;111;110;115;116;32;99;98;32;61;32;99;97;108;108;98;97;99;107;32;111;114;101;108;115;101;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;78;117;108;108;32;99;97;108;108;98;97;99;107;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;110;117;108;108;95;112;111;105;110;116;101;114;59;10;32;32;32;32;125;59;10;10;32;32;32;32;105;102;32;40;33;104;46;105;110;105;116;105;97;108;105;122;101;100;41;32;123;10;32;32;32;32;32;32;32;32;115;101;116;69;114;114;111;114;40;34;72;97;110;100;108;101;32;110;111;116;32;105;110;105;116;105;97;108;105;122;101;100;34;41;59;10;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;46;64;34;101;114;114;111;114;34;59;10;32;32;32;32;125;10;10;32;32;32;32;47;47;32;83;116;111;114;101;32;99;97;108;108;98;97;99;107;32;102;111;114;32;108;97;116;101;114;32;117;115;101;10;32;32;32;32;95;32;61;32;99;98;59;10;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;32;32;32;32;114;101;116;117;114;110;32;46;111;107;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;83;97;102;101;80;97;116;104;32;226;128;148;32;70;105;108;101;115;121;115;116;101;109;32;116;114;97;118;101;114;115;97;108;32;112;114;101;118;101;110;116;105;111;110;10;47;47;32;77;97;116;99;104;101;115;32;116;104;101;32;100;101;99;108;97;114;97;116;105;111;110;115;32;105;110;32;112;114;111;118;101;110;46;104;32;97;110;100;32;115;114;99;47;97;98;105;47;70;111;114;101;105;103;110;46;105;100;114;46;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;67;45;65;66;73;32;114;101;115;117;108;116;32;116;121;112;101;32;102;111;114;32;98;111;111;108;101;97;110;32;111;112;101;114;97;116;105;111;110;115;32;40;109;97;116;99;104;101;115;32;80;114;111;118;101;110;66;111;111;108;82;101;115;117;108;116;32;105;110;32;112;114;111;118;101;110;46;104;41;46;10;47;47;47;32;76;97;121;111;117;116;58;32;123;32;115;116;97;116;117;115;58;32;105;51;50;44;32;118;97;108;117;101;58;32;98;111;111;108;32;125;32;32;40;52;32;43;32;49;32;98;121;116;101;115;59;32;99;111;109;112;105;108;101;114;32;112;97;100;115;32;97;115;32;110;101;101;100;101;100;41;46;10;112;117;98;32;99;111;110;115;116;32;66;111;111;108;82;101;115;117;108;116;32;61;32;101;120;116;101;114;110;32;115;116;114;117;99;116;32;123;10;32;32;32;32;115;116;97;116;117;115;58;32;99;95;105;110;116;44;10;32;32;32;32;118;97;108;117;101;58;32;98;111;111;108;44;10;125;59;10;10;47;47;47;32;83;116;97;116;117;115;32;99;111;100;101;115;32;109;97;116;99;104;105;110;103;32;80;114;111;118;101;110;83;116;97;116;117;115;32;105;110;32;112;114;111;118;101;110;46;104;46;10;99;111;110;115;116;32;80;82;79;86;69;78;95;79;75;58;32;99;95;105;110;116;32;61;32;48;59;10;99;111;110;115;116;32;80;82;79;86;69;78;95;69;82;82;95;78;85;76;76;95;80;79;73;78;84;69;82;58;32;99;95;105;110;116;32;61;32;45;49;59;10;10;47;47;47;32;67;104;101;99;107;32;105;102;32;97;32;98;121;116;101;32;115;108;105;99;101;32;99;111;110;116;97;105;110;115;32;97;32;100;105;114;101;99;116;111;114;121;32;116;114;97;118;101;114;115;97;108;32;115;101;113;117;101;110;99;101;32;40;34;46;46;34;41;46;10;47;47;47;10;47;47;47;32;77;97;116;99;104;101;115;58;32;80;114;111;118;101;110;66;111;111;108;82;101;115;117;108;116;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;99;111;110;115;116;32;117;105;110;116;56;95;116;42;32;112;116;114;44;32;115;105;122;101;95;116;32;108;101;110;41;10;47;47;47;10;47;47;47;32;82;101;116;117;114;110;115;32;66;111;111;108;82;101;115;117;108;116;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;79;75;44;32;46;118;97;108;117;101;32;61;32;116;114;117;101;32;125;32;119;104;101;110;32;97;32;34;46;46;34;32;99;111;109;112;111;110;101;110;116;10;47;47;47;32;105;115;32;112;114;101;115;101;110;116;32;105;110;32;116;104;101;32;112;97;116;104;44;32;97;110;100;32;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;79;75;44;32;46;118;97;108;117;101;32;61;32;102;97;108;115;101;32;125;32;111;116;104;101;114;119;105;115;101;46;10;47;47;47;32;82;101;116;117;114;110;115;32;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;69;82;82;95;78;85;76;76;95;80;79;73;78;84;69;82;32;125;32;119;104;101;110;32;112;116;114;32;105;115;32;110;117;108;108;46;10;47;47;47;10;47;47;47;32;68;101;116;101;99;116;105;111;110;32;114;117;108;101;58;32;108;111;111;107;32;102;111;114;32;116;104;101;32;116;119;111;45;98;121;116;101;32;115;101;113;117;101;110;99;101;32;34;46;46;34;32;98;111;117;110;100;101;100;32;98;121;32;112;97;116;104;32;115;101;112;97;114;97;116;111;114;115;10;47;47;47;32;40;39;47;39;41;44;32;97;32;78;85;76;32;98;121;116;101;44;32;111;114;32;116;104;101;32;115;116;97;114;116;47;101;110;100;32;111;102;32;116;104;101;32;115;108;105;99;101;46;32;32;84;104;105;115;32;109;97;116;99;104;101;115;32;119;104;97;116;32;116;104;101;10;47;47;47;32;73;100;114;105;115;50;32;98;97;99;107;101;110;100;32;119;105;108;108;32;102;111;114;109;97;108;108;121;32;118;101;114;105;102;121;32;111;110;99;101;32;116;104;101;32;82;101;102;67;32;112;105;112;101;108;105;110;101;32;105;115;32;97;118;97;105;108;97;98;108;101;46;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;112;116;114;58;32;63;91;42;93;99;111;110;115;116;32;117;56;44;32;108;101;110;58;32;117;115;105;122;101;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;66;111;111;108;82;101;115;117;108;116;32;123;10;32;32;32;32;99;111;110;115;116;32;112;32;61;32;112;116;114;32;111;114;101;108;115;101;32;114;101;116;117;114;110;32;66;111;111;108;82;101;115;117;108;116;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;69;82;82;95;78;85;76;76;95;80;79;73;78;84;69;82;44;32;46;118;97;108;117;101;32;61;32;102;97;108;115;101;32;125;59;10;32;32;32;32;105;102;32;40;108;101;110;32;61;61;32;48;41;32;114;101;116;117;114;110;32;66;111;111;108;82;101;115;117;108;116;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;79;75;44;32;46;118;97;108;117;101;32;61;32;102;97;108;115;101;32;125;59;10;10;32;32;32;32;99;111;110;115;116;32;98;121;116;101;115;32;61;32;112;91;48;46;46;108;101;110;93;59;10;10;32;32;32;32;47;47;32;87;97;108;107;32;116;104;101;32;98;121;116;101;32;115;108;105;99;101;32;97;110;100;32;99;104;101;99;107;32;101;118;101;114;121;32;34;46;46;34;32;99;111;109;112;111;110;101;110;116;46;10;32;32;32;32;118;97;114;32;105;58;32;117;115;105;122;101;32;61;32;48;59;10;32;32;32;32;119;104;105;108;101;32;40;105;32;60;32;108;101;110;41;32;123;10;32;32;32;32;32;32;32;32;47;47;32;70;105;110;100;32;110;101;120;116;32;99;111;109;112;111;110;101;110;116;32;98;111;117;110;100;97;114;121;58;32;97;100;118;97;110;99;101;32;112;97;115;116;32;108;101;97;100;105;110;103;32;115;101;112;97;114;97;116;111;114;115;46;10;32;32;32;32;32;32;32;32;119;104;105;108;101;32;40;105;32;60;32;108;101;110;32;97;110;100;32;98;121;116;101;115;91;105;93;32;61;61;32;39;47;39;41;32;58;32;40;105;32;43;61;32;49;41;32;123;125;10;32;32;32;32;32;32;32;32;105;102;32;40;105;32;62;61;32;108;101;110;41;32;98;114;101;97;107;59;10;10;32;32;32;32;32;32;32;32;47;47;32;77;101;97;115;117;114;101;32;116;104;101;32;99;111;109;112;111;110;101;110;116;46;10;32;32;32;32;32;32;32;32;99;111;110;115;116;32;99;111;109;112;95;115;116;97;114;116;32;61;32;105;59;10;32;32;32;32;32;32;32;32;119;104;105;108;101;32;40;105;32;60;32;108;101;110;32;97;110;100;32;98;121;116;101;115;91;105;93;32;33;61;32;39;47;39;41;32;58;32;40;105;32;43;61;32;49;41;32;123;125;10;32;32;32;32;32;32;32;32;99;111;110;115;116;32;99;111;109;112;111;110;101;110;116;32;61;32;98;121;116;101;115;91;99;111;109;112;95;115;116;97;114;116;46;46;105;93;59;10;10;32;32;32;32;32;32;32;32;105;102;32;40;115;116;100;46;109;101;109;46;101;113;108;40;117;56;44;32;99;111;109;112;111;110;101;110;116;44;32;34;46;46;34;41;41;32;123;10;32;32;32;32;32;32;32;32;32;32;32;32;114;101;116;117;114;110;32;66;111;111;108;82;101;115;117;108;116;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;79;75;44;32;46;118;97;108;117;101;32;61;32;116;114;117;101;32;125;59;10;32;32;32;32;32;32;32;32;125;10;32;32;32;32;125;10;10;32;32;32;32;114;101;116;117;114;110;32;66;111;111;108;82;101;115;117;108;116;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;79;75;44;32;46;118;97;108;117;101;32;61;32;102;97;108;115;101;32;125;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;83;97;102;101;72;101;97;100;101;114;32;226;128;148;32;72;84;84;80;32;104;101;97;100;101;114;32;115;97;102;101;116;121;10;47;47;32;77;97;116;99;104;101;115;32;116;104;101;32;100;101;99;108;97;114;97;116;105;111;110;115;32;105;110;32;112;114;111;118;101;110;46;104;32;97;110;100;32;115;114;99;47;97;98;105;47;70;111;114;101;105;103;110;46;105;100;114;46;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;67;104;101;99;107;32;105;102;32;97;32;98;121;116;101;32;115;108;105;99;101;32;99;111;110;116;97;105;110;115;32;67;82;76;70;32;105;110;106;101;99;116;105;111;110;32;99;104;97;114;97;99;116;101;114;115;32;40;34;92;114;92;110;34;41;46;10;47;47;47;10;47;47;47;32;77;97;116;99;104;101;115;58;32;80;114;111;118;101;110;66;111;111;108;82;101;115;117;108;116;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;99;111;110;115;116;32;117;105;110;116;56;95;116;42;32;112;116;114;44;32;115;105;122;101;95;116;32;108;101;110;41;10;47;47;47;10;47;47;47;32;82;101;116;117;114;110;115;32;115;117;99;99;101;115;115;47;116;114;117;101;32;119;104;101;110;32;101;105;116;104;101;114;32;67;82;32;111;114;32;76;70;32;105;115;32;102;111;117;110;100;32;98;121;32;116;104;101;32;73;100;114;105;115;32;98;121;116;101;32;107;101;114;110;101;108;44;10;47;47;47;32;97;110;100;32;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;79;75;44;32;46;118;97;108;117;101;32;61;32;102;97;108;115;101;32;125;32;111;116;104;101;114;119;105;115;101;46;10;47;47;47;32;82;101;116;117;114;110;115;32;123;32;46;115;116;97;116;117;115;32;61;32;80;82;79;86;69;78;95;69;82;82;95;78;85;76;76;95;80;79;73;78;84;69;82;32;125;32;119;104;101;110;32;112;116;114;32;105;115;32;110;117;108;108;46;10;47;47;47;10;47;47;47;32;84;104;101;32;101;120;97;99;116;32;98;121;116;101;32;114;97;110;103;101;32;105;115;32;112;97;115;115;101;100;32;116;111;32;73;100;114;105;115;59;32;101;109;98;101;100;100;101;100;32;78;85;76;32;105;115;32;100;97;116;97;46;10;47;47;47;32;87;105;116;104;111;117;116;32;97;32;108;105;110;107;101;100;32;73;100;114;105;115;32;98;97;99;107;101;110;100;44;32;114;101;116;117;114;110;115;32;80;82;79;86;69;78;95;69;82;82;95;78;79;84;95;73;77;80;76;69;77;69;78;84;69;68;32;40;45;57;57;41;46;10;112;117;98;32;102;110;32;104;101;97;100;101;114;72;97;115;67;114;108;102;40;99;111;109;112;116;105;109;101;32;104;101;97;100;101;114;95;98;97;99;107;101;110;100;58;32;116;121;112;101;44;32;112;116;114;58;32;63;91;42;93;99;111;110;115;116;32;117;56;44;32;108;101;110;58;32;117;115;105;122;101;41;32;66;111;111;108;82;101;115;117;108;116;32;123]. +Definition core_suffix : list nat := [125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;85;116;105;108;105;116;121;32;70;117;110;99;116;105;111;110;115;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;47;47;47;32;67;104;101;99;107;32;105;102;32;104;97;110;100;108;101;32;105;115;32;105;110;105;116;105;97;108;105;122;101;100;10;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;104;97;110;100;108;101;95;105;115;95;105;110;105;116;105;97;108;105;122;101;100;40;104;97;110;100;108;101;58;32;63;42;72;97;110;100;108;101;41;32;117;51;50;32;123;10;32;32;32;32;99;111;110;115;116;32;104;32;61;32;104;97;110;100;108;101;32;111;114;101;108;115;101;32;114;101;116;117;114;110;32;48;59;10;32;32;32;32;114;101;116;117;114;110;32;105;102;32;40;104;46;105;110;105;116;105;97;108;105;122;101;100;41;32;49;32;101;108;115;101;32;48;59;10;125;10;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;47;47;32;84;101;115;116;115;10;47;47;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;61;10;10;116;101;115;116;32;34;108;105;102;101;99;121;99;108;101;34;32;123;10;32;32;32;32;99;111;110;115;116;32;104;97;110;100;108;101;32;61;32;112;114;111;118;101;110;95;104;97;110;100;108;101;95;99;114;101;97;116;101;40;41;32;111;114;101;108;115;101;32;114;101;116;117;114;110;32;101;114;114;111;114;46;73;110;105;116;70;97;105;108;101;100;59;10;32;32;32;32;100;101;102;101;114;32;112;114;111;118;101;110;95;102;114;101;101;40;104;97;110;100;108;101;41;59;10;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;112;114;111;118;101;110;95;104;97;110;100;108;101;95;105;115;95;105;110;105;116;105;97;108;105;122;101;100;40;104;97;110;100;108;101;41;32;61;61;32;49;41;59;10;125;10;10;116;101;115;116;32;34;101;114;114;111;114;32;104;97;110;100;108;105;110;103;34;32;123;10;32;32;32;32;99;111;110;115;116;32;114;101;115;117;108;116;32;61;32;112;114;111;118;101;110;95;112;114;111;99;101;115;115;40;110;117;108;108;44;32;48;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;82;101;115;117;108;116;46;110;117;108;108;95;112;111;105;110;116;101;114;44;32;114;101;115;117;108;116;41;59;10;10;32;32;32;32;99;111;110;115;116;32;101;114;114;32;61;32;112;114;111;118;101;110;95;108;97;115;116;95;101;114;114;111;114;40;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;101;114;114;32;33;61;32;110;117;108;108;41;59;10;125;10;10;116;101;115;116;32;34;118;101;114;115;105;111;110;34;32;123;10;32;32;32;32;99;111;110;115;116;32;118;101;114;32;61;32;112;114;111;118;101;110;95;118;101;114;115;105;111;110;40;41;59;10;32;32;32;32;99;111;110;115;116;32;118;101;114;95;115;116;114;32;61;32;115;116;100;46;109;101;109;46;115;112;97;110;40;118;101;114;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;83;116;114;105;110;103;115;40;86;69;82;83;73;79;78;44;32;118;101;114;95;115;116;114;41;59;10;125;10;10;116;101;115;116;32;34;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;32;100;101;116;101;99;116;115;32;116;114;97;118;101;114;115;97;108;34;32;123;10;32;32;32;32;47;47;32;67;108;97;115;115;105;99;32;97;116;116;97;99;107;115;46;10;32;32;32;32;99;111;110;115;116;32;114;49;32;61;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;34;46;46;47;101;116;99;47;112;97;115;115;119;100;34;46;112;116;114;44;32;34;46;46;47;101;116;99;47;112;97;115;115;119;100;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;80;82;79;86;69;78;95;79;75;41;44;32;114;49;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;114;49;46;118;97;108;117;101;41;59;10;10;32;32;32;32;99;111;110;115;116;32;114;50;32;61;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;34;47;116;109;112;47;46;46;47;46;46;47;114;111;111;116;34;46;112;116;114;44;32;34;47;116;109;112;47;46;46;47;46;46;47;114;111;111;116;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;80;82;79;86;69;78;95;79;75;41;44;32;114;50;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;114;50;46;118;97;108;117;101;41;59;10;125;10;10;116;101;115;116;32;34;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;32;97;108;108;111;119;115;32;115;97;102;101;32;112;97;116;104;115;34;32;123;10;32;32;32;32;99;111;110;115;116;32;114;49;32;61;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;34;47;118;97;114;47;109;110;116;47;101;99;108;105;112;115;101;47;114;101;112;111;115;47;109;121;114;101;112;111;47;102;105;108;101;46;115;99;109;34;46;112;116;114;44;32;34;47;118;97;114;47;109;110;116;47;101;99;108;105;112;115;101;47;114;101;112;111;115;47;109;121;114;101;112;111;47;102;105;108;101;46;115;99;109;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;80;82;79;86;69;78;95;79;75;41;44;32;114;49;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;49;46;118;97;108;117;101;41;59;10;10;32;32;32;32;99;111;110;115;116;32;114;50;32;61;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;34;47;116;109;112;47;115;99;114;97;116;99;104;46;115;99;109;34;46;112;116;114;44;32;34;47;116;109;112;47;115;99;114;97;116;99;104;46;115;99;109;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;80;82;79;86;69;78;95;79;75;41;44;32;114;50;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;50;46;118;97;108;117;101;41;59;10;125;10;10;116;101;115;116;32;34;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;32;104;97;110;100;108;101;115;32;110;117;108;108;32;97;110;100;32;101;109;112;116;121;34;32;123;10;32;32;32;32;99;111;110;115;116;32;114;95;110;117;108;108;32;61;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;110;117;108;108;44;32;48;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;80;82;79;86;69;78;95;69;82;82;95;78;85;76;76;95;80;79;73;78;84;69;82;41;44;32;114;95;110;117;108;108;46;115;116;97;116;117;115;41;59;10;10;32;32;32;32;99;111;110;115;116;32;114;95;101;109;112;116;121;32;61;32;112;114;111;118;101;110;95;112;97;116;104;95;104;97;115;95;116;114;97;118;101;114;115;97;108;40;34;34;46;112;116;114;44;32;48;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;80;82;79;86;69;78;95;79;75;41;44;32;114;95;101;109;112;116;121;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;95;101;109;112;116;121;46;118;97;108;117;101;41;59;10;125;10;10;116;101;115;116;32;34;99;97;110;111;110;105;99;97;108;32;108;105;102;101;99;121;99;108;101;32;117;115;101;115;32;116;104;101;32;100;101;99;108;97;114;101;100;32;67;32;116;121;112;101;115;32;97;110;100;32;102;97;105;108;115;32;99;108;111;115;101;100;34;32;123;10;32;32;32;32;99;111;110;115;116;32;105;110;105;116;105;97;108;105;122;101;58;32;42;99;111;110;115;116;32;102;110;32;40;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;105;51;50;32;61;32;38;112;114;111;118;101;110;95;105;110;105;116;59;10;32;32;32;32;99;111;110;115;116;32;115;104;117;116;100;111;119;110;58;32;42;99;111;110;115;116;32;102;110;32;40;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;118;111;105;100;32;61;32;38;112;114;111;118;101;110;95;100;101;105;110;105;116;59;10;32;32;32;32;99;111;110;115;116;32;105;110;105;116;105;97;108;105;122;101;100;58;32;42;99;111;110;115;116;32;102;110;32;40;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;98;111;111;108;32;61;32;38;112;114;111;118;101;110;95;105;115;95;105;110;105;116;105;97;108;105;122;101;100;59;10;32;32;32;32;115;104;117;116;100;111;119;110;40;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;105;110;105;116;105;97;108;105;122;101;100;40;41;41;59;10;32;32;32;32;99;111;110;115;116;32;101;120;112;101;99;116;101;100;58;32;105;51;50;32;61;32;105;102;32;40;108;105;102;101;99;121;99;108;101;46;97;118;97;105;108;97;98;108;101;41;32;48;32;101;108;115;101;32;45;57;57;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;101;120;112;101;99;116;101;100;44;32;105;110;105;116;105;97;108;105;122;101;40;41;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;108;105;102;101;99;121;99;108;101;46;97;118;97;105;108;97;98;108;101;44;32;105;110;105;116;105;97;108;105;122;101;100;40;41;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;101;120;112;101;99;116;101;100;44;32;105;110;105;116;105;97;108;105;122;101;40;41;41;59;10;32;32;32;32;115;104;117;116;100;111;119;110;40;41;59;10;32;32;32;32;115;104;117;116;100;111;119;110;40;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;105;110;105;116;105;97;108;105;122;101;100;40;41;41;59;10;125;10;10;116;101;115;116;32;34;101;114;114;111;114;32;109;101;115;115;97;103;101;115;32;97;114;101;32;98;111;114;114;111;119;101;100;32;115;116;97;116;105;99;32;115;116;111;114;97;103;101;34;32;123;10;32;32;32;32;95;32;61;32;112;114;111;118;101;110;95;112;114;111;99;101;115;115;40;110;117;108;108;44;32;48;41;59;10;32;32;32;32;99;111;110;115;116;32;102;105;114;115;116;32;61;32;112;114;111;118;101;110;95;108;97;115;116;95;101;114;114;111;114;40;41;32;111;114;101;108;115;101;32;114;101;116;117;114;110;32;101;114;114;111;114;46;77;105;115;115;105;110;103;69;114;114;111;114;59;10;32;32;32;32;102;111;114;32;40;48;46;46;49;48;50;52;41;32;124;95;124;32;123;10;32;32;32;32;32;32;32;32;99;111;110;115;116;32;110;101;120;116;32;61;32;112;114;111;118;101;110;95;108;97;115;116;95;101;114;114;111;114;40;41;32;111;114;101;108;115;101;32;114;101;116;117;114;110;32;101;114;114;111;114;46;77;105;115;115;105;110;103;69;114;114;111;114;59;10;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;102;105;114;115;116;32;61;61;32;110;101;120;116;41;59;10;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;83;116;114;105;110;103;115;40;34;78;117;108;108;32;104;97;110;100;108;101;34;44;32;115;116;100;46;109;101;109;46;115;112;97;110;40;110;101;120;116;41;41;59;10;32;32;32;32;125;10;32;32;32;32;99;108;101;97;114;69;114;114;111;114;40;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;112;114;111;118;101;110;95;108;97;115;116;95;101;114;114;111;114;40;41;32;61;61;32;110;117;108;108;41;59;10;125;10]. +Definition export_prefix : list nat := [47;47;32;83;80;68;88;45;76;105;99;101;110;115;101;45;73;100;101;110;116;105;102;105;101;114;58;32;77;80;76;45;50;46;48;10;47;47;32;67;111;112;121;114;105;103;104;116;32;40;99;41;32;50;48;50;54;32;74;111;110;97;116;104;97;110;32;68;46;65;46;32;74;101;119;101;108;108;32;60;106;46;100;46;97;46;106;101;119;101;108;108;64;111;112;101;110;46;97;99;46;117;107;62;10;99;111;110;115;116;32;99;111;114;101;32;61;32;64;105;109;112;111;114;116;40;34;99;111;114;101;46;122;105;103;34;41;59;10;112;117;98;32;99;111;110;115;116;32;82;101;115;117;108;116;32;61;32;99;111;114;101;46;82;101;115;117;108;116;59;10;112;117;98;32;99;111;110;115;116;32;72;97;110;100;108;101;32;61;32;99;111;114;101;46;72;97;110;100;108;101;59;10;112;117;98;32;99;111;110;115;116;32;67;97;108;108;98;97;99;107;32;61;32;99;111;114;101;46;67;97;108;108;98;97;99;107;59;10;112;117;98;32;99;111;110;115;116;32;66;111;111;108;82;101;115;117;108;116;32;61;32;99;111;114;101;46;66;111;111;108;82;101;115;117;108;116;59;10;99;111;109;112;116;105;109;101;32;123;10;32;32;32;32;95;32;61;32;99;111;114;101;59;10;125;10;112;117;98;32;99;111;110;115;116;32;112;114;111;118;101;110;32;61;32;64;84;104;105;115;40;41;59;10;112;117;98;32;101;120;112;111;114;116;32;102;110;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;112;116;114;58;32;63;91;42;93;99;111;110;115;116;32;117;56;44;32;108;101;110;58;32;117;115;105;122;101;41;32;99;97;108;108;99;111;110;118;40;46;99;41;32;99;111;114;101;46;66;111;111;108;82;101;115;117;108;116;32;123]. +Definition export_suffix : list nat := [125;10;10;99;111;110;115;116;32;115;116;100;32;61;32;64;105;109;112;111;114;116;40;34;115;116;100;34;41;59;10;116;101;115;116;32;34;104;101;97;100;101;114;32;65;66;73;32;117;115;101;115;32;73;100;114;105;115;32;102;111;114;32;101;118;101;114;121;32;111;110;101;45;98;121;116;101;32;97;110;100;32;116;119;111;45;98;121;116;101;32;105;110;112;117;116;34;32;123;10;32;32;32;32;118;97;114;32;98;121;116;101;115;58;32;91;50;93;117;56;32;61;32;117;110;100;101;102;105;110;101;100;59;10;32;32;32;32;102;111;114;32;40;48;46;46;50;53;54;41;32;124;97;124;32;123;10;32;32;32;32;32;32;32;32;98;121;116;101;115;91;48;93;32;61;32;64;105;110;116;67;97;115;116;40;97;41;59;10;32;32;32;32;32;32;32;32;99;111;110;115;116;32;115;105;110;103;108;101;32;61;32;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;38;98;121;116;101;115;44;32;49;41;59;10;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;115;105;110;103;108;101;46;115;116;97;116;117;115;41;59;10;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;97;32;61;61;32;49;48;32;111;114;32;97;32;61;61;32;49;51;44;32;115;105;110;103;108;101;46;118;97;108;117;101;41;59;10;32;32;32;32;32;32;32;32;102;111;114;32;40;48;46;46;50;53;54;41;32;124;98;124;32;123;10;32;32;32;32;32;32;32;32;32;32;32;32;98;121;116;101;115;91;49;93;32;61;32;64;105;110;116;67;97;115;116;40;98;41;59;10;32;32;32;32;32;32;32;32;32;32;32;32;99;111;110;115;116;32;114;32;61;32;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;38;98;121;116;101;115;44;32;50;41;59;10;32;32;32;32;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;46;115;116;97;116;117;115;41;59;10;32;32;32;32;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;97;32;61;61;32;49;48;32;111;114;32;97;32;61;61;32;49;51;32;111;114;32;98;32;61;61;32;49;48;32;111;114;32;98;32;61;61;32;49;51;44;32;114;46;118;97;108;117;101;41;59;10;32;32;32;32;32;32;32;32;125;10;32;32;32;32;125;10;125;10;116;101;115;116;32;34;104;101;97;100;101;114;32;65;66;73;32;112;114;101;115;101;114;118;101;115;32;110;117;108;108;44;32;108;101;110;103;116;104;44;32;78;85;76;32;97;110;100;32;110;111;110;45;85;84;70;56;32;115;101;109;97;110;116;105;99;115;34;32;123;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;45;49;41;44;32;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;110;117;108;108;44;32;48;41;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;45;49;41;44;32;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;110;117;108;108;44;32;57;57;41;46;115;116;97;116;117;115;41;59;10;32;32;32;32;99;111;110;115;116;32;98;121;116;101;115;32;61;32;91;95;93;117;56;123;32;48;120;102;102;44;32;48;44;32;49;51;44;32;48;120;56;48;32;125;59;10;32;32;32;32;102;111;114;32;40;48;46;46;98;121;116;101;115;46;108;101;110;32;43;32;49;41;32;124;108;101;110;124;32;123;10;32;32;32;32;32;32;32;32;99;111;110;115;116;32;114;32;61;32;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;38;98;121;116;101;115;44;32;108;101;110;41;59;10;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;46;115;116;97;116;117;115;41;59;10;32;32;32;32;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;108;101;110;32;62;61;32;51;44;32;114;46;118;97;108;117;101;41;59;10;32;32;32;32;125;10;32;32;32;32;118;97;114;32;108;111;110;103;32;61;32;91;95;93;117;56;123;48;125;32;42;42;32;56;49;57;50;59;10;32;32;32;32;108;111;110;103;91;108;111;110;103;46;108;101;110;32;45;32;49;93;32;61;32;49;48;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;38;108;111;110;103;44;32;108;111;110;103;46;108;101;110;41;46;118;97;108;117;101;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;112;114;111;118;101;110;46;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;38;108;111;110;103;44;32;108;111;110;103;46;108;101;110;32;45;32;49;41;46;118;97;108;117;101;41;59;10;125;10;10;116;101;115;116;32;34;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;32;100;101;116;101;99;116;115;32;67;82;76;70;34;32;123;10;32;32;32;32;47;47;32;67;108;97;115;115;105;99;32;67;82;76;70;32;105;110;106;101;99;116;105;111;110;46;10;32;32;32;32;99;111;110;115;116;32;114;49;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;34;83;101;116;45;67;111;111;107;105;101;58;32;102;111;111;61;98;97;114;92;114;92;110;83;101;116;45;67;111;111;107;105;101;58;32;97;100;109;105;110;61;116;114;117;101;34;46;112;116;114;44;32;34;83;101;116;45;67;111;111;107;105;101;58;32;102;111;111;61;98;97;114;92;114;92;110;83;101;116;45;67;111;111;107;105;101;58;32;97;100;109;105;110;61;116;114;117;101;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;49;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;114;49;46;118;97;108;117;101;41;59;10;10;32;32;32;32;99;111;110;115;116;32;114;50;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;34;88;45;67;117;115;116;111;109;92;114;92;110;34;46;112;116;114;44;32;34;88;45;67;117;115;116;111;109;92;114;92;110;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;50;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;114;50;46;118;97;108;117;101;41;59;10;125;10;10;116;101;115;116;32;34;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;32;97;108;108;111;119;115;32;115;97;102;101;32;104;101;97;100;101;114;115;34;32;123;10;32;32;32;32;99;111;110;115;116;32;114;49;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;34;67;111;110;116;101;110;116;45;84;121;112;101;58;32;97;112;112;108;105;99;97;116;105;111;110;47;106;115;111;110;34;46;112;116;114;44;32;34;67;111;110;116;101;110;116;45;84;121;112;101;58;32;97;112;112;108;105;99;97;116;105;111;110;47;106;115;111;110;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;49;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;49;46;118;97;108;117;101;41;59;10;10;32;32;32;32;99;111;110;115;116;32;114;50;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;34;65;117;116;104;111;114;105;122;97;116;105;111;110;58;32;66;101;97;114;101;114;32;116;111;107;101;110;49;50;51;34;46;112;116;114;44;32;34;65;117;116;104;111;114;105;122;97;116;105;111;110;58;32;66;101;97;114;101;114;32;116;111;107;101;110;49;50;51;34;46;108;101;110;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;50;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;50;46;118;97;108;117;101;41;59;10;125;10;10;116;101;115;116;32;34;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;32;104;97;110;100;108;101;115;32;110;117;108;108;32;97;110;100;32;101;109;112;116;121;34;32;123;10;32;32;32;32;99;111;110;115;116;32;114;95;110;117;108;108;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;110;117;108;108;44;32;48;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;45;49;41;44;32;114;95;110;117;108;108;46;115;116;97;116;117;115;41;59;10;10;32;32;32;32;99;111;110;115;116;32;114;95;101;109;112;116;121;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;34;34;46;112;116;114;44;32;48;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;95;101;109;112;116;121;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;95;101;109;112;116;121;46;118;97;108;117;101;41;59;10;10;32;32;32;32;47;47;32;83;105;110;103;108;101;32;98;121;116;101;32;115;104;111;117;108;100;32;110;111;116;32;99;114;97;115;104;46;10;32;32;32;32;99;111;110;115;116;32;114;95;115;105;110;103;108;101;32;61;32;112;114;111;118;101;110;95;104;101;97;100;101;114;95;104;97;115;95;99;114;108;102;40;34;88;34;46;112;116;114;44;32;49;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;69;113;117;97;108;40;64;97;115;40;99;95;105;110;116;44;32;48;41;44;32;114;95;115;105;110;103;108;101;46;115;116;97;116;117;115;41;59;10;32;32;32;32;116;114;121;32;115;116;100;46;116;101;115;116;105;110;103;46;101;120;112;101;99;116;40;33;114;95;115;105;110;103;108;101;46;118;97;108;117;101;41;59;10;125;10]. diff --git a/verification/atoma/consumer/coq/HeaderBoundarySource.v b/verification/atoma/consumer/coq/HeaderBoundarySource.v new file mode 100644 index 0000000..0a2b753 --- /dev/null +++ b/verification/atoma/consumer/coq/HeaderBoundarySource.v @@ -0,0 +1,218 @@ +(* SPDX-License-Identifier: MPL-2.0 *) +(* Closed original public-entry interpretation. Pointer/region correspondence, + machine representability and compiler correctness remain premises. *) +From Coq Require Import List String Ascii Bool Arith ZArith Lia. +Require Import ScalarSource RegistrySource WrapperSource HeapOwnership HeaderBoundaryContext. +Import ListNotations. +Open Scope string_scope. +Open Scope nat_scope. +Open Scope list_scope. + +Fixpoint same_bytes (a b : list nat) : bool := + match a,b with + | [],[] => true + | x::xs,y::ys => Nat.eqb x y && same_bytes xs ys + | _,_ => false end. +Definition peel (prefix suffix bytes : list nat) : option (list nat) := + let pre := List.length prefix in let post := List.length suffix in + let size := List.length bytes in + if (pre + post <=? size) && same_bytes prefix (firstn pre bytes) && + same_bytes suffix (skipn (size-post) bytes) + then Some (firstn (size-pre-post) (skipn pre bytes)) else None. + +(* Same restricted ASCII tokens as WrapperSource, with the '-' token needed by + the actual public status mapping. Minus is not erased or substituted. *) +Fixpoint lex (fuel : nat) (xs : list nat) : option (list string) := + match xs with + | [] => Some [] + | c::rest => match fuel with + | O => None + | S f => if ScalarSource.white c then lex f rest else + match xs with + | 47::47::tail => lex f (ScalarSource.after_comment tail) + | _ => + let token := if Nat.eqb c 34 then + match WrapperSource.literal (List.length rest) rest with + | Some (s,tail) => Some (String.append "quoted:" s,tail) | None => None end + else if ScalarSource.wordchar c then Some (ScalarSource.take_word xs) + else match xs with + | 61::61::tail => Some ("==",tail) + | 33::61::tail => Some ("!=",tail) + | 61::62::tail => Some ("=>",tail) + | _ => if existsb (Nat.eqb c) [40;41;58;123;125;59;64;44;45;61;63;46;42;33;91;93;124;62] + then Some (String (ascii_of_nat c) EmptyString,rest) else None end in + match token with + | Some (t,tail) => match lex f tail with Some ts => Some (t::ts) | None => None end + | None => None end + end + end end. +Definition tokenize bytes := if forallb (fun c => c Some (Program start missing invalid) + | _ => None end. +Definition parse_core bytes := + match peel HeaderBoundaryContext.core_prefix HeaderBoundaryContext.core_suffix bytes with + | Some body => match tokenize body with Some ts => parse_body ts | None => None end + | None => None end. +Definition check_export bytes := + match peel HeaderBoundaryContext.export_prefix HeaderBoundaryContext.export_suffix bytes with + | Some body => match tokenize body with + | Some ts => RegistrySource.same ts ["return";"core";".";"headerHasCrlf";"(";"@";"import";"(";"quoted:header_refc.zig";")";",";"ptr";",";"len";")";";"] + | None => false end + | None => false end. +Definition program_eq_dec (a b : program) : {a=b}+{a<>b}. +Proof. decide equality; apply Nat.eq_dec. Defined. +Definition check core exports := match parse_core core with + | Some p => if program_eq_dec p canonical then check_export exports else false + | None => false end. +Lemma bound : forall core exports, check core exports = true -> + parse_core core = Some canonical /\ check_export exports = true. +Proof. + intros core exports H; unfold check in H. + destruct (parse_core core) as [p|] eqn:E; [|discriminate]. + destruct (program_eq_dec p canonical); [subst; auto|discriminate]. +Qed. + +Inductive backend_outcome := BackendValue (value : bool) | BackendMissing | BackendInvalid. +Definition backend_fn := list nat -> HeapOwnership.heap -> bool -> + (HeapOwnership.heap * bool) * backend_outcome. +Record observation := Observe { + status : Z; value : bool; final_heap : HeapOwnership.heap; + error_mark : bool; calls : list (list nat) +}. +(* error_mark is only a projection of thread-local error presence/effects, not + the native error pointer or a theorem about message storage layout. *) +Definition finish_call p result after tls bytes := match result with + | BackendValue b => Observe 0%Z b after tls [bytes] + | BackendMissing => Observe (- Z.of_nat (unavailable_error p))%Z false after true [bytes] + | BackendInvalid => Observe (- Z.of_nat (invalid_error p))%Z false after true [bytes] + end. +(* None means the request lies outside the admitted readable-span interpretation; + it is NOT an additional runtime refusal implemented by core.zig. A native + pointer and its usize range must correspond to this live region and snapshot. + The physical read lease must stay valid and immutable throughout the call; + a backend may not retain the span. Final heap equality cannot establish that + temporal condition: a native backend could write and restore between reads. *) +Definition run p present (h : HeapOwnership.heap) addr offset count tls + (backend : backend_fn) := + if present then + match h addr with + | HeapOwnership.Vacant => None + | HeapOwnership.Live bytes retained readers => + if HeapOwnership.span_fits offset count bytes then + let span := skipn (slice_start p) (HeapOwnership.borrowed_span offset count bytes) in + let '((after,after_tls),result) := backend span h tls in + Some (finish_call p result after after_tls span) + else None + end + else Some (Observe (-1)%Z false h tls []). +Definition backend_frames (addr : nat) + (backend : backend_fn) := forall span h tls, + fst (fst (backend span h tls)) addr = h addr. +(* backend_frames states FINAL region equality only. It does not imply a + continuous no-write/no-retention discipline for an arbitrary foreign call. *) + +Theorem source_null : forall core exports h addr offset count tls backend, + check core exports = true -> exists p, + parse_core core = Some p /\ check_export exports = true /\ + run p false h addr offset count tls backend = Some (Observe (-1)%Z false h tls []). +Proof. intros; destruct (bound core exports H) as [Hp He]. + exists canonical; repeat split; auto. Qed. + +Theorem source_normal : forall core exports h addr offset count tls backend bytes retained readers, + check core exports = true -> h addr = HeapOwnership.Live bytes retained (S readers) -> + HeapOwnership.span_fits offset count bytes = true -> backend_frames addr backend -> + exists p, parse_core core = Some p /\ check_export exports = true /\ + exists observed, run p true h addr offset count tls backend = Some observed /\ + calls observed = [HeapOwnership.borrowed_span offset count bytes] /\ + final_heap observed addr = h addr /\ + HeapOwnership.cell_step HeapOwnership.ReturnRead (final_heap observed addr) = + Some (HeapOwnership.Live bytes retained readers). +Proof. + intros core exports h addr offset count tls backend bytes retained readers Hsource Hcell Hfits Hframe. + destruct (bound core exports Hsource) as [Hp He]. + exists canonical; split; [exact Hp|]; split; [exact He|]. + unfold run; rewrite Hcell, Hfits; simpl. + pose proof (Hframe (HeapOwnership.borrowed_span offset count bytes) h tls) as Hsame. + destruct (backend (HeapOwnership.borrowed_span offset count bytes) h tls) as [[after after_tls] result] eqn:E. + simpl in Hsame. exists (finish_call canonical result after after_tls (HeapOwnership.borrowed_span offset count bytes)). + split; [reflexivity|]. destruct result; simpl; repeat split; + try reflexivity; try exact Hsame; rewrite Hsame, Hcell; reflexivity. +Qed. + +Theorem result_mapping : forall result after tls span, + status (finish_call canonical result after tls span) = + match result with BackendValue _ => 0%Z | BackendMissing => (-99)%Z | BackendInvalid => (-7)%Z end /\ + value (finish_call canonical result after tls span) = + match result with BackendValue b => b | _ => false end /\ + error_mark (finish_call canonical result after tls span) = + match result with BackendValue _ => tls | _ => true end. +Proof. intros; destruct result; repeat split; reflexivity. Qed. + +Definition implements_scan foreign + (backend : backend_fn) := forall span h tls, + snd (backend span h tls) = match WrapperSource.header_run WrapperSource.header_canonical foreign span with + | Some b => BackendValue b | None => BackendInvalid end. +Definition interpreted_backend foreign + (effect : list nat -> HeapOwnership.heap -> bool -> HeapOwnership.heap * bool) + (span : list nat) (h : HeapOwnership.heap) (tls : bool) := + (effect span h tls, match WrapperSource.header_run WrapperSource.header_canonical foreign span with + | Some b => BackendValue b | None => BackendInvalid end). +(* This composes the checked callee's snapshot semantics. Relating native reads + to that snapshot still requires the synchronous immutable read-lease premise; + the arbitrary effect parameter is not certified to obey that premise. *) +Theorem source_fold : forall core exports header h addr offset count tls backend bytes retained readers step foreign, + check core exports = true -> WrapperSource.check_header header = true -> + h addr = HeapOwnership.Live bytes retained (S readers) -> + HeapOwnership.span_fits offset count bytes = true -> + Forall (fun b => b < 256) (HeapOwnership.borrowed_span offset count bytes) -> + (forall s b, b < 256 -> foreign (WrapperSource.encode s) b = Some (WrapperSource.encode (step s b))) -> + implements_scan foreign backend -> + exists p, parse_core core = Some p /\ check_export exports = true /\ + exists observed, run p true h addr offset count tls backend = Some observed /\ + status observed = 0%Z /\ value observed = + WrapperSource.fold step false (HeapOwnership.borrowed_span offset count bytes). +Proof. + intros core exports header h addr offset count tls backend bytes retained readers step foreign + Hsource Hheader Hcell Hfits Hbytes Hforeign Hbackend. + destruct (bound core exports Hsource) as [Hp He]. + destruct (WrapperSource.header_source_fold header step foreign + (HeapOwnership.borrowed_span offset count bytes) Hheader Hbytes Hforeign) as [scan [Hscan Hfold]]. + rewrite (WrapperSource.header_bound header Hheader) in Hscan; inversion Hscan; subst scan. + pose proof (Hbackend (HeapOwnership.borrowed_span offset count bytes) h tls) as Hout. + rewrite Hfold in Hout. + exists canonical; split; [exact Hp|]; split; [exact He|]. + unfold run; rewrite Hcell, Hfits; simpl. + destruct (backend (HeapOwnership.borrowed_span offset count bytes) h tls) as [[after after_tls] result] eqn:E. + simpl in Hout; subst result. + eexists; repeat split; reflexivity. +Qed. + +(* Dropping the frame premise is observably unsound: a foreign backend can + return a heap in which the borrowed region was destroyed. This is not a pass + for native memory safety; it records the necessary contract boundary. *) +Example unframed_backend_counterexample : + let h : HeapOwnership.heap := fun _ => HeapOwnership.Live [13] 0 1 in + let bad := fun (_ : list nat) (_ : HeapOwnership.heap) (_ : bool) => + (((fun _ => HeapOwnership.Vacant),false),BackendValue false) in + exists observed, run canonical true h 0 0 1 false bad = Some observed /\ + final_heap observed 0 <> h 0. +Proof. simpl; eexists; split; [reflexivity|discriminate]. Qed. + +Print Assumptions source_null. +Print Assumptions source_normal. +Print Assumptions result_mapping. +Print Assumptions source_fold. +Print Assumptions unframed_backend_counterexample. diff --git a/verification/atoma/consumer/coq/RegistryLifetimeSource.v b/verification/atoma/consumer/coq/RegistryLifetimeSource.v new file mode 100644 index 0000000..acb54c1 --- /dev/null +++ b/verification/atoma/consumer/coq/RegistryLifetimeSource.v @@ -0,0 +1,171 @@ +(* SPDX-License-Identifier: MPL-2.0 *) +(* Admitted original destroy body; permission accounting is ghost state, not + a claim that the current pointer ABI performs lifetime checks. *) +From Coq Require Import List String Bool Arith Lia. +Require Import ScalarSource RegistrySource WrapperSource HeapOwnership. +Import ListNotations. +Open Scope string_scope. +Open Scope nat_scope. + +Record destroy_program := DestroyProgram { + null_status : nat; busy_status : nat; ok_status : nat }. +Definition canonical := DestroyProgram 4 6 0. +Definition program_eq_dec (a b : destroy_program) : {a=b}+{a<>b}. +Proof. decide equality; apply Nat.eq_dec. Defined. +Definition parse_destroy (tokens : list string) : option destroy_program := + match WrapperSource.operands + [["const";"registry";"=";"r";"orelse";"return"]; + [";";"if";"(";"registry";".";"active";")";"return"]; + [";";"std";".";"heap";".";"c_allocator";".";"destroy";"(";"registry";")";";";"return"]; + [";"]] tokens with + | Some [n;b;o] => Some (DestroyProgram n b o) + | _ => None end. +Definition parse (bytes : list nat) : option destroy_program := + if WrapperSource.check_registry bytes then + match WrapperSource.tokenize bytes with + | Some tokens => match RegistrySource.strip WrapperSource.registry_prefix tokens with + | Some tail => match RegistrySource.functions WrapperSource.registry_signatures tail with + | Some [_;destroy;_;_;_] => parse_destroy destroy + | _ => None end + | None => None end + | None => None end + else None. +Definition check (bytes : list nat) : bool := + match parse bytes with + | Some p => if program_eq_dec p canonical then true else false + | None => false end. +Lemma accepted_program : forall bytes, + check bytes = true -> parse bytes = Some canonical. +Proof. intros bytes H; unfold check in H; destruct (parse bytes) as [p|] eqn:E; [|discriminate]. + destruct (program_eq_dec p canonical); [now subst|discriminate]. Qed. + +Record endpoint_refs := EndpointRefs { code_region : nat; context_region : option nat }. +Definition endpoint_regions (e : endpoint_refs) := + code_region e :: match context_region e with None => [] | Some r => [r] end. +Definition slot_regions (slot : option endpoint_refs) := + match slot with None => [] | Some e => endpoint_regions e end. +Definition references (s : RegistrySource.state endpoint_refs) := + List.app (slot_regions (RegistrySource.rest s)) (slot_regions (RegistrySource.mcp s)). +Definition retentions (s : RegistrySource.state endpoint_refs) (region : nat) := + count_occ Nat.eq_dec (references s) region. +Definition accounted (s : RegistrySource.state endpoint_refs) (h : HeapOwnership.heap) : Prop := + forall key, match h key with + | HeapOwnership.Vacant => retentions s key = 0 + | HeapOwnership.Live _ retained _ => retentions s key <= retained end. + +(* Removing registry roots releases THEIR retained obligations. Shared references + from other registries remain in the global retained count. No endpoint payload + is destroyed or written by this ghost accounting operation. *) +Definition detach (s : RegistrySource.state endpoint_refs) (h : HeapOwnership.heap) : HeapOwnership.heap := + fun key => match h key with + | HeapOwnership.Vacant => HeapOwnership.Vacant + | HeapOwnership.Live bytes retained readers => + HeapOwnership.Live bytes (retained - retentions s key) readers end. + +Record destruction := Destroyed { + status : nat; + store : HeapOwnership.heap; + registration : option (RegistrySource.state endpoint_refs) }. + +(* Native interpretation follows null -> active -> allocator.destroy(registry). + The allocator effect requires the usual valid allocation/authority premise. + Detachment is the corresponding ghost lifetime effect, not native instructions. + This function intentionally does not invent a runtime readers/count check. *) +Definition destroy_run (p : destroy_program) (present : bool) + (s : RegistrySource.state endpoint_refs) (h : HeapOwnership.heap) (addr : nat) : destruction := + if negb present then Destroyed (null_status p) h (Some s) else + if RegistrySource.active s then Destroyed (busy_status p) h (Some s) else + Destroyed (ok_status p) (detach s (HeapOwnership.replace h addr HeapOwnership.Vacant)) None. + +Theorem null_refuses : forall p s h addr, + destroy_run p false s h addr = Destroyed (null_status p) h (Some s). +Proof. reflexivity. Qed. +Theorem busy_preserves : forall p s h addr, + RegistrySource.active s = true -> + destroy_run p true s h addr = Destroyed (busy_status p) h (Some s). +Proof. intros p s h addr H; unfold destroy_run; simpl; now rewrite H. Qed. +Theorem idle_release : forall p s h addr bytes, + RegistrySource.active s = false -> h addr = HeapOwnership.Live bytes 0 0 -> + status (destroy_run p true s h addr) = ok_status p /\ + forall key, store (destroy_run p true s h addr) key = + detach s (snd (HeapOwnership.run HeapOwnership.Release h addr)) key. +Proof. intros p s h addr bytes Hidle Howned; unfold destroy_run; cbn [negb]; rewrite Hidle. + split; [reflexivity|]. intro key; unfold HeapOwnership.run; rewrite Howned; reflexivity. Qed. +Theorem other_allocation_live : forall p s h addr key bytes retained readers, + RegistrySource.active s = false -> key <> addr -> accounted s h -> + h key = HeapOwnership.Live bytes retained readers -> + exists remaining, store (destroy_run p true s h addr) key = HeapOwnership.Live bytes remaining readers /\ + remaining + retentions s key = retained. +Proof. + intros p s h addr key bytes retained readers Hidle Hneq Haccount Hlive. + pose proof (Haccount key) as Hcount; rewrite Hlive in Hcount; simpl in Hcount. + unfold destroy_run; cbn [negb]; rewrite Hidle; cbn [store]. + unfold detach, HeapOwnership.replace; destruct (Nat.eq_dec key addr); [contradiction|]. + rewrite Hlive; exists (retained - retentions s key); split; [reflexivity|]. + now apply Nat.sub_add. +Qed. +Theorem detaches_registrations : forall p s h addr, + RegistrySource.active s = false -> registration (destroy_run p true s h addr) = None. +Proof. intros p s h addr H; unfold destroy_run; cbn [negb]; now rewrite H. Qed. + +(* Source-facing contracts require a live mapped registry allocation. The caller + additionally owes correspondence between s and the native registry payload; + the byte representation/layout and raw-pointer provenance are not derived by + this model. Distinct region IDs express assumed native separation. *) +Theorem source_idle_release : forall bytes, + check bytes = true -> exists p, parse bytes = Some p /\ + forall s h addr payload, + RegistrySource.active s = false -> h addr = HeapOwnership.Live payload 0 0 -> accounted s h -> + status (destroy_run p true s h addr) = 0 /\ + forall key, store (destroy_run p true s h addr) key = + detach s (snd (HeapOwnership.run HeapOwnership.Release h addr)) key. +Proof. intros bytes H; exists canonical; split; [now apply accepted_program|]. + intros; now apply idle_release. Qed. +Theorem source_busy_preserves : forall bytes, + check bytes = true -> exists p, parse bytes = Some p /\ + forall s h addr payload retained readers, + h addr = HeapOwnership.Live payload retained readers -> RegistrySource.active s = true -> + destroy_run p true s h addr = Destroyed 6 h (Some s). +Proof. intros bytes H; exists canonical; split; [now apply accepted_program|]. + intros; now apply busy_preserves. Qed. +Theorem source_other_allocation_live : forall bytes, + check bytes = true -> exists p, parse bytes = Some p /\ + forall s h addr key registry_payload payload retained readers, + h addr = HeapOwnership.Live registry_payload 0 0 -> + RegistrySource.active s = false -> key <> addr -> accounted s h -> + h key = HeapOwnership.Live payload retained readers -> + exists remaining, store (destroy_run p true s h addr) key = HeapOwnership.Live payload remaining readers /\ + remaining + retentions s key = retained. +Proof. intros bytes H; exists canonical; split; [now apply accepted_program|]. + intros; now apply other_allocation_live. Qed. +Theorem source_detaches_registrations : forall bytes, + check bytes = true -> exists p, parse bytes = Some p /\ + forall s h addr payload, h addr = HeapOwnership.Live payload 0 0 -> + accounted s h -> RegistrySource.active s = false -> + registration (destroy_run p true s h addr) = None. +Proof. intros bytes H; exists canonical; split; [now apply accepted_program|]. + intros; now apply detaches_registrations. Qed. + +(* Two slots share one context; an unrelated owner's retention must survive. + The registry is region 0, code regions 1/2, context region 9. *) +Definition shared_endpoints := RegistrySource.State + (Some (EndpointRefs 1 (Some 9))) (Some (EndpointRefs 2 (Some 9))) false. +Definition shared_heap (key : nat) : HeapOwnership.allocation := + match key with + | 0 => HeapOwnership.Live [42] 0 0 + | 1 | 2 => HeapOwnership.Live [] 1 0 + | 9 => HeapOwnership.Live [7] 3 0 + | _ => HeapOwnership.Vacant end. +Example shared_context_count : retentions shared_endpoints 9 = 2. +Proof. reflexivity. Qed. +Example shared_context_survives_destroy : + store (destroy_run canonical true shared_endpoints shared_heap 0) 9 = HeapOwnership.Live [7] 1 0. +Proof. reflexivity. Qed. +Example registry_removed : + store (destroy_run canonical true shared_endpoints shared_heap 0) 0 = HeapOwnership.Vacant. +Proof. reflexivity. Qed. + +Print Assumptions source_idle_release. +Print Assumptions source_busy_preserves. +Print Assumptions source_other_allocation_live. +Print Assumptions source_detaches_registrations. From 9ae81b2c34e2d2e35dcad0d5d694d50fab2bea00 Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Thu, 26 Nov 2026 05:54:43 +0000 Subject: [PATCH 3/3] Repair heap proof replay and harden the heap gate Agda: compute <= by recursion so the span-length proof needs no injectivity of suc under --cubical-compatible. Lean: prove the heap laws without simp. All ten theorems now report no axioms; releaseRemovesOwned previously failed and relied on sorry. Coq: type the public-header presence flag as bool, and pass the registry payload explicitly in source_idle_release. Gate: check staged proof copies against the original source digests, and reject any Coq diagnostic beyond the ten audit lines. --- scripts/atoma-heap-proof-gate.sh | 9 +++++- .../atoma/consumer/agda/HeapOwnership.agda | 16 +++++++---- .../atoma/consumer/coq/HeaderBoundarySource.v | 2 +- .../consumer/coq/RegistryLifetimeSource.v | 2 +- .../atoma/consumer/lean4/HeapOwnership.lean | 28 +++++++++++++------ 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/scripts/atoma-heap-proof-gate.sh b/scripts/atoma-heap-proof-gate.sh index 7511350..1422c40 100644 --- a/scripts/atoma-heap-proof-gate.sh +++ b/scripts/atoma-heap-proof-gate.sh @@ -16,7 +16,12 @@ sources=(verification/atoma/consumer/agda/HeapOwnership.agda for source in "${sources[@]:0:4}"; do cp "$root/$source" "$work/"; cmp "$root/$source" "$work/$(basename "$source")"; done (cd "$root"; sha256sum -c "$out/source-inputs.sha256") > "$out/snapshot-recheck.txt" cd "$work" -sha256sum HeapOwnership.agda HeapOwnershipCubical.agda HeapOwnership.lean HeapOwnership.v > "$out/checked-inputs.sha256" +# Check the staged copies against the ORIGINAL digests, not a fresh hash of +# whatever was staged: a transient edit restored before the recheck must fail. +while read -r digest path; do + [[ $path == scripts/* ]] || printf '%s %s\n' "$digest" "${path##*/}" +done < "$out/source-inputs.sha256" > "$out/checked-inputs.sha256" +sha256sum -c "$out/checked-inputs.sha256" > "$out/staged-recheck.txt" agda --safe --without-K --cubical-compatible --double-check --warning=error HeapOwnership.agda > "$out/agda.txt" 2>&1 lean HeapOwnership.lean > "$out/lean.txt" 2>&1 awk ' @@ -35,6 +40,8 @@ BEGIN { END {if (count != 10) exit 1}' "$out/lean.txt" coqc -q HeapOwnership.v > "$out/coq.txt" 2>&1 [[ $(grep -c '^Closed under the global context$' "$out/coq.txt") == 10 ]] +# A zero-exit build may still print warnings; accept only the ten audit lines. +if grep -qv '^Closed under the global context$' "$out/coq.txt"; then echo 'FAIL: Coq diagnostics' >&2; exit 1; fi if grep -q '^Axioms:' "$out/coq.txt"; then echo 'FAIL: heap proof axioms' >&2; exit 1; fi coqchk -silent -Q . '' HeapOwnership > "$out/coqchk.txt" 2>&1 agda --safe --cubical --double-check --warning=error HeapOwnershipCubical.agda > "$out/cubical.txt" 2>&1 diff --git a/verification/atoma/consumer/agda/HeapOwnership.agda b/verification/atoma/consumer/agda/HeapOwnership.agda index eed78c7..ab897af 100644 --- a/verification/atoma/consumer/agda/HeapOwnership.agda +++ b/verification/atoma/consumer/agda/HeapOwnership.agda @@ -133,9 +133,15 @@ drop zero xs = xs drop (suc n) [] = [] drop (suc n) (_ ∷ xs) = drop n xs infix 4 _≤_ -data _≤_ : Nat → Nat → Set where - z≤n : ∀ {n} → zero ≤ n - s≤s : ∀ {m n} → m ≤ n → suc m ≤ suc n +-- A computed order, not an indexed family: Cubical-compatible matching then +-- needs no injectivity of suc. +data ⊤ : Set where + tt : ⊤ +data ⊥ : Set where +_≤_ : Nat → Nat → Set +zero ≤ n = ⊤ +suc m ≤ zero = ⊥ +suc m ≤ suc n = m ≤ n -- Machine-usize/address representability is an additional native premise. borrowed-span : Nat → Nat → List Nat → List Nat @@ -145,6 +151,6 @@ span-length : ∀ offset count bytes → offset + count ≤ length bytes → length (borrowed-span offset count bytes) ≡ count span-length zero zero bytes fits = refl span-length zero (suc count) [] () -span-length zero (suc count) (b ∷ bytes) (s≤s fits) = cong suc (span-length zero count bytes fits) +span-length zero (suc count) (b ∷ bytes) fits = cong suc (span-length zero count bytes fits) span-length (suc offset) count [] () -span-length (suc offset) count (b ∷ bytes) (s≤s fits) = span-length offset count bytes fits +span-length (suc offset) count (b ∷ bytes) fits = span-length offset count bytes fits diff --git a/verification/atoma/consumer/coq/HeaderBoundarySource.v b/verification/atoma/consumer/coq/HeaderBoundarySource.v index 0a2b753..4a9e217 100644 --- a/verification/atoma/consumer/coq/HeaderBoundarySource.v +++ b/verification/atoma/consumer/coq/HeaderBoundarySource.v @@ -105,7 +105,7 @@ Definition finish_call p result after tls bytes := match result with The physical read lease must stay valid and immutable throughout the call; a backend may not retain the span. Final heap equality cannot establish that temporal condition: a native backend could write and restore between reads. *) -Definition run p present (h : HeapOwnership.heap) addr offset count tls +Definition run p (present : bool) (h : HeapOwnership.heap) addr offset count tls (backend : backend_fn) := if present then match h addr with diff --git a/verification/atoma/consumer/coq/RegistryLifetimeSource.v b/verification/atoma/consumer/coq/RegistryLifetimeSource.v index acb54c1..ba24d53 100644 --- a/verification/atoma/consumer/coq/RegistryLifetimeSource.v +++ b/verification/atoma/consumer/coq/RegistryLifetimeSource.v @@ -120,7 +120,7 @@ Theorem source_idle_release : forall bytes, forall key, store (destroy_run p true s h addr) key = detach s (snd (HeapOwnership.run HeapOwnership.Release h addr)) key. Proof. intros bytes H; exists canonical; split; [now apply accepted_program|]. - intros; now apply idle_release. Qed. + intros s h addr payload Hidle Hlive _; now apply (idle_release canonical s h addr payload). Qed. Theorem source_busy_preserves : forall bytes, check bytes = true -> exists p, parse bytes = Some p /\ forall s h addr payload retained readers, diff --git a/verification/atoma/consumer/lean4/HeapOwnership.lean b/verification/atoma/consumer/lean4/HeapOwnership.lean index 6457767..50c9804 100644 --- a/verification/atoma/consumer/lean4/HeapOwnership.lean +++ b/verification/atoma/consumer/lean4/HeapOwnership.lean @@ -47,28 +47,38 @@ theorem writeBorrowedRefused (bytes old : List Nat) (retained readers : Nat) : cellStep (writeBytes bytes) (live old retained (readers+1)) = none := rfl theorem failedPreserves (op : Operation) (h : Heap) (addr key : Nat) (refused : cellStep op (h addr) = none) : (run op h addr).2 key = h key := by - simp only [run, refused] + unfold run; rw [refused] theorem borrowReturnCell (bytes : List Nat) (retained readers : Nat) : thenCell borrowRead returnRead (live bytes retained readers) = some (live bytes retained readers) := rfl theorem borrowPreservesBytes (bytes : List Nat) (retained readers : Nat) : bytesAfter borrowRead (live bytes retained readers) = readBytes (live bytes retained readers) := rfl theorem releaseRemovesOwned (h : Heap) (addr : Nat) (bytes : List Nat) (owned : h addr = live bytes 0 0) : (run release h addr).2 addr = vacant := by - simp only [run, owned, cellStep, replace, if_pos rfl] + unfold run; rw [owned] + show (if addr = addr then vacant else h addr) = vacant + exact if_pos rfl theorem releaseFramesOther (h : Heap) (addr key : Nat) (bytes : List Nat) (owned : h addr = live bytes 0 0) (other : key ≠ addr) : (run release h addr).2 key = h key := by - simp only [run, owned, cellStep, replace, if_neg other] + unfold run; rw [owned] + show (if key = addr then vacant else h key) = h key + exact if_neg other theorem acquireLiveRefused (bytes old : List Nat) (retained readers : Nat) : cellStep (acquire bytes) (live old retained readers) = none := rfl def borrowedSpan (offset count : Nat) (bytes : List Nat) : List Nat := (bytes.drop offset).take count -theorem spanLength (offset count : Nat) (bytes : List Nat) - (fits : offset+count ≤ bytes.length) : (borrowedSpan offset count bytes).length = count := by - rw [borrowedSpan, List.length_take, List.length_drop] - apply Nat.min_eq_left - apply Nat.le_sub_of_add_le - simpa only [Nat.add_comm] using fits +-- Structural proof, mirroring the Agda clauses: library simp lemmas would +-- import propext into the receipt. +theorem spanLength : ∀ (offset count : Nat) (bytes : List Nat), + offset+count ≤ bytes.length → (borrowedSpan offset count bytes).length = count + | 0, 0, _, _ => rfl + | 0, _+1, [], fits => absurd fits (Nat.not_succ_le_zero _) + | 0, count+1, _ :: bytes, fits => + congrArg Nat.succ (spanLength 0 count bytes (Nat.le_of_succ_le_succ fits)) + | _+1, _, [], fits => absurd fits (Nat.not_le_of_gt (Nat.lt_of_lt_of_le (Nat.succ_pos _) (Nat.le_add_right _ _))) + | offset+1, count, _ :: bytes, fits => + spanLength offset count bytes + (Nat.le_of_succ_le_succ (Nat.succ_add offset count ▸ fits)) #print axioms releaseBorrowedRefused #print axioms releaseRetainedRefused