| 1 |
(** * Push-Button Synthesis of Word-By-Word Montgomery: 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.Arithmetic.Core. |
| 6 |
Require Import Crypto.Arithmetic.Freeze. |
| 7 |
Require Import Crypto.Arithmetic.ModOps. |
| 8 |
Require Import Crypto.Arithmetic.WordByWordMontgomery. |
| 9 |
Require Import Rewriter.Language.Language. |
| 10 |
Require Import Crypto.Language.API. |
| 11 |
Require Import Crypto.PushButtonSynthesis.ReificationCache. |
| 12 |
Local Open Scope Z_scope. |
| 13 |
|
| 14 |
Import |
| 15 |
Language.Wf.Compilers |
| 16 |
Language.Compilers |
| 17 |
Language.API.Compilers. |
| 18 |
Import Compilers.API. |
| 19 |
|
| 20 |
Import Associational Positional. |
| 21 |
|
| 22 |
Local Set Keyed Unification. (* needed for making [autorewrite] fast, c.f. COQBUG(https://github.com/coq/coq/issues/9283) *) |
| 23 |
|
| 24 |
Module Export WordByWordMontgomery. |
| 25 |
Import WordByWordMontgomery.WordByWordMontgomery. |
| 26 |
|
| 27 |
Definition zeromod bitwidth n m m' := encodemod bitwidth n m m' 0. |
| 28 |
Definition onemod bitwidth n m m' := encodemod bitwidth n m m' 1. |
| 29 |
Definition evalmod bitwidth n := @eval bitwidth n. |
| 30 |
Definition bytes_evalmod s := @eval 8 (bytes_n s). |
| 31 |
|
| 32 |
(* we would do something faster, but it generally breaks extraction COQBUG(https://github.com/coq/coq/issues/7954) *) |
| 33 |
Local Ltac precache_reify_faster _ := |
| 34 |
split; |
| 35 |
[ let marker := fresh "marker" in |
| 36 |
pose I as marker; |
| 37 |
intros; |
| 38 |
let LHS := lazymatch goal with |- ?LHS = _ => LHS end in |
| 39 |
let reified_op_gen := lazymatch LHS with context[expr.Interp _ ?reified_op_gen] => reified_op_gen end in |
| 40 |
subst reified_op_gen; |
| 41 |
etransitivity; |
| 42 |
[ |
| 43 |
| let opmod := match goal with |- _ = ?RHS => head RHS end in |
| 44 |
cbv [opmod]; solve [ eauto with reify_cache_gen nocore ] ]; |
| 45 |
repeat lazymatch goal with |
| 46 |
| [ H : _ |- _ ] => tryif constr_eq H marker then fail else revert H |
| 47 |
end; |
| 48 |
clear marker |
| 49 |
| ]. |
| 50 |
Local Ltac cache_reify_faster_2arg _ := |
| 51 |
precache_reify_faster (); |
| 52 |
[ lazymatch goal with |
| 53 |
| [ |- forall bw n m m' v, ?interp ?ev bw n m m' v = ?interp' ?reified_mul_gen bw n m m' (@?A bw n m m' v) (@?B bw n m m' v) ] |
| 54 |
=> let rv := constr:(fun F bw n m m' v => (F bw n m m' (A bw n m m' v) (B bw n m m' v)):list Z) in |
| 55 |
intros; |
| 56 |
instantiate (1:=ltac:(let r := Reify rv in |
| 57 |
refine (r @ reified_mul_gen)%Expr)) |
| 58 |
end; |
| 59 |
reflexivity |
| 60 |
| prove_Wf () ]. |
| 61 |
Local Ltac cache_reify_faster_1arg _ := |
| 62 |
precache_reify_faster (); |
| 63 |
[ lazymatch goal with |
| 64 |
| [ |- forall bw n m m', ?interp ?ev bw n m m' = ?interp' ?reified_op_gen bw n m m' (@?A bw n m m') ] |
| 65 |
=> let rv := constr:(fun F bw n m m' => (F bw n m m' (A bw n m m')):list Z) in |
| 66 |
intros; |
| 67 |
instantiate (1:=ltac:(let r := Reify rv in |
| 68 |
refine (r @ reified_op_gen)%Expr)) |
| 69 |
end; |
| 70 |
reflexivity |
| 71 |
| prove_Wf () ]. |
| 72 |
(** |
| 73 |
<< |
| 74 |
#!/usr/bin/env python |
| 75 |
|
| 76 |
indent = ' ' |
| 77 |
|
| 78 |
print((indent + '(' + r'''** |
| 79 |
<< |
| 80 |
%s |
| 81 |
>> |
| 82 |
*''' + ')\n') % open(__file__, 'r').read()) |
| 83 |
|
| 84 |
for i in ('mul', 'add', 'sub', 'opp', 'to_bytes', 'from_bytes', 'nonzero', 'eval', 'bytes_eval'): |
| 85 |
print((fr'''{indent}Derive reified_{i}_gen |
| 86 |
SuchThat (is_reification_of reified_{i}_gen {i}mod) |
| 87 |
As reified_{i}_gen_correct. |
| 88 |
Proof. Time cache_reify (). Time Qed. |
| 89 |
Local Definition reified_{i}_gen_correct_proj1 := proj1 reified_{i}_gen_correct. |
| 90 |
Local Definition reified_{i}_gen_correct_proj2 := proj2 reified_{i}_gen_correct. |
| 91 |
#[global] |
| 92 |
Hint Extern 1 (_ = _) => apply_cached_reification {i}mod reified_{i}_gen_correct_proj1 : reify_cache_gen. |
| 93 |
#[global] |
| 94 |
Hint Immediate reified_{i}_gen_correct_proj2 : wf_gen_cache. |
| 95 |
#[global] |
| 96 |
Hint Rewrite reified_{i}_gen_correct_proj1 : interp_gen_cache. |
| 97 |
Local Opaque reified_{i}_gen. (* needed for making [autorewrite] not take a very long time *)''').replace('\n', f'\n{indent}') + '\n') |
| 98 |
|
| 99 |
for i in ('square', 'encode', 'from_montgomery', 'to_montgomery'): |
| 100 |
print((fr'''{indent}Derive reified_{i}_gen |
| 101 |
SuchThat (is_reification_of reified_{i}_gen {i}mod) |
| 102 |
As reified_{i}_gen_correct. |
| 103 |
Proof. |
| 104 |
Time cache_reify (). |
| 105 |
(* we would do something faster, but it breaks extraction COQBUG(https://github.com/coq/coq/issues/7954) *) |
| 106 |
(* Time cache_reify_faster_2arg (). *) |
| 107 |
Time Qed. |
| 108 |
Local Definition reified_{i}_gen_correct_proj1 := proj1 reified_{i}_gen_correct. |
| 109 |
Local Definition reified_{i}_gen_correct_proj2 := proj2 reified_{i}_gen_correct. |
| 110 |
#[global] |
| 111 |
Hint Extern 1 (_ = _) => apply_cached_reification {i}mod reified_{i}_gen_correct_proj1 : reify_cache_gen. |
| 112 |
#[global] |
| 113 |
Hint Immediate reified_{i}_gen_correct_proj2 : wf_gen_cache. |
| 114 |
#[global] |
| 115 |
Hint Rewrite reified_{i}_gen_correct_proj1 : interp_gen_cache. |
| 116 |
Local Opaque reified_{i}_gen. (* needed for making [autorewrite] not take a very long time *)''').replace('\n', f'\n{indent}') + '\n') |
| 117 |
|
| 118 |
|
| 119 |
for i in ('zero', 'one'): |
| 120 |
print((fr'''{indent}Derive reified_{i}_gen |
| 121 |
SuchThat (is_reification_of reified_{i}_gen {i}mod) |
| 122 |
As reified_{i}_gen_correct. |
| 123 |
Proof. |
| 124 |
(* Time cache_reify (). *) |
| 125 |
(* we do something faster *) |
| 126 |
Time cache_reify_faster_1arg (). |
| 127 |
Time Qed. |
| 128 |
Local Definition reified_{i}_gen_correct_proj1 := proj1 reified_{i}_gen_correct. |
| 129 |
Local Definition reified_{i}_gen_correct_proj2 := proj2 reified_{i}_gen_correct. |
| 130 |
#[global] |
| 131 |
Hint Extern 1 (_ = _) => apply_cached_reification {i}mod reified_{i}_gen_correct_proj1 : reify_cache_gen. |
| 132 |
#[global] |
| 133 |
Hint Immediate reified_{i}_gen_correct_proj2 : wf_gen_cache. |
| 134 |
#[global] |
| 135 |
Hint Rewrite reified_{i}_gen_correct_proj1 : interp_gen_cache. |
| 136 |
Local Opaque reified_{i}_gen. (* needed for making [autorewrite] not take a very long time *)''').replace('\n', f'\n{indent}') + '\n') |
| 137 |
|
| 138 |
>> |
| 139 |
*) |
| 140 |
|
| 141 |
Derive reified_mul_gen |
| 142 |
SuchThat (is_reification_of reified_mul_gen mulmod) |
| 143 |
As reified_mul_gen_correct. |
| 144 |
Proof. Time cache_reify (). Time Qed. |
| 145 |
Local Definition reified_mul_gen_correct_proj1 := proj1 reified_mul_gen_correct. |
| 146 |
Local Definition reified_mul_gen_correct_proj2 := proj2 reified_mul_gen_correct. |
| 147 |
#[global] |
| 148 |
Hint Extern 1 (_ = _) => apply_cached_reification mulmod reified_mul_gen_correct_proj1 : reify_cache_gen. |
| 149 |
#[global] |
| 150 |
Hint Immediate reified_mul_gen_correct_proj2 : wf_gen_cache. |
| 151 |
#[global] |
| 152 |
Hint Rewrite reified_mul_gen_correct_proj1 : interp_gen_cache. |
| 153 |
Local Opaque reified_mul_gen. (* needed for making [autorewrite] not take a very long time *) |
| 154 |
|
| 155 |
Derive reified_add_gen |
| 156 |
SuchThat (is_reification_of reified_add_gen addmod) |
| 157 |
As reified_add_gen_correct. |
| 158 |
Proof. Time cache_reify (). Time Qed. |
| 159 |
Local Definition reified_add_gen_correct_proj1 := proj1 reified_add_gen_correct. |
| 160 |
Local Definition reified_add_gen_correct_proj2 := proj2 reified_add_gen_correct. |
| 161 |
#[global] |
| 162 |
Hint Extern 1 (_ = _) => apply_cached_reification addmod reified_add_gen_correct_proj1 : reify_cache_gen. |
| 163 |
#[global] |
| 164 |
Hint Immediate reified_add_gen_correct_proj2 : wf_gen_cache. |
| 165 |
#[global] |
| 166 |
Hint Rewrite reified_add_gen_correct_proj1 : interp_gen_cache. |
| 167 |
Local Opaque reified_add_gen. (* needed for making [autorewrite] not take a very long time *) |
| 168 |
|
| 169 |
Derive reified_sub_gen |
| 170 |
SuchThat (is_reification_of reified_sub_gen submod) |
| 171 |
As reified_sub_gen_correct. |
| 172 |
Proof. Time cache_reify (). Time Qed. |
| 173 |
Local Definition reified_sub_gen_correct_proj1 := proj1 reified_sub_gen_correct. |
| 174 |
Local Definition reified_sub_gen_correct_proj2 := proj2 reified_sub_gen_correct. |
| 175 |
#[global] |
| 176 |
Hint Extern 1 (_ = _) => apply_cached_reification submod reified_sub_gen_correct_proj1 : reify_cache_gen. |
| 177 |
#[global] |
| 178 |
Hint Immediate reified_sub_gen_correct_proj2 : wf_gen_cache. |
| 179 |
#[global] |
| 180 |
Hint Rewrite reified_sub_gen_correct_proj1 : interp_gen_cache. |
| 181 |
Local Opaque reified_sub_gen. (* needed for making [autorewrite] not take a very long time *) |
| 182 |
|
| 183 |
Derive reified_opp_gen |
| 184 |
SuchThat (is_reification_of reified_opp_gen oppmod) |
| 185 |
As reified_opp_gen_correct. |
| 186 |
Proof. Time cache_reify (). Time Qed. |
| 187 |
Local Definition reified_opp_gen_correct_proj1 := proj1 reified_opp_gen_correct. |
| 188 |
Local Definition reified_opp_gen_correct_proj2 := proj2 reified_opp_gen_correct. |
| 189 |
#[global] |
| 190 |
Hint Extern 1 (_ = _) => apply_cached_reification oppmod reified_opp_gen_correct_proj1 : reify_cache_gen. |
| 191 |
#[global] |
| 192 |
Hint Immediate reified_opp_gen_correct_proj2 : wf_gen_cache. |
| 193 |
#[global] |
| 194 |
Hint Rewrite reified_opp_gen_correct_proj1 : interp_gen_cache. |
| 195 |
Local Opaque reified_opp_gen. (* needed for making [autorewrite] not take a very long time *) |
| 196 |
|
| 197 |
Derive reified_to_bytes_gen |
| 198 |
SuchThat (is_reification_of reified_to_bytes_gen to_bytesmod) |
| 199 |
As reified_to_bytes_gen_correct. |
| 200 |
Proof. Time cache_reify (). Time Qed. |
| 201 |
Local Definition reified_to_bytes_gen_correct_proj1 := proj1 reified_to_bytes_gen_correct. |
| 202 |
Local Definition reified_to_bytes_gen_correct_proj2 := proj2 reified_to_bytes_gen_correct. |
| 203 |
#[global] |
| 204 |
Hint Extern 1 (_ = _) => apply_cached_reification to_bytesmod reified_to_bytes_gen_correct_proj1 : reify_cache_gen. |
| 205 |
#[global] |
| 206 |
Hint Immediate reified_to_bytes_gen_correct_proj2 : wf_gen_cache. |
| 207 |
#[global] |
| 208 |
Hint Rewrite reified_to_bytes_gen_correct_proj1 : interp_gen_cache. |
| 209 |
Local Opaque reified_to_bytes_gen. (* needed for making [autorewrite] not take a very long time *) |
| 210 |
|
| 211 |
Derive reified_from_bytes_gen |
| 212 |
SuchThat (is_reification_of reified_from_bytes_gen from_bytesmod) |
| 213 |
As reified_from_bytes_gen_correct. |
| 214 |
Proof. Time cache_reify (). Time Qed. |
| 215 |
Local Definition reified_from_bytes_gen_correct_proj1 := proj1 reified_from_bytes_gen_correct. |
| 216 |
Local Definition reified_from_bytes_gen_correct_proj2 := proj2 reified_from_bytes_gen_correct. |
| 217 |
#[global] |
| 218 |
Hint Extern 1 (_ = _) => apply_cached_reification from_bytesmod reified_from_bytes_gen_correct_proj1 : reify_cache_gen. |
| 219 |
#[global] |
| 220 |
Hint Immediate reified_from_bytes_gen_correct_proj2 : wf_gen_cache. |
| 221 |
#[global] |
| 222 |
Hint Rewrite reified_from_bytes_gen_correct_proj1 : interp_gen_cache. |
| 223 |
Local Opaque reified_from_bytes_gen. (* needed for making [autorewrite] not take a very long time *) |
| 224 |
|
| 225 |
Derive reified_nonzero_gen |
| 226 |
SuchThat (is_reification_of reified_nonzero_gen nonzeromod) |
| 227 |
As reified_nonzero_gen_correct. |
| 228 |
Proof. Time cache_reify (). Time Qed. |
| 229 |
Local Definition reified_nonzero_gen_correct_proj1 := proj1 reified_nonzero_gen_correct. |
| 230 |
Local Definition reified_nonzero_gen_correct_proj2 := proj2 reified_nonzero_gen_correct. |
| 231 |
#[global] |
| 232 |
Hint Extern 1 (_ = _) => apply_cached_reification nonzeromod reified_nonzero_gen_correct_proj1 : reify_cache_gen. |
| 233 |
#[global] |
| 234 |
Hint Immediate reified_nonzero_gen_correct_proj2 : wf_gen_cache. |
| 235 |
#[global] |
| 236 |
Hint Rewrite reified_nonzero_gen_correct_proj1 : interp_gen_cache. |
| 237 |
Local Opaque reified_nonzero_gen. (* needed for making [autorewrite] not take a very long time *) |
| 238 |
|
| 239 |
Derive reified_eval_gen |
| 240 |
SuchThat (is_reification_of reified_eval_gen evalmod) |
| 241 |
As reified_eval_gen_correct. |
| 242 |
Proof. Time cache_reify (). Time Qed. |
| 243 |
Local Definition reified_eval_gen_correct_proj1 := proj1 reified_eval_gen_correct. |
| 244 |
Local Definition reified_eval_gen_correct_proj2 := proj2 reified_eval_gen_correct. |
| 245 |
#[global] |
| 246 |
Hint Extern 1 (_ = _) => apply_cached_reification evalmod reified_eval_gen_correct_proj1 : reify_cache_gen. |
| 247 |
#[global] |
| 248 |
Hint Immediate reified_eval_gen_correct_proj2 : wf_gen_cache. |
| 249 |
#[global] |
| 250 |
Hint Rewrite reified_eval_gen_correct_proj1 : interp_gen_cache. |
| 251 |
Local Opaque reified_eval_gen. (* needed for making [autorewrite] not take a very long time *) |
| 252 |
|
| 253 |
Derive reified_bytes_eval_gen |
| 254 |
SuchThat (is_reification_of reified_bytes_eval_gen bytes_evalmod) |
| 255 |
As reified_bytes_eval_gen_correct. |
| 256 |
Proof. Time cache_reify (). Time Qed. |
| 257 |
Local Definition reified_bytes_eval_gen_correct_proj1 := proj1 reified_bytes_eval_gen_correct. |
| 258 |
Local Definition reified_bytes_eval_gen_correct_proj2 := proj2 reified_bytes_eval_gen_correct. |
| 259 |
#[global] |
| 260 |
Hint Extern 1 (_ = _) => apply_cached_reification bytes_evalmod reified_bytes_eval_gen_correct_proj1 : reify_cache_gen. |
| 261 |
#[global] |
| 262 |
Hint Immediate reified_bytes_eval_gen_correct_proj2 : wf_gen_cache. |
| 263 |
#[global] |
| 264 |
Hint Rewrite reified_bytes_eval_gen_correct_proj1 : interp_gen_cache. |
| 265 |
Local Opaque reified_bytes_eval_gen. (* needed for making [autorewrite] not take a very long time *) |
| 266 |
|
| 267 |
Derive reified_square_gen |
| 268 |
SuchThat (is_reification_of reified_square_gen squaremod) |
| 269 |
As reified_square_gen_correct. |
| 270 |
Proof. |
| 271 |
Time cache_reify (). |
| 272 |
(* we would do something faster, but it breaks extraction COQBUG(https://github.com/coq/coq/issues/7954) *) |
| 273 |
(* Time cache_reify_faster_2arg (). *) |
| 274 |
Time Qed. |
| 275 |
Local Definition reified_square_gen_correct_proj1 := proj1 reified_square_gen_correct. |
| 276 |
Local Definition reified_square_gen_correct_proj2 := proj2 reified_square_gen_correct. |
| 277 |
#[global] |
| 278 |
Hint Extern 1 (_ = _) => apply_cached_reification squaremod reified_square_gen_correct_proj1 : reify_cache_gen. |
| 279 |
#[global] |
| 280 |
Hint Immediate reified_square_gen_correct_proj2 : wf_gen_cache. |
| 281 |
#[global] |
| 282 |
Hint Rewrite reified_square_gen_correct_proj1 : interp_gen_cache. |
| 283 |
Local Opaque reified_square_gen. (* needed for making [autorewrite] not take a very long time *) |
| 284 |
|
| 285 |
Derive reified_encode_gen |
| 286 |
SuchThat (is_reification_of reified_encode_gen encodemod) |
| 287 |
As reified_encode_gen_correct. |
| 288 |
Proof. |
| 289 |
Time cache_reify (). |
| 290 |
(* we would do something faster, but it breaks extraction COQBUG(https://github.com/coq/coq/issues/7954) *) |
| 291 |
(* Time cache_reify_faster_2arg (). *) |
| 292 |
Time Qed. |
| 293 |
Local Definition reified_encode_gen_correct_proj1 := proj1 reified_encode_gen_correct. |
| 294 |
Local Definition reified_encode_gen_correct_proj2 := proj2 reified_encode_gen_correct. |
| 295 |
#[global] |
| 296 |
Hint Extern 1 (_ = _) => apply_cached_reification encodemod reified_encode_gen_correct_proj1 : reify_cache_gen. |
| 297 |
#[global] |
| 298 |
Hint Immediate reified_encode_gen_correct_proj2 : wf_gen_cache. |
| 299 |
#[global] |
| 300 |
Hint Rewrite reified_encode_gen_correct_proj1 : interp_gen_cache. |
| 301 |
Local Opaque reified_encode_gen. (* needed for making [autorewrite] not take a very long time *) |
| 302 |
|
| 303 |
Derive reified_from_montgomery_gen |
| 304 |
SuchThat (is_reification_of reified_from_montgomery_gen from_montgomerymod) |
| 305 |
As reified_from_montgomery_gen_correct. |
| 306 |
Proof. |
| 307 |
Time cache_reify (). |
| 308 |
(* we would do something faster, but it breaks extraction COQBUG(https://github.com/coq/coq/issues/7954) *) |
| 309 |
(* Time cache_reify_faster_2arg (). *) |
| 310 |
Time Qed. |
| 311 |
Local Definition reified_from_montgomery_gen_correct_proj1 := proj1 reified_from_montgomery_gen_correct. |
| 312 |
Local Definition reified_from_montgomery_gen_correct_proj2 := proj2 reified_from_montgomery_gen_correct. |
| 313 |
#[global] |
| 314 |
Hint Extern 1 (_ = _) => apply_cached_reification from_montgomerymod reified_from_montgomery_gen_correct_proj1 : reify_cache_gen. |
| 315 |
#[global] |
| 316 |
Hint Immediate reified_from_montgomery_gen_correct_proj2 : wf_gen_cache. |
| 317 |
#[global] |
| 318 |
Hint Rewrite reified_from_montgomery_gen_correct_proj1 : interp_gen_cache. |
| 319 |
Local Opaque reified_from_montgomery_gen. (* needed for making [autorewrite] not take a very long time *) |
| 320 |
|
| 321 |
Derive reified_to_montgomery_gen |
| 322 |
SuchThat (is_reification_of reified_to_montgomery_gen to_montgomerymod) |
| 323 |
As reified_to_montgomery_gen_correct. |
| 324 |
Proof. |
| 325 |
Time cache_reify (). |
| 326 |
(* we would do something faster, but it breaks extraction COQBUG(https://github.com/coq/coq/issues/7954) *) |
| 327 |
(* Time cache_reify_faster_2arg (). *) |
| 328 |
Time Qed. |
| 329 |
Local Definition reified_to_montgomery_gen_correct_proj1 := proj1 reified_to_montgomery_gen_correct. |
| 330 |
Local Definition reified_to_montgomery_gen_correct_proj2 := proj2 reified_to_montgomery_gen_correct. |
| 331 |
#[global] |
| 332 |
Hint Extern 1 (_ = _) => apply_cached_reification to_montgomerymod reified_to_montgomery_gen_correct_proj1 : reify_cache_gen. |
| 333 |
#[global] |
| 334 |
Hint Immediate reified_to_montgomery_gen_correct_proj2 : wf_gen_cache. |
| 335 |
#[global] |
| 336 |
Hint Rewrite reified_to_montgomery_gen_correct_proj1 : interp_gen_cache. |
| 337 |
Local Opaque reified_to_montgomery_gen. (* needed for making [autorewrite] not take a very long time *) |
| 338 |
|
| 339 |
Derive reified_zero_gen |
| 340 |
SuchThat (is_reification_of reified_zero_gen zeromod) |
| 341 |
As reified_zero_gen_correct. |
| 342 |
Proof. |
| 343 |
(* Time cache_reify (). *) |
| 344 |
(* we do something faster *) |
| 345 |
Time cache_reify_faster_1arg (). |
| 346 |
Time Qed. |
| 347 |
Local Definition reified_zero_gen_correct_proj1 := proj1 reified_zero_gen_correct. |
| 348 |
Local Definition reified_zero_gen_correct_proj2 := proj2 reified_zero_gen_correct. |
| 349 |
#[global] |
| 350 |
Hint Extern 1 (_ = _) => apply_cached_reification zeromod reified_zero_gen_correct_proj1 : reify_cache_gen. |
| 351 |
#[global] |
| 352 |
Hint Immediate reified_zero_gen_correct_proj2 : wf_gen_cache. |
| 353 |
#[global] |
| 354 |
Hint Rewrite reified_zero_gen_correct_proj1 : interp_gen_cache. |
| 355 |
Local Opaque reified_zero_gen. (* needed for making [autorewrite] not take a very long time *) |
| 356 |
|
| 357 |
Derive reified_one_gen |
| 358 |
SuchThat (is_reification_of reified_one_gen onemod) |
| 359 |
As reified_one_gen_correct. |
| 360 |
Proof. |
| 361 |
(* Time cache_reify (). *) |
| 362 |
(* we do something faster *) |
| 363 |
Time cache_reify_faster_1arg (). |
| 364 |
Time Qed. |
| 365 |
Local Definition reified_one_gen_correct_proj1 := proj1 reified_one_gen_correct. |
| 366 |
Local Definition reified_one_gen_correct_proj2 := proj2 reified_one_gen_correct. |
| 367 |
#[global] |
| 368 |
Hint Extern 1 (_ = _) => apply_cached_reification onemod reified_one_gen_correct_proj1 : reify_cache_gen. |
| 369 |
#[global] |
| 370 |
Hint Immediate reified_one_gen_correct_proj2 : wf_gen_cache. |
| 371 |
#[global] |
| 372 |
Hint Rewrite reified_one_gen_correct_proj1 : interp_gen_cache. |
| 373 |
Local Opaque reified_one_gen. (* needed for making [autorewrite] not take a very long time *) |
| 374 |
End WordByWordMontgomery. |