October 2026 main drop: mirror from GitHub
Browse files- .gitattributes +12 -0
- .github/workflows/ats-spark.yml +134 -0
- .github/workflows/idris-proofs.yml +72 -0
- .gitignore +9 -0
- CHANGELOG.md +29 -0
- COMMERCIAL-LICENSING.md +27 -0
- CONTRIBUTING.md +67 -0
- LICENSE +21 -0
- LICENSING.md +29 -0
- README.md +18 -0
- SECURITY.md +52 -0
- SUPPORT.md +23 -0
- VERSION +1 -0
- ada/heap_demo.adb +28 -0
- ada/heap_model.adb +24 -0
- ada/heap_model.ads +29 -0
- ada/heap_model.gpr +13 -0
- agent_hooks.example.sh +21 -0
- ats/heap.sats +27 -0
- ats/state.sats +42 -0
- docs/DELIVERY.md +106 -0
- docs/WORKFLOW.md +130 -0
- docs/assets/README.md +29 -0
- docs/assets/bounded-memory.png +3 -0
- docs/assets/proof-workbench.png +3 -0
- docs/releases/v1.0.0.md +49 -0
- docs/source-sketches/heap.sats.txt +3 -0
- docs/source-sketches/state.sats.txt +4 -0
- docs/unlambda_x5f_ats_x5f_runtime_x5f_architecture.html +0 -0
- docs/verification/ats-spark-af40c4e.md +86 -0
- docs/verification/idris-bb9abcc.md +41 -0
- idris/LambdaProofs.idr +121 -0
- idris/Main.idr +82 -0
- iterate-proof.sh +57 -0
- spec/ats-runtime-architecture.md +113 -0
- spec/invariants.md +29 -0
- spec/lambda-proofs.md +54 -0
- verify.sh +42 -0
.gitattributes
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
@@ -33,3 +43,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
* text=auto
|
| 6 |
+
*.sh text eol=lf
|
| 7 |
+
*.idr text eol=lf
|
| 8 |
+
*.sats text eol=lf
|
| 9 |
+
*.dats text eol=lf
|
| 10 |
+
|
| 11 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 12 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 13 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 43 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 44 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 45 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
docs/assets/bounded-memory.png filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
docs/assets/proof-workbench.png filter=lfs diff=lfs merge=lfs -text
|
.github/workflows/ats-spark.yml
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
name: ATS and SPARK validation
|
| 6 |
+
|
| 7 |
+
on:
|
| 8 |
+
push:
|
| 9 |
+
pull_request:
|
| 10 |
+
workflow_dispatch:
|
| 11 |
+
|
| 12 |
+
permissions:
|
| 13 |
+
contents: read
|
| 14 |
+
|
| 15 |
+
jobs:
|
| 16 |
+
ats:
|
| 17 |
+
runs-on: ubuntu-24.04
|
| 18 |
+
timeout-minutes: 15
|
| 19 |
+
steps:
|
| 20 |
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
| 21 |
+
- name: Install ATS compiler
|
| 22 |
+
run: |
|
| 23 |
+
sudo apt-get update
|
| 24 |
+
sudo apt-get install -y ats2-lang=0.4.2-1.1 build-essential
|
| 25 |
+
- name: Typecheck supplied ATS interfaces
|
| 26 |
+
run: |
|
| 27 |
+
mkdir -p build/reports/ats
|
| 28 |
+
set -o pipefail
|
| 29 |
+
patsopt --version | tee build/reports/ats/version.txt
|
| 30 |
+
patsopt -tc -s ats/heap.sats 2>&1 | tee build/reports/ats/heap-typecheck.txt
|
| 31 |
+
patsopt -tc -s ats/state.sats 2>&1 | tee build/reports/ats/state-typecheck.txt
|
| 32 |
+
- name: Preserve ATS evidence
|
| 33 |
+
if: always()
|
| 34 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
| 35 |
+
with:
|
| 36 |
+
name: ats-validation-evidence
|
| 37 |
+
path: build/reports/ats/
|
| 38 |
+
spark:
|
| 39 |
+
runs-on: ubuntu-24.04
|
| 40 |
+
timeout-minutes: 20
|
| 41 |
+
steps:
|
| 42 |
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
| 43 |
+
- name: Install native Ada compiler
|
| 44 |
+
run: |
|
| 45 |
+
sudo apt-get update
|
| 46 |
+
sudo apt-get install -y gnat gprbuild
|
| 47 |
+
- name: Restore pinned SPARK toolchain
|
| 48 |
+
id: spark-cache
|
| 49 |
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
| 50 |
+
with:
|
| 51 |
+
path: ~/.local/gnatprove-15.1.0
|
| 52 |
+
key: gnatprove-linux-aad9a73f600d3008-v1
|
| 53 |
+
- name: Install checksum-verified GNATprove
|
| 54 |
+
if: steps.spark-cache.outputs.cache-hit != 'true'
|
| 55 |
+
run: |
|
| 56 |
+
curl --fail --location --retry 3 \
|
| 57 |
+
https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnatprove-15.1.0-1/gnatprove-x86_64-linux-15.1.0-1.tar.gz \
|
| 58 |
+
-o "$RUNNER_TEMP/gnatprove.tar.gz"
|
| 59 |
+
echo "aad9a73f600d3008f33141a6cd4c5314d4c210e8928edc172c23c76104ddf7b2 $RUNNER_TEMP/gnatprove.tar.gz" | sha256sum --check
|
| 60 |
+
mkdir -p "$HOME/.local/gnatprove-15.1.0"
|
| 61 |
+
tar -xzf "$RUNNER_TEMP/gnatprove.tar.gz" --strip-components=1 -C "$HOME/.local/gnatprove-15.1.0"
|
| 62 |
+
- name: Save prover before running project checks
|
| 63 |
+
if: steps.spark-cache.outputs.cache-hit != 'true'
|
| 64 |
+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830
|
| 65 |
+
with:
|
| 66 |
+
path: ~/.local/gnatprove-15.1.0
|
| 67 |
+
key: gnatprove-linux-aad9a73f600d3008-v1
|
| 68 |
+
- name: Build and run heap smoke test
|
| 69 |
+
run: |
|
| 70 |
+
mkdir -p build/reports/spark
|
| 71 |
+
set -o pipefail
|
| 72 |
+
gnat --version | tee build/reports/spark/compiler-version.txt
|
| 73 |
+
gprbuild -p -P ada/heap_model.gpr 2>&1 | tee build/reports/spark/build.txt
|
| 74 |
+
build/heap_demo | tee build/reports/spark/smoke.txt
|
| 75 |
+
test "$(cat build/reports/spark/smoke.txt)" = 'heap contract smoke test: PASS'
|
| 76 |
+
- name: Prove all heap obligations and fail on unproved checks
|
| 77 |
+
run: |
|
| 78 |
+
export PATH="$HOME/.local/gnatprove-15.1.0/bin:$PATH"
|
| 79 |
+
mkdir -p build/reports/spark
|
| 80 |
+
set -o pipefail
|
| 81 |
+
gnatprove --version | tee build/reports/spark/prover-version.txt
|
| 82 |
+
gnatprove -P ada/heap_model.gpr -u heap_model.adb --mode=all \
|
| 83 |
+
--checks-as-errors=on --warnings=error --report=all --level=2 \
|
| 84 |
+
2>&1 | tee build/reports/spark/proof.txt
|
| 85 |
+
- name: Preserve SPARK evidence
|
| 86 |
+
if: always()
|
| 87 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
| 88 |
+
with:
|
| 89 |
+
name: spark-validation-evidence
|
| 90 |
+
path: |
|
| 91 |
+
build/reports/spark/
|
| 92 |
+
build/ada_obj/gnatprove/
|
| 93 |
+
combined:
|
| 94 |
+
needs: [ats, spark]
|
| 95 |
+
runs-on: ubuntu-24.04
|
| 96 |
+
timeout-minutes: 35
|
| 97 |
+
steps:
|
| 98 |
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
| 99 |
+
- name: Install combined compiler dependencies
|
| 100 |
+
run: |
|
| 101 |
+
sudo apt-get update
|
| 102 |
+
sudo apt-get install -y ats2-lang=0.4.2-1.1 gnat gprbuild chezscheme build-essential libgmp-dev
|
| 103 |
+
- name: Restore pinned Idris compiler
|
| 104 |
+
id: combined-idris
|
| 105 |
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
| 106 |
+
with:
|
| 107 |
+
path: ~/.idris2
|
| 108 |
+
key: idris2-ubuntu24-15a3e4e70843f7a34100f6470c04b791330788df-v1
|
| 109 |
+
- name: Bootstrap Idris if cache was evicted
|
| 110 |
+
if: steps.combined-idris.outputs.cache-hit != 'true'
|
| 111 |
+
run: |
|
| 112 |
+
git clone https://github.com/idris-lang/Idris2.git "$RUNNER_TEMP/Idris2"
|
| 113 |
+
cd "$RUNNER_TEMP/Idris2"
|
| 114 |
+
git checkout 15a3e4e70843f7a34100f6470c04b791330788df
|
| 115 |
+
make bootstrap SCHEME=chezscheme
|
| 116 |
+
make install
|
| 117 |
+
- name: Restore SPARK toolchain validated by prerequisite job
|
| 118 |
+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830
|
| 119 |
+
with:
|
| 120 |
+
path: ~/.local/gnatprove-15.1.0
|
| 121 |
+
key: gnatprove-linux-aad9a73f600d3008-v1
|
| 122 |
+
fail-on-cache-miss: true
|
| 123 |
+
- name: Run the complete checked-component entry point
|
| 124 |
+
run: |
|
| 125 |
+
export PATH="$HOME/.idris2/bin:$HOME/.local/gnatprove-15.1.0/bin:$PATH"
|
| 126 |
+
mkdir -p build/reports
|
| 127 |
+
set -o pipefail
|
| 128 |
+
bash verify.sh 2>&1 | tee build/reports/combined.txt
|
| 129 |
+
- name: Preserve combined evidence
|
| 130 |
+
if: always()
|
| 131 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
| 132 |
+
with:
|
| 133 |
+
name: combined-validation-evidence
|
| 134 |
+
path: build/reports/combined.txt
|
.github/workflows/idris-proofs.yml
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
name: Idris proof typecheck
|
| 6 |
+
|
| 7 |
+
on:
|
| 8 |
+
push:
|
| 9 |
+
pull_request:
|
| 10 |
+
workflow_dispatch:
|
| 11 |
+
|
| 12 |
+
permissions:
|
| 13 |
+
contents: read
|
| 14 |
+
|
| 15 |
+
jobs:
|
| 16 |
+
typecheck:
|
| 17 |
+
runs-on: ubuntu-24.04
|
| 18 |
+
timeout-minutes: 35
|
| 19 |
+
steps:
|
| 20 |
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
| 21 |
+
- name: Install bootstrap dependencies
|
| 22 |
+
run: |
|
| 23 |
+
sudo apt-get update
|
| 24 |
+
sudo apt-get install -y chezscheme build-essential libgmp-dev
|
| 25 |
+
- name: Cache pinned Idris installation
|
| 26 |
+
id: idris-cache
|
| 27 |
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
| 28 |
+
with:
|
| 29 |
+
path: ~/.idris2
|
| 30 |
+
key: idris2-ubuntu24-15a3e4e70843f7a34100f6470c04b791330788df-v1
|
| 31 |
+
- name: Bootstrap pinned Idris 2
|
| 32 |
+
if: steps.idris-cache.outputs.cache-hit != 'true'
|
| 33 |
+
run: |
|
| 34 |
+
git clone https://github.com/idris-lang/Idris2.git "$RUNNER_TEMP/Idris2"
|
| 35 |
+
cd "$RUNNER_TEMP/Idris2"
|
| 36 |
+
git checkout 15a3e4e70843f7a34100f6470c04b791330788df
|
| 37 |
+
make bootstrap SCHEME=chezscheme
|
| 38 |
+
make install
|
| 39 |
+
- name: Save compiler before checking project proofs
|
| 40 |
+
if: steps.idris-cache.outputs.cache-hit != 'true'
|
| 41 |
+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830
|
| 42 |
+
with:
|
| 43 |
+
path: ~/.idris2
|
| 44 |
+
key: idris2-ubuntu24-15a3e4e70843f7a34100f6470c04b791330788df-v1
|
| 45 |
+
- name: Check handwritten proof terms and model
|
| 46 |
+
run: |
|
| 47 |
+
export PATH="$HOME/.idris2/bin:$PATH"
|
| 48 |
+
mkdir -p build/reports
|
| 49 |
+
idris2 --version | tee build/reports/idris-version.txt
|
| 50 |
+
set -o pipefail
|
| 51 |
+
cd idris
|
| 52 |
+
idris2 --total --check LambdaProofs.idr 2>&1 | tee ../build/reports/lambda-typecheck.txt
|
| 53 |
+
idris2 --total --check Main.idr 2>&1 | tee ../build/reports/model-typecheck.txt
|
| 54 |
+
- name: Compile and smoke-test the current control model
|
| 55 |
+
run: |
|
| 56 |
+
export PATH="$HOME/.idris2/bin:$PATH"
|
| 57 |
+
set -o pipefail
|
| 58 |
+
cd idris
|
| 59 |
+
idris2 --total -o control-model Main.idr 2>&1 | tee ../build/reports/model-build.txt
|
| 60 |
+
build/exec/control-model | tee ../build/reports/model-smoke.txt
|
| 61 |
+
test "$(cat ../build/reports/model-smoke.txt)" = 'step: advanced'
|
| 62 |
+
- name: Preserve typechecker evidence
|
| 63 |
+
if: always()
|
| 64 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
| 65 |
+
with:
|
| 66 |
+
name: idris-typecheck-evidence
|
| 67 |
+
path: build/reports/
|
| 68 |
+
- name: Preserve the prototype control-model executable
|
| 69 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
| 70 |
+
with:
|
| 71 |
+
name: idris-control-model-ubuntu24
|
| 72 |
+
path: idris/build/exec/
|
.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
/build/
|
| 6 |
+
/idris/build/
|
| 7 |
+
__pycache__/
|
| 8 |
+
*.pyc
|
| 9 |
+
/agent_hooks.sh
|
CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Changelog
|
| 8 |
+
|
| 9 |
+
## Unreleased
|
| 10 |
+
|
| 11 |
+
- Declare original project material proprietary and publicly source-visible, not open source; add license headers and the root LICENSE notice.
|
| 12 |
+
- Update public repository and commercial permission documentation; preserve third-party archives and published v1.0.0 assets.
|
| 13 |
+
|
| 14 |
+
## v1.0.0 — Verification scaffold
|
| 15 |
+
|
| 16 |
+
- Converted supplied heap/state sketches into ATS/Postiats-checked interfaces.
|
| 17 |
+
- Added handwritten I/K/S lambda derivations and explicit Idris beta witnesses.
|
| 18 |
+
- Added capture-avoidance examples, corrected fuel proofs, and explicit exhaustion status.
|
| 19 |
+
- Compiled the Idris control-model program and checked its output in CI.
|
| 20 |
+
- Strengthened Ada allocation contracts and tested capacity, exhaustion, and reset.
|
| 21 |
+
- Discharged all six SPARK checks for the allocation-counter model.
|
| 22 |
+
- Added pinned compiler/prover workflows and combined `verify.sh` validation.
|
| 23 |
+
- Recorded source-pinned verification reports and original sketch provenance.
|
| 24 |
+
- Added workflow diagrams, conceptual photographs, contribution/security policies,
|
| 25 |
+
licensing-inquiry and support pages, repository description, topics, and badges.
|
| 26 |
+
|
| 27 |
+
The ATS evaluator, generation-checked slot-map heap, FFI adapter, full effectful
|
| 28 |
+
semantics, differential tests, and cross-language correspondence remain open.
|
| 29 |
+
Commercial license terms and a payment destination remain owner decisions.
|
COMMERCIAL-LICENSING.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Commercial licensing inquiries
|
| 8 |
+
|
| 9 |
+
[](https://github.com/AHMADALIPARR)
|
| 10 |
+
|
| 11 |
+
Contact the [repository maintainer](https://github.com/AHMADALIPARR) to discuss
|
| 12 |
+
commercial licensing or support. An inquiry is not a license grant. Pricing,
|
| 13 |
+
license scope, support commitments, warranties, and permitted distribution must
|
| 14 |
+
be agreed in writing; no standard commercial agreement is published in v1.
|
| 15 |
+
|
| 16 |
+
Describe your intended use, deployment/distribution model, required components,
|
| 17 |
+
organization, and support needs. The agreement would need to identify the
|
| 18 |
+
covered source version, ownership/provenance, applicable third-party terms,
|
| 19 |
+
license duration, redistribution rights, and any support or maintenance terms.
|
| 20 |
+
|
| 21 |
+
Original project code is proprietary and source-visible, not open source. See [LICENSING.md](LICENSING.md). Commercial arrangements can cover
|
| 22 |
+
only rights the licensor can grant; they do not remove third-party obligations.
|
| 23 |
+
|
| 24 |
+
v1 is a verification scaffold, with an unimplemented ATS runtime and slot-map
|
| 25 |
+
heap. Its commercial availability must not be described as a certified
|
| 26 |
+
production interpreter. The [verification report](docs/verification/ats-spark-af40c4e.md)
|
| 27 |
+
defines the checked component scope.
|
CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Contributing
|
| 8 |
+
|
| 9 |
+
This public, proprietary source-visible repository develops a combined Unlambda/ATS/Idris/SPARK
|
| 10 |
+
verification scaffold. Review [LICENSE](LICENSE) before proposing contributions. Start with the
|
| 11 |
+
[workflow](docs/WORKFLOW.md), [current evidence](docs/verification/ats-spark-af40c4e.md),
|
| 12 |
+
and [delivery gates](docs/DELIVERY.md).
|
| 13 |
+
|
| 14 |
+
## Work on a reviewable increment
|
| 15 |
+
|
| 16 |
+
Open an issue describing the behavior or proof obligation, then use a focused
|
| 17 |
+
branch. An implementation change should include a test of observable behavior
|
| 18 |
+
or a constructive proof of the changed invariant. Documentation-only changes
|
| 19 |
+
should have working links and accurate scope statements.
|
| 20 |
+
|
| 21 |
+
```sh
|
| 22 |
+
git switch -c change/describe-the-increment
|
| 23 |
+
# Edit source, specifications, and relevant tests or proofs.
|
| 24 |
+
bash verify.sh
|
| 25 |
+
git add <changed-files>
|
| 26 |
+
git commit -m "Describe the resulting behavior"
|
| 27 |
+
git push -u origin change/describe-the-increment
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
Create a pull request with the concrete problem, resulting behavior, checked
|
| 31 |
+
commands/CI runs, and any remaining proof obligations. Reference the gate it
|
| 32 |
+
advances. Do not mark a runtime gate complete from interface checks alone.
|
| 33 |
+
|
| 34 |
+
## Proof and safety rules
|
| 35 |
+
|
| 36 |
+
- Keep handwritten derivations and Idris witnesses consistent. State the
|
| 37 |
+
quantified operand class and every required substitution lemma.
|
| 38 |
+
- Keep Idris proof-bearing definitions total. Do not use `believe_me`,
|
| 39 |
+
`assert_total`, `assert_smaller`, missing proof holes, or equivalent bypasses.
|
| 40 |
+
- Do not introduce `pragma Assume` or suppress required SPARK checks. Strengthen
|
| 41 |
+
contracts and supply loop invariants when needed; retain unproved-check failures.
|
| 42 |
+
- Preserve distinct `OutOfFuel`, `OutOfMemory`, failure, and successful statuses.
|
| 43 |
+
- Do not dereference a future node handle without generation-checked lookup.
|
| 44 |
+
- Preserve input/output ordering and record effects in explicit machine state.
|
| 45 |
+
- Add runtime code only with its actual compiler and behavioral checks. Abstract
|
| 46 |
+
ATS declarations do not establish implementation or FFI correctness.
|
| 47 |
+
- Never source unreviewed agent hooks. `agent_hooks.example.sh` is an example,
|
| 48 |
+
not an active proof-generation agent or a release gate.
|
| 49 |
+
|
| 50 |
+
The source scanner is a guardrail. Compiler/prover evidence and review are still
|
| 51 |
+
required. Do not invent coverage percentages, certification seals, or claims
|
| 52 |
+
that one language's tool verifies the other language's implementation.
|
| 53 |
+
|
| 54 |
+
## Review checklist
|
| 55 |
+
|
| 56 |
+
- The change explains its observable behavior and proof boundary.
|
| 57 |
+
- Specs and implementation agree; provenance and dependency versions are recorded.
|
| 58 |
+
- Relevant CI passes on the proposed source snapshot.
|
| 59 |
+
- Required checks are not skipped, assumed, or downgraded.
|
| 60 |
+
- Reports and release notes distinguish checked scope from future work.
|
| 61 |
+
- Contributions identify their authorship and any third-party license obligations.
|
| 62 |
+
|
| 63 |
+
Original project code is proprietary and source-visible, not open source;
|
| 64 |
+
see [LICENSING.md](LICENSING.md). Do not assume a copyright transfer or commercial
|
| 65 |
+
relicensing grant. Discuss the applicable contribution terms with the maintainer
|
| 66 |
+
before contributing third-party material. Report sensitive issues through
|
| 67 |
+
[SECURITY.md](SECURITY.md), rather than a normal issue or pull request.
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Proprietary source-visible notice
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 4 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 5 |
+
|
| 6 |
+
This repository is publicly visible source, not open-source software.
|
| 7 |
+
Except for rights provided by applicable law or the hosting platform's terms,
|
| 8 |
+
no permission is granted to use, copy, modify, distribute, sublicense, or sell
|
| 9 |
+
original project material without separate written permission from the owner.
|
| 10 |
+
Public access does not grant a general software license. GitHub platform rights
|
| 11 |
+
to view and fork a public repository under its terms are not revoked by this notice.
|
| 12 |
+
|
| 13 |
+
Commercial permissions must be agreed separately in writing. Contact:
|
| 14 |
+
https://github.com/AHMADALIPARR or ahmedparr93@gmail.com.
|
| 15 |
+
|
| 16 |
+
This notice applies only to original project material for which the owner holds
|
| 17 |
+
applicable rights. Third-party material retains its own notices and terms;
|
| 18 |
+
this notice does not replace them. Archived supplied material in
|
| 19 |
+
docs/source-sketches/ and docs/unlambda_x5f_ats_x5f_runtime_x5f_architecture.html
|
| 20 |
+
is preserved for provenance and is not assigned new ownership by this notice.
|
| 21 |
+
See LICENSING.md for scope and provenance details.
|
LICENSING.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Licensing and provenance
|
| 2 |
+
|
| 3 |
+
This is a **proprietary, publicly source-visible project, not open source**.
|
| 4 |
+
Original project material is covered by [LICENSE](LICENSE). Copyright (c) 2026
|
| 5 |
+
Ahmad Ali Parr. All rights reserved. Public visibility does not grant a general
|
| 6 |
+
license to use, modify, redistribute, or commercialize that material. Separate
|
| 7 |
+
written permission is required except for rights provided by applicable law or
|
| 8 |
+
GitHub's platform terms, including its public-repository viewing and forking rights.
|
| 9 |
+
See [GitHub's licensing guidance](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository).
|
| 10 |
+
|
| 11 |
+
Source headers use `SPDX-License-Identifier: LicenseRef-Proprietary`, a custom
|
| 12 |
+
identifier referring to the root notice rather than an open-source license.
|
| 13 |
+
The root notice also covers original documentation and applicable rights in
|
| 14 |
+
project assets; PNG files and the machine-readable VERSION file remain intact.
|
| 15 |
+
|
| 16 |
+
The supplied architecture notes mention Unlambda 2.0.0 and GPL-2.0-or-later
|
| 17 |
+
for upstream material from madore.org. Any actual third-party material retains
|
| 18 |
+
its own applicable notices and rights; this proprietary notice cannot override
|
| 19 |
+
those terms. Compiler and prover licenses are separate from project licensing.
|
| 20 |
+
|
| 21 |
+
Original supplied sketches in `docs/source-sketches/` and the archived
|
| 22 |
+
`docs/unlambda_x5f_ats_x5f_runtime_x5f_architecture.html` are preserved without
|
| 23 |
+
new ownership headers. Their provenance must be established before incorporating
|
| 24 |
+
third-party implementations or redistributing third-party material.
|
| 25 |
+
|
| 26 |
+
For separately negotiated permissions, see
|
| 27 |
+
[COMMERCIAL-LICENSING.md](COMMERCIAL-LICENSING.md). No standard commercial grant,
|
| 28 |
+
price, warranty, or support commitment is implied. Published v1.0.0 source and
|
| 29 |
+
evidence archives remain unchanged; current headers do not rewrite that snapshot.
|
README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: proprietary-source-visible
|
| 4 |
+
license_link: https://huggingface.co/Snapkitty/unlambda-idris-spark/blob/main/LICENSE
|
| 5 |
+
tags:
|
| 6 |
+
- snapkitty
|
| 7 |
+
- october-2026-drop
|
| 8 |
+
- unlambda
|
| 9 |
+
- idris
|
| 10 |
+
- ats
|
| 11 |
+
- ada
|
| 12 |
+
- spark
|
| 13 |
+
- lambda-calculus
|
| 14 |
+
- formal-verification
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
> Mirrored from [https://github.com/SNAPKITTYWEST/unlambda-idris-spark](https://github.com/SNAPKITTYWEST/unlambda-idris-spark) at commit `a42eccc`. Part of the **SnapKitty October 2026 main drop**.
|
| 18 |
+
|
SECURITY.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Security policy
|
| 8 |
+
|
| 9 |
+
## Supported scope
|
| 10 |
+
|
| 11 |
+
| Version | Scope |
|
| 12 |
+
| --- | --- |
|
| 13 |
+
| v1.0.x | Maintainer triage for the verification scaffold and build/proof workflow |
|
| 14 |
+
| Unreleased runtime designs | Design review; no supported deployed interpreter |
|
| 15 |
+
|
| 16 |
+
The repository is public and source-visible. v1 contains interfaces, a proof/control model, and an
|
| 17 |
+
allocation counter. It is not a sandbox for executing untrusted Unlambda code.
|
| 18 |
+
Passing typechecks and the counter's SPARK proofs do not establish security of
|
| 19 |
+
an interpreter, an FFI adapter, or a production deployment.
|
| 20 |
+
|
| 21 |
+
## Report privately
|
| 22 |
+
|
| 23 |
+
Email the repository owner at **ahmedparr93@gmail.com** with subject
|
| 24 |
+
`[unlambda-idris-spark] Security report`. This is the contact published on the
|
| 25 |
+
[maintainer's GitHub profile](https://github.com/AHMADALIPARR). If GitHub private
|
| 26 |
+
vulnerability reporting is enabled later, the repository's Security tab may
|
| 27 |
+
also provide a private report form. Do not assume that form is currently enabled.
|
| 28 |
+
|
| 29 |
+
Include the affected commit/version, relevant toolchain versions, a minimal
|
| 30 |
+
reproduction, expected impact, and suggested remediation if available. Do not
|
| 31 |
+
include credentials, personal data, or live customer input. Avoid publishing
|
| 32 |
+
an exploit or opening an ordinary issue containing sensitive details while
|
| 33 |
+
the report is being investigated.
|
| 34 |
+
|
| 35 |
+
The maintainer reviews reports and coordinates fixes and disclosure. No fixed
|
| 36 |
+
response SLA or paid bounty program is currently promised.
|
| 37 |
+
|
| 38 |
+
## What to report
|
| 39 |
+
|
| 40 |
+
- Build or agent-hook execution that can expose secrets or run unintended commands.
|
| 41 |
+
- A proof gate that reports success despite missing, suppressed, or unproved checks.
|
| 42 |
+
- Unsafe future handle lookup, generation reuse, or incorrect memory exhaustion.
|
| 43 |
+
- Release asset/source mismatch, compromised dependencies, or false evidence claims.
|
| 44 |
+
- A defect in the checked model or contracts that invalidates a documented result.
|
| 45 |
+
|
| 46 |
+
## Build and proof boundaries
|
| 47 |
+
|
| 48 |
+
CI actions and compiler sources are pinned; the GNATprove archive is checksum
|
| 49 |
+
verified. Evidence is tied to source commits. Credentials and local
|
| 50 |
+
`agent_hooks.sh` must not be committed. Generated proof modules require the same
|
| 51 |
+
review and typechecking as handwritten modules. Third-party compilers, provers,
|
| 52 |
+
and runtime libraries remain part of the trusted toolchain.
|
SUPPORT.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Support and donations
|
| 8 |
+
|
| 9 |
+
[](https://github.com/AHMADALIPARR)
|
| 10 |
+
|
| 11 |
+
The maintainer has not provided a verified donation destination yet. The badge
|
| 12 |
+
links to support information and the maintainer profile; it does not initiate
|
| 13 |
+
a payment. No payment account, donation URL, or GitHub Sponsors enrollment is
|
| 14 |
+
assumed. A funding link and `.github/FUNDING.yml` can be added when the owner
|
| 15 |
+
confirms the destination.
|
| 16 |
+
|
| 17 |
+
You can help now by reviewing the handwritten derivations, reproducing CI,
|
| 18 |
+
improving specifications, or contributing tests and the open runtime/heap
|
| 19 |
+
implementation work. Start with [CONTRIBUTING.md](CONTRIBUTING.md).
|
| 20 |
+
|
| 21 |
+
Future donations would support project work; they would not purchase a commercial
|
| 22 |
+
license, security SLA, or proof of production readiness. Commercial inquiries
|
| 23 |
+
belong in [COMMERCIAL-LICENSING.md](COMMERCIAL-LICENSING.md).
|
VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
1.0.0
|
ada/heap_demo.adb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
-- SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
-- Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
with Ada.Text_IO; use Ada.Text_IO;
|
| 6 |
+
with Heap_Model;
|
| 7 |
+
|
| 8 |
+
-- Test driver: I/O is outside the proof boundary of Heap_Model.
|
| 9 |
+
procedure Heap_Demo is
|
| 10 |
+
H : Heap_Model.Heap;
|
| 11 |
+
Success : Boolean;
|
| 12 |
+
begin
|
| 13 |
+
Heap_Model.Reset (H);
|
| 14 |
+
pragma Assert (Heap_Model.Used (H) = 0);
|
| 15 |
+
for Expected in 1 .. Heap_Model.Capacity loop
|
| 16 |
+
Heap_Model.Allocate (H, Success);
|
| 17 |
+
pragma Assert (Success);
|
| 18 |
+
pragma Assert (Heap_Model.Used (H) = Expected);
|
| 19 |
+
end loop;
|
| 20 |
+
Heap_Model.Allocate (H, Success);
|
| 21 |
+
pragma Assert (not Success);
|
| 22 |
+
pragma Assert (Heap_Model.Used (H) = Heap_Model.Capacity);
|
| 23 |
+
Heap_Model.Reset (H);
|
| 24 |
+
pragma Assert (Heap_Model.Used (H) = 0);
|
| 25 |
+
Heap_Model.Allocate (H, Success);
|
| 26 |
+
pragma Assert (Success and then Heap_Model.Used (H) = 1);
|
| 27 |
+
Put_Line ("heap contract smoke test: PASS");
|
| 28 |
+
end Heap_Demo;
|
ada/heap_model.adb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
-- SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
-- Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
package body Heap_Model with SPARK_Mode is
|
| 6 |
+
|
| 7 |
+
function Used (H : Heap) return Count is (H.Allocated);
|
| 8 |
+
|
| 9 |
+
procedure Reset (H : out Heap) is
|
| 10 |
+
begin
|
| 11 |
+
H := (Allocated => 0);
|
| 12 |
+
end Reset;
|
| 13 |
+
|
| 14 |
+
procedure Allocate (H : in out Heap; Success : out Boolean) is
|
| 15 |
+
begin
|
| 16 |
+
if H.Allocated < Capacity then
|
| 17 |
+
H.Allocated := H.Allocated + 1;
|
| 18 |
+
Success := True;
|
| 19 |
+
else
|
| 20 |
+
Success := False;
|
| 21 |
+
end if;
|
| 22 |
+
end Allocate;
|
| 23 |
+
|
| 24 |
+
end Heap_Model;
|
ada/heap_model.ads
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
-- SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
-- Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
package Heap_Model with SPARK_Mode is
|
| 6 |
+
Capacity : constant := 64;
|
| 7 |
+
subtype Index is Natural range 0 .. Capacity - 1;
|
| 8 |
+
subtype Count is Natural range 0 .. Capacity;
|
| 9 |
+
|
| 10 |
+
type Heap is private;
|
| 11 |
+
|
| 12 |
+
function Used (H : Heap) return Count;
|
| 13 |
+
|
| 14 |
+
procedure Reset (H : out Heap)
|
| 15 |
+
with Post => Used (H) = 0;
|
| 16 |
+
|
| 17 |
+
procedure Allocate (H : in out Heap; Success : out Boolean)
|
| 18 |
+
with
|
| 19 |
+
Pre => Used (H) <= Capacity,
|
| 20 |
+
Post =>
|
| 21 |
+
Success = (Used (H'Old) < Capacity) and then
|
| 22 |
+
(if Success then Used (H) = Used (H'Old) + 1
|
| 23 |
+
else Used (H) = Used (H'Old));
|
| 24 |
+
|
| 25 |
+
private
|
| 26 |
+
type Heap is record
|
| 27 |
+
Allocated : Count := 0;
|
| 28 |
+
end record;
|
| 29 |
+
end Heap_Model;
|
ada/heap_model.gpr
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
-- SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
-- Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
project Heap_Model is
|
| 6 |
+
for Source_Dirs use (".");
|
| 7 |
+
for Main use ("heap_demo.adb");
|
| 8 |
+
for Object_Dir use "../build/ada_obj";
|
| 9 |
+
for Exec_Dir use "../build";
|
| 10 |
+
package Compiler is
|
| 11 |
+
for Switches ("Ada") use ("-gnat2022", "-gnata");
|
| 12 |
+
end Compiler;
|
| 13 |
+
end Heap_Model;
|
agent_hooks.example.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
# Copy to agent_hooks.sh and replace the bodies with your local agent integration.
|
| 6 |
+
# Do not source unreviewed hook scripts: they execute with your user permissions.
|
| 7 |
+
|
| 8 |
+
generate_proof_tactic() {
|
| 9 |
+
# Print a COMPLETE Idris 2 module to stdout, not a tactic fragment.
|
| 10 |
+
# Example: invoke your local agent CLI here.
|
| 11 |
+
echo 'module GeneratedProofs'
|
| 12 |
+
echo '%default total'
|
| 13 |
+
echo 'example : 1 = 1'
|
| 14 |
+
echo 'example = Refl'
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
update_agent_context() {
|
| 18 |
+
# Persist feedback to your agent's context/session using your integration.
|
| 19 |
+
# This sample only writes feedback to stderr.
|
| 20 |
+
printf '%s\n' "$1" >&2
|
| 21 |
+
}
|
ats/heap.sats
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(*
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
*)
|
| 6 |
+
|
| 7 |
+
(* Typed contract for the planned heap adapter. Implementations are pending. *)
|
| 8 |
+
abstype heap = ptr
|
| 9 |
+
abstype node_ref = ptr
|
| 10 |
+
abstype node = ptr
|
| 11 |
+
|
| 12 |
+
datatype heap_err =
|
| 13 |
+
| StaleRef of ()
|
| 14 |
+
| InvalidSlot of ()
|
| 15 |
+
| OutOfMemory of ()
|
| 16 |
+
|
| 17 |
+
datatype heap_result (a:t@ype) =
|
| 18 |
+
| HeapOK of a
|
| 19 |
+
| HeapError of heap_err
|
| 20 |
+
|
| 21 |
+
fun heap_create (capacity: intGte(0)): heap_result(heap)
|
| 22 |
+
fun heap_alloc (h: heap, n: node): heap_result(node_ref)
|
| 23 |
+
fun heap_lookup (h: heap, r: node_ref): heap_result(node)
|
| 24 |
+
fun heap_update (h: heap, r: node_ref, n: node): heap_result(bool)
|
| 25 |
+
fun heap_free (h: heap, r: node_ref): heap_result(bool)
|
| 26 |
+
fun heap_live (h: heap): intGte(0)
|
| 27 |
+
fun heap_is_valid (h: heap): bool
|
ats/state.sats
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(*
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
*)
|
| 6 |
+
|
| 7 |
+
(* Typed contract for the planned machine. Implementations are pending. *)
|
| 8 |
+
staload H = "./heap.sats"
|
| 9 |
+
|
| 10 |
+
abstype term_ref = ptr
|
| 11 |
+
|
| 12 |
+
datatype status =
|
| 13 |
+
| Running of ()
|
| 14 |
+
| Halted of ()
|
| 15 |
+
| Failed of ()
|
| 16 |
+
| OutOfFuel of ()
|
| 17 |
+
| OutOfMemory of ()
|
| 18 |
+
|
| 19 |
+
datatype control =
|
| 20 |
+
| Ctrl_Term of term_ref
|
| 21 |
+
| Ctrl_Value of $H.node_ref
|
| 22 |
+
|
| 23 |
+
datatype frame =
|
| 24 |
+
| F_EvalArg of term_ref
|
| 25 |
+
| F_ApplyFun of $H.node_ref
|
| 26 |
+
|
| 27 |
+
typedef input_state = @{
|
| 28 |
+
buffer=List0(uchar), cursor=size_t, current=Option(uchar)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
typedef machine_state = @{
|
| 32 |
+
control=control,
|
| 33 |
+
kont=List0(frame),
|
| 34 |
+
heap=$H.heap,
|
| 35 |
+
input=input_state,
|
| 36 |
+
output=List0(uchar),
|
| 37 |
+
fuel=intGte(0),
|
| 38 |
+
status=status
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
fun state_invariant_holds (state: machine_state): bool
|
| 42 |
+
fun state_step (state: machine_state): machine_state
|
docs/DELIVERY.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Delivery workflow
|
| 8 |
+
|
| 9 |
+
Lead: Codex, during active working sessions. Product owner: repository owner.
|
| 10 |
+
Status: v1.0.0 verification-scaffold packaging; implementation continues and no
|
| 11 |
+
production interpreter release is certified.
|
| 12 |
+
|
| 13 |
+
## Working cycle
|
| 14 |
+
|
| 15 |
+
1. Select the next unmet gate and record its concrete acceptance criteria.
|
| 16 |
+
2. Implement a reviewable increment with tests of observable behavior.
|
| 17 |
+
3. Compile and run the tests; collect proof reports where applicable.
|
| 18 |
+
4. Commit the increment and update this ledger with evidence and blockers.
|
| 19 |
+
5. Release only after all required gates pass on the release commit.
|
| 20 |
+
|
| 21 |
+
## Backlog and acceptance gates
|
| 22 |
+
|
| 23 |
+
| Gate | Work | Required evidence | State |
|
| 24 |
+
| --- | --- | --- | --- |
|
| 25 |
+
| 0 | Combined ATS runtime, Idris semantic proofs, SPARK heap; freeze platform, dialect and licensing | Product decisions; authoritative semantics; license provenance | Architecture confirmed; remaining decisions open |
|
| 26 |
+
| A | Bounded slot-map heap with generations | Allocation exhaustion, reuse, stale lookup/update, invariant tests | Open |
|
| 27 |
+
| B | Parser and core machine: s,k,i,v,d,output,newline | Compiler success; strictness, delay, output order, fuel tests | Open |
|
| 28 |
+
| C | Continuations, exit and input primitives | Capture/restore, EOF, current-character, input order tests | Open |
|
| 29 |
+
| D | Independent reference comparisons | Pinned reference; byte-for-byte output and termination corpus | Open |
|
| 30 |
+
| E | GC, if required for release | Root tracing, continuation retention, stale-reference safety | Open |
|
| 31 |
+
| R | Packaging and production release | Clean builds; CI; installation smoke test; version/checksums; rollback instructions | Open |
|
| 32 |
+
|
| 33 |
+
## Current assessment
|
| 34 |
+
|
| 35 |
+
- Idris `stepControl` consumes fuel but does not evaluate terms.
|
| 36 |
+
- Ada heap is an allocation counter; it has no node slots or generation handles.
|
| 37 |
+
The counter implementation compiles, passes exhaustion/reset tests, and has
|
| 38 |
+
all six GNATprove checks discharged.
|
| 39 |
+
- ATS files are now typed, compiler-validated interfaces. There are no ATS
|
| 40 |
+
runtime implementations or heap adapter yet.
|
| 41 |
+
- No executable Unlambda interpreter exists yet. The Idris control-model
|
| 42 |
+
executable now builds and passes a smoke test in CI.
|
| 43 |
+
- Private GitHub repository and `origin` configured:
|
| 44 |
+
https://github.com/AHMADALIPARR/unlambda-idris-spark.
|
| 45 |
+
The owner explicitly approved the push; the Idris workflow is active.
|
| 46 |
+
- ATS, Idris 2, and GNATprove are absent from the current PATH. Git's bundled
|
| 47 |
+
Bash is available at `C:/Program Files/Git/bin/bash.exe`.
|
| 48 |
+
- WSL has no usable installed distribution in the current environment.
|
| 49 |
+
|
| 50 |
+
## Definition of done
|
| 51 |
+
|
| 52 |
+
A runtime increment must compile and pass behavior and resource-boundary tests.
|
| 53 |
+
A proof increment must produce checked proof evidence; a source scan is insufficient.
|
| 54 |
+
A release must include a documented supported platform, CLI contract, resource
|
| 55 |
+
limits, tested installation, reproducible build instructions, license/provenance,
|
| 56 |
+
and a recorded passing release-gate result. Design documents alone do not pass a gate.
|
| 57 |
+
|
| 58 |
+
## Next increment
|
| 59 |
+
|
| 60 |
+
Architecture confirmed by the owner: ATS runtime, handwritten lambda-calculus
|
| 61 |
+
derivations formalized in Idris 2, and SPARK-verified heap contracts. The Idris
|
| 62 |
+
program/models must typecheck. Begin with the explicit SKI proof terms and
|
| 63 |
+
compiler workflow, then implement gate A before connecting the core machine.
|
| 64 |
+
Production platform and packaging remain to be decided.
|
| 65 |
+
|
| 66 |
+
## Proof increment
|
| 67 |
+
|
| 68 |
+
- Handwritten I/K/S beta derivations recorded in `spec/lambda-proofs.md`.
|
| 69 |
+
- Explicit indexed reduction witnesses written in `idris/LambdaProofs.idr`.
|
| 70 |
+
- Capture-avoidance boundary cases expressed as equality proofs.
|
| 71 |
+
- Corrected the original fuel theorem's successor inequality; added explicit
|
| 72 |
+
`OutOfMemory` and exact fuel-consumption obligations.
|
| 73 |
+
- CI definition bootstraps pinned Idris 2 and retains typechecker logs.
|
| 74 |
+
- Local whitespace and Bash syntax checks pass; source scan finds no prohibited
|
| 75 |
+
proof escape hatches in Idris, Ada, or ATS files.
|
| 76 |
+
- GitHub upload completed after the owner's explicit approval.
|
| 77 |
+
- Idris 2 0.8.0 typechecked the lambda proofs and control model, compiled the
|
| 78 |
+
model program, and passed its smoke test at commit `bb9abcc`.
|
| 79 |
+
[Recorded evidence](verification/idris-bb9abcc.md) links the successful run.
|
| 80 |
+
- SPARK proves the allocation-counter heap's current contracts. The generation
|
| 81 |
+
slot-map required by gate A is still open.
|
| 82 |
+
- ATS interface validation passes; the ATS runtime, correspondence, and
|
| 83 |
+
production packaging remain open.
|
| 84 |
+
|
| 85 |
+
## ATS/SPARK validation increment
|
| 86 |
+
|
| 87 |
+
- Replaced invalid ATS shorthand with typed interfaces; preserved originals.
|
| 88 |
+
- Strengthened allocation's contract to require success whenever capacity remains.
|
| 89 |
+
- Added assertion-enabled tests for all 64 allocations, exhaustion, reset, and reuse.
|
| 90 |
+
- Ran GNAT 13.3.0 and checksum-pinned GNATprove distribution 15.1.0.
|
| 91 |
+
- Proved all six checks; no unproved or justified checks, warnings, or assumptions.
|
| 92 |
+
- [Verification report](verification/ats-spark-af40c4e.md) records source commit,
|
| 93 |
+
source hashes, toolchains, CI runs, proof scope, and remaining certification work.
|
| 94 |
+
- `verify.sh` now checks ATS interfaces, Idris proofs/executable, Ada tests, and
|
| 95 |
+
GNATprove with unproved checks and warnings treated as errors.
|
| 96 |
+
|
| 97 |
+
## v1.0.0 release scope
|
| 98 |
+
|
| 99 |
+
The owner requested a v1 release of the current repository. It packages the
|
| 100 |
+
validated scaffold, with documentation, evidence, and checksums. It does not
|
| 101 |
+
mark runtime or production gates A–R complete. Repository description/topics,
|
| 102 |
+
CI/evidence badges, Mermaid flowcharts, conceptual images, contributing and
|
| 103 |
+
security policies, licensing-inquiry information, and support documentation
|
| 104 |
+
are included. Current original source is proprietary and source-visible under
|
| 105 |
+
[LICENSE](../LICENSE). Negotiated commercial terms and a donation destination
|
| 106 |
+
remain owner decisions.
|
docs/WORKFLOW.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Development and verification workflow
|
| 8 |
+
|
| 9 |
+
The project combines three verification layers around the Unlambda language.
|
| 10 |
+
Each tool checks a different artifact. Their results become a shared evidence
|
| 11 |
+
record; they do not automatically prove one another's implementations.
|
| 12 |
+
|
| 13 |
+
## From mathematics to checked source
|
| 14 |
+
|
| 15 |
+
1. Define the dialect, reductions, observable I/O order, resource statuses, and
|
| 16 |
+
heap invariants in `spec/`. The intended dialect is Unlambda 2.0.0.
|
| 17 |
+
2. Write the mathematical derivation, including substitutions and intermediate
|
| 18 |
+
terms. Current I/K/S derivations are in `spec/lambda-proofs.md`.
|
| 19 |
+
3. Encode the derivation as explicit Idris proof terms. `LambdaProofs.idr` uses
|
| 20 |
+
locally nameless terms, capture-avoiding substitution, and indexed reduction
|
| 21 |
+
witnesses. Current witnesses quantify over symbolic free atoms.
|
| 22 |
+
4. Typecheck the proofs with totality checking. Compile and run the current
|
| 23 |
+
fuel/control model. Its output is `step: advanced`; it is not an evaluator.
|
| 24 |
+
5. Typecheck the ATS declarations. They describe abstract handles, error results,
|
| 25 |
+
stack frames, control, I/O, fuel, and status. Implementations remain pending.
|
| 26 |
+
6. Compile the Ada heap, run assertion-enabled boundary tests, and prove its
|
| 27 |
+
contracts with SPARK. The current heap is a capacity-64 allocation counter.
|
| 28 |
+
7. Run the combined validation command and retain the logs for the same source
|
| 29 |
+
snapshot. Reject unproved checks and warnings in the SPARK job.
|
| 30 |
+
8. Release the checked component scaffold with versioned source, checksums,
|
| 31 |
+
evidence, and a precise statement of what remains unimplemented.
|
| 32 |
+
|
| 33 |
+
## Target architecture and current boundary
|
| 34 |
+
|
| 35 |
+
```mermaid
|
| 36 |
+
flowchart LR
|
| 37 |
+
U["Unlambda program"] -. "planned parser" .-> A["ATS evaluator: planned"]
|
| 38 |
+
A -. "planned adapter" .-> H["Ada generational slot-map: planned"]
|
| 39 |
+
A -. "simulation obligation" .-> M["Idris semantic model: partial"]
|
| 40 |
+
H -. "correspondence obligation" .-> M
|
| 41 |
+
I["ATS interface declarations: checked"] --> T["ATS typechecker"]
|
| 42 |
+
C["Ada allocation counter: implemented"] --> P["GNATprove"]
|
| 43 |
+
L["Handwritten SKI derivations"] --> D["Idris proof terms: checked"]
|
| 44 |
+
T --> E["Verification evidence"]
|
| 45 |
+
P --> E
|
| 46 |
+
D --> E
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Solid arrows show existing checked paths. Dotted arrows show planned runtime
|
| 50 |
+
paths or outstanding correspondence obligations. There is no AST parser,
|
| 51 |
+
continuation evaluator, generation-checked slot-map, or ATS/Ada adapter in v1.
|
| 52 |
+
|
| 53 |
+

|
| 54 |
+
|
| 55 |
+
## Continuous integration
|
| 56 |
+
|
| 57 |
+
`idris-proofs.yml` bootstraps or restores Idris 2 from pinned upstream commit
|
| 58 |
+
`15a3e4e70843f7a34100f6470c04b791330788df`. It typechecks `LambdaProofs.idr` and
|
| 59 |
+
`Main.idr`, compiles the model, and checks its output.
|
| 60 |
+
|
| 61 |
+
`ats-spark.yml` has three jobs:
|
| 62 |
+
|
| 63 |
+
| Job | Checks | Evidence |
|
| 64 |
+
| --- | --- | --- |
|
| 65 |
+
| `ats` | ATS compiler version and both interface typechecks | `ats-validation-evidence` |
|
| 66 |
+
| `spark` | Native compilation, heap boundary tests, strict GNATprove checks | `spark-validation-evidence` |
|
| 67 |
+
| `combined` | All toolchains run the repository's `verify.sh` after the first two jobs pass | `combined-validation-evidence` |
|
| 68 |
+
|
| 69 |
+
The prover distribution is pinned by SHA-256 and cached before project checks.
|
| 70 |
+
The proof command uses `--mode=all --checks-as-errors=on --warnings=error
|
| 71 |
+
--report=all --level=2`, targeting `heap_model.adb`. The I/O test driver is outside
|
| 72 |
+
the SPARK proof boundary. Failures preserve the available reports for diagnosis.
|
| 73 |
+
|
| 74 |
+
```mermaid
|
| 75 |
+
flowchart TD
|
| 76 |
+
Push["Push or pull request"] --> ATS["ATS job"]
|
| 77 |
+
Push --> SPARK["SPARK job"]
|
| 78 |
+
Push --> Idris["Idris workflow"]
|
| 79 |
+
ATS --> Combined["Combined validation"]
|
| 80 |
+
SPARK --> Combined
|
| 81 |
+
Idris --> Review["Review source and evidence"]
|
| 82 |
+
Combined --> Review
|
| 83 |
+
Review --> Tag["Version tag on checked commit"]
|
| 84 |
+
Tag --> Package["Source and evidence archives"]
|
| 85 |
+
Package --> Hash["SHA-256 checksums"]
|
| 86 |
+
Hash --> Publish["Private GitHub release"]
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Toolchain setup
|
| 90 |
+
|
| 91 |
+
CI's supported host is Ubuntu 24.04, Linux x86-64. The ATS package is
|
| 92 |
+
`ats2-lang=0.4.2-1.1`, Idris is 0.8.0, the native compiler is GNAT 13.3.0, and
|
| 93 |
+
the checksum-pinned GNATprove distribution is Alire 15.1.0 (reports FSF 15.0).
|
| 94 |
+
|
| 95 |
+
For a local Linux environment, install ATS, the Ada compiler/build tool, and the
|
| 96 |
+
Idris bootstrap dependencies:
|
| 97 |
+
|
| 98 |
+
```sh
|
| 99 |
+
sudo apt-get update
|
| 100 |
+
sudo apt-get install -y ats2-lang=0.4.2-1.1 gnat gprbuild chezscheme build-essential libgmp-dev
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
Follow the [official Idris installation instructions](https://github.com/idris-lang/Idris2/blob/15a3e4e70843f7a34100f6470c04b791330788df/INSTALL.md)
|
| 104 |
+
for that source commit. GNATprove can be obtained through
|
| 105 |
+
[Alire](https://alire.ada.dev/crates/gnatprove); the exact verified archive and
|
| 106 |
+
hash are in [the evidence report](verification/ats-spark-af40c4e.md). The workflow
|
| 107 |
+
files record the commands used by CI. Ensure `idris2`, `patsopt`, `gprbuild`, and
|
| 108 |
+
`gnatprove` are on PATH before running `bash verify.sh`.
|
| 109 |
+
|
| 110 |
+
The local Windows workspace does not currently have those compiler toolchains;
|
| 111 |
+
the passing reports were produced by Linux CI. Native Windows runtime support
|
| 112 |
+
has not been established.
|
| 113 |
+
|
| 114 |
+
## Release and rollback
|
| 115 |
+
|
| 116 |
+
v1 is a verification-scaffold release. Release assets include source, recorded
|
| 117 |
+
evidence, and `SHA256SUMS.txt`. Compare the hash before unpacking an asset and
|
| 118 |
+
rerun validation when changing compilers or source.
|
| 119 |
+
|
| 120 |
+
To reproduce or return to the release source:
|
| 121 |
+
|
| 122 |
+
```sh
|
| 123 |
+
git fetch --tags
|
| 124 |
+
git switch --detach v1.0.0
|
| 125 |
+
bash verify.sh
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
A future interpreter release must pass the open gates in `DELIVERY.md`: actual
|
| 129 |
+
heap safety, all primitives and effects, differential tests, and correspondence.
|
| 130 |
+
The v1 tag does not mark those gates complete.
|
docs/assets/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Visual assets
|
| 8 |
+
|
| 9 |
+
These AI-generated conceptual photographs illustrate the project. They are
|
| 10 |
+
not screenshots, hardware products, or formal verification evidence. Read
|
| 11 |
+
`spec/lambda-proofs.md` for the actual derivations; notebook marks in artwork
|
| 12 |
+
are decorative.
|
| 13 |
+
|
| 14 |
+
Generated with the built-in imagegen tool. The selected PNG outputs are stored
|
| 15 |
+
in this repository; no external image-generation account or file URL is required
|
| 16 |
+
to render the README. Applicable rights in project artwork are reserved under
|
| 17 |
+
[LICENSE](../../LICENSE); see [LICENSING.md](../../LICENSING.md).
|
| 18 |
+
|
| 19 |
+
## `proof-workbench.png`
|
| 20 |
+
|
| 21 |
+
Exact prompt:
|
| 22 |
+
|
| 23 |
+
> Use case: photorealistic-natural. Asset type: wide GitHub README cover photo for the Unlambda + ATS + Idris 2 + SPARK proof scaffold. Primary request: a polished editorial photograph of a dark desk with a notebook of handwritten lambda calculus, a pen, and three translucent geometric blocks suggesting typed interfaces, checked proofs, and bounded memory. Wide landscape composition, restrained navy background, soft cyan and amber studio lighting, realistic paper and glass textures, plenty of clean visual space. No people. No logos, no fabricated software screenshot, no certification seals, no checkmarks, no readable claims of production readiness. Notebook symbols may include a simple lambda and S K I. No title text, no watermark.
|
| 24 |
+
|
| 25 |
+
## `bounded-memory.png`
|
| 26 |
+
|
| 27 |
+
Exact prompt:
|
| 28 |
+
|
| 29 |
+
> Use case: photorealistic-natural. Asset type: supporting editorial photograph for a README's bounded-memory verification section. An abstract desktop memory model made from a compact orderly array of small translucent square glass tiles, some softly illuminated amber and others clear, with a notebook and pen out of focus in the background. This is a conceptual tabletop scene, not a real hardware product or screenshot. Realistic glass textures, navy and teal studio lighting, wide landscape composition, visually cohesive with a dark lambda-calculus proof workbench photo. No people, no readable text, no logos, no certification seals, no checkmarks, no watermark.
|
docs/assets/bounded-memory.png
ADDED
|
Git LFS Details
|
docs/assets/proof-workbench.png
ADDED
|
Git LFS Details
|
docs/releases/v1.0.0.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# v1.0.0 — Verification scaffold
|
| 8 |
+
|
| 9 |
+
This first version packages the checked proof/model/interface components and
|
| 10 |
+
their evidence. It is a development foundation for the combined Unlambda,
|
| 11 |
+
ATS, Idris 2, and SPARK architecture.
|
| 12 |
+
|
| 13 |
+
## Included
|
| 14 |
+
|
| 15 |
+
- ATS/Postiats 0.4.2-checked heap and state interface declarations.
|
| 16 |
+
- Handwritten SKI derivations with Idris 2 0.8.0-checked proof terms.
|
| 17 |
+
- A compiled fuel/control model with an executable smoke test.
|
| 18 |
+
- An assertion-tested Ada allocation counter with all six SPARK checks discharged.
|
| 19 |
+
- Combined compiler/prover validation, documented toolchains, and source-pinned reports.
|
| 20 |
+
- Contributor/security policies, licensing/support information, diagrams, and artwork.
|
| 21 |
+
|
| 22 |
+
## Release assets
|
| 23 |
+
|
| 24 |
+
- `unlambda-idris-spark-v1.0.0-source.zip`: source snapshot and documentation.
|
| 25 |
+
- `unlambda-idris-spark-v1.0.0-evidence.zip`: release-commit CI reports, plus a
|
| 26 |
+
manifest identifying the source commit and workflow runs.
|
| 27 |
+
- `SHA256SUMS.txt`: SHA-256 hashes of those two archives.
|
| 28 |
+
|
| 29 |
+
The release record and evidence manifest identify the exact source commit.
|
| 30 |
+
Validate asset checksums, install the documented toolchains, and run
|
| 31 |
+
`bash verify.sh` to reproduce the component checks.
|
| 32 |
+
|
| 33 |
+
## Verification scope
|
| 34 |
+
|
| 35 |
+
The runtime `.sats` declarations have no `.dats` implementation or ATS/Ada
|
| 36 |
+
adapter. The Ada heap counts allocations and does not store nodes or generation
|
| 37 |
+
handles. The Idris control model does not evaluate Unlambda programs. These
|
| 38 |
+
components and their proof boundaries are documented in
|
| 39 |
+
[the verification report](https://github.com/AHMADALIPARR/unlambda-idris-spark/blob/v1.0.0/docs/verification/ats-spark-af40c4e.md).
|
| 40 |
+
|
| 41 |
+
This release does not claim full interpreter correctness, cross-language
|
| 42 |
+
correspondence, Windows runtime support, or production certification. The
|
| 43 |
+
[delivery backlog](https://github.com/AHMADALIPARR/unlambda-idris-spark/blob/v1.0.0/docs/DELIVERY.md) retains those open gates.
|
| 44 |
+
|
| 45 |
+
At initial publication, the repository was private and no original-code license
|
| 46 |
+
grant was selected. The repository is now public and proprietary source-visible;
|
| 47 |
+
see [current licensing policy](https://github.com/AHMADALIPARR/unlambda-idris-spark/blob/main/LICENSE).
|
| 48 |
+
Published v1.0.0 archives remain unchanged. Commercial permissions require a
|
| 49 |
+
separate written agreement; the donation destination remains pending.
|
docs/source-sketches/heap.sats.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
abstype heap, node_ref, node
|
| 2 |
+
heap_err StaleRef InvalidSlot OutOfMemory
|
| 3 |
+
heap_create, heap_alloc, heap_lookup, heap_update, heap_live, heap_is_valid
|
docs/source-sketches/state.sats.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
status Running Halted Failed OutOfFuel OutOfMemory
|
| 2 |
+
control Ctrl_Term Ctrl_Value
|
| 3 |
+
machine_state {control,kont,heap,input,output,fuel,status}
|
| 4 |
+
state_invariant_holds, state_step
|
docs/unlambda_x5f_ats_x5f_runtime_x5f_architecture.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
docs/verification/ats-spark-af40c4e.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# ATS/SPARK verification report
|
| 8 |
+
|
| 9 |
+
Checked source commit: `af40c4e75c51c4dfc636b3eaa53f2362ffae0c4a`.
|
| 10 |
+
|
| 11 |
+
[ATS and SPARK validation run](https://github.com/AHMADALIPARR/unlambda-idris-spark/actions/runs/38026024273)
|
| 12 |
+
and [Idris validation on the same source commit](https://github.com/AHMADALIPARR/unlambda-idris-spark/actions/runs/38026024320)
|
| 13 |
+
both passed.
|
| 14 |
+
|
| 15 |
+
## Checked scope
|
| 16 |
+
|
| 17 |
+
| Component | Result | Scope |
|
| 18 |
+
| --- | --- | --- |
|
| 19 |
+
| `ats/heap.sats` | ATS typecheck passed | Interface declarations |
|
| 20 |
+
| `ats/state.sats` | ATS typecheck passed | Interface declarations |
|
| 21 |
+
| Ada `Heap_Model` | Compiled and tests passed | Fixed-capacity allocation counter |
|
| 22 |
+
| Ada `Heap_Model` | All six GNATprove checks discharged | Initialization, range safety, postconditions, termination |
|
| 23 |
+
| Idris proofs/model | Typechecked; model built and smoke-tested | Previously documented proof/model slice |
|
| 24 |
+
| ATS runtime | Not certified | No `.dats` implementation exists |
|
| 25 |
+
| Generational slot-map heap | Not certified | Not yet implemented |
|
| 26 |
+
| Cross-language correspondence | Not certified | No checked adapter/simulation argument yet |
|
| 27 |
+
|
| 28 |
+
This report certifies only the observed compiler/prover results for the stated
|
| 29 |
+
source snapshot and scope. It is not a third-party certification, a full
|
| 30 |
+
interpreter correctness proof, or a production release certificate.
|
| 31 |
+
|
| 32 |
+
## Tools and reproducibility
|
| 33 |
+
|
| 34 |
+
- Runner: Ubuntu 24.04, x86-64.
|
| 35 |
+
- ATS/Postiats: 0.4.2; Ubuntu package `ats2-lang=0.4.2-1.1`.
|
| 36 |
+
- Native Ada compiler: GNAT 13.3.0; assertion checking enabled with `-gnata`.
|
| 37 |
+
- GNATprove distribution: Alire `gnatprove` 15.1.0 (reports `FSF 15.0`).
|
| 38 |
+
- GNATprove archive SHA-256:
|
| 39 |
+
`aad9a73f600d3008f33141a6cd4c5314d4c210e8928edc172c23c76104ddf7b2`.
|
| 40 |
+
- Prover checks use `--mode=all --checks-as-errors=on --warnings=error
|
| 41 |
+
--report=all --level=2`, targeting `heap_model.adb`.
|
| 42 |
+
- Machine evidence is retained in the run's `ats-validation-evidence` and
|
| 43 |
+
`spark-validation-evidence` artifacts, subject to GitHub retention.
|
| 44 |
+
|
| 45 |
+
The compiler/prover installation follows the official
|
| 46 |
+
[Ubuntu ATS package](https://packages.ubuntu.com/noble/ats2-lang),
|
| 47 |
+
[Alire GNATprove manifest](https://github.com/alire-project/alire-index/blob/9ecbbfb0f9442fa6e53f5492258837c430154a3e/index/gn/gnatprove/gnatprove-15.1.0.toml),
|
| 48 |
+
and [GNATprove command documentation](https://docs.adacore.com/spark2014-docs/html/ug/en/source/how_to_run_gnatprove.html).
|
| 49 |
+
|
| 50 |
+
## Discharged SPARK checks
|
| 51 |
+
|
| 52 |
+
The prover summary reports six checks: two initialization checks, one run-time
|
| 53 |
+
range check, two functional-contract checks, and one termination check. Three
|
| 54 |
+
are discharged by flow analysis and three by CVC5. There are zero unproved or
|
| 55 |
+
justified checks. The detailed report records no warnings or `pragma Assume`.
|
| 56 |
+
|
| 57 |
+
The functional contracts establish:
|
| 58 |
+
|
| 59 |
+
- Reset sets the used count to zero.
|
| 60 |
+
- Allocation succeeds exactly when the old count is below capacity.
|
| 61 |
+
- Successful allocation increments the count by one.
|
| 62 |
+
- Rejected allocation preserves the count.
|
| 63 |
+
|
| 64 |
+
The test driver fills all 64 slots counted by the model, checks exhaustion,
|
| 65 |
+
resets the count, and allocates again. It uses runtime assertions; its I/O
|
| 66 |
+
driver is outside the SPARK proof boundary.
|
| 67 |
+
|
| 68 |
+
## Checked source hashes
|
| 69 |
+
|
| 70 |
+
SHA-256 hashes are for the Git blob bytes in the checked commit, with LF endings.
|
| 71 |
+
|
| 72 |
+
| File | SHA-256 |
|
| 73 |
+
| --- | --- |
|
| 74 |
+
| `ats/heap.sats` | `31f057dca9fc21f88bda99f071904fb781cc02650d005b3aa098204f48a1d550` |
|
| 75 |
+
| `ats/state.sats` | `ce64db05252470b0dd1eb3ec930477f02aa22c812c3857eceab43466527836e4` |
|
| 76 |
+
| `ada/heap_model.ads` | `a98bd4dc755c03807b1ea84cc158fcd94f325503facfe5021443d60df33317ab` |
|
| 77 |
+
| `ada/heap_model.adb` | `8bb9c934b080efe8ff9d9e7e042c1fa3a95c92497f1f6511ce1cdd7409ded9cc` |
|
| 78 |
+
|
| 79 |
+
## Required before full runtime certification
|
| 80 |
+
|
| 81 |
+
Implement the ATS parser and evaluator, the Ada slot-map with generation-checked
|
| 82 |
+
references, and the ATS/Ada adapter. Compile/link the real runtime; test every
|
| 83 |
+
Unlambda primitive, strictness/delay, I/O ordering, continuation restoration,
|
| 84 |
+
fuel exhaustion, and heap exhaustion. Prove the extended heap contracts and
|
| 85 |
+
establish correspondence to the Idris semantics. Passing interface checks and
|
| 86 |
+
counter proofs alone cannot establish these properties.
|
docs/verification/idris-bb9abcc.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Idris compiler evidence
|
| 8 |
+
|
| 9 |
+
Source commit: `bb9abccd3eec626ce1aeac0894a75a6385ed898b`.
|
| 10 |
+
|
| 11 |
+
[Successful GitHub Actions run](https://github.com/AHMADALIPARR/unlambda-idris-spark/actions/runs/38025027084).
|
| 12 |
+
|
| 13 |
+
Runner: Ubuntu 24.04. Compiler: Idris 2 0.8.0, bootstrapped from upstream commit
|
| 14 |
+
`15a3e4e70843f7a34100f6470c04b791330788df`.
|
| 15 |
+
|
| 16 |
+
## Passed checks
|
| 17 |
+
|
| 18 |
+
- `idris2 --total --check LambdaProofs.idr`
|
| 19 |
+
- `idris2 --total --check Main.idr`
|
| 20 |
+
- `idris2 --total -o control-model Main.idr`
|
| 21 |
+
- Run `build/exec/control-model`; require exact output `step: advanced`.
|
| 22 |
+
|
| 23 |
+
The run retains the `idris-typecheck-evidence` artifact with version,
|
| 24 |
+
typechecker, build, and smoke-test logs. It also retains the prototype executable
|
| 25 |
+
as `idris-control-model-ubuntu24`. Artifact availability follows GitHub retention.
|
| 26 |
+
|
| 27 |
+
## What the checked proofs establish
|
| 28 |
+
|
| 29 |
+
- Explicit I/K/S beta-reduction witnesses for symbolic free atoms.
|
| 30 |
+
- Concrete substitution/capture-avoidance boundary cases.
|
| 31 |
+
- Fuel never increases in the current control model.
|
| 32 |
+
- A positive-fuel running transition consumes exactly one unit.
|
| 33 |
+
- Zero fuel reports `OutOfFuel`.
|
| 34 |
+
- `OutOfMemory` remains preserved through fuel handling.
|
| 35 |
+
|
| 36 |
+
## Remaining verification
|
| 37 |
+
|
| 38 |
+
The control model is still a stub; the smoke test is not an Unlambda semantic
|
| 39 |
+
test. ATS runtime compilation, SPARK heap verification, general substitution
|
| 40 |
+
lemmas, effectful semantics, and cross-language correspondence remain open.
|
| 41 |
+
No production release is certified by this run.
|
idris/LambdaProofs.idr
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
-- SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
-- Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
module LambdaProofs
|
| 6 |
+
|
| 7 |
+
%default total
|
| 8 |
+
|
| 9 |
+
||| Locally nameless syntax: free atoms cannot be captured by a binder.
|
| 10 |
+
public export
|
| 11 |
+
data Lambda = Free Nat | Bound Nat | Lam Lambda | App Lambda Lambda
|
| 12 |
+
|
| 13 |
+
predecessor : Nat -> Nat
|
| 14 |
+
predecessor Z = Z
|
| 15 |
+
predecessor (S n) = n
|
| 16 |
+
|
| 17 |
+
||| Shift bound indices at or above a cutoff when entering binders.
|
| 18 |
+
public export
|
| 19 |
+
shift : Nat -> Nat -> Lambda -> Lambda
|
| 20 |
+
shift amount cutoff (Free atom) = Free atom
|
| 21 |
+
shift amount cutoff (Bound index) =
|
| 22 |
+
case compare index cutoff of
|
| 23 |
+
LT => Bound index
|
| 24 |
+
EQ => Bound (amount + index)
|
| 25 |
+
GT => Bound (amount + index)
|
| 26 |
+
shift amount cutoff (Lam body) = Lam (shift amount (S cutoff) body)
|
| 27 |
+
shift amount cutoff (App fun arg) =
|
| 28 |
+
App (shift amount cutoff fun) (shift amount cutoff arg)
|
| 29 |
+
|
| 30 |
+
||| Remove one binder, substituting its argument without variable capture.
|
| 31 |
+
public export
|
| 32 |
+
substitute : Nat -> Lambda -> Lambda -> Lambda
|
| 33 |
+
substitute depth argument (Free atom) = Free atom
|
| 34 |
+
substitute depth argument (Bound index) =
|
| 35 |
+
case compare index depth of
|
| 36 |
+
LT => Bound index
|
| 37 |
+
EQ => shift depth Z argument
|
| 38 |
+
GT => Bound (predecessor index)
|
| 39 |
+
substitute depth argument (Lam body) =
|
| 40 |
+
Lam (substitute (S depth) argument body)
|
| 41 |
+
substitute depth argument (App fun arg) =
|
| 42 |
+
App (substitute depth argument fun) (substitute depth argument arg)
|
| 43 |
+
|
| 44 |
+
public export
|
| 45 |
+
identity : Lambda
|
| 46 |
+
identity = Lam (Bound 0)
|
| 47 |
+
|
| 48 |
+
public export
|
| 49 |
+
constant : Lambda
|
| 50 |
+
constant = Lam (Lam (Bound 1))
|
| 51 |
+
|
| 52 |
+
public export
|
| 53 |
+
substitutionBody : Lambda
|
| 54 |
+
substitutionBody = Lam (Lam (App (App (Bound 2) (Bound 0))
|
| 55 |
+
(App (Bound 1) (Bound 0))))
|
| 56 |
+
|
| 57 |
+
public export
|
| 58 |
+
substitutionCombinator : Lambda
|
| 59 |
+
substitutionCombinator = Lam substitutionBody
|
| 60 |
+
|
| 61 |
+
||| One beta reduction, possibly in the function side of an application.
|
| 62 |
+
||| This relation describes the pure SKI fragment, not effectful evaluation.
|
| 63 |
+
public export
|
| 64 |
+
data BetaStep : Lambda -> Lambda -> Type where
|
| 65 |
+
Contract : (body : Lambda) -> (argument : Lambda) ->
|
| 66 |
+
BetaStep (App (Lam body) argument)
|
| 67 |
+
(substitute Z argument body)
|
| 68 |
+
InFunction : BetaStep before after -> (argument : Lambda) ->
|
| 69 |
+
BetaStep (App before argument) (App after argument)
|
| 70 |
+
|
| 71 |
+
public export
|
| 72 |
+
data BetaSteps : Lambda -> Lambda -> Type where
|
| 73 |
+
Done : BetaSteps term term
|
| 74 |
+
Then : BetaStep before middle -> BetaSteps middle after ->
|
| 75 |
+
BetaSteps before after
|
| 76 |
+
|
| 77 |
+
||| I x -> x for every symbolic free atom x.
|
| 78 |
+
public export
|
| 79 |
+
iBeta : (x : Nat) -> BetaStep (App LambdaProofs.identity (Free x)) (Free x)
|
| 80 |
+
iBeta x = Contract (Bound 0) (Free x)
|
| 81 |
+
|
| 82 |
+
||| Substitution under a binder must lift a bound argument to avoid capture.
|
| 83 |
+
public export
|
| 84 |
+
captureAvoidance : substitute Z (Bound 0) (Lam (Bound 1)) = Lam (Bound 1)
|
| 85 |
+
captureAvoidance = Refl
|
| 86 |
+
|
| 87 |
+
||| The inner binder's variable remains untouched by outer substitution.
|
| 88 |
+
public export
|
| 89 |
+
innerBinderPreserved : substitute Z (Free 7) (Lam (Bound 0)) = Lam (Bound 0)
|
| 90 |
+
innerBinderPreserved = Refl
|
| 91 |
+
|
| 92 |
+
||| Removing a binder decrements references to enclosing binders.
|
| 93 |
+
public export
|
| 94 |
+
outerIndexDecremented : substitute Z (Free 7) (Bound 2) = Bound 1
|
| 95 |
+
outerIndexDecremented = Refl
|
| 96 |
+
|
| 97 |
+
||| K x y -> x, with two explicit contractions.
|
| 98 |
+
public export
|
| 99 |
+
kBeta : (x, y : Nat) ->
|
| 100 |
+
BetaSteps (App (App LambdaProofs.constant (Free x)) (Free y)) (Free x)
|
| 101 |
+
kBeta x y =
|
| 102 |
+
Then (InFunction (Contract (Lam (Bound 1)) (Free x)) (Free y))
|
| 103 |
+
(Then (Contract (Free x) (Free y)) Done)
|
| 104 |
+
|
| 105 |
+
||| S x y z -> (x z) (y z), with three explicit contractions.
|
| 106 |
+
public export
|
| 107 |
+
sBeta : (x, y, z : Nat) ->
|
| 108 |
+
BetaSteps (App (App (App LambdaProofs.substitutionCombinator (Free x))
|
| 109 |
+
(Free y)) (Free z))
|
| 110 |
+
(App (App (Free x) (Free z)) (App (Free y) (Free z)))
|
| 111 |
+
sBeta x y z =
|
| 112 |
+
Then (InFunction (InFunction (Contract substitutionBody (Free x))
|
| 113 |
+
(Free y)) (Free z))
|
| 114 |
+
(Then (InFunction
|
| 115 |
+
(Contract (Lam (App (App (Free x) (Bound 0))
|
| 116 |
+
(App (Bound 1) (Bound 0))))
|
| 117 |
+
(Free y))
|
| 118 |
+
(Free z))
|
| 119 |
+
(Then (Contract (App (App (Free x) (Bound 0))
|
| 120 |
+
(App (Free y) (Bound 0)))
|
| 121 |
+
(Free z)) Done))
|
idris/Main.idr
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 2 |
+
-- SPDX-License-Identifier: LicenseRef-Proprietary
|
| 3 |
+
-- Public source visibility does not grant an open-source license. See LICENSE.
|
| 4 |
+
|
| 5 |
+
module Main
|
| 6 |
+
|
| 7 |
+
import Data.Nat
|
| 8 |
+
|
| 9 |
+
%default total
|
| 10 |
+
|
| 11 |
+
||| Abstract execution status. Resource exhaustion is not successful termination.
|
| 12 |
+
data Status = Running | Halted | OutOfFuel | OutOfMemory | Failed
|
| 13 |
+
|
| 14 |
+
||| Minimal control term for the first machine milestone.
|
| 15 |
+
||| Extend only after the selected Unlambda dialect is specified.
|
| 16 |
+
data Term = PrimI | PrimK | PrimS | Apply Term Term | DelayedTerm Term
|
| 17 |
+
|
| 18 |
+
record Machine where
|
| 19 |
+
constructor MkMachine
|
| 20 |
+
control : Term
|
| 21 |
+
fuel : Nat
|
| 22 |
+
status : Status
|
| 23 |
+
|
| 24 |
+
||| A transition outcome always records the next explicit machine status.
|
| 25 |
+
data Transition = Advanced Machine | Finished Machine
|
| 26 |
+
|
| 27 |
+
||| Fuel is consumed exactly once for an ordinary transition.
|
| 28 |
+
consumeRunning : Term -> Nat -> Machine
|
| 29 |
+
consumeRunning t Z = MkMachine t Z OutOfFuel
|
| 30 |
+
consumeRunning t (S k) = MkMachine t k Running
|
| 31 |
+
|
| 32 |
+
consumeFuel : Machine -> Machine
|
| 33 |
+
consumeFuel (MkMachine t n Running) = consumeRunning t n
|
| 34 |
+
consumeFuel (MkMachine t n Halted) = MkMachine t n Halted
|
| 35 |
+
consumeFuel (MkMachine t n OutOfFuel) = MkMachine t n OutOfFuel
|
| 36 |
+
consumeFuel (MkMachine t n OutOfMemory) = MkMachine t n OutOfMemory
|
| 37 |
+
consumeFuel (MkMachine t n Failed) = MkMachine t n Failed
|
| 38 |
+
|
| 39 |
+
||| The transition function is intentionally a control-model stub until
|
| 40 |
+
||| the full Unlambda operational semantics are fixed in spec/.
|
| 41 |
+
stepControl : Machine -> Transition
|
| 42 |
+
stepControl m@(MkMachine _ Z Running) = Finished (consumeFuel m)
|
| 43 |
+
stepControl m@(MkMachine _ (S _) Running) = Advanced (consumeFuel m)
|
| 44 |
+
stepControl m = Finished m
|
| 45 |
+
|
| 46 |
+
||| A structural fact: consuming fuel never increases the fuel counter.
|
| 47 |
+
natLteRefl : (n : Nat) -> LTE n n
|
| 48 |
+
natLteRefl Z = LTEZero
|
| 49 |
+
natLteRefl (S n) = LTESucc (natLteRefl n)
|
| 50 |
+
|
| 51 |
+
natLteNext : (n : Nat) -> LTE n (S n)
|
| 52 |
+
natLteNext Z = LTEZero
|
| 53 |
+
natLteNext (S n) = LTESucc (natLteNext n)
|
| 54 |
+
|
| 55 |
+
fuelDoesNotIncrease : (m : Machine) -> fuel (consumeFuel m) `LTE` fuel m
|
| 56 |
+
fuelDoesNotIncrease (MkMachine t Z Running) = LTEZero
|
| 57 |
+
fuelDoesNotIncrease (MkMachine t (S k) Running) = natLteNext k
|
| 58 |
+
fuelDoesNotIncrease (MkMachine t n Halted) = natLteRefl n
|
| 59 |
+
fuelDoesNotIncrease (MkMachine t n OutOfFuel) = natLteRefl n
|
| 60 |
+
fuelDoesNotIncrease (MkMachine t n OutOfMemory) = natLteRefl n
|
| 61 |
+
fuelDoesNotIncrease (MkMachine t n Failed) = natLteRefl n
|
| 62 |
+
|
| 63 |
+
||| One running transition consumes exactly one unit, not two or zero.
|
| 64 |
+
positiveFuelConsumesOne : (t : Term) -> (n : Nat) ->
|
| 65 |
+
fuel (consumeFuel (MkMachine t (S n) Running)) = n
|
| 66 |
+
positiveFuelConsumesOne t n = Refl
|
| 67 |
+
|
| 68 |
+
||| Heap exhaustion remains distinct from generic failure and termination.
|
| 69 |
+
memoryExhaustionIsPreserved : (t : Term) -> (n : Nat) ->
|
| 70 |
+
status (consumeFuel (MkMachine t n OutOfMemory)) = OutOfMemory
|
| 71 |
+
memoryExhaustionIsPreserved t n = Refl
|
| 72 |
+
|
| 73 |
+
||| Resource exhaustion is explicit when a running machine has zero fuel.
|
| 74 |
+
zeroFuelIsNotHalted : (t : Term) -> status (consumeFuel (MkMachine t Z Running)) = OutOfFuel
|
| 75 |
+
zeroFuelIsNotHalted t = Refl
|
| 76 |
+
|
| 77 |
+
main : IO ()
|
| 78 |
+
main = do
|
| 79 |
+
let initial = MkMachine PrimI 1 Running
|
| 80 |
+
case stepControl initial of
|
| 81 |
+
Advanced next => putStrLn "step: advanced"
|
| 82 |
+
Finished next => putStrLn "step: finished"
|
iterate-proof.sh
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
|
| 6 |
+
set -euo pipefail
|
| 7 |
+
|
| 8 |
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 9 |
+
HOOKS="${AGENT_HOOKS:-$ROOT/agent_hooks.sh}"
|
| 10 |
+
MAX_RETRIES="${MAX_RETRIES:-5}"
|
| 11 |
+
ATTEMPT=1
|
| 12 |
+
TARGET="$ROOT/idris/GeneratedProofs.idr"
|
| 13 |
+
|
| 14 |
+
if [[ ! -f "$HOOKS" ]]; then
|
| 15 |
+
echo "Missing agent hook file: $HOOKS" >&2
|
| 16 |
+
echo "Create it with generate_proof_tactic and update_agent_context functions." >&2
|
| 17 |
+
exit 2
|
| 18 |
+
fi
|
| 19 |
+
# The hook file is executable project configuration and must be reviewed before sourcing.
|
| 20 |
+
# shellcheck source=/dev/null
|
| 21 |
+
source "$HOOKS"
|
| 22 |
+
command -v generate_proof_tactic >/dev/null || { echo "generate_proof_tactic hook missing" >&2; exit 2; }
|
| 23 |
+
command -v update_agent_context >/dev/null || { echo "update_agent_context hook missing" >&2; exit 2; }
|
| 24 |
+
command -v idris2 >/dev/null || { echo "idris2 not installed" >&2; exit 2; }
|
| 25 |
+
|
| 26 |
+
while (( ATTEMPT <= MAX_RETRIES )); do
|
| 27 |
+
echo "Proof iteration $ATTEMPT/$MAX_RETRIES"
|
| 28 |
+
if ! generate_proof_tactic > "$TARGET"; then
|
| 29 |
+
FEEDBACK="Agent generation command failed. Return a complete Idris 2 module with explicit theorem statements and constructive proof terms."
|
| 30 |
+
update_agent_context "$FEEDBACK"
|
| 31 |
+
((ATTEMPT+=1))
|
| 32 |
+
continue
|
| 33 |
+
fi
|
| 34 |
+
|
| 35 |
+
if grep -nE '\b(believe_me|sorry|admit|assert_total|assert_smaller)\b' "$TARGET"; then
|
| 36 |
+
FEEDBACK="Rejected: prohibited Idris proof escape hatch detected. Remove the escape hatch and construct a proof term that typechecks."
|
| 37 |
+
update_agent_context "$FEEDBACK"
|
| 38 |
+
((ATTEMPT+=1))
|
| 39 |
+
continue
|
| 40 |
+
fi
|
| 41 |
+
|
| 42 |
+
set +e
|
| 43 |
+
COMPILER_OUT="$(cd "$ROOT/idris" && idris2 --total --check GeneratedProofs.idr 2>&1)"
|
| 44 |
+
COMPILER_STATUS=$?
|
| 45 |
+
set -e
|
| 46 |
+
|
| 47 |
+
if (( COMPILER_STATUS == 0 )); then
|
| 48 |
+
echo "Idris typecheck passed. This validates the generated module only; it does not by itself establish the cross-language SPARK correspondence."
|
| 49 |
+
exit 0
|
| 50 |
+
fi
|
| 51 |
+
|
| 52 |
+
update_agent_context "Idris 2 typechecker output (attempt $ATTEMPT):\n$COMPILER_OUT"
|
| 53 |
+
((ATTEMPT+=1))
|
| 54 |
+
done
|
| 55 |
+
|
| 56 |
+
echo "FAIL: proof generation did not produce a typechecking module after $MAX_RETRIES attempts." >&2
|
| 57 |
+
exit 1
|
spec/ats-runtime-architecture.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Unlambda ATS runtime specification
|
| 8 |
+
|
| 9 |
+
Supplied design notes. These describe intended behavior and proof obligations;
|
| 10 |
+
they do not claim that the current starter implements or verifies them.
|
| 11 |
+
The `ats/heap.sats` and `ats/state.sats` files now contain compiler-validated
|
| 12 |
+
typed interfaces derived from the supplied sketches. Original shorthand files
|
| 13 |
+
are preserved in `docs/source-sketches/`. No ATS runtime implementation exists
|
| 14 |
+
yet. [Validation evidence](../docs/verification/ats-spark-af40c4e.md) defines the
|
| 15 |
+
checked scope.
|
| 16 |
+
|
| 17 |
+
## Language semantics — Unlambda 2.0.0
|
| 18 |
+
|
| 19 |
+
Dialect: 2.0.0 GPL2+ from madore.org (as specified by the supplied notes).
|
| 20 |
+
|
| 21 |
+
Syntax: application, primitives `s k i v c d e r @ | .x ?x`.
|
| 22 |
+
|
| 23 |
+
Evaluation is strict except for `d`: `d x => Delayed(x)` without evaluating
|
| 24 |
+
`x`; `Delayed(x) y => Eval(x)` applied to `y`.
|
| 25 |
+
|
| 26 |
+
Reductions:
|
| 27 |
+
|
| 28 |
+
- `i x => x`
|
| 29 |
+
- `k x => K1(x)`; `K1(x) y => x`
|
| 30 |
+
- `s x => S1`; `s x y => S2`; `s x y z => x z y z`
|
| 31 |
+
- `v x => v`
|
| 32 |
+
- `.c x => print c, return x`; `r => newline`
|
| 33 |
+
- `e x => halt`
|
| 34 |
+
- `c x => capture K as Cont(K), eval x, apply x to Cont`
|
| 35 |
+
- `Cont(k) y => K=k, result y`
|
| 36 |
+
- `@ x => read byte, cur_char set, x i if byte else x v`
|
| 37 |
+
- `?c x => if cur_char==c then x i else x v`
|
| 38 |
+
- `| x => if cur_char Some(b) then x .b else x v`
|
| 39 |
+
|
| 40 |
+
Observables: output `O` is ordered; input cursor `I` is monotonic.
|
| 41 |
+
|
| 42 |
+
## Abstract machine
|
| 43 |
+
|
| 44 |
+
`Sigma=<C,K,H,I,O,F,Q>`
|
| 45 |
+
|
| 46 |
+
- `C=Ctrl_Term|Ctrl_Value`
|
| 47 |
+
- `K=list Frame`: `F_EvalArg(arg_term)`, `F_ApplyFun(fun_ref)`
|
| 48 |
+
- `H=slot-map NodeRef {slot,gen}`
|
| 49 |
+
- `I={buf,cursor,cur_char}`
|
| 50 |
+
- `O=vec OutChar`
|
| 51 |
+
- `F=fuel`
|
| 52 |
+
- `Q=Running|Halted|Failed|OutOfFuel|OutOfMemory`
|
| 53 |
+
|
| 54 |
+
Step: at most one transition, consumes one fuel. If `F==0`, set `OutOfFuel`.
|
| 55 |
+
Apply logic handles `d` specially in `EvalArg`: if `fun==D`, produce
|
| 56 |
+
`Delayed(arg_term)`; otherwise evaluate strictly.
|
| 57 |
+
Capture the continuation on `c`; restore it on `Cont` application.
|
| 58 |
+
|
| 59 |
+
## Memory model
|
| 60 |
+
|
| 61 |
+
Slot-map: slots contain generation plus state `Free|Occupied(Node)`;
|
| 62 |
+
maintain a free list, capacity, and live count.
|
| 63 |
+
|
| 64 |
+
`NodeRef` contains slot and generation. Allocation pops the free list and
|
| 65 |
+
checks generation. Lookup checks `gen==slot.gen` and `Occupied`, otherwise
|
| 66 |
+
returns `StaleRef`. Update performs the same checks. Free increments generation.
|
| 67 |
+
|
| 68 |
+
- H1: stored references valid at store time.
|
| 69 |
+
- H2: free list exact.
|
| 70 |
+
- H3: live count equals occupied count.
|
| 71 |
+
- H4: generation monotonic.
|
| 72 |
+
- H5: no dereference without lookup.
|
| 73 |
+
|
| 74 |
+
Capacity is fixed initially; `OutOfMemory` is explicit and leaves the heap valid.
|
| 75 |
+
Future GC roots: `C`, `K`, and continuation nodes.
|
| 76 |
+
|
| 77 |
+
## Invariants
|
| 78 |
+
|
| 79 |
+
- I1: stack references valid.
|
| 80 |
+
- I2: control valid.
|
| 81 |
+
- I3: heap satisfies H1–H5.
|
| 82 |
+
- I4: fuel decreases monotonically by one per transition.
|
| 83 |
+
- I5: output extends monotonically.
|
| 84 |
+
- I6: input cursor monotonic.
|
| 85 |
+
- I7: no hidden state.
|
| 86 |
+
- I8: status consistent.
|
| 87 |
+
- R1: `OutOfFuel != Halted`.
|
| 88 |
+
- R2: `OutOfMemory != Failed`.
|
| 89 |
+
- R3: `StaleRef` never dereferenced.
|
| 90 |
+
|
| 91 |
+
Intended ATS enforcement: abstract `term_ref` constructible only via parser,
|
| 92 |
+
abstract `NodeRef`, typed stack, abstract heap.
|
| 93 |
+
Runtime assertions: lookup before use, depth limit, spans.
|
| 94 |
+
Future proofs: `s,k,i` match SKI; `d` delays side effects; `c` captures/restores;
|
| 95 |
+
I/O preserves order.
|
| 96 |
+
|
| 97 |
+
## Gates
|
| 98 |
+
|
| 99 |
+
- A: heap safety.
|
| 100 |
+
- B: core machine `s,k,i,v,d,.,r`.
|
| 101 |
+
- C: all primitives.
|
| 102 |
+
- D: differential testing.
|
| 103 |
+
- E: garbage collection.
|
| 104 |
+
|
| 105 |
+
## Source materials
|
| 106 |
+
|
| 107 |
+
- [Architecture HTML](../docs/unlambda_x5f_ats_x5f_runtime_x5f_architecture.html)
|
| 108 |
+
- [Heap interface sketch](../ats/heap.sats)
|
| 109 |
+
- [State interface sketch](../ats/state.sats)
|
| 110 |
+
|
| 111 |
+
The supplied syntax sentence omits its application symbol, and the newline
|
| 112 |
+
rule does not specify an argument or return value. These details remain to be
|
| 113 |
+
resolved against the dialect before implementing the evaluator.
|
spec/invariants.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Unlambda / Idris 2 / SPARK verification contract
|
| 8 |
+
|
| 9 |
+
## Scope of this executable slice
|
| 10 |
+
|
| 11 |
+
This starter project verifies a bounded heap model and a small abstract-machine control model. It is not yet a complete Unlambda implementation. Before adding the remaining language primitives, freeze the chosen Unlambda dialect and its operational semantics.
|
| 12 |
+
|
| 13 |
+
## Shared invariants
|
| 14 |
+
|
| 15 |
+
- H1: heap capacity is fixed and every valid index is in `0 .. Capacity - 1`.
|
| 16 |
+
- H2: `Used <= Capacity`.
|
| 17 |
+
- H3: allocation succeeds only when capacity remains; failure does not change `Used`.
|
| 18 |
+
- H4: a successful allocation increases `Used` by exactly one.
|
| 19 |
+
- M1: machine fuel never increases during a transition.
|
| 20 |
+
- M2: an exhausted machine reports `OutOfFuel`, never `Halted`.
|
| 21 |
+
- M3: the Idris model's state constructors make the terminal status explicit.
|
| 22 |
+
|
| 23 |
+
## Proof boundary
|
| 24 |
+
|
| 25 |
+
Idris 2 checks the model and its proof terms. SPARK/GNATprove checks Ada contracts and runtime-safety/functional verification conditions. Neither tool proves the other language's implementation. Agreement is established through the shared invariants, tests, and (later) a translation/correspondence proof.
|
| 26 |
+
|
| 27 |
+
## Escape-hatch policy
|
| 28 |
+
|
| 29 |
+
Reject `believe_me`, `assert_total`, `assert_smaller`, `sorry`, `admit`, `pragma Assume`, and unchecked imported proof claims in proof-bearing files unless a specific reviewed exception is documented. The scanner is a guardrail, not a sound proof of absence of unsoundness.
|
spec/lambda-proofs.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
-->
|
| 6 |
+
|
| 7 |
+
# Handwritten lambda-calculus proofs: pure SKI fragment
|
| 8 |
+
|
| 9 |
+
Application associates to the left. Bound variables are alpha-renamed to avoid
|
| 10 |
+
capture. The implementation uses de Bruijn indices for bound variables and
|
| 11 |
+
separate free atoms; see `idris/LambdaProofs.idr`.
|
| 12 |
+
|
| 13 |
+
## Identity
|
| 14 |
+
|
| 15 |
+
`I = λa.a`
|
| 16 |
+
|
| 17 |
+
`I x = (λa.a) x →β x`.
|
| 18 |
+
|
| 19 |
+
Idris witness: `iBeta`, one `Contract`.
|
| 20 |
+
|
| 21 |
+
## Constant
|
| 22 |
+
|
| 23 |
+
`K = λa.λb.a`
|
| 24 |
+
|
| 25 |
+
`K x y = ((λa.λb.a) x) y →β (λb.x) y →β x`.
|
| 26 |
+
|
| 27 |
+
Idris witness: `kBeta`, two contractions, the first inside the function position.
|
| 28 |
+
|
| 29 |
+
## Substitution
|
| 30 |
+
|
| 31 |
+
`S = λa.λb.λc.(a c) (b c)`
|
| 32 |
+
|
| 33 |
+
`S x y z = (((λa.λb.λc.(a c) (b c)) x) y) z`
|
| 34 |
+
|
| 35 |
+
`→β ((λb.λc.(x c) (b c)) y) z`
|
| 36 |
+
|
| 37 |
+
`→β (λc.(x c) (y c)) z`
|
| 38 |
+
|
| 39 |
+
`→β (x z) (y z)`.
|
| 40 |
+
|
| 41 |
+
Idris witness: `sBeta`, three explicit contractions.
|
| 42 |
+
|
| 43 |
+
## Scope and remaining obligations
|
| 44 |
+
|
| 45 |
+
The Idris witnesses quantify over symbolic free atoms. They do not yet establish
|
| 46 |
+
substitution lemmas for arbitrary compound operands, confluence, or operational
|
| 47 |
+
equivalence of the ATS evaluator. Unlambda is strict and effectful: beta equality
|
| 48 |
+
of pure SKI terms alone cannot justify reordering output, input, delay, or
|
| 49 |
+
continuation operations.
|
| 50 |
+
|
| 51 |
+
SPARK verifies Ada heap safety and contracts. It does not check these lambda
|
| 52 |
+
proof terms or the Idris compiler. The production argument additionally needs
|
| 53 |
+
ATS-to-model simulation, a checked FFI contract, and correspondence evidence for
|
| 54 |
+
the Idris heap abstraction and the concrete Ada implementation.
|
verify.sh
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Copyright (c) 2026 Ahmad Ali Parr. All rights reserved.
|
| 3 |
+
# SPDX-License-Identifier: LicenseRef-Proprietary
|
| 4 |
+
# Public source visibility does not grant an open-source license. See LICENSE.
|
| 5 |
+
|
| 6 |
+
set -euo pipefail
|
| 7 |
+
|
| 8 |
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 9 |
+
IDRIS_DIR="$ROOT/idris"
|
| 10 |
+
ADA_DIR="$ROOT/ada"
|
| 11 |
+
ATS_DIR="$ROOT/ats"
|
| 12 |
+
|
| 13 |
+
# Guardrail only: semantic review and compiler checks remain necessary.
|
| 14 |
+
if grep -RniE '\b(believe_me|sorry|admit|assert_total|assert_smaller)\b|pragma[[:space:]]+Assume' \
|
| 15 |
+
"$IDRIS_DIR" "$ADA_DIR" "$ATS_DIR"; then
|
| 16 |
+
echo "FAIL: prohibited proof escape hatch detected" >&2
|
| 17 |
+
exit 20
|
| 18 |
+
fi
|
| 19 |
+
|
| 20 |
+
for tool in idris2 patsopt gprbuild gnatprove; do
|
| 21 |
+
if ! command -v "$tool" >/dev/null 2>&1; then
|
| 22 |
+
echo "FAIL: $tool not installed" >&2
|
| 23 |
+
exit 2
|
| 24 |
+
fi
|
| 25 |
+
done
|
| 26 |
+
|
| 27 |
+
mkdir -p "$ROOT/build"
|
| 28 |
+
patsopt -tc -s "$ATS_DIR/heap.sats"
|
| 29 |
+
patsopt -tc -s "$ATS_DIR/state.sats"
|
| 30 |
+
cd "$IDRIS_DIR"
|
| 31 |
+
idris2 --total --check Main.idr
|
| 32 |
+
idris2 --total --check LambdaProofs.idr
|
| 33 |
+
idris2 --total -o unlambda_model Main.idr
|
| 34 |
+
test "$(build/exec/unlambda_model)" = 'step: advanced'
|
| 35 |
+
|
| 36 |
+
cd "$ADA_DIR"
|
| 37 |
+
gprbuild -p -P heap_model.gpr
|
| 38 |
+
test "$("$ROOT/build/heap_demo")" = 'heap contract smoke test: PASS'
|
| 39 |
+
# All required checks must be proved; ordinary successful invocation is insufficient.
|
| 40 |
+
gnatprove -P heap_model.gpr -u heap_model.adb --mode=all \
|
| 41 |
+
--checks-as-errors=on --warnings=error --report=all --level=2
|
| 42 |
+
echo "PASS: ATS interfaces, Idris model, and allocation-counter heap."
|