| 1 |
(** * Push-Button Synthesis of Solinas Reduction: Reification Cache *) |
| 2 |
From Coq Require Import QArith_base Qround. |
| 3 |
From Coq Require Import Nat. |
| 4 |
From Coq Require Import ZArith. |
| 5 |
From Coq Require Import BinInt. |
| 6 |
From Coq Require Import Derive. |
| 7 |
Require Import Crypto.Arithmetic.Core. |
| 8 |
Require Import Crypto.Arithmetic.ModOps. |
| 9 |
Require Import Crypto.Arithmetic.Saturated. |
| 10 |
Require Import Crypto.Arithmetic.SolinasReduction. |
| 11 |
Require Import Crypto.PushButtonSynthesis.ReificationCache. |
| 12 |
|
| 13 |
Require Import Crypto.Language.IdentifierParameters. |
| 14 |
From Coq Require Import String. |
| 15 |
From Coq Require Import ZArith. |
| 16 |
Require Import Crypto.Util.ListUtil Coq.Lists.List. |
| 17 |
Require Import Crypto.Util.ZRange. |
| 18 |
Require Import Crypto.Util.ZUtil.Definitions. |
| 19 |
Require Import Crypto.Language.PreExtra. |
| 20 |
|
| 21 |
Local Open Scope Z_scope. |
| 22 |
|
| 23 |
Local Set Keyed Unification. (* needed for making [autorewrite] fast, c.f. COQBUG(https://github.com/coq/coq/issues/9283) *) |
| 24 |
|
| 25 |
Import |
| 26 |
Language.API.Compilers |
| 27 |
Language.Wf.Compilers. |
| 28 |
Import SolinasReduction.SolinasReduction. |
| 29 |
|
| 30 |
Module Export SolinasReduction. |
| 31 |
|
| 32 |
Derive reified_mul_gen |
| 33 |
SuchThat (is_reification_of reified_mul_gen mulmod) |
| 34 |
As reified_mul_gen_correct. |
| 35 |
Proof. Time cache_reify (). Time Qed. |
| 36 |
|
| 37 |
Derive reified_square_gen |
| 38 |
SuchThat (is_reification_of reified_square_gen squaremod) |
| 39 |
As reified_square_gen_correct. |
| 40 |
Proof. Time cache_reify (). Time Qed. |
| 41 |
|
| 42 |
#[global] |
| 43 |
Hint Extern 1 (_ = _) => apply_cached_reification mulmod (proj1 reified_mul_gen) : reify_cache_gen. |
| 44 |
Local Definition reified_mul_gen_correct_proj2 := proj2 reified_mul_gen_correct. |
| 45 |
Hint Immediate reified_mul_gen_correct_proj2 : wf_gen_cache. |
| 46 |
#[global] |
| 47 |
Hint Rewrite (proj1 reified_mul_gen_correct) : interp_gen_cache. |
| 48 |
Local Opaque reified_mul_gen. (* needed for making [autorewrite] not take a very long time *) |
| 49 |
|
| 50 |
#[global] |
| 51 |
Hint Extern 1 (_ = _) => apply_cached_reification squaremod (proj1 reified_square_gen) : reify_cache_gen. |
| 52 |
Local Definition reified_square_gen_correct_proj2 := proj2 reified_square_gen_correct. |
| 53 |
Hint Immediate reified_square_gen_correct_proj2 : wf_gen_cache. |
| 54 |
#[global] |
| 55 |
Hint Rewrite (proj1 reified_square_gen_correct) : interp_gen_cache. |
| 56 |
Local Opaque reified_square_gen. (* needed for making [autorewrite] not take a very long time *) |
| 57 |
|
| 58 |
End SolinasReduction. |