interplane.Get Omega
Read in your language

aien-architecture-mv

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

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / bootstrap / formal-oracles / lean / run-seq-formal.sh

56 lines · 2452 bytes Raw Blame History
1#!/bin/sh
2# FORMAL-6: sequence identity formal bootstrap runner (DEVELOPMENT_ORACLE, not permanent lineage).
3# Builds the real model (must PASS) and each deliberate mutant claim (must FAIL for a proof reason).
4# Last stdout line: SEQ_FORMAL_BOOTSTRAP: PASS | FAIL | NOT_RUN
5# No network needed after the toolchain is installed (core Lean only, no dependencies).
6set -u
7here=$(cd "$(dirname "$0")" && pwd)
8cd "$here" || exit 2
9PATH="$HOME/.elan/bin:$PATH"; export PATH
10
11quiet="${AIEN_SPARK_QUIET_FLAG:-$HOME/workspace/.spark-quiet}"
12if [ -e "$quiet" ]; then
13 echo "quiet flag present ($quiet): not building"
14 echo "SEQ_FORMAL_BOOTSTRAP: NOT_RUN"
15 exit 3
16fi
17command -v lake >/dev/null 2>&1 || { echo "lake not found (install elan)"; echo "SEQ_FORMAL_BOOTSTRAP: NOT_RUN"; exit 3; }
18
19log=$(mktemp); trap 'rm -f "$log"' EXIT
20echo "toolchain: $(cat lean-toolchain) / $(lean --version)"
21fail=0
22
23# Forbidden constructs in the receipt sources (comments excluded by matching code-like uses).
24if grep -nE '^[^-]*\b(sorry|admit|native_decide|unsafe)\b|^axiom |^ *axiom ' AienSeq/*.lean AienSeq.lean >"$log"; then
25 echo "forbidden_constructs: FAIL"; cat "$log"; fail=1
26else
27 echo "forbidden_constructs: PASS"
28fi
29
30lake build AienSeq >"$log" 2>&1; rc=$?
31if [ $rc -eq 0 ] && ! grep -qi "sorry" "$log"; then
32 echo "real_model: PASS"
33else
34 echo "real_model: FAIL (rc=$rc)"; tail -20 "$log"; fail=1
35fi
36
37lake build MutantSeqModels >"$log" 2>&1; rc=$?
38if [ $rc -eq 0 ] && ! grep -qi "sorry" "$log"; then
39 echo "mutant_models_compile: PASS"
40else
41 echo "mutant_models_compile: FAIL (rc=$rc)"; tail -20 "$log"; fail=1
42fi
43
44# A mutant is killed only by a proof error in its own claim file, not a syntax or import error.
45for m in MutantSeqNoBumpClaim MutantSeqIgnoreGenClaim MutantSeqZeroWrapClaim MutantSeqActiveClaim MutantSeqForkClaim; do
46 lake build "$m" >"$log" 2>&1; rc=$?
47 if [ $rc -ne 0 ] && grep -qE "^error: $m.lean:[0-9]+:[0-9]+: (unsolved goals|simp_all made no progress|Type mismatch|Application type mismatch|.?simp.? made no progress|omega could not prove|Tactic)" "$log" \
48 && ! grep -q "unexpected token" "$log" && ! grep -qE "^error: (MutantSeqModels|AienSeq)" "$log"; then
49 echo "$m: FAIL_AS_EXPECTED (mutant killed)"
50 else
51 echo "$m: UNEXPECTED_BUILD_SUCCESS_OR_NO_PROOF_ERROR (rc=$rc), mutant survived"; fail=1
52 fi
53done
54
55if [ $fail -eq 0 ]; then echo "SEQ_FORMAL_BOOTSTRAP: PASS"; else echo "SEQ_FORMAL_BOOTSTRAP: FAIL"; fi
56exit $fail