[gcc r12-6452] [Ada] Adapt ghost code to maintain proof

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Tue Jan 11 13:27:04 GMT 2022


https://gcc.gnu.org/g:371b4ad7c423891d13f9b855f5fdd469a82f7160

commit r12-6452-g371b4ad7c423891d13f9b855f5fdd469a82f7160
Author: Yannick Moy <moy@adacore.com>
Date:   Tue Jan 4 10:37:53 2022 +0100

    [Ada] Adapt ghost code to maintain proof
    
    gcc/ada/
    
            * libgnat/s-expmod.adb (Exp_Modular): Add assertions.

Diff:
---
 gcc/ada/libgnat/s-expmod.adb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/ada/libgnat/s-expmod.adb b/gcc/ada/libgnat/s-expmod.adb
index 61faed16b25..60d86e505b8 100644
--- 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);


More information about the Gcc-cvs mailing list