| 1 |
(** * Push-Button Synthesis of Bernstein-Yang Inversion: Reification Cache *) |
| 2 |
From Coq Require Import ZArith. |
| 3 |
From Coq Require Import Derive. |
| 4 |
Require Import Crypto.Util.Tactics.Head. |
| 5 |
Require Import Crypto.Util.ZUtil.Pow. |
| 6 |
Require Import Crypto.Arithmetic.Core. |
| 7 |
Require Import Crypto.Arithmetic.Partition. |
| 8 |
Require Import Crypto.Arithmetic.Freeze. |
| 9 |
Require Import Crypto.Arithmetic.ModOps. |
| 10 |
Require Import Crypto.Arithmetic.WordByWordMontgomery. |
| 11 |
Require Import Crypto.Arithmetic.BYInv. |
| 12 |
Require Import Rewriter.Language.Language. |
| 13 |
Require Import Crypto.Language.API. |
| 14 |
Require Import Crypto.PushButtonSynthesis.ReificationCache. |
| 15 |
Local Open Scope Z_scope. |
| 16 |
|
| 17 |
Require Import Crypto.Arithmetic.UniformWeight. |
| 18 |
Require Import Lists.List. |
| 19 |
|
| 20 |
Import |
| 21 |
Language.Wf.Compilers |
| 22 |
Language.Compilers |
| 23 |
Language.API.Compilers. |
| 24 |
Import Compilers.API. |
| 25 |
|
| 26 |
Import Associational Positional. |
| 27 |
|
| 28 |
Local Set Keyed Unification. (* needed for making [autorewrite] fast, c.f. COQBUG(https://github.com/coq/coq/issues/9283) *) |
| 29 |
|
| 30 |
Module Export WordByWordMontgomeryInversion. |
| 31 |
Import WordByWordMontgomery.WordByWordMontgomery. |
| 32 |
|
| 33 |
Definition msat bitwidth n m := Partition.partition (uweight bitwidth) n m. (* m in saturated representation *) |
| 34 |
|
| 35 |
Derive reified_divstep_gen |
| 36 |
SuchThat (is_reification_of reified_divstep_gen divstep) |
| 37 |
As reified_divstep_gen_correct. |
| 38 |
Proof. Time cache_reify (). Time Qed. |
| 39 |
Local Definition reified_divstep_gen_correct_proj1 := proj1 reified_divstep_gen_correct. |
| 40 |
Local Definition reified_divstep_gen_correct_proj2 := proj2 reified_divstep_gen_correct. |
| 41 |
#[global] |
| 42 |
Hint Extern 1 (_ = _) => apply_cached_reification divstep reified_divstep_gen_correct_proj1 : reify_cache_gen. |
| 43 |
#[global] |
| 44 |
Hint Immediate reified_divstep_gen_correct_proj2 : wf_gen_cache. |
| 45 |
#[global] |
| 46 |
Hint Rewrite reified_divstep_gen_correct_proj1 : interp_gen_cache. |
| 47 |
Local Opaque reified_divstep_gen. (* needed for making [autorewrite] not take a very long time *) |
| 48 |
|
| 49 |
Derive reified_msat_gen |
| 50 |
SuchThat (is_reification_of reified_msat_gen msat) |
| 51 |
As reified_msat_gen_correct. |
| 52 |
Proof. |
| 53 |
Time cache_reify (). |
| 54 |
Time Qed. |
| 55 |
Local Definition reified_msat_gen_correct_proj1 := proj1 reified_msat_gen_correct. |
| 56 |
Local Definition reified_msat_gen_correct_proj2 := proj2 reified_msat_gen_correct. |
| 57 |
#[global] |
| 58 |
Hint Extern 1 (_ = _) => apply_cached_reification msat reified_msat_gen_correct_proj1 : reify_cache_gen. |
| 59 |
#[global] |
| 60 |
Hint Immediate reified_msat_gen_correct_proj2 : wf_gen_cache. |
| 61 |
#[global] |
| 62 |
Hint Rewrite reified_msat_gen_correct_proj1 : interp_gen_cache. |
| 63 |
Local Opaque reified_msat_gen. (* needed for making [autorewrite] not take a very long time *) |
| 64 |
|
| 65 |
Derive reified_eval_twos_complement_gen |
| 66 |
SuchThat (is_reification_of reified_eval_twos_complement_gen eval_twos_complement) |
| 67 |
As reified_eval_twos_complement_gen_correct. |
| 68 |
Proof. Time cache_reify (). Time Qed. |
| 69 |
Local Definition reified_eval_twos_complement_gen_correct_proj1 := proj1 reified_eval_twos_complement_gen_correct. |
| 70 |
Local Definition reified_eval_twos_complement_gen_correct_proj2 := proj2 reified_eval_twos_complement_gen_correct. |
| 71 |
#[global] |
| 72 |
Hint Extern 1 (_ = _) => apply_cached_reification eval_twos_complement reified_eval_twos_complement_gen_correct_proj1 : reify_cache_gen. |
| 73 |
#[global] |
| 74 |
Hint Immediate reified_eval_twos_complement_gen_correct_proj2 : wf_gen_cache. |
| 75 |
#[global] |
| 76 |
Hint Rewrite reified_eval_twos_complement_gen_correct_proj1 : interp_gen_cache. |
| 77 |
Local Opaque reified_eval_twos_complement_gen. (* needed for making [autorewrite] not take a very long time *) |
| 78 |
End WordByWordMontgomeryInversion. |