Skip to content

Commit 3226ad6

Browse files
committed
lint: verify that all expected theorems are present
We add a check to the linting 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 94fad12 commit 3226ad6

5 files changed

Lines changed: 53 additions & 8 deletions

File tree

proofs/hol_light/aarch64/proofs/mlkem_rej_uniform.ml

Lines changed: 3 additions & 3 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 /\
@@ -3119,6 +3119,6 @@ let MLKEM_REJ_UNIFORM_SUBROUTINE_MEMSAFE = time prove
31193119
REWRITE_CONV[wordlist_from_memory] in
31203120
CONV_TAC TWEAK_CONV THEN
31213121
ARM_ADD_RETURN_STACK_TAC MLKEM_REJ_UNIFORM_EXEC
3122-
(CONV_RULE TWEAK_CONV MLKEM_REJ_UNIFORM_MEMSAFE)
3122+
(CONV_RULE TWEAK_CONV MLKEM_REJ_UNIFORM_SAFE)
31233123
`[]:int64 list` 576 THEN
31243124
DISCHARGE_MEMSAFE_TAC);;

proofs/hol_light/x86_64/proofs/mlkem_intt.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ let MLKEM_INTT_CORRECT = prove
12061206
CONV_TAC INT_REDUCE_CONV]))
12071207
);;
12081208

1209-
let MLKEM_INTT_NOIBT_SUBROUTINE_CORRECT = prove
1209+
let MLKEM_INTT_NOIBT_SUBROUTINE_CORRECT = prove
12101210
(`!a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
12111211
aligned 32 a /\
12121212
aligned 32 zetas /\
@@ -1241,7 +1241,7 @@ let MLKEM_INTT_NOIBT_SUBROUTINE_CORRECT = prove
12411241
(* NOTE: This must be kept in sync with the CBMC specification
12421242
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
12431243

1244-
let MLKEM_INTT_SUBROUTINE_CORRECT = prove
1244+
let MLKEM_INTT_SUBROUTINE_CORRECT = prove
12451245
(`!a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
12461246
aligned 32 a /\
12471247
aligned 32 zetas /\

proofs/hol_light/x86_64/proofs/mlkem_mulcache_compute.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ let MLKEM_MULCACHE_COMPUTE_CORRECT = prove(
259259
CONV_TAC INT_REDUCE_CONV])
260260
);;
261261

262-
let MLKEM_MULCACHE_COMPUTE_NOIBT_SUBROUTINE_CORRECT = prove(
262+
let MLKEM_MULCACHE_COMPUTE_NOIBT_SUBROUTINE_CORRECT = prove(
263263
`!r a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
264264
aligned 32 r /\
265265
aligned 32 a /\

proofs/hol_light/x86_64/proofs/mlkem_ntt.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ let MLKEM_NTT_CORRECT = prove
12141214
CONV_TAC INT_REDUCE_CONV]))
12151215
);;
12161216

1217-
let MLKEM_NTT_NOIBT_SUBROUTINE_CORRECT = prove
1217+
let MLKEM_NTT_NOIBT_SUBROUTINE_CORRECT = prove
12181218
(`!a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
12191219
aligned 32 a /\
12201220
aligned 32 zetas /\
@@ -1250,7 +1250,7 @@ let MLKEM_NTT_NOIBT_SUBROUTINE_CORRECT = prove
12501250
(* NOTE: This must be kept in sync with the CBMC specification
12511251
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
12521252

1253-
let MLKEM_NTT_SUBROUTINE_CORRECT = prove
1253+
let MLKEM_NTT_SUBROUTINE_CORRECT = prove
12541254
(`!a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
12551255
aligned 32 a /\
12561256
aligned 32 zetas /\

scripts/lint

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,51 @@ gh_group_start "Check contracts"
295295
check-contracts
296296
gh_group_end
297297

298+
check-theorems()
299+
{
300+
local success=true
301+
for arch in aarch64 x86_64; do
302+
local proofs_dir="$ROOT/proofs/hol_light/$arch/proofs"
303+
local proofs
304+
proofs=$("$ROOT/proofs/hol_light/$arch/list_proofs.sh")
305+
306+
for routine in $proofs; do
307+
local suffixes=("CORRECT" "SAFE" "SUBROUTINE_SAFE")
308+
if [[ $arch == "x86_64" && ${routine} == "mlkem_rej_uniform" ]]; then
309+
suffixes=("CORRECT")
310+
elif [[ $arch == "x86_64" ]]; then
311+
suffixes+=("SUBROUTINE_CORRECT" "NOIBT_SUBROUTINE_CORRECT" "NOIBT_SUBROUTINE_SAFE")
312+
fi
313+
314+
for sfx in "${suffixes[@]}"; do
315+
if ! grep -qE "_${sfx} = (time )?prove" "$proofs_dir/${routine}.ml"; then
316+
gh_error "${routine}" "" "Missing theorem" "${routine}_${sfx} not found in ${routine}.ml for arch ${arch}"
317+
success=false
318+
fi
319+
done
320+
321+
# Check for CHEAT_TAC usage (bypasses actual proving)
322+
if grep -q "CHEAT_TAC" "$proofs_dir/${routine}.ml"; then
323+
gh_error "${routine}" "" "CHEAT_TAC detected" "${routine}.ml uses CHEAT_TAC"
324+
success=false
325+
fi
326+
done
327+
done
328+
329+
if $success; then
330+
info "Check HOL-Light theorems"
331+
gh_summary_success "Check HOL-Light theorems"
332+
else
333+
error "Check HOL-Light theorems"
334+
SUCCESS=false
335+
gh_summary_failure "Check HOL-Light theorems"
336+
fi
337+
}
338+
339+
gh_group_start "Check HOL-Light theorems"
340+
check-theorems
341+
gh_group_end
342+
298343
if ! $SUCCESS; then
299344
if $IN_GITHUB_CONTEXT; then
300345
printf "%b%s%b\n" "${RED}" "The following checks failed, expand each for more details." "${NORMAL}"

0 commit comments

Comments
 (0)