按任务包规范组织文件,并记录与精确版本对应的证据。
向解题者提供要证明的准确命题,并固定 Lean 工具链和允许的导入。本例使用自行编写的自然数等式。Lean 证明验证
编写与验证
在验证器中保存目标类型的声明。检查提交的证明是否具有该类型,并查看证明依赖的公理。此处以固定环境中的证明检查器作第 2 层参照。校准前确定允许的公理集合。如果还要评估说明是否清楚,应另设评分标准。
校准与修正
分别运行完整证明、未完成的证明和其他命题的证明。为每次试验固定命题、检查器和导入。证明被拒绝记为检查失败,工具链缺失记为基础设施错误。如果占位证明或未获准的公理被接受,收紧验证器并重跑所有对照。
可运行示例
使用官方发布的 Lean 4.19.0,在新目录中运行。完整证明应能编译并报告不依赖公理,未完成的证明和其他命题的证明应被拒绝。Lean 4.19.0 发布页
set -eu
cat > Complete.lean <<'EOF'
theorem submitted (n : Nat) : n + 2 = (n + 1) + 1 := by rfl
theorem checked : ∀ n : Nat, n + 2 = (n + 1) + 1 := submitted
#print axioms checked
EOF
lean -DwarningAsError=true Complete.lean > complete.txt
grep -Fx "'checked' does not depend on any axioms" complete.txt
sed 's/by rfl/by sorry/' Complete.lean > Incomplete.lean
if lean -DwarningAsError=true Incomplete.lean > incomplete.txt 2>&1; then
echo "Incomplete proof passed" >&2
exit 1
fi
grep -F 'uses' incomplete.txt
cat > Wrong.lean <<'EOF'
theorem submitted (n : Nat) : n = n := by rfl
theorem checked : ∀ n : Nat, n + 2 = (n + 1) + 1 := submitted
EOF
if lean -DwarningAsError=true Wrong.lean > wrong.txt 2>&1; then
echo "Wrong theorem passed" >&2
exit 1
fi
grep -F 'type mismatch' wrong.txt
printf '%s\n' 'complete proof pass, incomplete and wrong-theorem proofs fail'编写任务包验证器时,把目标声明和公理规则放在解题输出之外,并在固定的隔离环境中编译。