Preface前言
欢迎
- 用表达力强、且有良好【证明理论|Proof Theory】的语言 写程序(即嵌入 Rocq 逻辑中的 Gallina 语言)。
- 在 Rocq 中证明程序正确。
- 提取为 ML,再用优化的 ML 编译器编译。
- 学习【《逻辑基础》】(【《软件基础》】第 1 卷),并完成习题!
- 学习【《编程语言基础》】(【《软件基础》】第 2 卷)的 Hoare 与 Hoare2 两章,并完成习题!
- 学习【《经验证的函数式算法》】(【《软件基础》】第 3 卷)的 Sort、SearchTree 与 ADT 三章,并完成习题!
实用事项
系统需求
- opam update (【视需要】)
- opam install coq-vst.2.16 (【要花 30 分钟以上】)
下载 Rocq 文件
安装
习题
- 一星:简单习题,用于强调正文中的要点,
对多数读者只需一两分钟。
遇到就做,养成习惯。
- 两星:直截了当的习题(五到十分钟)。
- 三星:需要一点思考的习题
(十分钟到半小时)。
- 四星与五星:较难的习题(半小时起)。
推荐的引用格式
@book {Appel:SF5,
author = {Andrew W. Appel, Lennart Beringer, and Qinxiang Cao},
editor = {Benjamin C. Pierce},
title = "可验证的 C",
series = "Software Foundations",
volume = "5",
year = "2026",
publisher = "Electronic textbook",
note = {Version 2.1, \URL{http://softwarefoundations.cis.upenn.edu} },
}
面向授课员与贡献者
鸣谢
Check that we have the right version of VST
Require Import Stdlib.Strings.String.
Open Scope string.
Definition release_needed := "2.17".
Require Import VST.veric.version. (* If this line fails, it means
you don't have a VST installed. *)
Goal release = release_needed ∨ release="2.16" ∧ release_needed="2.17".
Proof.
compute; auto ||
let need := constr:(release_needed) in let need := eval hnf in need in
let rel := constr:(release) in let rel := eval hnf in rel in
fail "The wrong version of VST is installed. You have VST version"
rel "but this version of 'Software Foundations Volume 5: Verifiable C'"
"demands version" need ". If possible, install VST version" need
"using the Rocq Platform or using opam. Or, if not From Stdlib Platform or opam,"
"for instructions about building VST from source and accessing that version, see the README file in this directory."
"Or, instead of installing VST" need ","
"if you want to proceed using VST version" rel ","
"then edit the Definition release_needed in Preface.v".
Abort.
From Stdlib Require Import ZArith.
Local Open Scope Z_scope.
Require VC.stack. (* If this line fails, do 'make stack.vo' *)
Goal VC.stack.Info.bitsize = VST.veric.version.bitsize.
reflexivity ||
let b1 := constr:(VST.veric.version.bitsize) in let b1 := eval compute in b1 in
let b2 := constr:(VC.stack.Info.bitsize) in let b2 := eval compute in b2 in
fail "Your installed VST is configured to verify C programs compiled with"
b1 "bit pointers,"
"but the .c files in the local directory have been clightgen'ed as if compiled with"
b2 "bit pointers."
"You can fix this by executing the shell command, "
"bash cfiles-bitsize" b1 " to install the properly configured clightgen outputs."
"It is not necessary to have clightgen installed".
Abort.
(* 2026-11-26 16:01 *)
Open Scope string.
Definition release_needed := "2.17".
Require Import VST.veric.version. (* If this line fails, it means
you don't have a VST installed. *)
Goal release = release_needed ∨ release="2.16" ∧ release_needed="2.17".
Proof.
compute; auto ||
let need := constr:(release_needed) in let need := eval hnf in need in
let rel := constr:(release) in let rel := eval hnf in rel in
fail "The wrong version of VST is installed. You have VST version"
rel "but this version of 'Software Foundations Volume 5: Verifiable C'"
"demands version" need ". If possible, install VST version" need
"using the Rocq Platform or using opam. Or, if not From Stdlib Platform or opam,"
"for instructions about building VST from source and accessing that version, see the README file in this directory."
"Or, instead of installing VST" need ","
"if you want to proceed using VST version" rel ","
"then edit the Definition release_needed in Preface.v".
Abort.
From Stdlib Require Import ZArith.
Local Open Scope Z_scope.
Require VC.stack. (* If this line fails, do 'make stack.vo' *)
Goal VC.stack.Info.bitsize = VST.veric.version.bitsize.
reflexivity ||
let b1 := constr:(VST.veric.version.bitsize) in let b1 := eval compute in b1 in
let b2 := constr:(VC.stack.Info.bitsize) in let b2 := eval compute in b2 in
fail "Your installed VST is configured to verify C programs compiled with"
b1 "bit pointers,"
"but the .c files in the local directory have been clightgen'ed as if compiled with"
b2 "bit pointers."
"You can fix this by executing the shell command, "
"bash cfiles-bitsize" b1 " to install the properly configured clightgen outputs."
"It is not necessary to have clightgen installed".
Abort.
(* 2026-11-26 16:01 *)
