diff mbox series

[Ada] Adapt ghost code to maintain proof

Message ID 20220111133212.GA748677@adacore.com
State New
Headers show
Series [Ada] Adapt ghost code to maintain proof | expand

Commit Message

Pierre-Marie de Rodat Jan. 11, 2022, 1:32 p.m. UTC
Add two assertions that are now required for the proof of System.Exp_Mod
to go through.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-expmod.adb (Exp_Modular): Add assertions.
diff mbox series

Patch

diff --git a/gcc/ada/libgnat/s-expmod.adb b/gcc/ada/libgnat/s-expmod.adb
--- a/gcc/ada/libgnat/s-expmod.adb
+++ b/gcc/ada/libgnat/s-expmod.adb
@@ -278,6 +278,7 @@  is
                  (Big (Result) * Big (Factor) ** (Exp - 1),
                   Big (Left) ** Right));
                Lemma_Exp_Expand (Big (Factor), Exp - 1);
+               pragma Assert (Exp / 2 = (Exp - 1) / 2);
             end if;
 
             Lemma_Exp_Expand (Big (Factor), Exp);
@@ -286,6 +287,8 @@  is
             exit when Exp = 0;
 
             Rest := Big (Factor) ** Exp;
+            pragma Assert (Equal_Modulo
+              (Big (Result) * (Rest * Rest), Big (Left) ** Right));
             Lemma_Exp_Mod (Big (Factor) * Big (Factor), Exp, Big (Modulus));
             pragma Assert
               ((Big (Factor) * Big (Factor)) ** Exp = Rest * Rest);