Skip to content

Commit aa3bc4a

Browse files
committed
scripts: verify that all expected theorems are present
We add a script called check-theorems that ensures that all HOL-Light proofs provide the expected set of theorems depending on the architecture. Signed-off-by: Andreas Hatziiliou <andreas.hatziiliou@savoirfairelinux.com>
1 parent c6162d2 commit aa3bc4a

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

proofs/hol_light/aarch64/proofs/mlkem_rej_uniform.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ let STRIP_EXISTS_ASSUM_TAC =
17551755
(* The main memory safety theorem. *)
17561756
(* ========================================================================= *)
17571757

1758-
let MLKEM_REJ_UNIFORM_MEMSAFE = prove
1758+
let MLKEM_REJ_UNIFORM_SAFE = prove
17591759
(`!res buf buflen table (inlist:(12 word)list) pc e stackpointer.
17601760
24 divides val buflen /\
17611761
8 * val buflen = 12 * LENGTH inlist /\
@@ -3086,7 +3086,7 @@ let MLKEM_REJ_UNIFORM_MEMSAFE = prove
30863086
(* Memory safety of the subroutine version. *)
30873087
(* ------------------------------------------------------------------------- *)
30883088

3089-
let MLKEM_REJ_UNIFORM_SUBROUTINE_MEMSAFE = time prove
3089+
let MLKEM_REJ_UNIFORM_SUBROUTINE_SAFE = time prove
30903090
(`!res buf buflen table (inlist:(12 word)list) pc e stackpointer returnaddress.
30913091
24 divides val buflen /\
30923092
8 * val buflen = 12 * LENGTH inlist /\

scripts/check-theorems

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) The mlkem-native project authors
3+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4+
5+
# Verify that every proof contains the expected set of theorems.
6+
7+
set -euo pipefail
8+
9+
usage()
10+
{
11+
echo "Usage: $0 <architecture>" >&2
12+
echo " architecture: aarch64 | x86_64" >&2
13+
exit 1
14+
}
15+
16+
[[ $# -eq 1 ]] || usage
17+
ARCH="$1"
18+
19+
case "$ARCH" in
20+
aarch64 | x86_64) ;;
21+
*)
22+
echo "ERROR: Unknown architecture '$ARCH'." >&2
23+
usage
24+
;;
25+
esac
26+
27+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28+
PROOFS_DIR="$SCRIPT_DIR/../proofs/hol_light/$ARCH/proofs"
29+
30+
PROOFS="$(tests hol_light -l -a "$ARCH")"
31+
ERRORS=0
32+
33+
for routine in $PROOFS; do
34+
suffixes=("CORRECT" "SAFE" "SUBROUTINE_SAFE")
35+
[[ $ARCH == "x86_64" ]] && suffixes+=("SUBROUTINE_CORRECT" "NOIBT_SUBROUTINE_CORRECT" "NOIBT_SUBROUTINE_SAFE")
36+
37+
# mlkem_rej_uniform on x86_64 only has a functional correctness proof
38+
[[ $ARCH == "x86_64" && $routine == "mlkem_rej_uniform" ]] && suffixes=("CORRECT")
39+
40+
for sfx in "${suffixes[@]}"; do
41+
if ! grep -q "_${sfx}" "$PROOFS_DIR/${routine}.ml"; then
42+
echo "FAIL: ${routine}_${sfx} not found in ${routine}.ml" >&2
43+
((ERRORS++)) || true
44+
fi
45+
done
46+
done
47+
48+
[[ $ERRORS -eq 0 ]] && echo "OK" || exit 1

0 commit comments

Comments
 (0)