Files
marqdo/doc/verification/skill-proof/run-lean-check.sh
T
cflmy fa832268b3 prove: fix issues found in Lean verification round
- p2_len fixture claim corrected: pure function's trace is always empty,
  so '长度(轨迹) = 2' was an authoring mistake -> '长度(轨迹) = 0'
  (Nat-path coverage unchanged); all 7 claim-bearing files now prove
- generated Lean headers set linter.unusedVariables/unusedSimpArgs off:
  machine-emitted artifacts should not trigger human-authoring lints
  (0 warnings now)
- verification driver script + updated results in design doc 12 and
  library README
2026-11-18 10:28:18 +08:00

50 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# run-lean-check.sh — 用真实 Lean 4.35.0 校验 `marqdo prove --emit` 的产物。
# 用法: run-lean-check.sh <file.mq.md>...
# 每个文件: prove 生成 → lake env lean 编译 → 按退出状态分类。
set -u
ROOT="$(cd "$(dirname "$0")/../.." && pwd)" # /workspace/marqdo
LEAN_BIN="$ROOT/target/toolchain/lean-4.35.0-linux/bin"
PROOF_DIR="$ROOT/target/proof/skill-proof"
MARQDO="$ROOT/target/node/debug/marqdo"
export PATH="$LEAN_BIN:$PATH"
[ -x "$MARQDO" ] || { echo "marqdo binary missing: $MARQDO" >&2; exit 2; }
[ -f "$PROOF_DIR/.lake/build/lib/lean/MarqdoProof.olean" ] || \
{ (cd "$PROOF_DIR" && lake build) >&2 || exit 2; }
declare -A RESULT
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
for src in "$@"; do
name="$(basename "$src" .mq.md)"
outdir="$work/$name"
mkdir -p "$outdir"
if ! "$MARQDO" prove "$src" --emit "$outdir" >/dev/null 2>&1; then
RESULT[$src]="emit-failed"
continue
fi
lean_file="$(find "$outdir" -name '*.lean' | head -1)"
[ -n "$lean_file" ] || { RESULT[$src]="no-lean-emitted"; continue; }
cp "$lean_file" "$PROOF_DIR/Generated/_check.lean"
log="$work/$name.leanlog"
(cd "$PROOF_DIR" && lake env lean Generated/_check.lean) >"$log" 2>&1
rc=$?
rm -f "$PROOF_DIR/Generated/_check.lean"
if [ $rc -eq 0 ] && ! grep -q "error" "$log"; then
RESULT[$src]="proved"
elif grep -q "unsolved goals" "$log"; then
RESULT[$src]="unproved"
else
RESULT[$src]="lean-error"
fi
done
fail=0
for src in "$@"; do
status="${RESULT[$src]}"
printf '%-12s %s\n' "$status" "$src"
[ "$status" = "proved" ] || fail=1
done
exit $fail