| 1 |
(** * Push-Button Synthesis of Barrett Reduction: Reification Cache *) |
| 2 |
From Coq Require Import ZArith. |
| 3 |
From Coq Require Import Derive. |
| 4 |
From Coq Require Import List. |
| 5 |
Require Import Crypto.Util.ListUtil. |
| 6 |
Require Import Crypto.Arithmetic.BarrettReduction. |
| 7 |
Require Import Crypto.PushButtonSynthesis.ReificationCache. |
| 8 |
Local Open Scope Z_scope. |
| 9 |
|
| 10 |
Import BarrettReduction. |
| 11 |
|
| 12 |
Local Set Keyed Unification. (* needed for making [autorewrite] fast, c.f. COQBUG(https://github.com/coq/coq/issues/9283) *) |
| 13 |
|
| 14 |
Module Export BarrettReduction. |
| 15 |
(* all the list operations from for_reification.ident *) |
| 16 |
Strategy 100 [length seq repeat combine map flat_map partition app rev fold_right update_nth nth_default ]. |
| 17 |
Strategy -10 [Fancy.fancy_reduce reduce]. |
| 18 |
|
| 19 |
Derive reified_barrett_red_gen |
| 20 |
SuchThat (is_reification_of reified_barrett_red_gen Fancy.fancy_reduce) |
| 21 |
As reified_barrett_red_gen_correct. |
| 22 |
Proof. Time cache_reify (). Time Qed. |
| 23 |
Local Definition reified_barrett_red_gen_correct_proj1 := proj1 reified_barrett_red_gen_correct. |
| 24 |
Local Definition reified_barrett_red_gen_correct_proj2 := proj2 reified_barrett_red_gen_correct. |
| 25 |
|
| 26 |
Module Export ReifyHints. |
| 27 |
#[global] |
| 28 |
Hint Extern 1 (_ = _) => apply_cached_reification Fancy.fancy_reduce (proj1 reified_barrett_red_gen_correct) : reify_cache_gen. |
| 29 |
#[global] |
| 30 |
Hint Immediate reified_barrett_red_gen_correct_proj2 : wf_gen_cache. |
| 31 |
#[global] |
| 32 |
Hint Rewrite reified_barrett_red_gen_correct_proj1 : interp_gen_cache. |
| 33 |
End ReifyHints. |
| 34 |
Local Opaque reified_barrett_red_gen. (* needed for making [autorewrite] not take a very long time *) |
| 35 |
End BarrettReduction. |