From patchwork Tue Jan 11 13:32:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1578478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=DWurCZZv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYBvb2rVsz9s0r for ; Wed, 12 Jan 2022 00:52:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5D7538A942C for ; Tue, 11 Jan 2022 13:52:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5D7538A942C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641909127; bh=fJuNYCUTn9xcj1f98Lw1MNaPBTW6tJd6DZZdeQeWJMA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=DWurCZZvX+WWcu8BlqCdQAB7AlUZ7Pg6ITgx0MSQFzqp6YVlrv1+cYSnm6907OfNG QeYuabMXkqahBBM/iFtNqdnDnXeTn7HUstDgpE1xsP0cpMco1JDktU1kiL2eohviPI T2FWvT6qodBL4CGdMrStv1chycsXPtuxANeRfBfw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id D846338A9439 for ; Tue, 11 Jan 2022 13:32:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D846338A9439 Received: by mail-wm1-x334.google.com with SMTP id c66so11013490wma.5 for ; Tue, 11 Jan 2022 05:32:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=fJuNYCUTn9xcj1f98Lw1MNaPBTW6tJd6DZZdeQeWJMA=; b=70Zk+c5en3G4/yjtWShR0P2kF9JEmObL8/yHqI7KceieMym+1tac7HoCwQwf/6Ezgy knQDZy7LqMsC/aq+FpDDB7v2F60Ap9JHVACq2XbPSQ9oQCBw78FTxay/q9vPd9ICE17H s2Umk/724EUW+FveZ9oCve3f2XSreh1ijpl24K3o5WjiN38gErb+eBx4LBsboo7uL0uv iNGATdrTljeIX/ALNeXP+Os7Qi67jatR+BVgx2WxBvV+E6ON44hFDRsnQhIv1s6zZXvO tDQ4vSvsa1ri+iOUCnrxGfKrz9vzJQmE1gL9LHvyGttCqeYxJI/SxXVI+oGtBJC6Y9t3 2qCQ== X-Gm-Message-State: AOAM532+5TPDyFB8bl9O/H1eyctDEj7ikJxI46kPtA8llaJdehXxvQit I/8byBZMwmhw3O1gdJkSIAxW3/lq9vY2tg== X-Google-Smtp-Source: ABdhPJxj1WS8c4fRXmYS3s6Yq+wOukJiFvY1wDC9Wj1+uhsZbdYjBr5nhtsC3elnuGEulhvKJCjohA== X-Received: by 2002:a05:600c:2f8f:: with SMTP id t15mr2454787wmn.7.1641907933979; Tue, 11 Jan 2022 05:32:13 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id d22sm9578154wrb.83.2022.01.11.05.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 05:32:13 -0800 (PST) Date: Tue, 11 Jan 2022 13:32:12 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Adapt ghost code to maintain proof Message-ID: <20220111133212.GA748677@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Yannick Moy Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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 --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);