| 1 |
From Coq Require Import ZArith. |
| 2 |
From Coq Require Import QArith. |
| 3 |
From Coq Require Import Qround. |
| 4 |
From Coq Require Import String. |
| 5 |
From Coq Require Import Derive. |
| 6 |
From Coq Require Import List. |
| 7 |
Require Import Crypto.Util.LetIn. |
| 8 |
Require Import Crypto.Util.ZRange. |
| 9 |
Require Import Crypto.Util.ZUtil.Zselect. |
| 10 |
Require Import Crypto.Util.ZUtil.Definitions. |
| 11 |
Require Import Crypto.Arithmetic.Core. |
| 12 |
Require Import Crypto.Arithmetic.SolinasReduction. |
| 13 |
Require Import Crypto.Arithmetic.ModOps. |
| 14 |
Require Import Crypto.Arithmetic.Partition. |
| 15 |
Require Import Crypto.PushButtonSynthesis.UnsaturatedSolinas. |
| 16 |
Require Import Crypto.UnsaturatedSolinasHeuristics. |
| 17 |
Require Crypto.PushButtonSynthesis.SaturatedSolinas. |
| 18 |
Require Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 19 |
Require Crypto.Stringification.C. |
| 20 |
Require Crypto.Stringification.Go. |
| 21 |
Require Crypto.Stringification.Java. |
| 22 |
Require Import Crypto.BoundsPipeline. |
| 23 |
Require Import Crypto.Util.DebugMonad. |
| 24 |
Require Import Crypto.Util.ZUtil.ModInv. |
| 25 |
|
| 26 |
Require Import Crypto.Util.Notations. |
| 27 |
Local Open Scope string_scope. |
| 28 |
Local Open Scope list_scope. |
| 29 |
Import ListNotations. Local Open Scope Z_scope. |
| 30 |
|
| 31 |
Import |
| 32 |
AbstractInterpretation.Compilers |
| 33 |
Language.Compilers |
| 34 |
Language.API.Compilers. |
| 35 |
|
| 36 |
Import Language.API.Compilers.API. |
| 37 |
|
| 38 |
Import Associational Positional. |
| 39 |
|
| 40 |
Local Coercion Z.of_nat : nat >-> Z. |
| 41 |
Local Coercion QArith_base.inject_Z : Z >-> Q. |
| 42 |
Local Coercion Z.pos : positive >-> Z. |
| 43 |
|
| 44 |
Local Existing Instance default_translate_to_fancy. |
| 45 |
Local Existing Instances |
| 46 |
Primitives.Options.default_PipelineOptions |
| 47 |
Primitives.Options.default_PipelineToStringOptions |
| 48 |
Primitives.Options.default_SynthesisOptions |
| 49 |
| 100. |
| 50 |
Local Instance : unfold_value_barrier_opt := true. |
| 51 |
Local Instance : tight_upperbound_fraction_opt := default_tight_upperbound_fraction. |
| 52 |
|
| 53 |
Module debugging_go_bits_add. |
| 54 |
Import Stringification.Go. |
| 55 |
Section __. |
| 56 |
Local Existing Instance Go.OutputGoAPI. |
| 57 |
Local Instance : Primitives.Options.PipelineOptions := |
| 58 |
{| Primitives.Options.output_options := |
| 59 |
{| relax_adc_sbb_return_carry_to_bitwidth_ := [32; 64] |
| 60 |
; skip_typedefs_ := true |
| 61 |
; language_specific_cast_adjustment_ := true |
| 62 |
|} |
| 63 |
; Primitives.Options.widen_carry := true |
| 64 |
; Primitives.Options.widen_bytes := true |
| 65 |
; Primitives.Options.only_signed := false |
| 66 |
; Primitives.Options.no_select := false |
| 67 |
; Primitives.Options.should_split_mul := true (* only for x64 *) |
| 68 |
; Primitives.Options.should_split_multiret := false |
| 69 |
|}. |
| 70 |
|
| 71 |
Context (s := 2^127) |
| 72 |
(c := [(1,1)]) |
| 73 |
(machine_wordsize := 64). |
| 74 |
|
| 75 |
Goal True. |
| 76 |
pose (WordByWordMontgomery.smul (s - Associational.eval c) machine_wordsize "p256_") as v. |
| 77 |
vm_compute Z.sub in v. |
| 78 |
cbv [WordByWordMontgomery.smul] in v. |
| 79 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 80 |
vm_compute in v. |
| 81 |
clear v. |
| 82 |
cbv beta delta [Pipeline.BoundsPipelineWithDebug] in k. |
| 83 |
rename k into k'; pose (DebugMonad.Debug.eval_result k') as k; subst k'. |
| 84 |
cbv [Rewriter.Util.LetIn.Let_In DebugMonad.Debug.eval_result DebugMonad.Debug.sequence Pipeline.debug_after_rewrite DebugMonad.Debug.ret] in k. |
| 85 |
vm_compute Pipeline.debug_rewriting in k. |
| 86 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 87 |
set (v := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 88 |
vm_compute in v. |
| 89 |
repeat match goal with |
| 90 |
| [ H := @inl ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inl A B H') in (value of H); subst H; rename H' into H; cbv beta iota in * |
| 91 |
| [ H := @inr ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inr A B H') in (value of H); subst H; rename H' into H; cbv beta iota in * |
| 92 |
end. |
| 93 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 94 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 95 |
set (v' := DebugMonad.Debug.bind _) in (value of k) at 1. |
| 96 |
vm_compute in v'; subst v'; cbn [snd] in k. |
| 97 |
set (v' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 98 |
vm_compute in v'. |
| 99 |
clear -k. |
| 100 |
repeat match goal with |
| 101 |
| [ H := @inl ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inl A B H') in (value of H); subst H; rename H' into H; cbv beta iota in * |
| 102 |
| [ H := @inr ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inr A B H') in (value of H); subst H; rename H' into H; cbv beta iota in * |
| 103 |
end. |
| 104 |
vm_compute Pipeline.no_select_size in k. |
| 105 |
vm_compute Pipeline.split_mul_to in k. |
| 106 |
vm_compute Pipeline.split_multiret_to in k. |
| 107 |
vm_compute Pipeline.split_multiret_to in k. |
| 108 |
vm_compute Pipeline.translate_to_fancy in k. |
| 109 |
cbv beta iota in k. |
| 110 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 111 |
set (v := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 112 |
vm_compute in v. |
| 113 |
clear -k. |
| 114 |
repeat match goal with |
| 115 |
| [ H := @inl ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inl A B H') in (value of H); subst H; rename H' into H; cbv beta iota in * |
| 116 |
| [ H := @inr ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inr A B H') in (value of H); subst H; rename H' into H; cbv beta iota in * |
| 117 |
end. |
| 118 |
vm_compute Pipeline.relax_adc_sbb_return_carry_to_bitwidth in k. |
| 119 |
cbv beta iota in k. |
| 120 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 121 |
set (v' := DebugMonad.Debug.bind _) in (value of k) at 1. |
| 122 |
vm_compute in v'; subst v'; cbn [snd] in k. |
| 123 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 124 |
set (v' := Pipeline.RewriteAndEliminateDeadAndInline _ _ _ _ _ _) in (value of k). |
| 125 |
vm_compute in v'; clear -k. |
| 126 |
unfold DebugMonad.Debug.bind in (value of k) at 1; subst v'; cbn [snd] in k. |
| 127 |
cbv [Pipeline.wrap_debug_rewrite] in k. |
| 128 |
set (v := RelaxBitwidthAdcSbb.Compilers.RewriteRules.RewriteRelaxBitwidthAdcSbb _ _ _) in (value of k). |
| 129 |
Notation uint64 := r[0~>18446744073709551615]%zrange. |
| 130 |
Import IdentifiersBasicGENERATED.Compilers. |
| 131 |
Import API.Compilers. |
| 132 |
Import APINotations.Compilers. |
| 133 |
(* |
| 134 |
Compute 2^64-1. |
| 135 |
Compute Z.log2(18446744073709551615+1). |
| 136 |
clear -v. |
| 137 |
vm_compute in v. |
| 138 |
subst v; cbv beta iota zeta in k. |
| 139 |
vm_compute in k. |
| 140 |
|
| 141 |
Import Rewriter.Util.LetIn. |
| 142 |
let do_set a v f := |
| 143 |
lazymatch v with |
| 144 |
| context[let n := _ in _] => fail |
| 145 |
| context[dlet n := _ in _] => fail |
| 146 |
| _ => idtac |
| 147 |
end; |
| 148 |
first [ pose v as a; change (f a) in (value of k) |
| 149 |
| let a := fresh "E" in pose v as a; change (f a) in (value of k) ] |
| 150 |
in |
| 151 |
repeat |
| 152 |
(repeat (lazymatch (eval cbv delta [k] in k) with |
| 153 |
| context T[(let a := ?v in @?f a) ?x] |
| 154 |
=> let G' := context T[let a := v in f a x] in change G' in (value of k) |
| 155 |
end; cbv beta in k); |
| 156 |
match (eval cbv delta [k] in k) with |
| 157 |
| context T[let a := ?v in @?f a] => do_set a v f |
| 158 |
| context T[dlet a := ?v in @?f a] => do_set a v f |
| 159 |
end; cbv beta in k). |
| 160 |
clear -k. |
| 161 |
match (eval cbv delta [E] in E) with |
| 162 |
| context T[@expr.APP ?a ?b ?c ?d ?e ?f] |
| 163 |
=> pose (@expr.APP a b c d e f) as v; |
| 164 |
let T' := context T[v] in |
| 165 |
change T' in (value of E) |
| 166 |
end. |
| 167 |
Time vm_compute in v. |
| 168 |
cbv beta delta [Pipeline.PreBoundsPipeline] in E. |
| 169 |
repeat (lazymatch (eval cbv delta [E] in E) with |
| 170 |
| context T[(let a := ?v in @?f a) ?x] |
| 171 |
=> let G' := context T[let a := v in f a x] in change G' in (value of E) |
| 172 |
end; cbv beta in E). |
| 173 |
let do_set a v f := |
| 174 |
lazymatch v with |
| 175 |
| context[let n := _ in _] => fail |
| 176 |
| context[dlet n := _ in _] => fail |
| 177 |
| _ => idtac |
| 178 |
end; |
| 179 |
first [ pose v as a; change (f a) in (value of E) |
| 180 |
| let a := fresh "E" in pose v as a; change (f a) in (value of E) ] |
| 181 |
in |
| 182 |
repeat |
| 183 |
(repeat (lazymatch (eval cbv delta [E] in E) with |
| 184 |
| context T[(let a := ?v in @?f a) ?x] |
| 185 |
=> let G' := context T[let a := v in f a x] in change G' in (value of E) |
| 186 |
end; cbv beta in E); |
| 187 |
match (eval cbv delta [E] in E) with |
| 188 |
| context T[let a := ?v in @?f a] => do_set a v f |
| 189 |
| context T[dlet a := ?v in @?f a] => do_set a v f |
| 190 |
end; cbv beta iota in * ). |
| 191 |
vm_compute Primitives.possible_values_of_machine_wordsize in relax_zrange. |
| 192 |
cbv [only_signed_opt_instance_0] in relax_zrange. |
| 193 |
cbv [Pipeline.opts_of_method] in E1; subst E0. |
| 194 |
cbv [default_low_level_rewriter_method] in E1. |
| 195 |
vm_compute in E1. |
| 196 |
Notation "'hide'" := (expr.Abs _) : expr_scope. |
| 197 |
Time vm_compute in E2. |
| 198 |
Time vm_compute in E3. |
| 199 |
clear -k. |
| 200 |
subst E7. |
| 201 |
Time time vm_compute in E4; time vm_compute in E5; time vm_compute in E6; time vm_compute in e; time vm_compute in E8; subst E8; time vm_compute in E'; clear -k. |
| 202 |
repeat match goal with |
| 203 |
| [ H := @inl ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inl A B H') in (value of H); subst H; rename H' into H |
| 204 |
| [ H := @inr ?A ?B ?v |- _ ] => let H' := fresh "E" in pose v as H'; change (@inr A B H') in (value of H); subst H; rename H' into H |
| 205 |
end. |
| 206 |
cbv beta iota in *. |
| 207 |
let do_set a v f := |
| 208 |
lazymatch v with |
| 209 |
| context[let n := _ in _] => idtac v; fail |
| 210 |
| context[dlet n := _ in _] => idtac v; fail |
| 211 |
| _ => idtac |
| 212 |
end; |
| 213 |
first [ pose v as a; change (f a) in (value of k) |
| 214 |
| let a := fresh "k" in pose v as a; change (f a) in (value of k) ] |
| 215 |
in |
| 216 |
repeat |
| 217 |
(repeat (lazymatch (eval cbv delta [k] in k) with |
| 218 |
| context T[(let a := ?v in @?f a) ?x] |
| 219 |
=> let G' := context T[let a := v in f a x] in change G' in (value of k) |
| 220 |
end; cbv beta in k); |
| 221 |
match (eval cbv delta [k] in k) with |
| 222 |
| context T[let a := ?v in @?f a] => do_set a v f |
| 223 |
| context T[dlet a := ?v in @?f a] => do_set a v f |
| 224 |
end; cbv beta iota in * ). |
| 225 |
HERE |
| 226 |
Set Printing Implicit. |
| 227 |
end. |
| 228 |
let do_set a v f := |
| 229 |
lazymatch v with |
| 230 |
| context[let n := _ in _] => fail |
| 231 |
| context[dlet n := _ in _] => fail |
| 232 |
| _ => idtac |
| 233 |
end; |
| 234 |
first [ pose v as a; change (f a) in (value of k) |
| 235 |
| let a := fresh "E" in pose v as a; change (f a) in (value of k) ] |
| 236 |
in |
| 237 |
lazymatch (eval cbv delta [E] in E) with |
| 238 |
| context T[let a := ?v in @?f a] => idtac a v f; do_set a v f |
| 239 |
| context T[dlet a := ?v in @?f a] => do_set a v f |
| 240 |
end. |
| 241 |
let do_set a v f := |
| 242 |
lazymatch v with |
| 243 |
| context[let n := _ in _] => fail |
| 244 |
| context[dlet n := _ in _] => fail |
| 245 |
| _ => idtac |
| 246 |
end; |
| 247 |
first [ set (a := v) in (value of k); change (f a) in (value of k) |
| 248 |
| let a := fresh "E" in set (a := v) in (value of k); change (f a) in (value of k) ] |
| 249 |
in |
| 250 |
do 1 |
| 251 |
(repeat (lazymatch (eval cbv delta [E] in E) with |
| 252 |
| context T[(let a := ?v in @?f a) ?x] |
| 253 |
=> let G' := context T[let a := v in f a x] in change G' in (value of E) |
| 254 |
end; cbv beta in E); |
| 255 |
match (eval cbv delta [E] in E) with |
| 256 |
| context T[let a := ?v in @?f a] => do_set a v f |
| 257 |
| context T[dlet a := ?v in @?f a] => do_set a v f |
| 258 |
end; cbv beta in E). |
| 259 |
lazymatch (eval cbv delta [E] in E) with |
| 260 |
| context T[(let a := ?v in @?f a) ?x] |
| 261 |
=> let G' := context T[let a := v in f a x] in change G' in (value of E) |
| 262 |
end; cbv beta in E. |
| 263 |
Time vm_compute in E. |
| 264 |
set (k' := expr.APP _ _) in (value of E) at 1. |
| 265 |
Time vm_compute in E. |
| 266 |
vm_compute in E'. |
| 267 |
vm_compute in k. |
| 268 |
vm_compute in v. |
| 269 |
subst k. |
| 270 |
cbv beta iota in v. |
| 271 |
cbv [Language.Compilers.ToString.ToFunctionLines] in v. |
| 272 |
cbv [Go.OutputGoAPI Crypto.Util.Option.sequence_return] in v. |
| 273 |
cbv [Go.ToFunctionLines] in v. |
| 274 |
set (k := IR.OfPHOAS.ExprOfPHOAS _ _ _ _) in (value of v). |
| 275 |
clear v. |
| 276 |
cbv [IR.OfPHOAS.ExprOfPHOAS IR.OfPHOAS.ExprOfPHOAS_cps IR.OfPHOAS.ExprOfPHOAS_with_opt_outbounds_cps IR.OfPHOAS.ExprOfPHOAS_cont] in k; rename k into v. |
| 277 |
cbv [IR.OfPHOAS.expr_of_PHOAS IR.OfPHOAS.expr_of_PHOAS_cps IR.OfPHOAS.expr_of_PHOAS_cont] in v. |
| 278 |
set (k := partial.Extract _ _ _) in (value of v). |
| 279 |
cbv [partial.Extract] in k. |
| 280 |
clear v; rename k into v. |
| 281 |
cbv [partial.ident.extract] in v. |
| 282 |
cbv [partial.extract_gen] in v. |
| 283 |
cbv [type.app_curried] in v. |
| 284 |
cbv delta [partial.extract'] in v. |
| 285 |
cbv delta [partial.extract_gen] in v. |
| 286 |
cbv beta in v. |
| 287 |
cbv [type.app_curried] in v. |
| 288 |
cbv delta [partial.extract'] in v. |
| 289 |
cbv beta in v. |
| 290 |
cbv iota in v; cbv beta in v. |
| 291 |
cbv iota in v; cbv beta in v. |
| 292 |
cbv iota in v; cbv beta in v. |
| 293 |
cbv iota in v; cbv beta in v. |
| 294 |
cbv iota in v; cbv beta in v. |
| 295 |
cbv iota in v; cbv beta in v. |
| 296 |
cbv iota in v; cbv beta in v. |
| 297 |
cbv iota in v; cbv beta in v. |
| 298 |
cbv iota in v; cbv beta in v. |
| 299 |
cbv iota in v; cbv beta in v. |
| 300 |
cbv iota in v; cbv beta in v. |
| 301 |
do 50 (cbv iota in v; cbv beta in v). |
| 302 |
Import Rewriter.Util.LetIn. |
| 303 |
repeat match (eval cbv [v] in v) with |
| 304 |
| Let_In ?x ?f |
| 305 |
=> let x := (eval vm_compute in x) in |
| 306 |
clear v; pose (f x) as v |
| 307 |
end. |
| 308 |
(* |
| 309 |
cbv beta in v. |
| 310 |
cbv [partial.abstract_interp_ident] in v. |
| 311 |
set (k := ZRange.ident.option.interp true Compilers.ident_cons) in (value of v). |
| 312 |
cbn in k; subst k; cbv beta in v. |
| 313 |
set (k := ZRange.ident.option.interp true Compilers.ident_nil) in (value of v). |
| 314 |
cbn in k; subst k; cbv beta in v. |
| 315 |
cbn [option_map] in v. |
| 316 |
set (l := ZRange.ident.option.interp true _) in (value of v) at 2; vm_compute in l. |
| 317 |
subst l. |
| 318 |
set (l := ZRange.ident.option.interp true _) in (value of v) at 3; vm_compute in l. |
| 319 |
subst l. |
| 320 |
set (l := ZRange.ident.option.interp true _) in (value of v) at 4; vm_compute in l. |
| 321 |
subst l. |
| 322 |
*) |
| 323 |
(* |
| 324 |
cbv [ZRange.ident.option.interp] in v. |
| 325 |
cbv [ |
| 326 |
cbv beta zeta delta [Rewriter.Util.LetIn.Let_In]. |
| 327 |
cbv [partial.extract'] in v. |
| 328 |
vm_compute in k. |
| 329 |
vm_compute in k. |
| 330 |
vm_compute in k; subst k. |
| 331 |
cbv beta iota zeta in v. |
| 332 |
set (v' := Go.to_function_lines _ _ _ _) in (value of v). |
| 333 |
|
| 334 |
clear v; rename v' into v. |
| 335 |
cbv [WordByWordMontgomery.add] in k. |
| 336 |
cbv [Primitives.possible_values_of_machine_wordsize] in k. |
| 337 |
cbv [widen_carry] in k. |
| 338 |
cbv [widen_carry_opt_instance_0] in k. |
| 339 |
cbv [Pipeline.BoundsPipeline Pipeline.PreBoundsPipeline] in k. |
| 340 |
set (k' := GeneralizeVar.ToFlat _) in (value of k). |
| 341 |
vm_compute in k'; subst k'. |
| 342 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 343 |
set (k' := GeneralizeVar.FromFlat _) in (value of k); vm_compute in k'; subst k'. |
| 344 |
cbv [CheckedPartialEvaluateWithBounds] in k. |
| 345 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 346 |
set (k' := CheckCasts.GetUnsupportedCasts _) in (value of k). |
| 347 |
vm_compute in k'. |
| 348 |
subst k'. |
| 349 |
cbv beta iota in k. |
| 350 |
*) *) |
| 351 |
Abort. |
| 352 |
End __. |
| 353 |
End debugging_go_bits_add. |
| 354 |
|
| 355 |
Local Existing Instance default_output_options. |
| 356 |
|
| 357 |
Module debugging_typedefs. |
| 358 |
Import Crypto.PushButtonSynthesis.UnsaturatedSolinas. |
| 359 |
Import Stringification.C. |
| 360 |
Import Stringification.C.Compilers. |
| 361 |
Import Stringification.C.Compilers.ToString. |
| 362 |
Section __. |
| 363 |
Local Existing Instance C.OutputCAPI. |
| 364 |
Local Instance static : static_opt := false. |
| 365 |
Local Instance : internal_static_opt := true. |
| 366 |
Local Instance : inline_opt := true. |
| 367 |
Local Instance : inline_internal_opt := true. |
| 368 |
Local Instance : emit_primitives_opt := false. |
| 369 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 370 |
Local Instance : widen_carry_opt := false. |
| 371 |
Local Instance : widen_bytes_opt := false. |
| 372 |
Local Instance : only_signed_opt := false. |
| 373 |
Local Instance : no_select_opt := false. |
| 374 |
Local Instance : should_split_mul_opt := false. |
| 375 |
Local Instance : should_split_multiret_opt :=false. |
| 376 |
|
| 377 |
Definition n := 3%nat (*5%nat*). |
| 378 |
Definition s := 2^127 (* 255*). |
| 379 |
Definition c := [(1, 1(*9*))]. |
| 380 |
Definition machine_wordsize := 64. |
| 381 |
|
| 382 |
Import IR.Compilers.ToString. |
| 383 |
Redirect "log" |
| 384 |
Compute match (sadd n s c machine_wordsize "1271") return (string * Pipeline.ErrorT _) with |
| 385 |
| (name, v) |
| 386 |
=> match Debug.eval_result v with |
| 387 |
| ErrorT.Success {| Pipeline.lines := v |} => (name, ErrorT.Success (String.concat String.NewLine v)) |
| 388 |
| _ => _ |
| 389 |
end |
| 390 |
end. |
| 391 |
Redirect "log" |
| 392 |
Compute Synthesize n s c machine_wordsize [] "curve" ["add"]. |
| 393 |
|
| 394 |
Goal True. |
| 395 |
pose (sadd n s c machine_wordsize "1271") as v. |
| 396 |
cbv [sadd] in v. |
| 397 |
vm_compute Pipeline.BoundsPipelineWithDebug in v. |
| 398 |
cbv beta iota zeta in v. |
| 399 |
unfold Debug.bind in (value of v) at 1. |
| 400 |
cbn [fst snd] in v. |
| 401 |
cbv [Language.Compilers.ToString.ToFunctionLines] in v. |
| 402 |
cbv [C.OutputCAPI] in v. |
| 403 |
cbv [ToFunctionLines] in v. |
| 404 |
try (set (dbg := tree.smart_app _ _) in (value of v) at 1; |
| 405 |
vm_compute in dbg; subst dbg). |
| 406 |
vm_compute IR.OfPHOAS.ExprOfPHOAS in v. |
| 407 |
cbv beta iota zeta in v. |
| 408 |
(*vm_compute in v.*) |
| 409 |
set (k := ToString.OfPHOAS.input_bounds_to_string _ _) in (value of v). |
| 410 |
clear v. |
| 411 |
vm_compute in k. |
| 412 |
Abort. |
| 413 |
End __. |
| 414 |
End debugging_typedefs. |
| 415 |
|
| 416 |
Module debugging_21271_from_bytes. |
| 417 |
Import Crypto.PushButtonSynthesis.UnsaturatedSolinas. |
| 418 |
Import Stringification.C. |
| 419 |
Import Stringification.C.Compilers. |
| 420 |
Import Stringification.C.Compilers.ToString. |
| 421 |
Section __. |
| 422 |
Local Existing Instance C.OutputCAPI. |
| 423 |
Local Instance static : static_opt := false. |
| 424 |
Local Instance : internal_static_opt := true. |
| 425 |
Local Instance : inline_opt := true. |
| 426 |
Local Instance : inline_internal_opt := true. |
| 427 |
Local Instance : emit_primitives_opt := false. |
| 428 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 429 |
Local Instance : widen_carry_opt := false. |
| 430 |
Local Instance : widen_bytes_opt := false. |
| 431 |
Local Instance : only_signed_opt := false. |
| 432 |
Local Instance : no_select_opt := false. |
| 433 |
Local Instance : should_split_mul_opt := false. |
| 434 |
Local Instance : should_split_multiret_opt :=false. |
| 435 |
|
| 436 |
Definition n := 3%nat (*5%nat*). |
| 437 |
Definition s := 2^127 (* 255*). |
| 438 |
Definition c := [(1, 1(*9*))]. |
| 439 |
Definition machine_wordsize := 64. |
| 440 |
|
| 441 |
Import IR.Compilers.ToString. |
| 442 |
|
| 443 |
Goal True. |
| 444 |
pose (sfrom_bytes n s c machine_wordsize "1271") as v. |
| 445 |
cbv [sfrom_bytes] in v. |
| 446 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 447 |
clear v. |
| 448 |
cbv [from_bytes] in k. |
| 449 |
cbv [Pipeline.BoundsPipelineWithDebug] in k. |
| 450 |
set (k' := Pipeline.PreBoundsPipeline _ _ _ _) in (value of k). |
| 451 |
vm_compute in k'. |
| 452 |
cbv beta delta [Pipeline.BoundsPipelineWithDebug] in k. |
| 453 |
let k' := fresh in rename k into k'; pose (DebugMonad.Debug.eval_result k') as k; subst k'. |
| 454 |
cbv [Rewriter.Util.LetIn.Let_In DebugMonad.Debug.eval_result DebugMonad.Debug.sequence Pipeline.debug_after_rewrite DebugMonad.Debug.ret] in k. |
| 455 |
vm_compute Pipeline.debug_rewriting in k. |
| 456 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 457 |
set (k'' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 458 |
vm_compute in k''. |
| 459 |
lazymatch (eval cbv [k''] in k'') with |
| 460 |
| @inl ?A ?B ?v => pose v as V; change k'' with (@inl A B V) in (value of k) |
| 461 |
end. |
| 462 |
cbv beta iota zeta in k. |
| 463 |
clear k''. |
| 464 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 465 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 466 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 467 |
set (e := GeneralizeVar.FromFlat _) in (value of k). |
| 468 |
vm_compute in e. |
| 469 |
set (k'' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 470 |
cbv [CheckedPartialEvaluateWithBounds] in k''. |
| 471 |
clear -k''. |
| 472 |
cbv [Rewriter.Util.LetIn.Let_In] in k''. |
| 473 |
set (e' := (GeneralizeVar.FromFlat (GeneralizeVar.ToFlat e))) in (value of k''). |
| 474 |
vm_compute in e'; clear e; rename e' into e. |
| 475 |
set (b := (partial.Extract _ _ _)) in (value of k''). |
| 476 |
clear -b. |
| 477 |
cbv [partial.Extract partial.ident.extract partial.extract_gen type.app_curried partial.extract'] in b. |
| 478 |
subst e. |
| 479 |
cbv beta iota zeta in b. |
| 480 |
Import Rewriter.Util.LetIn. |
| 481 |
cbn [partial.abstract_interp_ident] in b. |
| 482 |
cbv [partial.abstract_interp_ident] in b. |
| 483 |
cbv [ZRange.ident.option.interp] in b. |
| 484 |
cbv [ZRange.ident.option.of_literal] in b. |
| 485 |
cbn [ZRange.ident.option.interp_Z_cast option_map] in b. |
| 486 |
cbv [partial.abstract_domain ZRange.type.base.option.interp type.interp ZRange.type.base.interp] in b. |
| 487 |
cbn [fst snd] in b. |
| 488 |
(do 54 try (lazymatch (eval cbv [b] in b) with |
| 489 |
| dlet x := ?v in _ => let v' := (eval vm_compute in v) in change v with v' in (value of b) |
| 490 |
end; |
| 491 |
unfold Let_In at 1 in (value of b)); |
| 492 |
try lazymatch (eval cbv [b] in b) with |
| 493 |
| dlet x := ?v in _ => let v' := (eval vm_compute in v) in change v with v' in (value of b) |
| 494 |
end). |
| 495 |
(* |
| 496 |
unfold Let_In at 1 in (value of b). |
| 497 |
lazymatch (eval cbv [b] in b) with |
| 498 |
| context[Crypto.Util.Option.bind ?v _] => let v' := (eval vm_compute in v) in change v with v' in (value of b) |
| 499 |
end. |
| 500 |
cbn [Crypto.Util.Option.bind] in b. |
| 501 |
set (k' := Operations.ZRange.land_bounds _ _) in (value of b). |
| 502 |
cbv [Operations.ZRange.land_bounds] in k'. |
| 503 |
clear -k'.*) |
| 504 |
Abort. |
| 505 |
End __. |
| 506 |
End debugging_21271_from_bytes. |
| 507 |
|
| 508 |
Module debugging_sat_solinas_25519. |
| 509 |
Section __. |
| 510 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 511 |
Import Stringification.C. |
| 512 |
Import Stringification.C.Compilers. |
| 513 |
Import Stringification.C.Compilers.ToString. |
| 514 |
|
| 515 |
(* We split these off to make things a bit easier on typeclass resolution and speed things up. *) |
| 516 |
Local Existing Instances ToString.C.OutputCAPI Pipeline.show_ErrorMessage. |
| 517 |
Local Instance : only_signed_opt := false. |
| 518 |
Local Instance : no_select_opt := false. |
| 519 |
Local Instance : static_opt := true. |
| 520 |
Local Instance : internal_static_opt := true. |
| 521 |
Local Instance : inline_opt := true. |
| 522 |
Local Instance : inline_internal_opt := true. |
| 523 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 524 |
Local Instance : emit_primitives_opt := true. |
| 525 |
Local Instance : should_split_mul_opt := false. |
| 526 |
Local Instance : should_split_multiret_opt := false. |
| 527 |
Local Instance : widen_carry_opt := false. |
| 528 |
Local Instance : widen_bytes_opt := true. (* true, because we don't allow byte-sized things anyway, so we should not expect carries to be widened to byte-size when emitting C code *) |
| 529 |
|
| 530 |
(** ======= these are the changable parameters ====== *) |
| 531 |
Let s := 2^256. |
| 532 |
Let c := [(1, 38)]. |
| 533 |
Let machine_wordsize := 64. |
| 534 |
(** ================================================= *) |
| 535 |
Let possible_values := prefix_with_carry [machine_wordsize]. |
| 536 |
Local Instance : machine_wordsize_opt := machine_wordsize. (* for show *) |
| 537 |
Local Instance : no_select_size_opt := no_select_size_of_no_select machine_wordsize. |
| 538 |
Local Instance : split_mul_to_opt := split_mul_to_of_should_split_mul machine_wordsize possible_values. |
| 539 |
Local Instance : split_multiret_to_opt := split_multiret_to_of_should_split_multiret machine_wordsize possible_values. |
| 540 |
Let n : nat := Z.to_nat (Qceiling (Z.log2_up s / machine_wordsize)). |
| 541 |
Let m := s - Associational.eval c. |
| 542 |
(* Number of reductions is calculated as follows : |
| 543 |
Let i be the highest limb index of c. Then, each reduction |
| 544 |
decreases the number of extra limbs by (n-i-1). (The -1 comes |
| 545 |
from possibly having an extra high partial product at the end |
| 546 |
of a reduction.) So, to go from the n extra limbs we have |
| 547 |
post-multiplication down to 0, we need ceil (n / (n - i - 1)) |
| 548 |
reductions. In some cases. however, [n - i <= 1], and in |
| 549 |
this case, we do [n] reductions (is this enough?). *) |
| 550 |
Let nreductions : nat := |
| 551 |
let i := fold_right Z.max 0 (map (fun t => Z.log2 (fst t) / machine_wordsize) c) in |
| 552 |
if Z.of_nat n - i <=? 1 |
| 553 |
then n |
| 554 |
else Z.to_nat (Qceiling (Z.of_nat n / (Z.of_nat n - i - 1))). |
| 555 |
Let bound := Some r[0 ~> (2^machine_wordsize - 1)]%zrange. |
| 556 |
Let boundsn : list (ZRange.type.option.interp base.type.Z) |
| 557 |
:= repeat bound n. |
| 558 |
|
| 559 |
Time Redirect "log" Compute |
| 560 |
Show.show (* [show] for pretty-printing of the AST without needing lots of imports *) |
| 561 |
(Pipeline.BoundsPipelineToString |
| 562 |
"fiat" "mul" |
| 563 |
false (* subst01 *) |
| 564 |
false (* inline *) |
| 565 |
possible_values |
| 566 |
machine_wordsize |
| 567 |
ltac:(let n := (eval cbv in n) (* needs to be reduced to reify correctly *) in |
| 568 |
let nreductions := (eval cbv in nreductions) (* needs to be reduced to reify correctly *) in |
| 569 |
let r := Reify (@Saturated.Rows.mulmod (weight machine_wordsize 1) (2^machine_wordsize) s c n nreductions) in |
| 570 |
exact r) |
| 571 |
(fun _ _ => []) (* comment *) |
| 572 |
(Some boundsn, (Some boundsn, tt)) |
| 573 |
(Some boundsn, None (* Should be: Some r[0~>0]%zrange, but bounds analysis is not good enough *) ) |
| 574 |
(None, (None, tt)) |
| 575 |
(None, None) |
| 576 |
: Pipeline.ErrorT _). |
| 577 |
(* Finished transaction in 6.9 secs (4.764u,0.001s) (successful) *) |
| 578 |
End __. |
| 579 |
End debugging_sat_solinas_25519. |
| 580 |
|
| 581 |
Module debugging_sat_solinas_25519_expanded_straightforward. |
| 582 |
Import PreExtra. |
| 583 |
Import Util.LetIn. |
| 584 |
Import ZUtil.Definitions. |
| 585 |
Module Saturated. |
| 586 |
Module Associational. |
| 587 |
Definition sat_multerm := |
| 588 |
fun (s : Z) (t t' : Z * Z) => |
| 589 |
dlet xy : Z * Z := Z.mul_split s (snd t) (snd t') in |
| 590 |
dlet _ := ident.comment ("sat_multerm", ("xy", xy)) in |
| 591 |
[(fst t * fst t', fst xy); (fst t * fst t' * s, snd xy)]. |
| 592 |
Definition sat_mul := |
| 593 |
fun (s : Z) (p q : list (Z * Z)) => |
| 594 |
flat_map |
| 595 |
(fun t : Z * Z => |
| 596 |
flat_map |
| 597 |
(fun t' : Z * Z => sat_multerm s t t') q) |
| 598 |
p. |
| 599 |
Definition sat_multerm_const := |
| 600 |
fun (s : Z) (t t' : Z * Z) => |
| 601 |
if snd t =? 1 |
| 602 |
then [(fst t * fst t', snd t')] |
| 603 |
else |
| 604 |
if snd t =? -1 |
| 605 |
then [(fst t * fst t', - snd t')] |
| 606 |
else |
| 607 |
if snd t =? 0 |
| 608 |
then [] |
| 609 |
else |
| 610 |
dlet xy : Z * Z := Z.mul_split s (snd t) (snd t') in |
| 611 |
[(fst t * fst t', fst xy); (fst t * fst t' * s, snd xy)]. |
| 612 |
Definition sat_mul_const := |
| 613 |
fun (s : Z) (p q : list (Z * Z)) => |
| 614 |
flat_map |
| 615 |
(fun t : Z * Z => |
| 616 |
flat_map |
| 617 |
(fun t' : Z * Z => |
| 618 |
sat_multerm_const s t t') q) p. |
| 619 |
End Associational. |
| 620 |
Module Columns. |
| 621 |
Definition cons_to_nth := |
| 622 |
fun (i : nat) (x : Z) (xs : list (list Z)) => |
| 623 |
Crypto.Util.ListUtil.update_nth i (fun y : list Z => x :: y) xs. |
| 624 |
Definition nils : nat -> list (list Z) := fun n => repeat [] n. |
| 625 |
Definition from_associational := |
| 626 |
fun (weight : nat -> Z) (n : nat) (p : list (Z * Z)) => |
| 627 |
fold_right |
| 628 |
(fun (t : Z * Z) (ls : list (list Z)) => |
| 629 |
dlet p0 : nat * Z := place weight t (Init.Nat.pred n) in |
| 630 |
cons_to_nth (fst p0) (snd p0) ls) |
| 631 |
(nils n) p. |
| 632 |
End Columns. |
| 633 |
Module Rows. |
| 634 |
(* if [s] is not exactly equal to a weight, we must adjust it to |
| 635 |
be a weight, so that rather than dividing by s and |
| 636 |
multiplying by c, we divide by w and multiply by c*(w/s). |
| 637 |
See |
| 638 |
https://github.com/mit-plv/fiat-crypto/issues/326#issuecomment-404135131 |
| 639 |
for a bit more discussion *) |
| 640 |
Definition adjust_s := |
| 641 |
fun (weight : nat -> Z) (fuel : nat) (s : Z) => |
| 642 |
fold_right |
| 643 |
(fun (w_i : Z) '(v, found_adjustment) => |
| 644 |
let res0 := (v, found_adjustment) in |
| 645 |
if found_adjustment : bool |
| 646 |
then res0 |
| 647 |
else if w_i mod s =? 0 then (w_i, true) else res0) |
| 648 |
(s, false) (map weight (rev (seq 0 fuel))). |
| 649 |
Definition sat_reduce := |
| 650 |
fun (weight : nat -> Z) (base s : Z) (c : list (Z * Z)) |
| 651 |
(n : nat) (p : list (Z * Z)) => |
| 652 |
let |
| 653 |
'(s', _) := adjust_s weight (S (S n)) s in |
| 654 |
let lo_hi := split s' p in |
| 655 |
fst lo_hi ++ |
| 656 |
Associational.sat_mul_const base [ |
| 657 |
(1, s' / s)] |
| 658 |
(Associational.sat_mul_const base c (snd lo_hi)). |
| 659 |
Definition repeat_sat_reduce := |
| 660 |
fun (weight : nat -> Z) (base s : Z) (c p : list (Z * Z)) (n : nat) => |
| 661 |
fold_right |
| 662 |
(fun (_ : nat) (q : list (Z * Z)) => |
| 663 |
sat_reduce weight base s c n q) p |
| 664 |
(seq 0 n). |
| 665 |
Definition sum_rows' := |
| 666 |
fun (weight : nat -> Z) (start_state : list Z * Z * nat) (row1 row2 : list Z) => |
| 667 |
fold_right |
| 668 |
(fun (next : Z * Z) (state : list Z * Z * nat) => |
| 669 |
let i := snd state in |
| 670 |
let low_high' := |
| 671 |
let low_high := fst state in |
| 672 |
let low := fst low_high in |
| 673 |
let high := snd low_high in |
| 674 |
dlet sum_carry : Z * Z := Z.add_with_get_carry_full |
| 675 |
((fun i0 : nat => weight (S i0) / weight i0) i) |
| 676 |
high (fst next) (snd next) in |
| 677 |
(low ++ [fst sum_carry], snd sum_carry) in |
| 678 |
(low_high', S i)) start_state (rev (combine row1 row2)). |
| 679 |
Definition sum_rows := |
| 680 |
fun (weight : nat -> Z) (row1 row2 : list Z) => |
| 681 |
fst (sum_rows' weight ([], 0, 0%nat) row1 row2). |
| 682 |
Definition flatten' := |
| 683 |
fun (weight : nat -> Z) (start_state : list Z * Z) (inp : list (list Z)) => |
| 684 |
fold_right |
| 685 |
(fun (next_row : list Z) (state : list Z * Z) => |
| 686 |
let out_carry := sum_rows weight (fst state) next_row |
| 687 |
in |
| 688 |
(fst out_carry, snd state + snd out_carry)) start_state inp. |
| 689 |
Definition flatten := |
| 690 |
fun (weight : nat -> Z) (n : nat) (inp : list (list Z)) => |
| 691 |
let default := zeros n in |
| 692 |
flatten' weight (hd default inp, 0) |
| 693 |
(hd default (tl inp) :: tl (tl inp)). |
| 694 |
Definition extract_row := |
| 695 |
fun inp : list (list Z) => |
| 696 |
(map (fun c : list Z => tl c) inp, map (fun c : list Z => hd 0 c) inp). |
| 697 |
Definition from_columns' := |
| 698 |
fun (n : nat) (start_state : list (list Z) * list (list Z)) => |
| 699 |
fold_right |
| 700 |
(fun (_ : Z) (state : list (list Z) * list (list Z)) => |
| 701 |
let cols'_row := extract_row (fst state) in |
| 702 |
(fst cols'_row, snd state ++ [snd cols'_row])) start_state |
| 703 |
(repeat 0 n). |
| 704 |
Definition from_columns := |
| 705 |
fun inp : list (list Z) => |
| 706 |
snd |
| 707 |
(from_columns' (Saturated.Rows.max_column_size inp) |
| 708 |
(inp, [])). |
| 709 |
Definition from_associational := |
| 710 |
fun (weight : nat -> Z) (n : nat) (p : list (Z * Z)) => |
| 711 |
from_columns |
| 712 |
(Columns.from_associational weight n p). |
| 713 |
Definition mulmod := |
| 714 |
fun (weight : nat -> Z) (base s : Z) (c : list (Z * Z)) |
| 715 |
(n nreductions : nat) (p q : list Z) => |
| 716 |
let p_a := to_associational weight n p in |
| 717 |
let q_a := to_associational weight n q in |
| 718 |
let pq_a := Associational.sat_mul base p_a q_a in |
| 719 |
let r_a := |
| 720 |
Rows.repeat_sat_reduce weight base s c pq_a nreductions in |
| 721 |
Rows.flatten weight n |
| 722 |
(Rows.from_associational weight n r_a). |
| 723 |
End Rows. |
| 724 |
End Saturated. |
| 725 |
|
| 726 |
Section __. |
| 727 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 728 |
Import Stringification.C. |
| 729 |
Import Stringification.C.Compilers. |
| 730 |
Import Stringification.C.Compilers.ToString. |
| 731 |
|
| 732 |
(* We split these off to make things a bit easier on typeclass resolution and speed things up. *) |
| 733 |
Local Existing Instances ToString.C.OutputCAPI Pipeline.show_ErrorMessage. |
| 734 |
Local Instance : only_signed_opt := false. |
| 735 |
Local Instance : no_select_opt := false. |
| 736 |
Local Instance : static_opt := true. |
| 737 |
Local Instance : internal_static_opt := true. |
| 738 |
Local Instance : inline_opt := true. |
| 739 |
Local Instance : inline_internal_opt := true. |
| 740 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 741 |
Local Instance : emit_primitives_opt := true. |
| 742 |
Local Instance : should_split_mul_opt := false. |
| 743 |
Local Instance : should_split_multiret_opt := false. |
| 744 |
Local Instance : widen_carry_opt := false. |
| 745 |
Local Instance : widen_bytes_opt := true. (* true, because we don't allow byte-sized things anyway, so we should not expect carries to be widened to byte-size when emitting C code *) |
| 746 |
|
| 747 |
(** ======= these are the changable parameters ====== *) |
| 748 |
Let s := 2^256. |
| 749 |
Let c := [(1, 38)]. |
| 750 |
Let machine_wordsize := 64. |
| 751 |
(** ================================================= *) |
| 752 |
Let possible_values := prefix_with_carry [machine_wordsize]. |
| 753 |
Local Instance : machine_wordsize_opt := machine_wordsize. (* for show *) |
| 754 |
Local Instance : no_select_size_opt := no_select_size_of_no_select machine_wordsize. |
| 755 |
Local Instance : split_mul_to_opt := split_mul_to_of_should_split_mul machine_wordsize possible_values. |
| 756 |
Local Instance : split_multiret_to_opt := split_multiret_to_of_should_split_multiret machine_wordsize possible_values. |
| 757 |
Let n : nat := Z.to_nat (Qceiling (Z.log2_up s / machine_wordsize)). |
| 758 |
Let m := s - Associational.eval c. |
| 759 |
(* Number of reductions is calculated as follows : |
| 760 |
Let i be the highest limb index of c. Then, each reduction |
| 761 |
decreases the number of extra limbs by (n-i-1). (The -1 comes |
| 762 |
from possibly having an extra high partial product at the end |
| 763 |
of a reduction.) So, to go from the n extra limbs we have |
| 764 |
post-multiplication down to 0, we need ceil (n / (n - i - 1)) |
| 765 |
reductions. In some cases. however, [n - i <= 1], and in |
| 766 |
this case, we do [n] reductions (is this enough?). *) |
| 767 |
Let nreductions : nat := |
| 768 |
let i := fold_right Z.max 0 (map (fun t => Z.log2 (fst t) / machine_wordsize) c) in |
| 769 |
if Z.of_nat n - i <=? 1 |
| 770 |
then n |
| 771 |
else Z.to_nat (Qceiling (Z.of_nat n / (Z.of_nat n - i - 1))). |
| 772 |
Let bound := Some r[0 ~> (2^machine_wordsize - 1)]%zrange. |
| 773 |
Let boundsn : list (ZRange.type.option.interp base.type.Z) |
| 774 |
:= repeat bound n. |
| 775 |
|
| 776 |
Time Redirect "log" |
| 777 |
Compute |
| 778 |
Show.show (* [show] for pretty-printing of the AST without needing lots of imports *) |
| 779 |
(Pipeline.BoundsPipelineToString |
| 780 |
"fiat" "mul" |
| 781 |
false (* subst01 *) |
| 782 |
false (* inline *) |
| 783 |
possible_values |
| 784 |
machine_wordsize |
| 785 |
ltac:(let n := (eval cbv in n) (* needs to be reduced to reify correctly *) in |
| 786 |
let nreductions := (eval cbv in nreductions) (* needs to be reduced to reify correctly *) in |
| 787 |
let r := Reify (@Saturated.Rows.mulmod (weight machine_wordsize 1) (2^machine_wordsize) s c n nreductions) in |
| 788 |
exact r) |
| 789 |
(fun _ _ => []) (* comment *) |
| 790 |
(Some boundsn, (Some boundsn, tt)) |
| 791 |
(Some boundsn, None (* Should be: Some r[0~>0]%zrange, but bounds analysis is not good enough *) ) |
| 792 |
(None, (None, tt)) |
| 793 |
(None, None) |
| 794 |
: Pipeline.ErrorT _). |
| 795 |
(* Finished transaction in 6.9 secs (4.764u,0.001s) (successful) *) |
| 796 |
End __. |
| 797 |
End debugging_sat_solinas_25519_expanded_straightforward. |
| 798 |
|
| 799 |
Module debugging_sat_solinas_25519_expanded. |
| 800 |
Import PreExtra. |
| 801 |
Import Util.LetIn. |
| 802 |
Import ZUtil.Definitions. |
| 803 |
Module Saturated. |
| 804 |
Module Associational. |
| 805 |
Definition sat_multerm := |
| 806 |
fun (s : Z) (t t' : Z * Z) => |
| 807 |
dlet xy : Z * Z := Z.mul_split s (snd t) (snd t') in |
| 808 |
dlet _ := ident.comment ("sat_multerm", ("xy", xy)) in |
| 809 |
[(fst t * fst t', fst xy); (fst t * fst t' * s, snd xy)]. |
| 810 |
Definition sat_mul := |
| 811 |
fun (s : Z) (p q : list (Z * Z)) => |
| 812 |
flat_map |
| 813 |
(fun t : Z * Z => |
| 814 |
flat_map |
| 815 |
(fun t' : Z * Z => sat_multerm s t t') q) |
| 816 |
p. |
| 817 |
Definition sat_multerm_const := |
| 818 |
fun (s : Z) (t t' : Z * Z) => |
| 819 |
if snd t =? 1 |
| 820 |
then [(fst t * fst t', snd t')] |
| 821 |
else |
| 822 |
if snd t =? -1 |
| 823 |
then [(fst t * fst t', - snd t')] |
| 824 |
else |
| 825 |
if snd t =? 0 |
| 826 |
then [] |
| 827 |
else |
| 828 |
dlet xy : Z * Z := Z.mul_split s (snd t) (snd t') in |
| 829 |
[(fst t * fst t', fst xy); (fst t * fst t' * s, snd xy)]. |
| 830 |
Definition sat_mul_const := |
| 831 |
fun (s : Z) (p q : list (Z * Z)) => |
| 832 |
flat_map |
| 833 |
(fun t : Z * Z => |
| 834 |
flat_map |
| 835 |
(fun t' : Z * Z => |
| 836 |
sat_multerm_const s t t') q) p. |
| 837 |
End Associational. |
| 838 |
Module Columns. |
| 839 |
Definition cons_to_nth := |
| 840 |
fun (i : nat) (x : Z) (xs : list (list Z)) => |
| 841 |
Crypto.Util.ListUtil.update_nth i (fun y : list Z => x :: y) xs. |
| 842 |
Definition nils : nat -> list (list Z) := fun n => repeat [] n. |
| 843 |
Definition from_associational := |
| 844 |
fun (weight : nat -> Z) (n : nat) (p : list (Z * Z)) => |
| 845 |
fold_right |
| 846 |
(fun (t : Z * Z) (ls : list (list Z)) => |
| 847 |
dlet p0 : nat * Z := place weight t (Init.Nat.pred n) in |
| 848 |
cons_to_nth (fst p0) (snd p0) ls) |
| 849 |
(nils n) p. |
| 850 |
End Columns. |
| 851 |
Module Rows. |
| 852 |
(* if [s] is not exactly equal to a weight, we must adjust it to |
| 853 |
be a weight, so that rather than dividing by s and |
| 854 |
multiplying by c, we divide by w and multiply by c*(w/s). |
| 855 |
See |
| 856 |
https://github.com/mit-plv/fiat-crypto/issues/326#issuecomment-404135131 |
| 857 |
for a bit more discussion *) |
| 858 |
Definition adjust_s := |
| 859 |
fun (weight : nat -> Z) (fuel : nat) (s : Z) => |
| 860 |
fold_right |
| 861 |
(fun (w_i : Z) '(v, found_adjustment) => |
| 862 |
let res0 := (v, found_adjustment) in |
| 863 |
if found_adjustment : bool |
| 864 |
then res0 |
| 865 |
else if w_i mod s =? 0 then (w_i, true) else res0) |
| 866 |
(s, false) (map weight (rev (seq 0 fuel))). |
| 867 |
Definition sat_reduce := |
| 868 |
fun (weight : nat -> Z) (base s : Z) (c : list (Z * Z)) |
| 869 |
(n : nat) (p : list (Z * Z)) => |
| 870 |
let |
| 871 |
'(s', _) := adjust_s weight (S (S n)) s in |
| 872 |
let lo_hi := split s' p in |
| 873 |
fst lo_hi ++ |
| 874 |
Associational.sat_mul_const base [ |
| 875 |
(1, s' / s)] |
| 876 |
(Associational.sat_mul_const base c (snd lo_hi)). |
| 877 |
Definition repeat_sat_reduce := |
| 878 |
fun (weight : nat -> Z) (base s : Z) (c p : list (Z * Z)) (n : nat) => |
| 879 |
fold_right |
| 880 |
(fun (_ : nat) (q : list (Z * Z)) => |
| 881 |
sat_reduce weight base s c n q) p |
| 882 |
(seq 0 n). |
| 883 |
Definition sum_rows' := |
| 884 |
fun (weight : nat -> Z) (start_state : list Z * Z * nat) (row1 row2 : list Z) => |
| 885 |
fold_right |
| 886 |
(fun (next : Z * Z) (state : list Z * Z * nat) => |
| 887 |
let i := snd state in |
| 888 |
let low_high' := |
| 889 |
let low_high := fst state in |
| 890 |
let low := fst low_high in |
| 891 |
let high := snd low_high in |
| 892 |
dlet sum_carry : Z * Z := Z.add_with_get_carry_full |
| 893 |
((fun i0 : nat => weight (S i0) / weight i0) i) |
| 894 |
high (fst next) (snd next) in |
| 895 |
(low ++ [fst sum_carry], snd sum_carry) in |
| 896 |
(low_high', S i)) start_state (rev (combine row1 row2)). |
| 897 |
Definition sum_rows := |
| 898 |
fun (weight : nat -> Z) (row1 row2 : list Z) => |
| 899 |
fst (sum_rows' weight ([], 0, 0%nat) row1 row2). |
| 900 |
Definition flatten' := |
| 901 |
fun (weight : nat -> Z) (start_state : list Z * Z) (inp : list (list Z)) => |
| 902 |
fold_right |
| 903 |
(fun (next_row : list Z) (state : list Z * Z) => |
| 904 |
let out_carry := sum_rows weight (fst state) next_row |
| 905 |
in |
| 906 |
(fst out_carry, snd state + snd out_carry)) start_state inp. |
| 907 |
Definition flatten := |
| 908 |
fun (weight : nat -> Z) (n : nat) (inp : list (list Z)) => |
| 909 |
let default := zeros n in |
| 910 |
flatten' weight (hd default inp, 0) |
| 911 |
(hd default (tl inp) :: tl (tl inp)). |
| 912 |
Definition extract_row := |
| 913 |
fun inp : list (list Z) => |
| 914 |
(map (fun c : list Z => tl c) inp, map (fun c : list Z => hd 0 c) inp). |
| 915 |
Definition from_columns' := |
| 916 |
fun (n : nat) (start_state : list (list Z) * list (list Z)) => |
| 917 |
fold_right |
| 918 |
(fun (_ : Z) (state : list (list Z) * list (list Z)) => |
| 919 |
let cols'_row := extract_row (fst state) in |
| 920 |
(fst cols'_row, snd state ++ [snd cols'_row])) start_state |
| 921 |
(repeat 0 n). |
| 922 |
Definition from_columns := |
| 923 |
fun inp : list (list Z) => |
| 924 |
snd |
| 925 |
(from_columns' (Saturated.Rows.max_column_size inp) |
| 926 |
(inp, [])). |
| 927 |
Definition from_associational := |
| 928 |
fun (weight : nat -> Z) (n : nat) (p : list (Z * Z)) => |
| 929 |
from_columns |
| 930 |
(Columns.from_associational weight n p). |
| 931 |
Definition mulmod := |
| 932 |
fun (weight : nat -> Z) (base s : Z) (c : list (Z * Z)) |
| 933 |
(n nreductions : nat) (p q : list Z) => |
| 934 |
let p_a := to_associational weight n p in |
| 935 |
let q_a := to_associational weight n q in |
| 936 |
let pq_a := Associational.sat_mul base p_a q_a in |
| 937 |
let pq_r := fst (Rows.flatten weight (n+n) (Rows.from_associational weight (n+n) pq_a)) in |
| 938 |
|
| 939 |
let pq_a := to_associational weight (n+n) pq_r in |
| 940 |
let pq_a := Rows.sat_reduce weight base s c 1 pq_a in |
| 941 |
let pq_r := fst (Rows.flatten weight (n+1) (Rows.from_associational weight (n+1) pq_a)) in |
| 942 |
|
| 943 |
let pq_a := to_associational weight (n+1) pq_r in |
| 944 |
let pq_a := Rows.sat_reduce weight base s c 1 pq_a in |
| 945 |
let pq_r := Rows.flatten weight n (Rows.from_associational weight n pq_a) in |
| 946 |
|
| 947 |
pq_r. |
| 948 |
End Rows. |
| 949 |
End Saturated. |
| 950 |
|
| 951 |
Section __. |
| 952 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 953 |
Import Stringification.C. |
| 954 |
Import Stringification.C.Compilers. |
| 955 |
Import Stringification.C.Compilers.ToString. |
| 956 |
|
| 957 |
(* We split these off to make things a bit easier on typeclass resolution and speed things up. *) |
| 958 |
Local Existing Instances ToString.C.OutputCAPI Pipeline.show_ErrorMessage. |
| 959 |
Local Instance : only_signed_opt := false. |
| 960 |
Local Instance : no_select_opt := false. |
| 961 |
Local Instance : static_opt := true. |
| 962 |
Local Instance : internal_static_opt := true. |
| 963 |
Local Instance : inline_opt := true. |
| 964 |
Local Instance : inline_internal_opt := true. |
| 965 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 966 |
Local Instance : emit_primitives_opt := true. |
| 967 |
Local Instance : should_split_mul_opt := false. |
| 968 |
Local Instance : should_split_multiret_opt := false. |
| 969 |
Local Instance : widen_carry_opt := false. |
| 970 |
Local Instance : widen_bytes_opt := true. (* true, because we don't allow byte-sized things anyway, so we should not expect carries to be widened to byte-size when emitting C code *) |
| 971 |
|
| 972 |
(** ======= these are the changable parameters ====== *) |
| 973 |
Let s := 2^256. |
| 974 |
Let c := [(1, 38)]. |
| 975 |
Let machine_wordsize := 64. |
| 976 |
(** ================================================= *) |
| 977 |
Let possible_values := prefix_with_carry [machine_wordsize]. |
| 978 |
Local Instance : machine_wordsize_opt := machine_wordsize. (* for show *) |
| 979 |
Local Instance : no_select_size_opt := no_select_size_of_no_select machine_wordsize. |
| 980 |
Local Instance : split_mul_to_opt := split_mul_to_of_should_split_mul machine_wordsize possible_values. |
| 981 |
Local Instance : split_multiret_to_opt := split_multiret_to_of_should_split_multiret machine_wordsize possible_values. |
| 982 |
Let n : nat := Z.to_nat (Qceiling (Z.log2_up s / machine_wordsize)). |
| 983 |
Let m := s - Associational.eval c. |
| 984 |
(* Number of reductions is calculated as follows : |
| 985 |
Let i be the highest limb index of c. Then, each reduction |
| 986 |
decreases the number of extra limbs by (n-i-1). (The -1 comes |
| 987 |
from possibly having an extra high partial product at the end |
| 988 |
of a reduction.) So, to go from the n extra limbs we have |
| 989 |
post-multiplication down to 0, we need ceil (n / (n - i - 1)) |
| 990 |
reductions. In some cases. however, [n - i <= 1], and in |
| 991 |
this case, we do [n] reductions (is this enough?). *) |
| 992 |
Let nreductions : nat := 2. |
| 993 |
Let bound := Some r[0 ~> (2^machine_wordsize - 1)]%zrange. |
| 994 |
Let boundsn : list (ZRange.type.option.interp base.type.Z) |
| 995 |
:= repeat bound n. |
| 996 |
|
| 997 |
Time Redirect "log" |
| 998 |
Compute |
| 999 |
Show.show (* [show] for pretty-printing of the AST without needing lots of imports *) |
| 1000 |
(Pipeline.BoundsPipelineToString |
| 1001 |
"fiat" "mul" |
| 1002 |
false (* subst01 *) |
| 1003 |
false (* inline *) |
| 1004 |
possible_values |
| 1005 |
machine_wordsize |
| 1006 |
ltac:(let n := (eval cbv in n) (* needs to be reduced to reify correctly *) in |
| 1007 |
let nreductions := (eval cbv in nreductions) (* needs to be reduced to reify correctly *) in |
| 1008 |
let r := Reify (@Saturated.Rows.mulmod (weight machine_wordsize 1) (2^machine_wordsize) s c n nreductions) in |
| 1009 |
exact r) |
| 1010 |
(fun _ _ => []) (* comment *) |
| 1011 |
(Some boundsn, (Some boundsn, tt)) |
| 1012 |
(Some boundsn, None (* Should be: Some r[0~>0]%zrange, but bounds analysis is not good enough *) ) |
| 1013 |
(None, (None, tt)) |
| 1014 |
(None, None) |
| 1015 |
: Pipeline.ErrorT _). |
| 1016 |
|
| 1017 |
|
| 1018 |
(* |
| 1019 |
= "Success (""/* |
| 1020 |
* Input Bounds: |
| 1021 |
* arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] |
| 1022 |
* arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] |
| 1023 |
* Output Bounds: |
| 1024 |
* out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] |
| 1025 |
* out2: None |
| 1026 |
*/ |
| 1027 |
static void mul(uint64_t out1[4], fiatuint1* out2, const uint64_t arg1[4], const uint64_t arg2[4]) { |
| 1028 |
// 16 mulx |
| 1029 |
uint64_t x1; |
| 1030 |
uint64_t x2; |
| 1031 |
fiatmulx_u64(&x1, &x2, (arg1[3]), (arg2[3])); |
| 1032 |
uint64_t x3; |
| 1033 |
uint64_t x4; |
| 1034 |
fiatmulx_u64(&x3, &x4, (arg1[3]), (arg2[2])); |
| 1035 |
uint64_t x5; |
| 1036 |
uint64_t x6; |
| 1037 |
fiatmulx_u64(&x5, &x6, (arg1[3]), (arg2[1])); |
| 1038 |
uint64_t x7; |
| 1039 |
uint64_t x8; |
| 1040 |
fiatmulx_u64(&x7, &x8, (arg1[3]), (arg2[0])); |
| 1041 |
uint64_t x9; |
| 1042 |
uint64_t x10; |
| 1043 |
fiatmulx_u64(&x9, &x10, (arg1[2]), (arg2[3])); |
| 1044 |
uint64_t x11; |
| 1045 |
uint64_t x12; |
| 1046 |
fiatmulx_u64(&x11, &x12, (arg1[2]), (arg2[2])); |
| 1047 |
uint64_t x13; |
| 1048 |
uint64_t x14; |
| 1049 |
fiatmulx_u64(&x13, &x14, (arg1[2]), (arg2[1])); |
| 1050 |
uint64_t x15; |
| 1051 |
uint64_t x16; |
| 1052 |
fiatmulx_u64(&x15, &x16, (arg1[2]), (arg2[0])); |
| 1053 |
uint64_t x17; |
| 1054 |
uint64_t x18; |
| 1055 |
fiatmulx_u64(&x17, &x18, (arg1[1]), (arg2[3])); |
| 1056 |
uint64_t x19; |
| 1057 |
uint64_t x20; |
| 1058 |
fiatmulx_u64(&x19, &x20, (arg1[1]), (arg2[2])); |
| 1059 |
uint64_t x21; |
| 1060 |
uint64_t x22; |
| 1061 |
fiatmulx_u64(&x21, &x22, (arg1[1]), (arg2[1])); |
| 1062 |
uint64_t x23; |
| 1063 |
uint64_t x24; |
| 1064 |
fiatmulx_u64(&x23, &x24, (arg1[1]), (arg2[0])); |
| 1065 |
uint64_t x25; |
| 1066 |
uint64_t x26; |
| 1067 |
fiatmulx_u64(&x25, &x26, (arg1[0]), (arg2[3])); |
| 1068 |
uint64_t x27; |
| 1069 |
uint64_t x28; |
| 1070 |
fiatmulx_u64(&x27, &x28, (arg1[0]), (arg2[2])); |
| 1071 |
uint64_t x29; |
| 1072 |
uint64_t x30; |
| 1073 |
fiatmulx_u64(&x29, &x30, (arg1[0]), (arg2[1])); |
| 1074 |
uint64_t x31; |
| 1075 |
uint64_t x32; |
| 1076 |
fiatmulx_u64(&x31, &x32, (arg1[0]), (arg2[0])); |
| 1077 |
// 30 addcarryx and some normal additions |
| 1078 |
uint64_t x33; |
| 1079 |
fiatuint1 x34; |
| 1080 |
fiataddcarryx_u64(&x33, &x34, 0x0, x28, x7); |
| 1081 |
uint64_t x35; |
| 1082 |
fiatuint1 x36; |
| 1083 |
fiataddcarryx_u64(&x35, &x36, x34, x26, x5); |
| 1084 |
uint64_t x37 = (x36 + x18); |
| 1085 |
uint64_t x38; |
| 1086 |
fiatuint1 x39; |
| 1087 |
fiataddcarryx_u64(&x38, &x39, 0x0, x33, x13); |
| 1088 |
uint64_t x40; |
| 1089 |
fiatuint1 x41; |
| 1090 |
fiataddcarryx_u64(&x40, &x41, x39, x35, x8); |
| 1091 |
uint64_t x42; |
| 1092 |
fiatuint1 x43; |
| 1093 |
fiataddcarryx_u64(&x42, &x43, x41, x37, 0x0); |
| 1094 |
uint64_t x44 = (x43 + x10); |
| 1095 |
uint64_t x45; |
| 1096 |
fiatuint1 x46; |
| 1097 |
fiataddcarryx_u64(&x45, &x46, 0x0, x30, x15); |
| 1098 |
uint64_t x47; |
| 1099 |
fiatuint1 x48; |
| 1100 |
fiataddcarryx_u64(&x47, &x48, x46, x38, x16); |
| 1101 |
uint64_t x49; |
| 1102 |
fiatuint1 x50; |
| 1103 |
fiataddcarryx_u64(&x49, &x50, x48, x40, x11); |
| 1104 |
uint64_t x51; |
| 1105 |
fiatuint1 x52; |
| 1106 |
fiataddcarryx_u64(&x51, &x52, x50, x42, x3); |
| 1107 |
uint64_t x53; |
| 1108 |
fiatuint1 x54; |
| 1109 |
fiataddcarryx_u64(&x53, &x54, x52, x44, 0x0); |
| 1110 |
uint64_t x55 = (x54 + x2); |
| 1111 |
uint64_t x56; |
| 1112 |
fiatuint1 x57; |
| 1113 |
fiataddcarryx_u64(&x56, &x57, 0x0, x45, x21); |
| 1114 |
uint64_t x58; |
| 1115 |
fiatuint1 x59; |
| 1116 |
fiataddcarryx_u64(&x58, &x59, x57, x47, x19); |
| 1117 |
uint64_t x60; |
| 1118 |
fiatuint1 x61; |
| 1119 |
fiataddcarryx_u64(&x60, &x61, x59, x49, x14); |
| 1120 |
uint64_t x62; |
| 1121 |
fiatuint1 x63; |
| 1122 |
fiataddcarryx_u64(&x62, &x63, x61, x51, x6); |
| 1123 |
uint64_t x64; |
| 1124 |
fiatuint1 x65; |
| 1125 |
fiataddcarryx_u64(&x64, &x65, x63, x53, 0x0); |
| 1126 |
uint64_t x66; |
| 1127 |
fiatuint1 x67; |
| 1128 |
fiataddcarryx_u64(&x66, &x67, x65, x55, 0x0); |
| 1129 |
uint64_t x68; |
| 1130 |
fiatuint1 x69; |
| 1131 |
fiataddcarryx_u64(&x68, &x69, 0x0, x32, x23); |
| 1132 |
uint64_t x70; |
| 1133 |
fiatuint1 x71; |
| 1134 |
fiataddcarryx_u64(&x70, &x71, x69, x56, x24); |
| 1135 |
uint64_t x72; |
| 1136 |
fiatuint1 x73; |
| 1137 |
fiataddcarryx_u64(&x72, &x73, x71, x58, x22); |
| 1138 |
uint64_t x74; |
| 1139 |
fiatuint1 x75; |
| 1140 |
fiataddcarryx_u64(&x74, &x75, x73, x60, x17); |
| 1141 |
uint64_t x76; |
| 1142 |
fiatuint1 x77; |
| 1143 |
fiataddcarryx_u64(&x76, &x77, x75, x62, x9); |
| 1144 |
uint64_t x78; |
| 1145 |
fiatuint1 x79; |
| 1146 |
fiataddcarryx_u64(&x78, &x79, x77, x64, x1); |
| 1147 |
uint64_t x80; |
| 1148 |
fiatuint1 x81; |
| 1149 |
fiataddcarryx_u64(&x80, &x81, x79, x66, 0x0); |
| 1150 |
uint64_t x82; |
| 1151 |
fiatuint1 x83; |
| 1152 |
fiataddcarryx_u64(&x82, &x83, 0x0, x68, x29); |
| 1153 |
uint64_t x84; |
| 1154 |
fiatuint1 x85; |
| 1155 |
fiataddcarryx_u64(&x84, &x85, x83, x70, x27); |
| 1156 |
uint64_t x86; |
| 1157 |
fiatuint1 x87; |
| 1158 |
fiataddcarryx_u64(&x86, &x87, x85, x72, x25); |
| 1159 |
uint64_t x88; |
| 1160 |
fiatuint1 x89; |
| 1161 |
fiataddcarryx_u64(&x88, &x89, x87, x74, x20); |
| 1162 |
uint64_t x90; |
| 1163 |
fiatuint1 x91; |
| 1164 |
fiataddcarryx_u64(&x90, &x91, x89, x76, x12); |
| 1165 |
uint64_t x92; |
| 1166 |
fiatuint1 x93; |
| 1167 |
fiataddcarryx_u64(&x92, &x93, x91, x78, x4); |
| 1168 |
uint64_t x94; |
| 1169 |
fiatuint1 x95; |
| 1170 |
fiataddcarryx_u64(&x94, &x95, x93, x80, 0x0); |
| 1171 |
uint64_t x96; |
| 1172 |
uint64_t x97; |
| 1173 |
fiatmulx_u64(&x96, &x97, UINT8_C(0x26), x94); |
| 1174 |
uint64_t x98; |
| 1175 |
uint64_t x99; |
| 1176 |
fiatmulx_u64(&x98, &x99, UINT8_C(0x26), x92); |
| 1177 |
uint64_t x100; |
| 1178 |
uint64_t x101; |
| 1179 |
fiatmulx_u64(&x100, &x101, UINT8_C(0x26), x90); |
| 1180 |
uint64_t x102; |
| 1181 |
uint64_t x103; |
| 1182 |
fiatmulx_u64(&x102, &x103, UINT8_C(0x26), x88); |
| 1183 |
uint64_t x104; |
| 1184 |
fiatuint1 x105; |
| 1185 |
fiataddcarryx_u64(&x104, &x105, 0x0, x82, x100); |
| 1186 |
uint64_t x106; |
| 1187 |
fiatuint1 x107; |
| 1188 |
fiataddcarryx_u64(&x106, &x107, x105, x84, x98); |
| 1189 |
uint64_t x108; |
| 1190 |
fiatuint1 x109; |
| 1191 |
fiataddcarryx_u64(&x108, &x109, x107, x86, x96); |
| 1192 |
uint64_t x110 = (x109 + x97); |
| 1193 |
uint64_t x111; |
| 1194 |
fiatuint1 x112; |
| 1195 |
fiataddcarryx_u64(&x111, &x112, 0x0, x31, x102); |
| 1196 |
uint64_t x113; |
| 1197 |
fiatuint1 x114; |
| 1198 |
fiataddcarryx_u64(&x113, &x114, x112, x104, x103); |
| 1199 |
uint64_t x115; |
| 1200 |
fiatuint1 x116; |
| 1201 |
fiataddcarryx_u64(&x115, &x116, x114, x106, x101); |
| 1202 |
uint64_t x117; |
| 1203 |
fiatuint1 x118; |
| 1204 |
fiataddcarryx_u64(&x117, &x118, x116, x108, x99); |
| 1205 |
uint64_t x119 = (x118 + x110); |
| 1206 |
uint64_t x120; |
| 1207 |
uint64_t x121; |
| 1208 |
fiatmulx_u64(&x120, &x121, UINT8_C(0x26), x119); |
| 1209 |
uint64_t x122; |
| 1210 |
fiatuint1 x123; |
| 1211 |
fiataddcarryx_u64(&x122, &x123, 0x0, x111, x120); |
| 1212 |
uint64_t x124; |
| 1213 |
fiatuint1 x125; |
| 1214 |
fiataddcarryx_u64(&x124, &x125, x123, x113, 0x0); |
| 1215 |
uint64_t x126; |
| 1216 |
fiatuint1 x127; |
| 1217 |
fiataddcarryx_u64(&x126, &x127, x125, x115, 0x0); |
| 1218 |
uint64_t x128; |
| 1219 |
fiatuint1 x129; |
| 1220 |
fiataddcarryx_u64(&x128, &x129, x127, x117, 0x0); |
| 1221 |
out1[0] = x122; |
| 1222 |
out1[1] = x124; |
| 1223 |
out1[2] = x126; |
| 1224 |
out1[3] = x128; |
| 1225 |
*out2 = x129; |
| 1226 |
}"", {| bitwidths_used := [uint1, uint64] ; addcarryx_lg_splits := [64] ; mulx_lg_splits := [64] ; cmovznz_bitwidths := [] |})"%string |
| 1227 |
: string |
| 1228 |
*) |
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
(* Finished transaction in 6.9 secs (4.764u,0.001s) (successful) *) |
| 1233 |
End __. |
| 1234 |
End debugging_sat_solinas_25519_expanded. |
| 1235 |
|
| 1236 |
(*Require Import Crypto.Bedrock.Stringification.*) |
| 1237 |
Module debugging_p256_mul_bedrock2. |
| 1238 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 1239 |
Import Stringification.C. |
| 1240 |
Import Stringification.C.Compilers. |
| 1241 |
Import Stringification.C.Compilers.ToString. |
| 1242 |
Section __. |
| 1243 |
Local Existing Instance (*OutputBedrock2API*) C.OutputCAPI. |
| 1244 |
Local Instance static : static_opt := false. |
| 1245 |
Local Instance : internal_static_opt := true. |
| 1246 |
Local Instance : inline_opt := true. |
| 1247 |
Local Instance : inline_internal_opt := true. |
| 1248 |
Local Instance : emit_primitives_opt := false. |
| 1249 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 1250 |
Local Instance : widen_carry_opt := true. |
| 1251 |
Local Instance : widen_bytes_opt := true. |
| 1252 |
Local Instance : only_signed_opt := false. |
| 1253 |
Local Instance : no_select_opt := false. |
| 1254 |
Local Instance : should_split_mul_opt := true. |
| 1255 |
Local Instance : should_split_multiret_opt := true. |
| 1256 |
|
| 1257 |
Definition m := (2^64 - 1)%Z. (*(2^256 - 2^224 + 2^192 + 2^96 - 1)%Z.*) |
| 1258 |
Definition machine_wordsize := 64. |
| 1259 |
|
| 1260 |
Import IR.Compilers.ToString. |
| 1261 |
|
| 1262 |
Goal True. |
| 1263 |
pose (smul m machine_wordsize "p256") as v. |
| 1264 |
Import IdentifiersBasicGENERATED.Compilers. |
| 1265 |
cbv [smul] in v. |
| 1266 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 1267 |
vm_compute in v. |
| 1268 |
clear v. |
| 1269 |
cbv [mul] in k. |
| 1270 |
cbv -[Pipeline.BoundsPipelineWithDebug WordByWordMontgomeryReificationCache.WordByWordMontgomery.reified_mul_gen] in k. |
| 1271 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline Rewriter.Util.LetIn.Let_In] in k. |
| 1272 |
let k' := fresh in rename k into k'; epose (DebugMonad.Debug.eval_result k') as k; subst k'. |
| 1273 |
cbv [Rewriter.Util.LetIn.Let_In DebugMonad.Debug.eval_result DebugMonad.Debug.sequence Pipeline.debug_after_rewrite DebugMonad.Debug.ret] in k. |
| 1274 |
vm_compute Pipeline.debug_rewriting in k. |
| 1275 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 1276 |
set (k' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 1277 |
vm_compute in k'. |
| 1278 |
subst k'; cbv beta iota zeta in k. |
| 1279 |
cbv [Pipeline.RewriteAndEliminateDeadAndInline] in k. |
| 1280 |
(* |
| 1281 |
set (k' := ArithWithCasts.Compilers.RewriteRules.RewriteArithWithCasts _ _ _) in (value of k). |
| 1282 |
vm_compute in k'. |
| 1283 |
Notation uint64 := (expr.Ident (ident_Literal r[0 ~> 18446744073709551615]%zrange)). |
| 1284 |
Notation "'(uint64)' x" := (#ident_Z_cast @ uint64 @ x)%expr (at level 0) : expr_scope. |
| 1285 |
Notation "'(uint64,uint64)' x" := (#ident_Z_cast2 @ (uint64, uint64) @ x)%expr (at level 0) : expr_scope. |
| 1286 |
subst k'; cbv beta iota zeta in k. |
| 1287 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1288 |
set (k' := UnderLets.LetBindReturn _ _) in (value of k) at 1. |
| 1289 |
vm_compute in k'; subst k'. |
| 1290 |
set (k' := ArithWithCasts.Compilers.RewriteRules.RewriteArithWithCasts _ _ _) in (value of k). |
| 1291 |
vm_compute in k'. |
| 1292 |
subst k'; cbv beta iota zeta in k. |
| 1293 |
set (k' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 1294 |
vm_compute in k'. |
| 1295 |
subst k'; cbv beta iota zeta in k. |
| 1296 |
set (k' := MulSplit.Compilers.RewriteRules.RewriteMulSplit _ _ _ _) in (value of k) at 1. |
| 1297 |
vm_compute in k'. |
| 1298 |
subst k'. |
| 1299 |
set (k' := MultiRetSplit.Compilers.RewriteRules.RewriteMultiRetSplit _ _ _ _) in (value of k) at 2. |
| 1300 |
vm_compute in k'. |
| 1301 |
vm_compute in k. |
| 1302 |
vm_compute in k'. |
| 1303 |
Import IdentifiersBasicGENERATED.Compilers. |
| 1304 |
subst k'; cbv beta iota zeta in k. |
| 1305 |
*) |
| 1306 |
Abort. |
| 1307 |
End __. |
| 1308 |
End debugging_p256_mul_bedrock2. |
| 1309 |
|
| 1310 |
Module debugging_25519_to_bytes_bedrock2. |
| 1311 |
Import Crypto.PushButtonSynthesis.UnsaturatedSolinas. |
| 1312 |
Import Stringification.C. |
| 1313 |
Import Stringification.C.Compilers. |
| 1314 |
Import Stringification.C.Compilers.ToString. |
| 1315 |
Section __. |
| 1316 |
Local Existing Instance C.OutputCAPI. |
| 1317 |
Local Instance static : static_opt := false. |
| 1318 |
Local Instance : internal_static_opt := true. |
| 1319 |
Local Instance : inline_opt := true. |
| 1320 |
Local Instance : inline_internal_opt := true. |
| 1321 |
Local Instance : emit_primitives_opt := false. |
| 1322 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 1323 |
Local Instance : widen_carry_opt := true. |
| 1324 |
Local Instance : widen_bytes_opt := true. |
| 1325 |
Local Instance : only_signed_opt := false. |
| 1326 |
Local Instance : no_select_opt := false. |
| 1327 |
Local Instance : should_split_mul_opt := true. |
| 1328 |
Local Instance : should_split_multiret_opt := true. |
| 1329 |
|
| 1330 |
Definition n := 2%nat (*5%nat*). |
| 1331 |
Definition s := 2^127 (* 255*). |
| 1332 |
Definition c := [(1, 1(*9*))]. |
| 1333 |
Definition machine_wordsize := 64. |
| 1334 |
|
| 1335 |
Import IR.Compilers.ToString. |
| 1336 |
|
| 1337 |
Goal True. |
| 1338 |
pose (sto_bytes n s c machine_wordsize "curve25519") as v. |
| 1339 |
cbv [sto_bytes] in v. |
| 1340 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 1341 |
clear v. |
| 1342 |
(* |
| 1343 |
cbv [to_bytes] in k. |
| 1344 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline] in k. |
| 1345 |
set (k' := Arith.Compilers.RewriteRules.RewriteArith _ _ _) in (value of k). |
| 1346 |
vm_compute in k'. |
| 1347 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1348 |
set (k'' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 1349 |
vm_compute in k''. |
| 1350 |
set (uint64 := r[0 ~> 18446744073709551615]%zrange) in (value of k''). |
| 1351 |
subst k''. |
| 1352 |
cbv beta iota zeta in k. |
| 1353 |
set (k'' := Pipeline.RewriteAndEliminateDeadAndInline _ _ _ _ _ _) in (value of k). |
| 1354 |
vm_compute in k''. |
| 1355 |
Compute Z.log2 9223372036854775808. |
| 1356 |
clear -k''. |
| 1357 |
set (k'' := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 1358 |
vm_compute in k''. |
| 1359 |
subst k''. |
| 1360 |
cbv beta iota zeta in k. |
| 1361 |
subst k'. |
| 1362 |
set (v := split_multiret_to machine_wordsize) in (value of k); vm_compute in v; subst v. |
| 1363 |
set (v := split_mul_to machine_wordsize) in (value of k); vm_compute in v; subst v. |
| 1364 |
cbv beta iota zeta in k. |
| 1365 |
set (k' := MulSplit.Compilers.RewriteRules.RewriteMulSplit _ _ _ _) in (value of k). |
| 1366 |
vm_compute in k'. |
| 1367 |
cbv [Pipeline.RewriteAndEliminateDeadAndInline] in k. |
| 1368 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1369 |
set (k'' := MultiRetSplit.Compilers.RewriteRules.RewriteMultiRetSplit _ _ _ k') in (value of k). |
| 1370 |
clear k. |
| 1371 |
evar (varT : Type); evar (var : varT); subst varT. |
| 1372 |
evar (xT : Type); evar (x : xT); subst xT. |
| 1373 |
pose ((*Option.invert_Some*) (option_map (fun f => f x) (invert_expr.invert_Abs (k'' var)))) as k; subst k'' var x. |
| 1374 |
cbv [option_map Option.invert_Some invert_expr.invert_Abs MultiRetSplit.Compilers.RewriteRules.RewriteMultiRetSplit] in k. |
| 1375 |
cbv [Rewriter.Compilers.RewriteRules.Make.GoalType.rewrite_head_gen] in k. |
| 1376 |
set (v := ProofsCommon.Compilers.RewriteRules.GoalType.DefaultOptionType.use_precomputed_functions _) in (value of k); vm_compute in v; subst v. |
| 1377 |
set (v := ProofsCommon.Compilers.RewriteRules.GoalType.DefaultOptionType.use_decision_tree _) in (value of k); vm_compute in v; subst v. |
| 1378 |
cbv [Rewriter.Compilers.RewriteRules.Compile.Rewrite] in k. |
| 1379 |
cbv [Rewriter.Compilers.RewriteRules.Make.GoalType.rewrite_head] in k. |
| 1380 |
cbv [Rewriter.Compilers.RewriteRules.Compile.rewrite] in k. |
| 1381 |
set (fuel := 6%nat) in (value of k). |
| 1382 |
cbn [Rewriter.Compilers.RewriteRules.Compile.repeat_rewrite] in k. |
| 1383 |
set (k'' := k' _) in (value of k). |
| 1384 |
match (eval cbv delta [k'] in k') with |
| 1385 |
| fun var : ?T => expr.Abs ?f |
| 1386 |
=> evar (var' : T); |
| 1387 |
pose (match var' return _ with var => f end) as F; subst var'; |
| 1388 |
assert (k'' = expr.Abs F) by reflexivity; clearbody k''; subst k'' |
| 1389 |
end. |
| 1390 |
cbn [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k. |
| 1391 |
cbn [Rewriter.Compilers.RewriteRules.Compile.reify] in k. |
| 1392 |
set (v := F _) in (value of k). |
| 1393 |
clear k'. |
| 1394 |
match (eval cbv delta [F] in F) with |
| 1395 |
| fun x : ?T => ?f |
| 1396 |
=> evar (x' : T); |
| 1397 |
pose (match x' return _ with x => f end) as f'; subst x'; |
| 1398 |
assert (v = f') by refine eq_refl; clearbody v; subst F v |
| 1399 |
end. |
| 1400 |
match (eval cbv delta [f'] in f') with |
| 1401 |
| expr.LetIn ?v ?f => |
| 1402 |
pose v as V; pose f as F; |
| 1403 |
assert (f' = expr.LetIn V F) by refine eq_refl; clearbody f'; subst f'; rename F into f' |
| 1404 |
end. |
| 1405 |
cbn [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k; |
| 1406 |
cbv [Rewriter.Compilers.RewriteRules.Compile.splice_value_with_lets Rewriter.Compilers.RewriteRules.Compile.splice_under_lets_with_value Rewriter.Compilers.RewriteRules.Compile.reify_and_let_binds_cps] in k. |
| 1407 |
set (k'' := Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup _ _ _) in (value of k). |
| 1408 |
vm_compute in k''. |
| 1409 |
subst k''. |
| 1410 |
cbn [UnderLets.splice] in k. |
| 1411 |
set (k' := UnderLets.reify_and_let_binds_base_cps _ _ _ _) in (value of k). |
| 1412 |
vm_compute in k'. |
| 1413 |
subst k'. |
| 1414 |
cbn [UnderLets.splice] in k. |
| 1415 |
subst V. |
| 1416 |
match (eval cbv delta [f'] in f') with |
| 1417 |
| fun x : ?T => expr.LetIn ?v ?f => |
| 1418 |
pose (fun x : T => v) as V; pose (fun x : T => f) as F; |
| 1419 |
assert (f' = fun x : T => expr.LetIn (V x) (F x)) by refine eq_refl; clearbody f'; subst f'; rename F into f' |
| 1420 |
end. |
| 1421 |
cbn [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k; |
| 1422 |
cbv [Rewriter.Compilers.RewriteRules.Compile.splice_value_with_lets Rewriter.Compilers.RewriteRules.Compile.splice_under_lets_with_value Rewriter.Compilers.RewriteRules.Compile.reify_and_let_binds_cps] in k. |
| 1423 |
subst V. |
| 1424 |
cbn [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k. |
| 1425 |
cbn [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k; |
| 1426 |
cbv [Rewriter.Compilers.RewriteRules.Compile.splice_value_with_lets Rewriter.Compilers.RewriteRules.Compile.splice_under_lets_with_value Rewriter.Compilers.RewriteRules.Compile.reify_and_let_binds_cps] in k. |
| 1427 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1428 |
vm_compute in v. |
| 1429 |
subst v. |
| 1430 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1431 |
vm_compute in v. |
| 1432 |
subst v. |
| 1433 |
cbn [UnderLets.splice] in k. |
| 1434 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1435 |
vm_compute in v. |
| 1436 |
subst v. |
| 1437 |
cbn [UnderLets.splice] in k. |
| 1438 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1439 |
vm_compute in v. |
| 1440 |
subst v. |
| 1441 |
cbn [UnderLets.splice] in k. |
| 1442 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1443 |
vm_compute in v. |
| 1444 |
subst v. |
| 1445 |
cbn [UnderLets.splice] in k. |
| 1446 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1447 |
vm_compute in v. |
| 1448 |
subst v. |
| 1449 |
cbn [UnderLets.splice] in k. |
| 1450 |
cbv [Rewriter.Compilers.RewriteRules.Compile.Base_value] in k. |
| 1451 |
cbn [UnderLets.splice] in k. |
| 1452 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1453 |
vm_compute in v. |
| 1454 |
subst v. |
| 1455 |
cbn [UnderLets.splice] in k. |
| 1456 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1457 |
vm_compute in v. |
| 1458 |
subst v. |
| 1459 |
cbn [UnderLets.splice] in k. |
| 1460 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1461 |
vm_compute in v. |
| 1462 |
subst v. |
| 1463 |
cbn [UnderLets.splice] in k. |
| 1464 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1465 |
vm_compute in v. |
| 1466 |
subst v. |
| 1467 |
cbn [UnderLets.splice] in k. |
| 1468 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1469 |
vm_compute in v. |
| 1470 |
subst v. |
| 1471 |
cbn [UnderLets.splice] in k. |
| 1472 |
unfold MultiRetSplit.Compilers.RewriteRules.rewrite_head in (value of k) at 1. |
| 1473 |
cbn [IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args] in k; |
| 1474 |
cbv [Option.sequence_return Option.bind] in k. |
| 1475 |
cbn [UnderLets.splice] in k. |
| 1476 |
cbn [Rewriter.Compilers.RewriteRules.Compile.reflect] in k. |
| 1477 |
cbn [UnderLets.splice] in k. |
| 1478 |
unfold MultiRetSplit.Compilers.RewriteRules.rewrite_head in (value of k) at 1. |
| 1479 |
cbn [IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args] in k; |
| 1480 |
cbv [Option.sequence_return Option.bind] in k. |
| 1481 |
cbn [UnderLets.splice] in k. |
| 1482 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1483 |
vm_compute in v. |
| 1484 |
subst v. |
| 1485 |
cbn [UnderLets.splice] in k. |
| 1486 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1487 |
vm_compute in v. |
| 1488 |
subst v. |
| 1489 |
cbn [UnderLets.splice] in k. |
| 1490 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1491 |
vm_compute in v. |
| 1492 |
subst v. |
| 1493 |
cbn [UnderLets.splice] in k. |
| 1494 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1495 |
vm_compute in v. |
| 1496 |
subst v. |
| 1497 |
cbn [UnderLets.splice] in k. |
| 1498 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1499 |
vm_compute in v. |
| 1500 |
subst v. |
| 1501 |
cbn [UnderLets.splice] in k. |
| 1502 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1503 |
vm_compute in v. |
| 1504 |
subst v. |
| 1505 |
cbn [UnderLets.splice] in k. |
| 1506 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1507 |
vm_compute in v. |
| 1508 |
subst v. |
| 1509 |
cbn [UnderLets.splice] in k. |
| 1510 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1511 |
vm_compute in v. |
| 1512 |
subst v. |
| 1513 |
cbn [UnderLets.splice] in k. |
| 1514 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1515 |
vm_compute in v. |
| 1516 |
subst v. |
| 1517 |
cbn [UnderLets.splice] in k. |
| 1518 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _ _) in (value of k) at 1. |
| 1519 |
set (v' := v _) in (value of k); subst v; rename v' into v. |
| 1520 |
cbn [UnderLets.to_expr] in k. |
| 1521 |
lazymatch (eval cbv delta [k] in k) with |
| 1522 |
| Some (expr.LetIn ?V (fun v : ?T => ?f)) |
| 1523 |
=> evar (v' : T); pose (match v' return _ with v => f end) as F; |
| 1524 |
subst v' |
| 1525 |
end. |
| 1526 |
clear k; rename F into k. |
| 1527 |
set (v' := v _) in (value of k); subst v; rename v' into v. |
| 1528 |
cbv beta iota zeta in v. |
| 1529 |
Import Util.Option. |
| 1530 |
set (uint64 := r[0 ~> 18446744073709551615]%zrange) in (value of v). |
| 1531 |
Arguments type.base {_ _}. |
| 1532 |
Arguments type.arrow {_ _ _}. |
| 1533 |
set (b := expr.App _ _) in (value of v) at 3. |
| 1534 |
cbn [MultiRetSplit.Compilers.RewriteRules.rewrite_head] in v. |
| 1535 |
Ltac separate H do_subst := |
| 1536 |
lazymatch (eval cbv delta [H] in H) with |
| 1537 |
| expr.App ?x ?y => let x' := fresh in |
| 1538 |
let y' := fresh in |
| 1539 |
set (x' := x) in (value of H); |
| 1540 |
set (y' := y) in (value of H); |
| 1541 |
separate x' true; separate y' false; |
| 1542 |
lazymatch do_subst with |
| 1543 |
| true => subst H |
| 1544 |
| false => idtac |
| 1545 |
end |
| 1546 |
| _ => idtac |
| 1547 |
end. |
| 1548 |
separate b false. |
| 1549 |
subst b. |
| 1550 |
cbv beta iota in v. |
| 1551 |
subst H5. |
| 1552 |
clear -v. |
| 1553 |
cbv beta iota in v. |
| 1554 |
subst H9 H10 H8. |
| 1555 |
subst H6. |
| 1556 |
cbv beta iota in v. |
| 1557 |
subst H11 H12 H7. |
| 1558 |
subst H4. |
| 1559 |
cbv beta iota in v. |
| 1560 |
revert v; repeat match goal with H : _ |- _ => clear H end; intro v. |
| 1561 |
subst H18 H22 H14. |
| 1562 |
subst H2. |
| 1563 |
cbv beta iota in v. |
| 1564 |
subst H24 H28 H1. |
| 1565 |
subst H0. |
| 1566 |
cbv beta iota in v. |
| 1567 |
cbn [IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args Option.bind Option.sequence_return Option.sequence] in v. |
| 1568 |
cbn [Rewriter.Compilers.pattern.type.unify_extracted Rewriter.Compilers.pattern.base.unify_extracted] in v. |
| 1569 |
cbn [IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args Option.bind Option.sequence_return Option.sequence] in v. |
| 1570 |
cbn [type.type_beq base.type.type_beq andb] in v. |
| 1571 |
cbn [IdentifiersGENERATED.Compilers.pattern.ident.unify] in v. |
| 1572 |
cbn [Option.bind] in v. |
| 1573 |
cbv [type.try_make_transport_cps base.try_make_transport_cps type.try_make_transport_cpsv Compilers.try_make_base_transport_cps Compilers.eta_base_cps Compilers.eta_base_cps_gen proj1_sig Compilers.base_eq_dec Compilers.base_rec Compilers.base_rect Rewriter.Util.CPSNotations.cpsreturn id eq_rect Rewriter.Util.CPSNotations.cps_option_bind Rewriter.Util.CPSNotations.cpsbind Rewriter.Util.CPSNotations.cpscall] in v. |
| 1574 |
set (k' := andb _ _) in (value of v). |
| 1575 |
Compute is_bounded_by_bool (2 ^ 64) (Operations.ZRange.normalize uint64). |
| 1576 |
vm_compute in k'. |
| 1577 |
do 9 (unfold IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args in (value of v) at 1; |
| 1578 |
c |
| 1579 |
unfold Option.bind in (value of v) at 1). |
| 1580 |
do 5 (unfold IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args in (value of v) at 1; |
| 1581 |
unfold Option.bind in (value of v) at 1). |
| 1582 |
do 5 (unfold IdentifiersGENERATED.Compilers.pattern.ident.raw_invert_bind_args in (value of v) at 1; |
| 1583 |
unfold Option.bind in (value of v) at 1). |
| 1584 |
unfold Option.bind in (value of v) at 1. |
| 1585 |
unfold Option.bind in (value of v) at 1. |
| 1586 |
unfold Option.bind in (value of v) at 1. |
| 1587 |
unfold Option.bind in (value of v) at 1. |
| 1588 |
unfold Option.bind in (value of v) at 1. |
| 1589 |
unfold Option.bind in (value of v) at 1. |
| 1590 |
unfold Option.bind in (value of v) at 1. |
| 1591 |
unfold Option.bind in (value of v) at 1. |
| 1592 |
unfold Option.bind in (value of v) at 1. |
| 1593 |
cbn [Option.bind] in v. |
| 1594 |
cbn [ |
| 1595 |
vm_compute in v. |
| 1596 |
|
| 1597 |
set (idc := Compilers.ident_Z_sub_with_get_borrow) in (value of b). |
| 1598 |
|
| 1599 |
subst b. |
| 1600 |
|
| 1601 |
cbv beta iota in v. |
| 1602 |
cbv beta delta [MultiRetSplit.Compilers.RewriteRules.rewrite_head] in v. |
| 1603 |
|
| 1604 |
cbv iota in v; cbv beta in v. |
| 1605 |
cbv iota in v; cbv beta in v. |
| 1606 |
cbv iota in v; cbv beta in v. |
| 1607 |
cbv iota in v; cbv beta in v. |
| 1608 |
cbv iota in v; cbv beta in v. |
| 1609 |
cbv iota in v; cbv beta in v. |
| 1610 |
vm_compute in v. |
| 1611 |
subst v. |
| 1612 |
cbn [UnderLets.splice] in k. |
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
cbn [Rewriter.Compilers.RewriteRules.Compile.repeat_rewrite] in k. |
| 1617 |
|
| 1618 |
|
| 1619 |
subst k'; cbv beta in k''. |
| 1620 |
cbv [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k. |
| 1621 |
cbv [Rewriter.Compilers.RewriteRules.Compile.splice_value_with_lets] in k. |
| 1622 |
cbv [Rewriter.Compilers.RewriteRules.Compile.splice_under_lets_with_value] in k. |
| 1623 |
cbv [Rewriter.Compilers.RewriteRules.Compile.reify] in k. |
| 1624 |
subst k'. |
| 1625 |
cbv beta iota zeta in k. |
| 1626 |
set (v := fun x => UnderLets.to_expr _) in (value of k); clear k. |
| 1627 |
evar (xT : Type); evar (x : varT); subst |
| 1628 |
epose (var : _). |
| 1629 |
set (v := MultiRetSplit.Compilers.RewriteRules.rewrite_head _ _ _ _ _) in (value of k''). |
| 1630 |
|
| 1631 |
Print Rewriter.Compilers.RewriteRules.Compile.repeat_rewrite. |
| 1632 |
cbv [Rewriter.Compilers.RewriteRules.Compile.repeat_rewrite] in k''. |
| 1633 |
cbv [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in k''. |
| 1634 |
vm_compute in k''. |
| 1635 |
cbv [split_multiret_to split_mul_to] in k. |
| 1636 |
cbv [should_split_multiret should_split_mul] in k. |
| 1637 |
|
| 1638 |
vm_ |
| 1639 |
vm_compute in k. |
| 1640 |
subst k. |
| 1641 |
cbv beta iota zeta in v. |
| 1642 |
set (k := Language.Compilers.ToString.ToFunctionLines _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) in (value of v). |
| 1643 |
clear v. |
| 1644 |
cbv [Language.Compilers.ToString.ToFunctionLines] in k. |
| 1645 |
cbv [Java.OutputJavaAPI] in k. |
| 1646 |
cbv [Language.Compilers.ToString.ToFunctionLines] in k. |
| 1647 |
cbv [Java.ToFunctionLines] in k. |
| 1648 |
set (k' := IR.OfPHOAS.ExprOfPHOAS _ _ _ _) in (value of k). |
| 1649 |
clear k. |
| 1650 |
cbv [IR.OfPHOAS.ExprOfPHOAS] in k'. |
| 1651 |
cbv [IR.OfPHOAS.expr_of_PHOAS] in k'. |
| 1652 |
set (k := IR.OfPHOAS.var_data_of_bounds _ _ _ _) in (value of k'). |
| 1653 |
vm_compute in k. |
| 1654 |
subst k. |
| 1655 |
cbv beta iota zeta in k'. |
| 1656 |
cbv [IR.OfPHOAS.expr_of_PHOAS'] in k'. |
| 1657 |
set (k := IR.OfPHOAS.var_data_of_bounds _ _ _ _) in (value of k'). |
| 1658 |
vm_compute in k. |
| 1659 |
subst k. |
| 1660 |
cbv beta iota zeta in k'. |
| 1661 |
cbv [invert_expr.invert_Abs] in k'. |
| 1662 |
cbv [IR.OfPHOAS.expr_of_base_PHOAS] in k'. |
| 1663 |
set (k := IR.OfPHOAS.make_assign_expr_of_PHOAS _ _) in (value of k') at 1. |
| 1664 |
cbv [IR.OfPHOAS.make_assign_expr_of_PHOAS] in k. |
| 1665 |
clear k'. |
| 1666 |
set (k' := type.try_transport _ _ _) in (value of k). |
| 1667 |
vm_compute in k'. |
| 1668 |
subst k'. |
| 1669 |
cbv beta iota zeta in k. |
| 1670 |
set (k' := invert_expr.invert_App_Z_cast2 _) in (value of k). |
| 1671 |
vm_compute in k'. |
| 1672 |
|
| 1673 |
subst k'. |
| 1674 |
cbv beta iota zeta in k. |
| 1675 |
set (k' := invert_expr.invert_AppIdent_curried _) in (value of k); vm_compute in k'; subst k'. |
| 1676 |
cbv beta iota in k. |
| 1677 |
set (k' := IR.OfPHOAS.arith_expr_of_PHOAS_args _) in (value of k). |
| 1678 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS_args] in k'. |
| 1679 |
(*clear k. |
| 1680 |
set (k := IR.OfPHOAS.arith_expr_of_base_PHOAS _ _) in (value of k') at 1. |
| 1681 |
cbv [Language.Compilers.ToString.int.option.None] in k. |
| 1682 |
cbv [IR.OfPHOAS.arith_expr_for_base] in k. |
| 1683 |
cbv [IR.OfPHOAS.arith_expr_of_base_PHOAS] in k. |
| 1684 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS] in k. |
| 1685 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS_ident] in k. |
| 1686 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS_literal_Z] in k. |
| 1687 |
vm_compute in k.*) |
| 1688 |
vm_compute in k'. |
| 1689 |
subst k'. |
| 1690 |
cbv beta iota zeta in k. |
| 1691 |
set (k' := Crypto.Util.Option.bind _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1692 |
cbv beta iota zeta in k. |
| 1693 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1694 |
cbv beta iota zeta in k. |
| 1695 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1696 |
cbv beta iota zeta in k. |
| 1697 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1698 |
cbv beta iota zeta in k. |
| 1699 |
set (k' := Language.Compilers.ToString.int.of_zrange_relaxed _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1700 |
set (k' := Language.Compilers.ToString.int.of_zrange_relaxed _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1701 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1702 |
cbv beta iota zeta in k. |
| 1703 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1704 |
cbv beta iota zeta in k. |
| 1705 |
set (k' := IR.OfPHOAS.result_upcast _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1706 |
cbv beta iota zeta in k. |
| 1707 |
set (k' := IR.OfPHOAS.result_upcast _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1708 |
cbv beta iota zeta in k. |
| 1709 |
set (k' := IR.OfPHOAS.result_upcast _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1710 |
(*cbv |
| 1711 |
vm_compute in k. |
| 1712 |
vm_compute in k'. |
| 1713 |
vm_compute in k'. |
| 1714 |
cbv -[Language.Compilers.ToString.ToFunctionLines] in v. |
| 1715 |
clear v. |
| 1716 |
cbv [to_bytes] in k. |
| 1717 |
cbv [Primitives.possible_values_of_machine_wordsize] in k. |
| 1718 |
cbv [Primitives.possible_values_of_machine_wordsize_with_bytes] in k. |
| 1719 |
cbv [widen_bytes] in k. |
| 1720 |
cbv [widen_bytes_opt_instance_0] in k. |
| 1721 |
cbv [widen_carry] in k. |
| 1722 |
cbv [widen_carry_opt_instance_0] in k. |
| 1723 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline] in k. |
| 1724 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1725 |
set (k' := GeneralizeVar.FromFlat _) in (value of k); vm_compute in k'; subst k'. |
| 1726 |
cbv [CheckedPartialEvaluateWithBounds] in k. |
| 1727 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1728 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k). |
| 1729 |
vm_compute in k'. |
| 1730 |
subst k'. |
| 1731 |
set (k' := CheckCasts.GetUnsupportedCasts _) in (value of k). |
| 1732 |
vm_compute in k'. |
| 1733 |
subst k'. |
| 1734 |
cbv beta iota in k. |
| 1735 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 1736 |
vm_compute in k'; subst k'. |
| 1737 |
cbv beta iota in k. |
| 1738 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 1739 |
vm_compute in k'; subst k'. |
| 1740 |
cbv beta iota in k. |
| 1741 |
cbv [split_multiret_to] in k. |
| 1742 |
cbv [should_split_multiret] in k. |
| 1743 |
cbv [should_split_multiret_opt_instance_0] in k. |
| 1744 |
cbv [split_mul_to] in k. |
| 1745 |
cbv [should_split_mul] in k. |
| 1746 |
cbv [should_split_mul_opt_instance_0] in k. |
| 1747 |
cbv [only_signed_opt_instance_0] in k. |
| 1748 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k) at 2. |
| 1749 |
vm_compute in k'. |
| 1750 |
subst k'. |
| 1751 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k) at 1. |
| 1752 |
vm_compute in k'. |
| 1753 |
subst k'. |
| 1754 |
set (k' := PartialEvaluateWithBounds _ _ _ _ _) in (value of k). |
| 1755 |
vm_compute in k'. |
| 1756 |
subst k'.*) |
| 1757 |
*) |
| 1758 |
Abort. |
| 1759 |
End __. |
| 1760 |
End debugging_25519_to_bytes_bedrock2. |
| 1761 |
|
| 1762 |
Local Instance : should_split_multiret_opt := false. |
| 1763 |
Local Instance : split_multiret_to_opt := None. |
| 1764 |
|
| 1765 |
Module debugging_25519_to_bytes_java. |
| 1766 |
Import Crypto.PushButtonSynthesis.UnsaturatedSolinas. |
| 1767 |
Import Stringification.Java. |
| 1768 |
Section __. |
| 1769 |
Local Existing Instance Java.OutputJavaAPI. |
| 1770 |
Local Instance static : static_opt := false. |
| 1771 |
Local Instance : internal_static_opt := true. |
| 1772 |
Local Instance : inline_opt := true. |
| 1773 |
Local Instance : inline_internal_opt := true. |
| 1774 |
Local Instance : emit_primitives_opt := true. |
| 1775 |
Local Instance : use_mul_for_cmovznz_opt := true. |
| 1776 |
Local Instance : widen_carry_opt := true. |
| 1777 |
Local Instance : widen_bytes_opt := true. |
| 1778 |
Local Instance : only_signed_opt := true. |
| 1779 |
Local Instance : no_select_opt := false. |
| 1780 |
Local Instance : should_split_mul_opt := false. (* only for x64 *) |
| 1781 |
|
| 1782 |
Definition n := 2%nat (*10%nat*). |
| 1783 |
Definition s := 2^51 (* 255*). |
| 1784 |
Definition c := [(1, 19)]. |
| 1785 |
Definition machine_wordsize := 32. |
| 1786 |
|
| 1787 |
Import IR.Compilers.ToString. |
| 1788 |
|
| 1789 |
Goal True. |
| 1790 |
pose (sto_bytes n s c machine_wordsize "curve25519") as v. |
| 1791 |
cbv [sto_bytes] in v. |
| 1792 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 1793 |
vm_compute in k. |
| 1794 |
subst k. |
| 1795 |
cbv beta iota zeta in v. |
| 1796 |
let k' := fresh in rename v into k'; pose (DebugMonad.Debug.eval_result (snd k')) as v; subst k'. |
| 1797 |
cbv [Rewriter.Util.LetIn.Let_In DebugMonad.Debug.eval_result DebugMonad.Debug.sequence Pipeline.debug_after_rewrite DebugMonad.Debug.ret] in v. |
| 1798 |
vm_compute Pipeline.debug_rewriting in v. |
| 1799 |
unfold DebugMonad.Debug.bind in (value of v) at 1; cbn [snd] in v. |
| 1800 |
set (k := Language.Compilers.ToString.ToFunctionLines _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) in (value of v). |
| 1801 |
clear v. |
| 1802 |
cbv [Language.Compilers.ToString.ToFunctionLines] in k. |
| 1803 |
cbv [Java.OutputJavaAPI] in k. |
| 1804 |
cbv [Language.Compilers.ToString.ToFunctionLines] in k. |
| 1805 |
cbv [Java.ToFunctionLines] in k. |
| 1806 |
set (k' := IR.OfPHOAS.ExprOfPHOAS _ _ _ _ _ _) in (value of k). |
| 1807 |
clear k. |
| 1808 |
cbv [IR.OfPHOAS.ExprOfPHOAS IR.OfPHOAS.ExprOfPHOAS_cps IR.OfPHOAS.ExprOfPHOAS_with_opt_outbounds_cps IR.OfPHOAS.ExprOfPHOAS_cont] in k'. |
| 1809 |
cbv [IR.OfPHOAS.expr_of_PHOAS IR.OfPHOAS.expr_of_PHOAS_cps IR.OfPHOAS.expr_of_PHOAS_cont] in k'. |
| 1810 |
set (k := IR.OfPHOAS.var_data_of_bounds_and_typedefs _ _ _ _ _) in (value of k'). |
| 1811 |
vm_compute in k. |
| 1812 |
subst k. |
| 1813 |
cbv beta iota zeta in k'. |
| 1814 |
cbv [IR.OfPHOAS.expr_of_PHOAS' IR.OfPHOAS.expr_of_PHOAS'_cps IR.OfPHOAS.expr_of_PHOAS'_cont] in k'. |
| 1815 |
set (k := IR.OfPHOAS.var_data_of_bounds_and_typedefs _ _ _ _ _) in (value of k'). |
| 1816 |
vm_compute in k. |
| 1817 |
subst k. |
| 1818 |
cbv beta iota zeta in k'. |
| 1819 |
cbv [invert_expr.invert_Abs] in k'. |
| 1820 |
cbv [IR.OfPHOAS.expr_of_base_PHOAS] in k'. |
| 1821 |
set (k := IR.OfPHOAS.make_assign_expr_of_PHOAS _ _) in (value of k') at 1. |
| 1822 |
cbv [IR.OfPHOAS.make_assign_expr_of_PHOAS] in k. |
| 1823 |
clear k'. |
| 1824 |
set (k' := type.try_transport _ _ _) in (value of k). |
| 1825 |
vm_compute in k'. |
| 1826 |
subst k'. |
| 1827 |
cbv beta iota zeta in k. |
| 1828 |
set (k' := invert_expr.invert_App_Z_cast2 _) in (value of k). |
| 1829 |
vm_compute in k'. |
| 1830 |
|
| 1831 |
subst k'. |
| 1832 |
cbv beta iota zeta in k. |
| 1833 |
set (k' := invert_expr.invert_AppIdent_curried _) in (value of k); vm_compute in k'; subst k'. |
| 1834 |
cbv beta iota in k. |
| 1835 |
set (k' := IR.OfPHOAS.arith_expr_of_PHOAS_args _) in (value of k). |
| 1836 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS_args] in k'. |
| 1837 |
(*clear k. |
| 1838 |
set (k := IR.OfPHOAS.arith_expr_of_base_PHOAS _ _) in (value of k') at 1. |
| 1839 |
cbv [Language.Compilers.ToString.int.option.None] in k. |
| 1840 |
cbv [IR.OfPHOAS.arith_expr_for_base] in k. |
| 1841 |
cbv [IR.OfPHOAS.arith_expr_of_base_PHOAS] in k. |
| 1842 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS] in k. |
| 1843 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS_ident] in k. |
| 1844 |
cbv [IR.OfPHOAS.arith_expr_of_PHOAS_literal_Z] in k. |
| 1845 |
vm_compute in k.*) |
| 1846 |
vm_compute in k'. |
| 1847 |
subst k'. |
| 1848 |
cbv beta iota zeta in k. |
| 1849 |
set (k' := Crypto.Util.Option.bind _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1850 |
cbv beta iota zeta in k. |
| 1851 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1852 |
cbv beta iota zeta in k. |
| 1853 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1854 |
cbv beta iota zeta in k. |
| 1855 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1856 |
cbv beta iota zeta in k. |
| 1857 |
set (k' := Language.Compilers.ToString.int.of_zrange_relaxed _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1858 |
set (k' := Language.Compilers.ToString.int.of_zrange_relaxed _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1859 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1860 |
cbv beta iota zeta in k. |
| 1861 |
(* |
| 1862 |
set (k' := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1863 |
cbv beta iota zeta in k. |
| 1864 |
set (k' := IR.OfPHOAS.result_upcast _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1865 |
cbv beta iota zeta in k. |
| 1866 |
set (k' := IR.OfPHOAS.result_upcast _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1867 |
cbv beta iota zeta in k. |
| 1868 |
set (k' := IR.OfPHOAS.result_upcast _ _) in (value of k) at 1; vm_compute in k'; subst k'. |
| 1869 |
*) |
| 1870 |
(*cbv |
| 1871 |
vm_compute in k. |
| 1872 |
vm_compute in k'. |
| 1873 |
vm_compute in k'. |
| 1874 |
cbv -[Language.Compilers.ToString.ToFunctionLines] in v. |
| 1875 |
clear v. |
| 1876 |
cbv [to_bytes] in k. |
| 1877 |
cbv [Primitives.possible_values_of_machine_wordsize] in k. |
| 1878 |
cbv [Primitives.possible_values_of_machine_wordsize_with_bytes] in k. |
| 1879 |
cbv [widen_bytes] in k. |
| 1880 |
cbv [widen_bytes_opt_instance_0] in k. |
| 1881 |
cbv [widen_carry] in k. |
| 1882 |
cbv [widen_carry_opt_instance_0] in k. |
| 1883 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline] in k. |
| 1884 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1885 |
set (k' := GeneralizeVar.FromFlat _) in (value of k); vm_compute in k'; subst k'. |
| 1886 |
cbv [CheckedPartialEvaluateWithBounds] in k. |
| 1887 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1888 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k). |
| 1889 |
vm_compute in k'. |
| 1890 |
subst k'. |
| 1891 |
set (k' := CheckCasts.GetUnsupportedCasts _) in (value of k). |
| 1892 |
vm_compute in k'. |
| 1893 |
subst k'. |
| 1894 |
cbv beta iota in k. |
| 1895 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 1896 |
vm_compute in k'; subst k'. |
| 1897 |
cbv beta iota in k. |
| 1898 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 1899 |
vm_compute in k'; subst k'. |
| 1900 |
cbv beta iota in k. |
| 1901 |
cbv [split_multiret_to] in k. |
| 1902 |
cbv [should_split_multiret] in k. |
| 1903 |
cbv [should_split_multiret_opt_instance_0] in k. |
| 1904 |
cbv [split_mul_to] in k. |
| 1905 |
cbv [should_split_mul] in k. |
| 1906 |
cbv [should_split_mul_opt_instance_0] in k. |
| 1907 |
cbv [only_signed_opt_instance_0] in k. |
| 1908 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k) at 2. |
| 1909 |
vm_compute in k'. |
| 1910 |
subst k'. |
| 1911 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k) at 1. |
| 1912 |
vm_compute in k'. |
| 1913 |
subst k'. |
| 1914 |
set (k' := PartialEvaluateWithBounds _ _ _ _ _) in (value of k). |
| 1915 |
vm_compute in k'. |
| 1916 |
subst k'.*) |
| 1917 |
Abort. |
| 1918 |
End __. |
| 1919 |
End debugging_25519_to_bytes_java. |
| 1920 |
|
| 1921 |
Local Instance : only_signed_opt := false. |
| 1922 |
Local Instance : no_select_opt := false. |
| 1923 |
Local Instance : no_select_size_opt := None. |
| 1924 |
|
| 1925 |
Module debugging_p256_uint1. |
| 1926 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 1927 |
Import Crypto.Arithmetic.WordByWordMontgomery.WordByWordMontgomery. |
| 1928 |
Import Stringification.Java. |
| 1929 |
Section __. |
| 1930 |
Local Existing Instance Java.OutputJavaAPI. |
| 1931 |
Local Instance static : static_opt := false. |
| 1932 |
Local Instance : internal_static_opt := true. |
| 1933 |
Local Instance : inline_opt := true. |
| 1934 |
Local Instance : inline_internal_opt := true. |
| 1935 |
Local Instance : emit_primitives_opt := true. |
| 1936 |
Local Instance : use_mul_for_cmovznz_opt := true. |
| 1937 |
Local Instance : widen_carry_opt := true. |
| 1938 |
Local Instance : widen_bytes_opt := true. |
| 1939 |
Local Instance : should_split_mul_opt := false. (* only for x64 *) |
| 1940 |
|
| 1941 |
Context (m : Z := 2^256 - 2^224 + 2^192 + 2^96 - 1) |
| 1942 |
(machine_wordsize : Z := 128). |
| 1943 |
|
| 1944 |
Goal True. |
| 1945 |
pose (smul m machine_wordsize "p256") as v. |
| 1946 |
cbv [smul] in v. |
| 1947 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 1948 |
cbv [WordByWordMontgomery.mul] in k. |
| 1949 |
cbv [Primitives.possible_values_of_machine_wordsize] in k. |
| 1950 |
cbv [widen_carry] in k. |
| 1951 |
cbv [widen_carry_opt_instance_0] in k. |
| 1952 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline] in k. |
| 1953 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1954 |
clear v. |
| 1955 |
let k' := fresh in rename k into k'; pose (DebugMonad.Debug.eval_result k') as k; subst k'. |
| 1956 |
cbv [Rewriter.Util.LetIn.Let_In DebugMonad.Debug.eval_result DebugMonad.Debug.sequence Pipeline.debug_after_rewrite DebugMonad.Debug.ret] in k. |
| 1957 |
vm_compute Pipeline.debug_rewriting in k. |
| 1958 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 1959 |
match (eval cbv delta [k] in k) with |
| 1960 |
| context[CheckedPartialEvaluateWithBounds _ _ _ _ ?e _ _] |
| 1961 |
=> set (k' := e) in (value of k) |
| 1962 |
end; vm_compute in k'; subst k'. |
| 1963 |
cbv [CheckedPartialEvaluateWithBounds] in k. |
| 1964 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 1965 |
set (k' := GeneralizeVar.FromFlat (GeneralizeVar.ToFlat _)) in (value of k). |
| 1966 |
vm_compute in k'. |
| 1967 |
subst k'. |
| 1968 |
set (k' := CheckCasts.GetUnsupportedCasts _) in (value of k). |
| 1969 |
vm_compute in k'. |
| 1970 |
subst k'. |
| 1971 |
cbv beta iota in k. |
| 1972 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 1973 |
vm_compute in k'; subst k'. |
| 1974 |
cbv beta iota in k. |
| 1975 |
cbv [split_mul_to] in k. |
| 1976 |
cbv [should_split_mul] in k. |
| 1977 |
cbv [should_split_mul_opt_instance_0] in k. |
| 1978 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 1979 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 1980 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 1981 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 1982 |
vm_compute in k'; subst k'. |
| 1983 |
cbv beta iota in k. |
| 1984 |
cbv [split_mul_to] in k. |
| 1985 |
cbv [should_split_mul] in k. |
| 1986 |
cbv [should_split_mul_opt_instance_0] in k. |
| 1987 |
cbv [split_multiret_to should_split_multiret should_split_multiret_opt_instance_0] in k. |
| 1988 |
vm_compute ZRange.type.base.option.is_tighter_than in k. |
| 1989 |
cbv beta iota zeta in k. |
| 1990 |
set (k' := PartialEvaluateWithBounds _ _ _ _ _ _) in (value of k) at 1. |
| 1991 |
vm_compute in k'. |
| 1992 |
Abort. |
| 1993 |
End __. |
| 1994 |
End debugging_p256_uint1. |
| 1995 |
|
| 1996 |
Module debugging_go_build0. |
| 1997 |
Import Stringification.Go. |
| 1998 |
Section __. |
| 1999 |
Local Existing Instance Go.OutputGoAPI. |
| 2000 |
Local Instance static : static_opt := false. |
| 2001 |
Local Instance : internal_static_opt := false. |
| 2002 |
Local Instance : inline_opt := false. |
| 2003 |
Local Instance : inline_internal_opt := false. |
| 2004 |
Local Instance : emit_primitives_opt := true. |
| 2005 |
Local Instance : use_mul_for_cmovznz_opt := true. |
| 2006 |
Local Instance : widen_carry_opt := true. |
| 2007 |
Local Instance : widen_bytes_opt := true. |
| 2008 |
Local Instance : should_split_mul_opt := true. (* only for x64 *) |
| 2009 |
|
| 2010 |
Context (n : nat := 3%nat) |
| 2011 |
(s : Z := 2^448) |
| 2012 |
(c : list (Z * Z) := [(2^224,1);(1,1)]) |
| 2013 |
(machine_wordsize : Z := 512/3). |
| 2014 |
(* |
| 2015 |
Goal True. |
| 2016 |
pose (scarry_mul n s c machine_wordsize "p448_") as v. |
| 2017 |
cbv [scarry_mul] in v. |
| 2018 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 2019 |
vm_compute in k. |
| 2020 |
subst k. |
| 2021 |
cbv beta iota in v. |
| 2022 |
cbv [Language.Compilers.ToString.ToFunctionLines] in v. |
| 2023 |
cbv [Go.OutputGoAPI Crypto.Util.Option.sequence_return] in v. |
| 2024 |
cbv [Go.ToFunctionLines] in v. |
| 2025 |
set (k := IR.OfPHOAS.ExprOfPHOAS _ _ _ _) in (value of v). |
| 2026 |
clear v. |
| 2027 |
cbv [IR.OfPHOAS.ExprOfPHOAS IR.OfPHOAS.ExprOfPHOAS_cps IR.OfPHOAS.ExprOfPHOAS_with_opt_outbounds_cps IR.OfPHOAS.ExprOfPHOAS_cont] in k; rename k into v. |
| 2028 |
cbv [IR.OfPHOAS.expr_of_PHOAS IR.OfPHOAS.expr_of_PHOAS_cps IR.OfPHOAS.expr_of_PHOAS_cont] in v. |
| 2029 |
set (k := partial.Extract _ _ _) in (value of v). |
| 2030 |
cbv [partial.Extract] in k. |
| 2031 |
clear v; rename k into v. |
| 2032 |
cbv [partial.ident.extract] in v. |
| 2033 |
cbv [partial.extract_gen] in v. |
| 2034 |
cbv [type.app_curried] in v. |
| 2035 |
cbv delta [partial.extract'] in v. |
| 2036 |
cbv delta [partial.extract_gen] in v. |
| 2037 |
cbv beta in v. |
| 2038 |
cbv [type.app_curried] in v. |
| 2039 |
cbv delta [partial.extract'] in v. |
| 2040 |
cbv beta in v. |
| 2041 |
cbv iota in v; cbv beta in v. |
| 2042 |
cbv iota in v; cbv beta in v. |
| 2043 |
cbv iota in v; cbv beta in v. |
| 2044 |
cbv iota in v; cbv beta in v. |
| 2045 |
cbv iota in v; cbv beta in v. |
| 2046 |
cbv iota in v; cbv beta in v. |
| 2047 |
cbv iota in v; cbv beta in v. |
| 2048 |
cbv iota in v; cbv beta in v. |
| 2049 |
cbv iota in v; cbv beta in v. |
| 2050 |
cbv iota in v; cbv beta in v. |
| 2051 |
cbv iota in v; cbv beta in v. |
| 2052 |
do 50 (cbv iota in v; cbv beta in v). |
| 2053 |
Import Rewriter.Util.LetIn. |
| 2054 |
repeat match (eval cbv [v] in v) with |
| 2055 |
| Let_In ?x ?f |
| 2056 |
=> let x := (eval vm_compute in x) in |
| 2057 |
clear v; pose (f x) as v |
| 2058 |
end. |
| 2059 |
(* |
| 2060 |
cbv beta in v. |
| 2061 |
cbv [partial.abstract_interp_ident] in v. |
| 2062 |
set (k := ZRange.ident.option.interp true Compilers.ident_cons) in (value of v). |
| 2063 |
cbn in k; subst k; cbv beta in v. |
| 2064 |
set (k := ZRange.ident.option.interp true Compilers.ident_nil) in (value of v). |
| 2065 |
cbn in k; subst k; cbv beta in v. |
| 2066 |
cbn [option_map] in v. |
| 2067 |
set (l := ZRange.ident.option.interp true _) in (value of v) at 2; vm_compute in l. |
| 2068 |
subst l. |
| 2069 |
set (l := ZRange.ident.option.interp true _) in (value of v) at 3; vm_compute in l. |
| 2070 |
subst l. |
| 2071 |
set (l := ZRange.ident.option.interp true _) in (value of v) at 4; vm_compute in l. |
| 2072 |
subst l. |
| 2073 |
*) |
| 2074 |
(* |
| 2075 |
cbv [ZRange.ident.option.interp] in v. |
| 2076 |
cbv [ |
| 2077 |
cbv beta zeta delta [Rewriter.Util.LetIn.Let_In]. |
| 2078 |
cbv [partial.extract'] in v. |
| 2079 |
vm_compute in k. |
| 2080 |
vm_compute in k. |
| 2081 |
vm_compute in k; subst k. |
| 2082 |
cbv beta iota zeta in v. |
| 2083 |
set (v' := Go.to_function_lines _ _ _ _) in (value of v). |
| 2084 |
|
| 2085 |
clear v; rename v' into v. |
| 2086 |
cbv [WordByWordMontgomery.add] in k. |
| 2087 |
cbv [Primitives.possible_values_of_machine_wordsize] in k. |
| 2088 |
cbv [widen_carry] in k. |
| 2089 |
cbv [widen_carry_opt_instance_0] in k. |
| 2090 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline] in k. |
| 2091 |
set (k' := GeneralizeVar.ToFlat _) in (value of k). |
| 2092 |
vm_compute in k'; subst k'. |
| 2093 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 2094 |
set (k' := GeneralizeVar.FromFlat _) in (value of k); vm_compute in k'; subst k'. |
| 2095 |
cbv [CheckedPartialEvaluateWithBounds] in k. |
| 2096 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 2097 |
set (k' := CheckCasts.GetUnsupportedCasts _) in (value of k). |
| 2098 |
vm_compute in k'. |
| 2099 |
subst k'. |
| 2100 |
cbv beta iota in k. |
| 2101 |
*) |
| 2102 |
Abort. |
| 2103 |
*) |
| 2104 |
End __. |
| 2105 |
End debugging_go_build0. |
| 2106 |
|
| 2107 |
Module debugging_go_build. |
| 2108 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 2109 |
Import Crypto.Arithmetic.WordByWordMontgomery.WordByWordMontgomery. |
| 2110 |
Import Stringification.Go. |
| 2111 |
Section __. |
| 2112 |
Local Existing Instance Go.OutputGoAPI. |
| 2113 |
Local Instance static : static_opt := false. |
| 2114 |
Local Instance : internal_static_opt := false. |
| 2115 |
Local Instance : inline_opt := false. |
| 2116 |
Local Instance : inline_internal_opt := false. |
| 2117 |
Local Instance : emit_primitives_opt := true. |
| 2118 |
Local Instance : use_mul_for_cmovznz_opt := true. |
| 2119 |
Local Instance : widen_carry_opt := true. |
| 2120 |
Local Instance : widen_bytes_opt := true. |
| 2121 |
Local Instance : should_split_mul_opt := true. (* only for x64 *) |
| 2122 |
|
| 2123 |
Context (m : Z := 2^256 - 2^224 + 2^192 + 2^96 - 1) |
| 2124 |
(machine_wordsize : Z := 64). |
| 2125 |
|
| 2126 |
(* |
| 2127 |
Goal True. |
| 2128 |
pose (sadd m machine_wordsize "p256") as v. |
| 2129 |
cbv [sadd] in v. |
| 2130 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 2131 |
cbv [WordByWordMontgomery.add] in k. |
| 2132 |
cbv [Primitives.possible_values_of_machine_wordsize] in k. |
| 2133 |
cbv [widen_carry] in k. |
| 2134 |
cbv [widen_carry_opt_instance_0] in k. |
| 2135 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline] in k. |
| 2136 |
set (k' := GeneralizeVar.ToFlat _) in (value of k). |
| 2137 |
vm_compute in k'; subst k'. |
| 2138 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 2139 |
set (k' := GeneralizeVar.FromFlat _) in (value of k); vm_compute in k'; subst k'. |
| 2140 |
cbv [CheckedPartialEvaluateWithBounds] in k. |
| 2141 |
cbv [Rewriter.Util.LetIn.Let_In] in k. |
| 2142 |
set (k' := CheckCasts.GetUnsupportedCasts _) in (value of k). |
| 2143 |
vm_compute in k'. |
| 2144 |
subst k'. |
| 2145 |
cbv beta iota in k. |
| 2146 |
set (k' := partial.Extract _ _ _) in (value of k). |
| 2147 |
vm_compute in k'. |
| 2148 |
subst k'. |
| 2149 |
set (k' := ZRange.type.base.option.is_tighter_than _ _) in (value of k). |
| 2150 |
vm_compute in k'; subst k'. |
| 2151 |
cbv beta iota in k. |
| 2152 |
cbv [split_mul_to] in k. |
| 2153 |
cbv [should_split_mul] in k. |
| 2154 |
cbv [should_split_mul_opt_instance_0] in k. |
| 2155 |
set (k' := PartialEvaluateWithBounds _ _ _ _ _ _) in (value of k). |
| 2156 |
vm_compute in k'. |
| 2157 |
subst k'. |
| 2158 |
vm_compute in k. |
| 2159 |
Notation "'λ'" := (expr.Abs _). |
| 2160 |
Notation "'LET'" := (expr.LetIn _ _). |
| 2161 |
subst k. |
| 2162 |
cbv beta iota zeta in v. |
| 2163 |
Arguments String.append !_ !_ / . |
| 2164 |
cbn [String.append List.map List.app String.concat] in v. |
| 2165 |
cbv [Language.Compilers.ToString.ToFunctionLines] in v. |
| 2166 |
cbv [Crypto.Util.Option.sequence_return] in v. |
| 2167 |
cbv [Go.OutputGoAPI] in v. |
| 2168 |
cbn [type.map_for_each_lhs_of_arrow] in v. |
| 2169 |
cbv [Go.ToFunctionLines] in v. |
| 2170 |
set (k := IR.OfPHOAS.ExprOfPHOAS _ _ _ _) in (value of v). |
| 2171 |
clear v. |
| 2172 |
rename k into v. |
| 2173 |
cbn [type.final_codomain] in v. |
| 2174 |
cbn [Language.Compilers.ToString.OfPHOAS.var_data type.for_each_lhs_of_arrow] in v. |
| 2175 |
cbn [Language.Compilers.ToString.OfPHOAS.base_var_data] in v. |
| 2176 |
cbv [IR.OfPHOAS.ExprOfPHOAS IR.OfPHOAS.ExprOfPHOAS_cps IR.OfPHOAS.ExprOfPHOAS_with_opt_outbounds_cps IR.OfPHOAS.ExprOfPHOAS_cont] in v. |
| 2177 |
cbn [IR.OfPHOAS.expr_of_PHOAS IR.OfPHOAS.expr_of_PHOAS_cps IR.OfPHOAS.expr_of_PHOAS_cont] in v. |
| 2178 |
cbv [IR.OfPHOAS.expr_of_PHOAS IR.OfPHOAS.expr_of_PHOAS_cps IR.OfPHOAS.expr_of_PHOAS_cont] in v. |
| 2179 |
set (k := IR.OfPHOAS.var_data_of_bounds _ _ _) in (value of v). |
| 2180 |
vm_compute in k. |
| 2181 |
subst k; cbv beta iota zeta in v. |
| 2182 |
cbn [IR.OfPHOAS.expr_of_PHOAS' IR.OfPHOAS.expr_of_PHOAS'_cps IR.OfPHOAS.expr_of_PHOAS'_cont] in v. |
| 2183 |
set (k := IR.OfPHOAS.var_data_of_bounds _ _ _) in (value of v). |
| 2184 |
vm_compute in k. |
| 2185 |
subst k; cbv beta iota zeta in v. |
| 2186 |
set (k := IR.OfPHOAS.var_data_of_bounds _ _ _) in (value of v). |
| 2187 |
vm_compute in k. |
| 2188 |
subst k; cbv beta iota zeta in v. |
| 2189 |
cbv [Show.show] in v. |
| 2190 |
cbv [Language.Compilers.ToString.PHOAS.type.show] in v. |
| 2191 |
cbn [Language.Compilers.ToString.PHOAS.type.show_type Language.Compilers.ToString.PHOAS.type.base.show] in v. |
| 2192 |
cbv [Language.Compilers.ToString.PHOAS.type.base.show] in v. |
| 2193 |
cbn [Language.Compilers.ToString.PHOAS.type.base.show_type Show.maybe_wrap_parens] in v. |
| 2194 |
cbv [Show.show] in v. |
| 2195 |
cbn [Language.Compilers.ToString.PHOAS.type.base.show_base] in v. |
| 2196 |
cbn [String.append List.map List.app String.concat] in v. |
| 2197 |
unfold invert_expr.invert_Abs at 1 in (value of v). |
| 2198 |
unfold invert_expr.invert_Abs at 1 in (value of v). |
| 2199 |
Time set (F := expr.LetIn _ _) in (value of v). |
| 2200 |
Arguments IR.OfPHOAS.make_assign_expr_of_PHOAS _ / . |
| 2201 |
Arguments Pos.to_nat !_ / . |
| 2202 |
Ltac bar v F X := |
| 2203 |
(time (try lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2204 |
end; |
| 2205 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2206 |
clear F; rename F' into F; subst X; |
| 2207 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v); |
| 2208 |
time (repeat lazymatch (eval cbv [v] in v) with |
| 2209 |
| context C[match ?f ?x with _ => _ end] |
| 2210 |
=> let f' := Tactics.Head.head f in |
| 2211 |
let fx := constr:(f x) in |
| 2212 |
(*idtac fx "(" f' ")";*) |
| 2213 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2214 |
| context C[fx] |
| 2215 |
=> pose fx as k; |
| 2216 |
clear v; |
| 2217 |
let C' := context C[k] in |
| 2218 |
pose C' as v; |
| 2219 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2220 |
end in |
| 2221 |
lazymatch f' with |
| 2222 |
| @type.try_transport => do_vm () |
| 2223 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2224 |
| @invert_expr.invert_App_Z_cast => do_vm () |
| 2225 |
| @invert_expr.invert_App_curried => do_vm () |
| 2226 |
| @Option.bind => do_vm () |
| 2227 |
| @Crypto.Util.Option.bind => do_vm () |
| 2228 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2229 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2230 |
| @fst => do_vm () |
| 2231 |
| @snd => do_vm () |
| 2232 |
| _ => progress cbn [f'] in v |
| 2233 |
end |
| 2234 |
end; |
| 2235 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v); |
| 2236 |
cbn -[F] in v)); |
| 2237 |
time (repeat match (eval cbv [v] in v) with |
| 2238 |
| context C[match match ?x with inl l => @?LX l | inr r => @?RX r end with inl l' => @?L l' | inr r' => @?R r' end] |
| 2239 |
=> let C' := context C[match x with inl l => match LX l with inl l' => L l' | inr r' => R r' end | inr r => match RX r with inl l' => L l' | inr r' => R r' end end] in |
| 2240 |
let C' := (eval cbv beta iota zeta in C') in |
| 2241 |
clear v; pose C' as v |
| 2242 |
end). |
| 2243 |
Arguments IR.name_infos.adjust_dead : simpl never. |
| 2244 |
do 3 bar v F X. |
| 2245 |
do 1 bar v F X. |
| 2246 |
time (try lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2247 |
end; |
| 2248 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2249 |
clear F; rename F' into F; subst X; |
| 2250 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v). |
| 2251 |
cbn [IR.OfPHOAS.make_assign_expr_of_PHOAS] in v. |
| 2252 |
do 4 lazymatch (eval cbv [v] in v) with |
| 2253 |
| context C[match ?f ?x with _ => _ end] |
| 2254 |
=> let f' := Tactics.Head.head f in |
| 2255 |
let fx := constr:(f x) in |
| 2256 |
(*idtac fx "(" f' ")";*) |
| 2257 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2258 |
| context C[fx] |
| 2259 |
=> pose fx as k; |
| 2260 |
clear v; |
| 2261 |
let C' := context C[k] in |
| 2262 |
pose C' as v; |
| 2263 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2264 |
end in |
| 2265 |
lazymatch f' with |
| 2266 |
| @type.try_transport => do_vm () |
| 2267 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2268 |
| @invert_expr.invert_App_Z_cast => do_vm () |
| 2269 |
| @invert_expr.invert_App_curried => do_vm () |
| 2270 |
| @Option.bind => do_vm () |
| 2271 |
| @Crypto.Util.Option.bind => do_vm () |
| 2272 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2273 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2274 |
| @fst => do_vm () |
| 2275 |
| @snd => do_vm () |
| 2276 |
| _ => progress cbn [f'] in v |
| 2277 |
end |
| 2278 |
end. |
| 2279 |
(*do 1 bar v F X. |
| 2280 |
Set Printing Depth 10000000. |
| 2281 |
do 2 bar v F X. |
| 2282 |
do 2 bar v F X. |
| 2283 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2284 |
end; |
| 2285 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2286 |
clear F; rename F' into F; subst X; |
| 2287 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v. |
| 2288 |
cbn [IR.OfPHOAS.make_assign_expr_of_PHOAS] in v.*) |
| 2289 |
(* |
| 2290 |
do 4 lazymatch (eval cbv [v] in v) with |
| 2291 |
| context C[match ?f ?x with _ => _ end] |
| 2292 |
=> let f' := Tactics.Head.head f in |
| 2293 |
let fx := constr:(f x) in |
| 2294 |
(*idtac fx "(" f' ")";*) |
| 2295 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2296 |
| context C[fx] |
| 2297 |
=> pose fx as k; |
| 2298 |
clear v; |
| 2299 |
let C' := context C[k] in |
| 2300 |
pose C' as v; |
| 2301 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2302 |
end in |
| 2303 |
lazymatch f' with |
| 2304 |
| @type.try_transport => do_vm () |
| 2305 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2306 |
| @invert_expr.invert_App_Z_cast => do_vm () |
| 2307 |
| @invert_expr.invert_App_curried => do_vm () |
| 2308 |
| @invert_expr.invert_AppIdent_curried => do_vm () |
| 2309 |
| @Option.bind => do_vm () |
| 2310 |
| @Crypto.Util.Option.bind => do_vm () |
| 2311 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2312 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2313 |
| @fst => do_vm () |
| 2314 |
| @snd => do_vm () |
| 2315 |
| _ => progress cbn [f'] in v |
| 2316 |
end |
| 2317 |
end. |
| 2318 |
set (k := Language.Compilers.ToString.int.type_beq _ _) in (value of v). |
| 2319 |
vm_compute in k. |
| 2320 |
subst k. |
| 2321 |
cbv iota in v; cbv beta in v. |
| 2322 |
subst k; cbv beta iota in v. |
| 2323 |
do 4 lazymatch (eval cbv [v] in v) with |
| 2324 |
| context C[match ?f ?x with _ => _ end] |
| 2325 |
=> let f' := Tactics.Head.head f in |
| 2326 |
let fx := constr:(f x) in |
| 2327 |
(*idtac fx "(" f' ")";*) |
| 2328 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2329 |
| context C[fx] |
| 2330 |
=> pose fx as k; |
| 2331 |
clear v; |
| 2332 |
let C' := context C[k] in |
| 2333 |
pose C' as v; |
| 2334 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2335 |
end in |
| 2336 |
lazymatch f' with |
| 2337 |
| @type.try_transport => do_vm () |
| 2338 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2339 |
| @invert_expr.invert_App_Z_cast => do_vm () |
| 2340 |
| @invert_expr.invert_App_curried => do_vm () |
| 2341 |
| @Option.bind => do_vm () |
| 2342 |
| @Crypto.Util.Option.bind => do_vm () |
| 2343 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2344 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2345 |
| @Language.Compilers.ToString.int.of_zrange_relaxed => do_vm () |
| 2346 |
| @fst => do_vm () |
| 2347 |
| @snd => do_vm () |
| 2348 |
| _ => progress cbn [f'] in v |
| 2349 |
end |
| 2350 |
end. |
| 2351 |
do 1 lazymatch (eval cbv [v] in v) with |
| 2352 |
| context C[match ?f ?x with _ => _ end] |
| 2353 |
=> let f' := Tactics.Head.head f in |
| 2354 |
let fx := constr:(f x) in |
| 2355 |
(*idtac fx "(" f' ")";*) |
| 2356 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2357 |
| context C[fx] |
| 2358 |
=> pose fx as k; |
| 2359 |
clear v; |
| 2360 |
let C' := context C[k] in |
| 2361 |
pose C' as v; |
| 2362 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2363 |
end in |
| 2364 |
lazymatch f' with |
| 2365 |
| @type.try_transport => do_vm () |
| 2366 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2367 |
| @invert_expr.invert_App_Z_cast => do_vm () |
| 2368 |
| @invert_expr.invert_App_curried => do_vm () |
| 2369 |
| @Option.bind => do_vm () |
| 2370 |
| @Crypto.Util.Option.bind => do_vm () |
| 2371 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2372 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2373 |
| @Language.Compilers.ToString.int.of_zrange_relaxed => do_vm () |
| 2374 |
| @NatUtil.nat_beq => do_vm () |
| 2375 |
| @fst => do_vm () |
| 2376 |
| @snd => do_vm () |
| 2377 |
| _ => progress cbn [f'] in v |
| 2378 |
end |
| 2379 |
end. |
| 2380 |
|
| 2381 |
set (k := IR.OfPHOAS.arith_expr_of_base_PHOAS _ _) in (value of v). |
| 2382 |
clear v; rename k into v. |
| 2383 |
cbv [IR.OfPHOAS.arith_expr_of_base_PHOAS] in v. |
| 2384 |
vm_compute in k. |
| 2385 |
subst k; cbv beta iota in v. |
| 2386 |
cbn [IR.OfPHOAS.arith_expr_of_base_PHOAS] in v. |
| 2387 |
set (k := |
| 2388 |
cbn -[F] in v. |
| 2389 |
|
| 2390 |
do 1 bar v F X. |
| 2391 |
Notation "'LL'" := expr.LetIn. |
| 2392 |
|
| 2393 |
subst X; cbn -[F] in v. |
| 2394 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2395 |
end. |
| 2396 |
Time match (eval cbv [F] in F) with context G[expr.LetIn ?x ?f] => set (F' := f) in (value of F); set (X := x) in (value of F) end; |
| 2397 |
subst F; rename F' into F. |
| 2398 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v. |
| 2399 |
set (k := IR.OfPHOAS.make_assign_expr_of_PHOAS _ _ _ _ _ _) in (value of v). |
| 2400 |
clear v. |
| 2401 |
subst X. |
| 2402 |
cbv [IR.OfPHOAS.make_assign_expr_of_PHOAS] in k. |
| 2403 |
set (k' := type.try_transport _ _ _ _) in (value of k). |
| 2404 |
vm_compute in k'; subst k'; cbv beta iota zeta in k. |
| 2405 |
set (k' := invert_expr.invert_App_Z_cast _) in (value of k); vm_compute in k'. |
| 2406 |
subst k'; cbv beta iota zeta in k. |
| 2407 |
set (k' := invert_expr.invert_AppIdent_curried _) in (value of k); vm_compute in k'. |
| 2408 |
subst k'; cbv beta iota zeta in k. |
| 2409 |
set (k' := IR.OfPHOAS.arith_expr_of_PHOAS_args _) in (value of k). |
| 2410 |
vm_compute in k'. |
| 2411 |
subst k'; cbv beta iota zeta in k. |
| 2412 |
set (k' := IR.OfPHOAS.arith_expr_of_base_PHOAS _ _) in (value of k). |
| 2413 |
vm_compute in k'. |
| 2414 |
subst k'; cbv beta iota zeta in k. |
| 2415 |
rename k into v. |
| 2416 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2417 |
end. |
| 2418 |
Time match (eval cbv [F] in F) with context G[expr.LetIn ?x ?f] => set (F' := f) in (value of F); set (X := x) in (value of F) end; |
| 2419 |
subst F; rename F' into F. |
| 2420 |
cbn -[F] in v. |
| 2421 |
subst X. |
| 2422 |
cbv [IR.OfPHOAS.make_assign_expr_of_PHOAS] in v. |
| 2423 |
cbn -[F] in v. |
| 2424 |
About base.try_make_transport_cps. |
| 2425 |
Arguments base.try_make_transport_cps _ _ _ !_ !_ / . |
| 2426 |
cbn -[F] in v. |
| 2427 |
cbn -[F] in v. |
| 2428 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2429 |
end. |
| 2430 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2431 |
clear F; rename F' into F. |
| 2432 |
subst X. |
| 2433 |
cbn -[F] in v. |
| 2434 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2435 |
end; |
| 2436 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2437 |
clear F; rename F' into F; subst X. |
| 2438 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v. |
| 2439 |
cbv [IR.OfPHOAS.make_assign_expr_of_PHOAS] in v. |
| 2440 |
set (k := type.try_transport _ _ _ _) in (value of v). |
| 2441 |
vm_compute in k. |
| 2442 |
subst k; cbv beta iota zeta in v. |
| 2443 |
set (k := invert_expr.invert_App_Z_cast2 _) in (value of v); vm_compute in k. |
| 2444 |
subst k; cbv beta iota zeta in v. |
| 2445 |
set (k := invert_expr.invert_AppIdent_curried _) in (value of v); |
| 2446 |
vm_compute in k. |
| 2447 |
subst k; cbv beta iota zeta in v. |
| 2448 |
set (k := IR.OfPHOAS.arith_expr_of_PHOAS_args _) in (value of v); |
| 2449 |
vm_compute in k. |
| 2450 |
subst k; cbv beta iota zeta in v. |
| 2451 |
set (k := Crypto.Util.Option.bind _ _) in (value of v). |
| 2452 |
vm_compute in k. |
| 2453 |
subst k; cbv beta iota zeta in v. |
| 2454 |
set (k := IR.OfPHOAS.bounds_check _ _ _ _ _ _) in (value of v). |
| 2455 |
vm_compute in k. |
| 2456 |
subst k; cbv beta iota zeta in v. |
| 2457 |
set (k := fst _) in (value of v) at 1. |
| 2458 |
vm_compute in k. |
| 2459 |
subst k; cbv beta iota zeta in v. |
| 2460 |
set (k := snd _) in (value of v) at 1. |
| 2461 |
vm_compute in k. |
| 2462 |
subst k; cbv beta iota zeta in v. |
| 2463 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v). |
| 2464 |
cbn -[F] in v. |
| 2465 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2466 |
end; |
| 2467 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2468 |
clear F; rename F' into F; subst X. |
| 2469 |
do 2 lazymatch (eval cbv [v] in v) with |
| 2470 |
| context[match ?f ?x with _ => _ end] |
| 2471 |
=> let f' := Tactics.Head.head f in |
| 2472 |
lazymatch f' with |
| 2473 |
| _ => cbn [f'] in v |
| 2474 |
end |
| 2475 |
end. |
| 2476 |
do 1 lazymatch (eval cbv [v] in v) with |
| 2477 |
| context[match ?f ?x with _ => _ end] |
| 2478 |
=> let f' := Tactics.Head.head f in |
| 2479 |
lazymatch f' with |
| 2480 |
| @type.try_transport => set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v |
| 2481 |
| _ => cbn [f'] in v |
| 2482 |
end |
| 2483 |
end. |
| 2484 |
do 3 lazymatch (eval cbv [v] in v) with |
| 2485 |
| context[match ?f ?x with _ => _ end] |
| 2486 |
=> let f' := Tactics.Head.head f in |
| 2487 |
let do_vm _ := set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v in |
| 2488 |
lazymatch f' with |
| 2489 |
| @type.try_transport => do_vm () |
| 2490 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2491 |
| @invert_expr.invert_App_curried => do_vm () |
| 2492 |
| _ => progress cbn [f'] in v |
| 2493 |
end |
| 2494 |
end. |
| 2495 |
do 2 lazymatch (eval cbv [v] in v) with |
| 2496 |
| context[match ?f ?x with _ => _ end] |
| 2497 |
=> let f' := Tactics.Head.head f in |
| 2498 |
let do_vm _ := set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v in |
| 2499 |
lazymatch f' with |
| 2500 |
| @type.try_transport => do_vm () |
| 2501 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2502 |
| @invert_expr.invert_App_curried => do_vm () |
| 2503 |
| @Option.bind => do_vm () |
| 2504 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2505 |
| _ => progress cbn [f'] in v |
| 2506 |
end |
| 2507 |
end. |
| 2508 |
do 1 lazymatch (eval cbv [v] in v) with |
| 2509 |
| context[match ?f ?x with _ => _ end] |
| 2510 |
=> let f' := Tactics.Head.head f in |
| 2511 |
let do_vm _ := set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v in |
| 2512 |
lazymatch f' with |
| 2513 |
| @type.try_transport => do_vm () |
| 2514 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2515 |
| @invert_expr.invert_App_curried => do_vm () |
| 2516 |
| @Option.bind => do_vm () |
| 2517 |
| @Crypto.Util.Option.bind => do_vm () |
| 2518 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2519 |
| _ => progress cbn [f'] in v |
| 2520 |
end |
| 2521 |
end. |
| 2522 |
Time do 6 lazymatch (eval cbv [v] in v) with |
| 2523 |
| context[match ?f ?x with _ => _ end] |
| 2524 |
=> let f' := Tactics.Head.head f in |
| 2525 |
let do_vm _ := (set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v) in |
| 2526 |
lazymatch f' with |
| 2527 |
| @type.try_transport => do_vm () |
| 2528 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2529 |
| @invert_expr.invert_App_curried => do_vm () |
| 2530 |
| @Option.bind => do_vm () |
| 2531 |
| @Crypto.Util.Option.bind => do_vm () |
| 2532 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2533 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2534 |
| @fst => do_vm () |
| 2535 |
| @snd => do_vm () |
| 2536 |
| _ => progress cbn [f'] in v |
| 2537 |
end |
| 2538 |
end. |
| 2539 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v). |
| 2540 |
cbn -[F] in v. |
| 2541 |
lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2542 |
end; |
| 2543 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2544 |
clear F; rename F' into F; subst X. |
| 2545 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v. |
| 2546 |
Time do 2 lazymatch (eval cbv [v] in v) with |
| 2547 |
| context[match ?f ?x with _ => _ end] |
| 2548 |
=> let f' := Tactics.Head.head f in |
| 2549 |
let fx := constr:(f x) in |
| 2550 |
idtac fx "(" f' ")"; |
| 2551 |
let do_vm _ := (set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v) in |
| 2552 |
lazymatch f' with |
| 2553 |
| @type.try_transport => do_vm () |
| 2554 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2555 |
| @invert_expr.invert_App_curried => do_vm () |
| 2556 |
| @Option.bind => do_vm () |
| 2557 |
| @Crypto.Util.Option.bind => do_vm () |
| 2558 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2559 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2560 |
| @fst => do_vm () |
| 2561 |
| @snd => do_vm () |
| 2562 |
| _ => progress cbn [f'] in v |
| 2563 |
end |
| 2564 |
end. |
| 2565 |
Time do 2 lazymatch (eval cbv [v] in v) with |
| 2566 |
| context[match ?f ?x with _ => _ end] |
| 2567 |
=> let f' := Tactics.Head.head f in |
| 2568 |
let fx := constr:(f x) in |
| 2569 |
idtac fx "(" f' ")"; |
| 2570 |
let do_vm _ := (set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v) in |
| 2571 |
lazymatch f' with |
| 2572 |
| @type.try_transport => do_vm () |
| 2573 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2574 |
| @invert_expr.invert_App_curried => do_vm () |
| 2575 |
| @Option.bind => do_vm () |
| 2576 |
| @Crypto.Util.Option.bind => do_vm () |
| 2577 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2578 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2579 |
| @fst => do_vm () |
| 2580 |
| @snd => do_vm () |
| 2581 |
| _ => progress cbn [f'] in v |
| 2582 |
end |
| 2583 |
end. |
| 2584 |
Time do 2 lazymatch (eval cbv [v] in v) with |
| 2585 |
| context[match ?f ?x with _ => _ end] |
| 2586 |
=> let f' := Tactics.Head.head f in |
| 2587 |
let fx := constr:(f x) in |
| 2588 |
idtac fx "(" f' ")"; |
| 2589 |
let do_vm _ := (set (k := f x) in (value of v); vm_compute in k; subst k; cbv beta iota in v) in |
| 2590 |
lazymatch f' with |
| 2591 |
| @type.try_transport => do_vm () |
| 2592 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2593 |
| @invert_expr.invert_App_curried => do_vm () |
| 2594 |
| @Option.bind => do_vm () |
| 2595 |
| @Crypto.Util.Option.bind => do_vm () |
| 2596 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2597 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2598 |
| @fst => do_vm () |
| 2599 |
| @snd => do_vm () |
| 2600 |
| _ => progress cbn [f'] in v |
| 2601 |
end |
| 2602 |
end. |
| 2603 |
Time repeat lazymatch (eval cbv [v] in v) with |
| 2604 |
| context C[match ?f ?x with _ => _ end] |
| 2605 |
=> let f' := Tactics.Head.head f in |
| 2606 |
let fx := constr:(f x) in |
| 2607 |
(*idtac fx "(" f' ")";*) |
| 2608 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2609 |
| context C[fx] |
| 2610 |
=> pose fx as k; |
| 2611 |
clear v; |
| 2612 |
let C' := context C[k] in |
| 2613 |
pose C' as v; |
| 2614 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2615 |
end in |
| 2616 |
lazymatch f' with |
| 2617 |
| @type.try_transport => do_vm () |
| 2618 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2619 |
| @invert_expr.invert_App_curried => do_vm () |
| 2620 |
| @Option.bind => do_vm () |
| 2621 |
| @Crypto.Util.Option.bind => do_vm () |
| 2622 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2623 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2624 |
| @fst => do_vm () |
| 2625 |
| @snd => do_vm () |
| 2626 |
| _ => progress cbn [f'] in v |
| 2627 |
end |
| 2628 |
end; |
| 2629 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v); |
| 2630 |
cbn -[F] in v. |
| 2631 |
do 2 (time (lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2632 |
end; |
| 2633 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2634 |
clear F; rename F' into F; subst X; |
| 2635 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v); |
| 2636 |
time (repeat lazymatch (eval cbv [v] in v) with |
| 2637 |
| context C[match ?f ?x with _ => _ end] |
| 2638 |
=> let f' := Tactics.Head.head f in |
| 2639 |
let fx := constr:(f x) in |
| 2640 |
(*idtac fx "(" f' ")";*) |
| 2641 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2642 |
| context C[fx] |
| 2643 |
=> pose fx as k; |
| 2644 |
clear v; |
| 2645 |
let C' := context C[k] in |
| 2646 |
pose C' as v; |
| 2647 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2648 |
end in |
| 2649 |
lazymatch f' with |
| 2650 |
| @type.try_transport => do_vm () |
| 2651 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2652 |
| @invert_expr.invert_App_curried => do_vm () |
| 2653 |
| @Option.bind => do_vm () |
| 2654 |
| @Crypto.Util.Option.bind => do_vm () |
| 2655 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2656 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2657 |
| @fst => do_vm () |
| 2658 |
| @snd => do_vm () |
| 2659 |
| _ => progress cbn [f'] in v |
| 2660 |
end |
| 2661 |
end; |
| 2662 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v); |
| 2663 |
cbn -[F] in v)). |
| 2664 |
do 4 (time (lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2665 |
end; |
| 2666 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2667 |
clear F; rename F' into F; subst X; |
| 2668 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v); |
| 2669 |
time (repeat lazymatch (eval cbv [v] in v) with |
| 2670 |
| context C[match ?f ?x with _ => _ end] |
| 2671 |
=> let f' := Tactics.Head.head f in |
| 2672 |
let fx := constr:(f x) in |
| 2673 |
(*idtac fx "(" f' ")";*) |
| 2674 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2675 |
| context C[fx] |
| 2676 |
=> pose fx as k; |
| 2677 |
clear v; |
| 2678 |
let C' := context C[k] in |
| 2679 |
pose C' as v; |
| 2680 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2681 |
end in |
| 2682 |
lazymatch f' with |
| 2683 |
| @type.try_transport => do_vm () |
| 2684 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2685 |
| @invert_expr.invert_App_curried => do_vm () |
| 2686 |
| @Option.bind => do_vm () |
| 2687 |
| @Crypto.Util.Option.bind => do_vm () |
| 2688 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2689 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2690 |
| @fst => do_vm () |
| 2691 |
| @snd => do_vm () |
| 2692 |
| _ => progress cbn [f'] in v |
| 2693 |
end |
| 2694 |
end; |
| 2695 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v); |
| 2696 |
cbn -[F] in v)). |
| 2697 |
Set Printing Depth 10000000. |
| 2698 |
Ltac foo v F X := |
| 2699 |
(time (lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2700 |
end; |
| 2701 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2702 |
clear F; rename F' into F; subst X; |
| 2703 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v); |
| 2704 |
time (repeat lazymatch (eval cbv [v] in v) with |
| 2705 |
| context C[match ?f ?x with _ => _ end] |
| 2706 |
=> let f' := Tactics.Head.head f in |
| 2707 |
let fx := constr:(f x) in |
| 2708 |
(*idtac fx "(" f' ")";*) |
| 2709 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2710 |
| context C[fx] |
| 2711 |
=> pose fx as k; |
| 2712 |
clear v; |
| 2713 |
let C' := context C[k] in |
| 2714 |
pose C' as v; |
| 2715 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2716 |
end in |
| 2717 |
lazymatch f' with |
| 2718 |
| @type.try_transport => do_vm () |
| 2719 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2720 |
| @invert_expr.invert_App_curried => do_vm () |
| 2721 |
| @Option.bind => do_vm () |
| 2722 |
| @Crypto.Util.Option.bind => do_vm () |
| 2723 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2724 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2725 |
| @fst => do_vm () |
| 2726 |
| @snd => do_vm () |
| 2727 |
| _ => progress cbn [f'] in v |
| 2728 |
end |
| 2729 |
end; |
| 2730 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v); |
| 2731 |
cbn -[F] in v)); |
| 2732 |
time (repeat match (eval cbv [v] in v) with |
| 2733 |
| context C[match match ?x with inl l => @?LX l | inr r => @?RX r end with inl l' => @?L l' | inr r' => @?R r' end] |
| 2734 |
=> let C' := context C[match x with inl l => match LX l with inl l' => L l' | inr r' => R r' end | inr r => match RX r with inl l' => L l' | inr r' => R r' end end] in |
| 2735 |
let C' := (eval cbv beta iota zeta in C') in |
| 2736 |
clear v; pose C' as v |
| 2737 |
end). |
| 2738 |
do 2 foo v F X. |
| 2739 |
Import ListNotations. |
| 2740 |
do 4 foo v F X. |
| 2741 |
Ltac bar v F X := |
| 2742 |
(time (lazymatch (eval cbv [v] in v) with context[F ?x] => pose (F x) as F'; change (F x) with F' in (value of v); subst F; rename F' into F; cbv beta iota zeta in F, v |
| 2743 |
end; |
| 2744 |
lazymatch (eval cbv [F] in F) with @expr.LetIn ?b ?i ?v ?A ?B ?x ?f => pose f as F'; pose x as X; change F with (@expr.LetIn b i v A B X F') in * end; |
| 2745 |
clear F; rename F' into F; subst X; |
| 2746 |
cbn [IR.OfPHOAS.expr_of_base_PHOAS] in v); |
| 2747 |
time (repeat lazymatch (eval cbv [v] in v) with |
| 2748 |
| context C[match ?f ?x with _ => _ end] |
| 2749 |
=> let f' := Tactics.Head.head f in |
| 2750 |
let fx := constr:(f x) in |
| 2751 |
(*idtac fx "(" f' ")";*) |
| 2752 |
let do_vm _ := lazymatch (eval cbv [v] in v) with |
| 2753 |
| context C[fx] |
| 2754 |
=> pose fx as k; |
| 2755 |
clear v; |
| 2756 |
let C' := context C[k] in |
| 2757 |
pose C' as v; |
| 2758 |
(vm_compute in k; subst k; cbv beta iota in v) |
| 2759 |
end in |
| 2760 |
lazymatch f' with |
| 2761 |
| @type.try_transport => do_vm () |
| 2762 |
| @invert_expr.invert_App_Z_cast2 => do_vm () |
| 2763 |
| @invert_expr.invert_App_curried => do_vm () |
| 2764 |
| @Option.bind => do_vm () |
| 2765 |
| @Crypto.Util.Option.bind => do_vm () |
| 2766 |
| @IR.OfPHOAS.arith_expr_of_PHOAS_args => do_vm () |
| 2767 |
| @IR.OfPHOAS.bounds_check => do_vm () |
| 2768 |
| @fst => do_vm () |
| 2769 |
| @snd => do_vm () |
| 2770 |
| _ => progress cbn [f'] in v |
| 2771 |
end |
| 2772 |
end; |
| 2773 |
repeat (set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v); |
| 2774 |
cbn -[F] in v)). |
| 2775 |
bar v F X. |
| 2776 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end. |
| 2777 |
bar v F X. |
| 2778 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end. |
| 2779 |
bar v F X. |
| 2780 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end. |
| 2781 |
do 5 (bar v F X; |
| 2782 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end). |
| 2783 |
do 5 (bar v F X; |
| 2784 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end). |
| 2785 |
do 5 (bar v F X; |
| 2786 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end). |
| 2787 |
do 5 (bar v F X; |
| 2788 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end). |
| 2789 |
do 50 (bar v F X; |
| 2790 |
match (eval cbv [v] in v) with match ?x with _ => _ end => clear v; pose x as v end). |
| 2791 |
Notation "'LL'" := expr.LetIn. |
| 2792 |
|
| 2793 |
vm_compute in v. |
| 2794 |
Set Printing All. |
| 2795 |
do 4 foo v F X. |
| 2796 |
do 16 foo v F X. |
| 2797 |
do 4 foo v F X. |
| 2798 |
Arguments |
| 2799 |
|
| 2800 |
set (k := option_map _ _) in (value of v) at 1; vm_compute in k; subst k; cbv beta iota in v. |
| 2801 |
cbn [fst snd] in k. |
| 2802 |
clear v. |
| 2803 |
Arguments Z.pow_pos _ / . |
| 2804 |
Arguments Language.Compilers.ToString.int.of_zrange_relaxed _ / . |
| 2805 |
Arguments Language.Compilers.ToString.int.union _ / . |
| 2806 |
Arguments Language.Compilers.ToString.int.bitwidth_of _ / . |
| 2807 |
Arguments Language.Compilers.ToString.int.lgbitwidth_of _ / . |
| 2808 |
cbn [Z.pow Z.sub Z.add Z.mul Z.pow_pos Pos.iter Pos.mul Z.opp Z.pos_sub Pos.pred_double Pos.add Pos.succ Z.log2_up Z.compare Z.eqb Z.ltb Z.eqb Pos.compare Pos.compare_cont Z.pred Z.log2 Z.succ Pos.size Z.max Z.leb Z.to_nat Pos.to_nat Pos.iter_op Nat.add Z.of_nat Pos.iter Z.mul Pos.of_succ_nat Z.max Z.min |
| 2809 |
Language.Compilers.ToString.int.of_zrange_relaxed |
| 2810 |
option_map |
| 2811 |
lower upper |
| 2812 |
Language.Compilers.ToString.int.union Language.Compilers.ToString.int.to_zrange Language.Compilers.ToString.int.is_signed Language.Compilers.ToString.int.bitwidth_of Language.Compilers.ToString.int.lgbitwidth_of |
| 2813 |
Operations.ZRange.union |
| 2814 |
] in k. |
| 2815 |
cbn [Z.pow Z.sub Z.add Z.mul Z.pow_pos Pos.iter Pos.mul Z.opp Z.pos_sub Pos.pred_double Pos.add Pos.succ Z.log2_up Z.compare Z.eqb Z.ltb Z.eqb Pos.compare Pos.compare_cont Z.pred Z.log2 Z.succ Pos.size Z.max Z.leb Z.to_nat Pos.to_nat Pos.iter_op Nat.add Z.of_nat Pos.iter Z.mul Pos.of_succ_nat] in k. |
| 2816 |
cbn [Operations.ZRange.union lower upper] in k. |
| 2817 |
cbn [Z.pow Z.sub Z.add Z.mul Z.pow_pos Pos.iter Pos.mul Z.opp Z.pos_sub Pos.pred_double Pos.add Pos.succ Z.log2_up Z.compare Z.eqb Z.ltb Z.eqb Pos.compare Pos.compare_cont Z.pred Z.log2 Z.succ Pos.size Z.max Z.leb Z.to_nat Pos.to_nat Pos.iter_op Nat.add Z.of_nat Pos.iter Z.mul Pos.of_succ_nat Z.max Z.min] in k. |
| 2818 |
cbn [Language.Compilers.ToString.int.of_zrange_relaxed lower upper] in k. |
| 2819 |
cbn [] in k. |
| 2820 |
. |
| 2821 |
|
| 2822 |
cbn in k. |
| 2823 |
cbn in k. |
| 2824 |
subst k; cbv beta iota zeta in v. |
| 2825 |
set (k := option_map _ _) in (value of v) at 1; vm_compute in k. |
| 2826 |
subst k; cbv beta iota zeta in v. |
| 2827 |
cbn -[F] in v. |
| 2828 |
subst X |
| 2829 |
vm_compute in k. |
| 2830 |
vm_compute in k. |
| 2831 |
subst k; cbv beta iota zeta in v. |
| 2832 |
|
| 2833 |
vm |
| 2834 |
set (k := (1 + 1)%Z) in (value of v). |
| 2835 |
vm_compute in v. |
| 2836 |
vm_compute in k. |
| 2837 |
cbn [String |
| 2838 |
|
| 2839 |
|
| 2840 |
vm_compute in v. |
| 2841 |
pose (match snd v as v' return match v' with ErrorT.Error _ => _ | _ => _ end with |
| 2842 |
| ErrorT.Error v => v |
| 2843 |
| _ => I |
| 2844 |
end) as v'. |
| 2845 |
vm_compute in v'; clear v. |
| 2846 |
pose (Show.show_lines false v') as s. |
| 2847 |
cbv [Show.show_lines] in s. |
| 2848 |
cbv [Pipeline.show_lines_ErrorMessage] in s. |
| 2849 |
lazymatch (eval cbv [v'] in v') with context[fun var => @?F var] => set (F' := F) in (value of v') end. |
| 2850 |
subst v'. |
| 2851 |
cbv beta iota zeta in s. |
| 2852 |
cbv [Show.maybe_wrap_parens_lines Show.show_lines Language.Compilers.ToString.PHOAS.expr.show_lines_Expr] in s. |
| 2853 |
cbn [List.app] in s. |
| 2854 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_lines_Expr] in s. |
| 2855 |
subst F'; cbv beta iota zeta in s. |
| 2856 |
match (eval cbv [s] in s) with context G[expr.Abs ?f] => set (F := f) in (value of s) end. |
| 2857 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_lines_expr] in s. |
| 2858 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_eta_cps] in s. |
| 2859 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in s. |
| 2860 |
lazymatch (eval cbv [s] in s) with context[F ?v] => pose (F v) as F'; change (F v) with F' in (value of s); subst F; rename F' into F; cbv beta iota zeta in F, s |
| 2861 |
end. |
| 2862 |
match (eval cbv [F] in F) with context G[expr.Abs ?f] => set (F' := f) in (value of F) end; |
| 2863 |
subst F; rename F' into F. |
| 2864 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in s. |
| 2865 |
set (k := Decimal.decimal_string_of_pos 1) in (value of s); vm_compute in k; subst k. |
| 2866 |
set (k := Decimal.decimal_string_of_pos _) in (value of s); vm_compute in k; subst k. |
| 2867 |
cbn [String.append] in s. |
| 2868 |
set (k := Pos.succ 1) in (value of s); vm_compute in k; subst k. |
| 2869 |
set (k := Pos.succ _) in (value of s); vm_compute in k; subst k. |
| 2870 |
cbn [String.append List.map List.app] in s. |
| 2871 |
lazymatch (eval cbv [s] in s) with context[F ?v] => pose (F v) as F'; change (F v) with F' in (value of s); subst F; rename F' into F; cbv beta iota zeta in F, s |
| 2872 |
end. |
| 2873 |
match (eval cbv [F] in F) with context G[expr.LetIn ?x ?f] => set (F' := f) in (value of F); set (X := x) in (value of F) end; |
| 2874 |
subst F; rename F' into F. |
| 2875 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in s. |
| 2876 |
cbv [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in s. |
| 2877 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_expr_lines] in s. |
| 2878 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_eta_cps] in s. |
| 2879 |
set (k := Decimal.decimal_string_of_pos _) in (value of s); vm_compute in k; subst k. |
| 2880 |
set (k := Pos.succ _) in (value of s); vm_compute in k; subst k. |
| 2881 |
cbn [String.append List.map List.app] in s. |
| 2882 |
repeat match (eval cbv [s] in s) with |
| 2883 |
| context C[let '(c, d) := let '(a, b) := ?x in @?F a b in @?G c d] |
| 2884 |
=> let C' := context C[let '(a, b) := x in let '(c, d) := F a b in G c d] in |
| 2885 |
clear s; pose C' as s; cbv beta iota zeta in s |
| 2886 |
end. |
| 2887 |
vm_compute in s. |
| 2888 |
set (XX := Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps' _ _ X) in (value of s). |
| 2889 |
clear s. |
| 2890 |
subst X. |
| 2891 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in XX. |
| 2892 |
|
| 2893 |
set (k := Decimal.decimal_string_of_pos _) in (value of XX); vm_compute in k; subst k. |
| 2894 |
cbn [String.append List.map List.app] in XX. |
| 2895 |
cbn [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in XX. |
| 2896 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_expr_lines] in XX. |
| 2897 |
repeat match (eval cbv [XX] in XX) with |
| 2898 |
| context C[let '(c, d) := let '(a, b) := ?x in @?F a b in @?G c d] |
| 2899 |
=> let C' := context C[let '(a, b) := x in let '(c, d) := F a b in G c d] in |
| 2900 |
clear XX; pose C' as XX; cbv beta iota zeta in XX |
| 2901 |
end. |
| 2902 |
unfold Language.Compilers.ToString.PHOAS.expr.show_eta_cps at 1 in (value of XX). |
| 2903 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in XX. |
| 2904 |
cbn [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in XX. |
| 2905 |
cbn [String.append List.map List.app String.concat] in XX. |
| 2906 |
repeat match (eval cbv [XX] in XX) with |
| 2907 |
| context C[let '(c, d) := let '(a, b) := ?x in @?F a b in @?G c d] |
| 2908 |
=> let C' := context C[let '(a, b) := x in let '(c, d) := F a b in G c d] in |
| 2909 |
clear XX; pose C' as XX; cbv beta iota zeta in XX |
| 2910 |
end. |
| 2911 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_expr_lines] in XX. |
| 2912 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_eta_cps] in XX. |
| 2913 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in XX. |
| 2914 |
cbv [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in XX. |
| 2915 |
set (k := Language.Compilers.ToString.PHOAS.expr.show_expr_lines _ _ _ _ _) in (value of XX) at 1. |
| 2916 |
vm_compute in k. |
| 2917 |
subst k; cbv beta iota zeta in XX. |
| 2918 |
set (k := Language.Compilers.ToString.PHOAS.expr.show_expr_lines _ _ _ _ _) in (value of XX) at 1. |
| 2919 |
vm_compute in k. |
| 2920 |
subst k; cbv beta iota zeta in XX. |
| 2921 |
set (k := Language.Compilers.ToString.PHOAS.expr.show_expr_lines _ _ _ _ _) in (value of XX) at 1. |
| 2922 |
vm_compute in k. |
| 2923 |
subst k; cbv beta iota zeta in XX. |
| 2924 |
set (k := Language.Compilers.ToString.PHOAS.ident.show_ident_lvl _ _ _) in (value of XX). |
| 2925 |
cbn in k. |
| 2926 |
subst k; cbv beta iota zeta in XX. |
| 2927 |
cbv [Ascii.NewLine] in XX. |
| 2928 |
cbn [String.append List.map List.app String.concat] in XX.*) |
| 2929 |
Abort. |
| 2930 |
*) |
| 2931 |
End __. |
| 2932 |
End debugging_go_build. |
| 2933 |
|
| 2934 |
Module debugging_go_output. |
| 2935 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 2936 |
Import Crypto.Arithmetic.WordByWordMontgomery.WordByWordMontgomery. |
| 2937 |
Import Stringification.Go. |
| 2938 |
Section __. |
| 2939 |
Local Existing Instance Go.OutputGoAPI. |
| 2940 |
Local Instance static : static_opt := false. |
| 2941 |
Local Instance : internal_static_opt := false. |
| 2942 |
Local Instance : inline_opt := false. |
| 2943 |
Local Instance : inline_internal_opt := false. |
| 2944 |
Local Instance : emit_primitives_opt := true. |
| 2945 |
Local Instance : use_mul_for_cmovznz_opt := true. |
| 2946 |
Local Instance : widen_carry_opt := true. |
| 2947 |
Local Instance : widen_bytes_opt := true. |
| 2948 |
Local Instance : should_split_mul_opt := true. (* only for x64 *) |
| 2949 |
|
| 2950 |
Context (m : Z := 2^256 - 2^224 + 2^192 + 2^96 - 1) |
| 2951 |
(machine_wordsize : Z := 64). |
| 2952 |
|
| 2953 |
(* |
| 2954 |
Goal True. |
| 2955 |
pose (smul m machine_wordsize "p256") as v. |
| 2956 |
cbv [smul] in v. |
| 2957 |
vm_compute in v. |
| 2958 |
pose (match snd v as v' return match v' with ErrorT.Error _ => _ | _ => _ end with |
| 2959 |
| ErrorT.Error v => v |
| 2960 |
| _ => I |
| 2961 |
end) as v'. |
| 2962 |
vm_compute in v'; clear v. |
| 2963 |
pose (Show.show_lines false v') as s. |
| 2964 |
cbv [Show.show_lines] in s. |
| 2965 |
cbv [Pipeline.show_lines_ErrorMessage] in s. |
| 2966 |
(* |
| 2967 |
lazymatch (eval cbv [v'] in v') with context[fun var => @?F var] => set (F' := F) in (value of v') end. |
| 2968 |
subst v'. |
| 2969 |
cbv beta iota zeta in s. |
| 2970 |
cbv [Show.maybe_wrap_parens_lines Show.show_lines Language.Compilers.ToString.PHOAS.expr.show_lines_Expr] in s. |
| 2971 |
cbn [List.app] in s. |
| 2972 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_lines_Expr] in s. |
| 2973 |
subst F'; cbv beta iota zeta in s. |
| 2974 |
match (eval cbv [s] in s) with context G[expr.Abs ?f] => set (F := f) in (value of s) end. |
| 2975 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_lines_expr] in s. |
| 2976 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_eta_cps] in s. |
| 2977 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in s. |
| 2978 |
Notation "'λ'" := (expr.Abs _). |
| 2979 |
Notation "'LET'" := (expr.LetIn _ _). |
| 2980 |
lazymatch (eval cbv [s] in s) with context[F ?v] => pose (F v) as F'; change (F v) with F' in (value of s); subst F; rename F' into F; cbv beta iota zeta in F, s |
| 2981 |
end. |
| 2982 |
match (eval cbv [F] in F) with context G[expr.Abs ?f] => set (F' := f) in (value of F) end; |
| 2983 |
subst F; rename F' into F. |
| 2984 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in s. |
| 2985 |
set (k := Decimal.decimal_string_of_pos 1) in (value of s); vm_compute in k; subst k. |
| 2986 |
set (k := Decimal.decimal_string_of_pos _) in (value of s); vm_compute in k; subst k. |
| 2987 |
Arguments String.append !_ !_ / . |
| 2988 |
cbn [String.append] in s. |
| 2989 |
set (k := Pos.succ 1) in (value of s); vm_compute in k; subst k. |
| 2990 |
set (k := Pos.succ _) in (value of s); vm_compute in k; subst k. |
| 2991 |
cbn [String.append List.map List.app] in s. |
| 2992 |
lazymatch (eval cbv [s] in s) with context[F ?v] => pose (F v) as F'; change (F v) with F' in (value of s); subst F; rename F' into F; cbv beta iota zeta in F, s |
| 2993 |
end. |
| 2994 |
match (eval cbv [F] in F) with context G[expr.LetIn ?x ?f] => set (F' := f) in (value of F); set (X := x) in (value of F) end; |
| 2995 |
subst F; rename F' into F. |
| 2996 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in s. |
| 2997 |
cbv [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in s. |
| 2998 |
progress cbn [Language.Compilers.ToString.PHOAS.expr.show_expr_lines] in s. |
| 2999 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_eta_cps] in s. |
| 3000 |
set (k := Decimal.decimal_string_of_pos _) in (value of s); vm_compute in k; subst k. |
| 3001 |
set (k := Pos.succ _) in (value of s); vm_compute in k; subst k. |
| 3002 |
cbn [String.append List.map List.app] in s. |
| 3003 |
repeat match (eval cbv [s] in s) with |
| 3004 |
| context C[let '(c, d) := let '(a, b) := ?x in @?F a b in @?G c d] |
| 3005 |
=> let C' := context C[let '(a, b) := x in let '(c, d) := F a b in G c d] in |
| 3006 |
clear s; pose C' as s; cbv beta iota zeta in s |
| 3007 |
end. |
| 3008 |
vm_compute in s. |
| 3009 |
set (XX := Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps' _ _ X) in (value of s). |
| 3010 |
clear s. |
| 3011 |
subst X. |
| 3012 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in XX. |
| 3013 |
|
| 3014 |
set (k := Decimal.decimal_string_of_pos _) in (value of XX); vm_compute in k; subst k. |
| 3015 |
cbn [String.append List.map List.app] in XX. |
| 3016 |
cbn [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in XX. |
| 3017 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_expr_lines] in XX. |
| 3018 |
repeat match (eval cbv [XX] in XX) with |
| 3019 |
| context C[let '(c, d) := let '(a, b) := ?x in @?F a b in @?G c d] |
| 3020 |
=> let C' := context C[let '(a, b) := x in let '(c, d) := F a b in G c d] in |
| 3021 |
clear XX; pose C' as XX; cbv beta iota zeta in XX |
| 3022 |
end. |
| 3023 |
unfold Language.Compilers.ToString.PHOAS.expr.show_eta_cps at 1 in (value of XX). |
| 3024 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in XX. |
| 3025 |
cbn [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in XX. |
| 3026 |
cbn [String.append List.map List.app String.concat] in XX. |
| 3027 |
repeat match (eval cbv [XX] in XX) with |
| 3028 |
| context C[let '(c, d) := let '(a, b) := ?x in @?F a b in @?G c d] |
| 3029 |
=> let C' := context C[let '(a, b) := x in let '(c, d) := F a b in G c d] in |
| 3030 |
clear XX; pose C' as XX; cbv beta iota zeta in XX |
| 3031 |
end. |
| 3032 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_expr_lines] in XX. |
| 3033 |
cbv [Language.Compilers.ToString.PHOAS.expr.show_eta_cps] in XX. |
| 3034 |
cbn [Language.Compilers.ToString.PHOAS.expr.show_eta_abs_cps'] in XX. |
| 3035 |
cbv [Language.Compilers.ToString.PHOAS.expr.get_eta_cps_args] in XX. |
| 3036 |
set (k := Language.Compilers.ToString.PHOAS.expr.show_expr_lines _ _ _ _ _) in (value of XX) at 1. |
| 3037 |
vm_compute in k. |
| 3038 |
subst k; cbv beta iota zeta in XX. |
| 3039 |
set (k := Language.Compilers.ToString.PHOAS.expr.show_expr_lines _ _ _ _ _) in (value of XX) at 1. |
| 3040 |
vm_compute in k. |
| 3041 |
subst k; cbv beta iota zeta in XX. |
| 3042 |
set (k := Language.Compilers.ToString.PHOAS.expr.show_expr_lines _ _ _ _ _) in (value of XX) at 1. |
| 3043 |
vm_compute in k. |
| 3044 |
subst k; cbv beta iota zeta in XX. |
| 3045 |
set (k := Language.Compilers.ToString.PHOAS.ident.show_ident_lvl _ _ _) in (value of XX). |
| 3046 |
cbn in k. |
| 3047 |
subst k; cbv beta iota zeta in XX. |
| 3048 |
cbv [Ascii.NewLine] in XX. |
| 3049 |
cbn [String.append List.map List.app String.concat] in XX.*) |
| 3050 |
Abort. |
| 3051 |
*) |
| 3052 |
End __. |
| 3053 |
End debugging_go_output. |
| 3054 |
|
| 3055 |
Import Stringification.C. |
| 3056 |
Import Stringification.C.Compilers. |
| 3057 |
|
| 3058 |
Local Existing Instance ToString.C.OutputCAPI. |
| 3059 |
Local Instance static : static_opt := true. |
| 3060 |
Local Instance : internal_static_opt := true. |
| 3061 |
Local Instance : inline_opt := true. |
| 3062 |
Local Instance : inline_internal_opt := true. |
| 3063 |
Local Instance : use_mul_for_cmovznz_opt := false. |
| 3064 |
Local Instance : emit_primitives_opt := true. |
| 3065 |
|
| 3066 |
Module debugging_remove_mul_split_to_C_uint1_carry. |
| 3067 |
Import PreExtra. |
| 3068 |
Import LetIn. |
| 3069 |
Section __. |
| 3070 |
Context (n : nat := 5%nat) |
| 3071 |
(s : Z := 2^255) |
| 3072 |
(c : list (Z * Z) := [(1,19)]) |
| 3073 |
(machine_wordsize : Z := 64) |
| 3074 |
(should_split_mul : should_split_mul_opt := true) |
| 3075 |
(widen_carry : widen_carry_opt := true) |
| 3076 |
(widen_bytes : widen_bytes_opt := false). |
| 3077 |
|
| 3078 |
Local Existing Instances should_split_mul widen_carry widen_bytes. |
| 3079 |
|
| 3080 |
Let limbwidth := (Z.log2_up (s - Associational.eval c) / Z.of_nat n)%Q. |
| 3081 |
Let idxs := (List.seq 0 n ++ [0; 1])%list%nat. |
| 3082 |
|
| 3083 |
Definition possible_values_of_machine_wordsize |
| 3084 |
:= prefix_with_carry [machine_wordsize; 2 * machine_wordsize]%Z. |
| 3085 |
|
| 3086 |
Let possible_values := possible_values_of_machine_wordsize. |
| 3087 |
|
| 3088 |
Local Instance split_mul_to : split_mul_to_opt := split_mul_to_of_should_split_mul machine_wordsize possible_values. |
| 3089 |
|
| 3090 |
Let prime_upperbound_list : list Z |
| 3091 |
:= Partition.partition (weight (Qnum limbwidth) (Qden limbwidth)) n (s-1). |
| 3092 |
Let tight_upperbounds : list Z |
| 3093 |
:= List.map |
| 3094 |
(fun v : Z => Qceiling (11/10 * v)) |
| 3095 |
prime_upperbound_list. |
| 3096 |
Definition tight_bounds : list (ZRange.type.option.interp base.type.Z) |
| 3097 |
:= List.map (fun u => Some r[0~>u]%zrange) tight_upperbounds. |
| 3098 |
Definition loose_bounds : list (ZRange.type.option.interp base.type.Z) |
| 3099 |
:= List.map (fun u => Some r[0 ~> 3*u]%zrange) tight_upperbounds. |
| 3100 |
|
| 3101 |
|
| 3102 |
Let limbwidth_num := Eval vm_compute in Qnum limbwidth. |
| 3103 |
Let limbwidth_den := Eval vm_compute in QDen limbwidth. |
| 3104 |
|
| 3105 |
Set Printing Depth 100000. |
| 3106 |
Local Open Scope string_scope. |
| 3107 |
|
| 3108 |
Redirect "log" |
| 3109 |
Compute |
| 3110 |
Pipeline.BoundsPipelineToString |
| 3111 |
"" (* prefix *) |
| 3112 |
"mul" |
| 3113 |
false (* subst01 *) |
| 3114 |
false (* inline *) |
| 3115 |
possible_values |
| 3116 |
machine_wordsize |
| 3117 |
ltac:(let r := Reify ((fun f g => dlet _ := ident.comment ("foo", f, g) in carry_mulmod limbwidth_num limbwidth_den s c n idxs f g)) in |
| 3118 |
exact r) |
| 3119 |
(fun _ _ => []) (* comment *) |
| 3120 |
(Some loose_bounds, (Some loose_bounds, tt)) |
| 3121 |
(Some tight_bounds) |
| 3122 |
(None, (None, tt)) |
| 3123 |
None |
| 3124 |
: Pipeline.ErrorT _ |
| 3125 |
. |
| 3126 |
(* /* |
| 3127 |
* Input Bounds: |
| 3128 |
* arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] |
| 3129 |
* arg2: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] |
| 3130 |
* Output Bounds: |
| 3131 |
* out1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] |
| 3132 |
*/ |
| 3133 |
static void mul(uint64_t out1[5], const uint64_t arg1[5], const uint64_t arg2[5]) { |
| 3134 |
/* (""foo"", arg1[0] :: arg1[1] :: arg1[2] :: arg1[3] :: arg1[4] :: [], arg2[0] :: arg2[1] :: arg2[2] :: arg2[3] :: arg2[4] :: []) */ |
| 3135 |
uint64_t x1; |
| 3136 |
uint64_t x2; |
| 3137 |
mulx_u64(&x1, &x2, (arg1[4]), ((arg2[4]) * (uint64_t)UINT8_C(0x13))); |
| 3138 |
uint64_t x3; |
| 3139 |
uint64_t x4; |
| 3140 |
mulx_u64(&x3, &x4, (arg1[4]), ((arg2[3]) * (uint64_t)UINT8_C(0x13))); |
| 3141 |
uint64_t x5; |
| 3142 |
uint64_t x6; |
| 3143 |
mulx_u64(&x5, &x6, (arg1[4]), ((arg2[2]) * (uint64_t)UINT8_C(0x13))); |
| 3144 |
uint64_t x7; |
| 3145 |
uint64_t x8; |
| 3146 |
mulx_u64(&x7, &x8, (arg1[4]), ((arg2[1]) * (uint64_t)UINT8_C(0x13))); |
| 3147 |
uint64_t x9; |
| 3148 |
uint64_t x10; |
| 3149 |
mulx_u64(&x9, &x10, (arg1[3]), ((arg2[4]) * (uint64_t)UINT8_C(0x13))); |
| 3150 |
uint64_t x11; |
| 3151 |
uint64_t x12; |
| 3152 |
mulx_u64(&x11, &x12, (arg1[3]), ((arg2[3]) * (uint64_t)UINT8_C(0x13))); |
| 3153 |
uint64_t x13; |
| 3154 |
uint64_t x14; |
| 3155 |
mulx_u64(&x13, &x14, (arg1[3]), ((arg2[2]) * (uint64_t)UINT8_C(0x13))); |
| 3156 |
uint64_t x15; |
| 3157 |
uint64_t x16; |
| 3158 |
mulx_u64(&x15, &x16, (arg1[2]), ((arg2[4]) * (uint64_t)UINT8_C(0x13))); |
| 3159 |
uint64_t x17; |
| 3160 |
uint64_t x18; |
| 3161 |
mulx_u64(&x17, &x18, (arg1[2]), ((arg2[3]) * (uint64_t)UINT8_C(0x13))); |
| 3162 |
uint64_t x19; |
| 3163 |
uint64_t x20; |
| 3164 |
mulx_u64(&x19, &x20, (arg1[1]), ((arg2[4]) * (uint64_t)UINT8_C(0x13))); |
| 3165 |
uint64_t x21; |
| 3166 |
uint64_t x22; |
| 3167 |
mulx_u64(&x21, &x22, (arg1[4]), (arg2[0])); |
| 3168 |
uint64_t x23; |
| 3169 |
uint64_t x24; |
| 3170 |
mulx_u64(&x23, &x24, (arg1[3]), (arg2[1])); |
| 3171 |
uint64_t x25; |
| 3172 |
uint64_t x26; |
| 3173 |
mulx_u64(&x25, &x26, (arg1[3]), (arg2[0])); |
| 3174 |
uint64_t x27; |
| 3175 |
uint64_t x28; |
| 3176 |
mulx_u64(&x27, &x28, (arg1[2]), (arg2[2])); |
| 3177 |
uint64_t x29; |
| 3178 |
uint64_t x30; |
| 3179 |
mulx_u64(&x29, &x30, (arg1[2]), (arg2[1])); |
| 3180 |
uint64_t x31; |
| 3181 |
uint64_t x32; |
| 3182 |
mulx_u64(&x31, &x32, (arg1[2]), (arg2[0])); |
| 3183 |
uint64_t x33; |
| 3184 |
uint64_t x34; |
| 3185 |
mulx_u64(&x33, &x34, (arg1[1]), (arg2[3])); |
| 3186 |
uint64_t x35; |
| 3187 |
uint64_t x36; |
| 3188 |
mulx_u64(&x35, &x36, (arg1[1]), (arg2[2])); |
| 3189 |
uint64_t x37; |
| 3190 |
uint64_t x38; |
| 3191 |
mulx_u64(&x37, &x38, (arg1[1]), (arg2[1])); |
| 3192 |
uint64_t x39; |
| 3193 |
uint64_t x40; |
| 3194 |
mulx_u64(&x39, &x40, (arg1[1]), (arg2[0])); |
| 3195 |
uint64_t x41; |
| 3196 |
uint64_t x42; |
| 3197 |
mulx_u64(&x41, &x42, (arg1[0]), (arg2[4])); |
| 3198 |
uint64_t x43; |
| 3199 |
uint64_t x44; |
| 3200 |
mulx_u64(&x43, &x44, (arg1[0]), (arg2[3])); |
| 3201 |
uint64_t x45; |
| 3202 |
uint64_t x46; |
| 3203 |
mulx_u64(&x45, &x46, (arg1[0]), (arg2[2])); |
| 3204 |
uint64_t x47; |
| 3205 |
uint64_t x48; |
| 3206 |
mulx_u64(&x47, &x48, (arg1[0]), (arg2[1])); |
| 3207 |
uint64_t x49; |
| 3208 |
uint64_t x50; |
| 3209 |
mulx_u64(&x49, &x50, (arg1[0]), (arg2[0])); |
| 3210 |
uint64_t x51; |
| 3211 |
uint1 x52; |
| 3212 |
addcarryx_u64(&x51, &x52, 0x0, x13, x7); |
| 3213 |
uint64_t x53; |
| 3214 |
uint1 x54; |
| 3215 |
addcarryx_u64(&x53, &x54, x52, x14, x8); |
| 3216 |
uint64_t x55; |
| 3217 |
uint1 x56; |
| 3218 |
addcarryx_u64(&x55, &x56, 0x0, x17, x51); |
| 3219 |
uint64_t x57; |
| 3220 |
uint1 x58; |
| 3221 |
addcarryx_u64(&x57, &x58, x56, x18, x53); |
| 3222 |
uint64_t x59; |
| 3223 |
uint1 x60; |
| 3224 |
addcarryx_u64(&x59, &x60, 0x0, x19, x55); |
| 3225 |
uint64_t x61; |
| 3226 |
uint1 x62; |
| 3227 |
addcarryx_u64(&x61, &x62, x60, x20, x57); |
| 3228 |
uint64_t x63; |
| 3229 |
uint1 x64; |
| 3230 |
addcarryx_u64(&x63, &x64, 0x0, x49, x59); |
| 3231 |
uint64_t x65; |
| 3232 |
uint1 x66; |
| 3233 |
addcarryx_u64(&x65, &x66, x64, x50, x61); |
| 3234 |
uint64_t x67 = ((x63 >> 51) | ((x65 << 13) & UINT64_C(0xffffffffffffffff))); |
| 3235 |
uint64_t x68 = (x63 & UINT64_C(0x7ffffffffffff)); |
| 3236 |
uint64_t x69; |
| 3237 |
uint1 x70; |
| 3238 |
addcarryx_u64(&x69, &x70, 0x0, x23, x21); |
| 3239 |
uint64_t x71; |
| 3240 |
uint1 x72; |
| 3241 |
addcarryx_u64(&x71, &x72, x70, x24, x22); |
| 3242 |
uint64_t x73; |
| 3243 |
uint1 x74; |
| 3244 |
addcarryx_u64(&x73, &x74, 0x0, x27, x69); |
| 3245 |
uint64_t x75; |
| 3246 |
uint1 x76; |
| 3247 |
addcarryx_u64(&x75, &x76, x74, x28, x71); |
| 3248 |
uint64_t x77; |
| 3249 |
uint1 x78; |
| 3250 |
addcarryx_u64(&x77, &x78, 0x0, x33, x73); |
| 3251 |
uint64_t x79; |
| 3252 |
uint1 x80; |
| 3253 |
addcarryx_u64(&x79, &x80, x78, x34, x75); |
| 3254 |
uint64_t x81; |
| 3255 |
uint1 x82; |
| 3256 |
addcarryx_u64(&x81, &x82, 0x0, x41, x77); |
| 3257 |
uint64_t x83; |
| 3258 |
uint1 x84; |
| 3259 |
addcarryx_u64(&x83, &x84, x82, x42, x79); |
| 3260 |
uint64_t x85; |
| 3261 |
uint1 x86; |
| 3262 |
addcarryx_u64(&x85, &x86, 0x0, x25, x1); |
| 3263 |
uint64_t x87; |
| 3264 |
uint1 x88; |
| 3265 |
addcarryx_u64(&x87, &x88, x86, x26, x2); |
| 3266 |
uint64_t x89; |
| 3267 |
uint1 x90; |
| 3268 |
addcarryx_u64(&x89, &x90, 0x0, x29, x85); |
| 3269 |
uint64_t x91; |
| 3270 |
uint1 x92; |
| 3271 |
addcarryx_u64(&x91, &x92, x90, x30, x87); |
| 3272 |
uint64_t x93; |
| 3273 |
uint1 x94; |
| 3274 |
addcarryx_u64(&x93, &x94, 0x0, x35, x89); |
| 3275 |
uint64_t x95; |
| 3276 |
uint1 x96; |
| 3277 |
addcarryx_u64(&x95, &x96, x94, x36, x91); |
| 3278 |
uint64_t x97; |
| 3279 |
uint1 x98; |
| 3280 |
addcarryx_u64(&x97, &x98, 0x0, x43, x93); |
| 3281 |
uint64_t x99; |
| 3282 |
uint1 x100; |
| 3283 |
addcarryx_u64(&x99, &x100, x98, x44, x95); |
| 3284 |
uint64_t x101; |
| 3285 |
uint1 x102; |
| 3286 |
addcarryx_u64(&x101, &x102, 0x0, x9, x3); |
| 3287 |
uint64_t x103; |
| 3288 |
uint1 x104; |
| 3289 |
addcarryx_u64(&x103, &x104, x102, x10, x4); |
| 3290 |
uint64_t x105; |
| 3291 |
uint1 x106; |
| 3292 |
addcarryx_u64(&x105, &x106, 0x0, x31, x101); |
| 3293 |
uint64_t x107; |
| 3294 |
uint1 x108; |
| 3295 |
addcarryx_u64(&x107, &x108, x106, x32, x103); |
| 3296 |
uint64_t x109; |
| 3297 |
uint1 x110; |
| 3298 |
addcarryx_u64(&x109, &x110, 0x0, x37, x105); |
| 3299 |
uint64_t x111; |
| 3300 |
uint1 x112; |
| 3301 |
addcarryx_u64(&x111, &x112, x110, x38, x107); |
| 3302 |
uint64_t x113; |
| 3303 |
uint1 x114; |
| 3304 |
addcarryx_u64(&x113, &x114, 0x0, x45, x109); |
| 3305 |
uint64_t x115; |
| 3306 |
uint1 x116; |
| 3307 |
addcarryx_u64(&x115, &x116, x114, x46, x111); |
| 3308 |
uint64_t x117; |
| 3309 |
uint1 x118; |
| 3310 |
addcarryx_u64(&x117, &x118, 0x0, x11, x5); |
| 3311 |
uint64_t x119; |
| 3312 |
uint1 x120; |
| 3313 |
addcarryx_u64(&x119, &x120, x118, x12, x6); |
| 3314 |
uint64_t x121; |
| 3315 |
uint1 x122; |
| 3316 |
addcarryx_u64(&x121, &x122, 0x0, x15, x117); |
| 3317 |
uint64_t x123; |
| 3318 |
uint1 x124; |
| 3319 |
addcarryx_u64(&x123, &x124, x122, x16, x119); |
| 3320 |
uint64_t x125; |
| 3321 |
uint1 x126; |
| 3322 |
addcarryx_u64(&x125, &x126, 0x0, x39, x121); |
| 3323 |
uint64_t x127; |
| 3324 |
uint1 x128; |
| 3325 |
addcarryx_u64(&x127, &x128, x126, x40, x123); |
| 3326 |
uint64_t x129; |
| 3327 |
uint1 x130; |
| 3328 |
addcarryx_u64(&x129, &x130, 0x0, x47, x125); |
| 3329 |
uint64_t x131; |
| 3330 |
uint1 x132; |
| 3331 |
addcarryx_u64(&x131, &x132, x130, x48, x127); |
| 3332 |
uint64_t x133; |
| 3333 |
uint1 x134; |
| 3334 |
addcarryx_u64(&x133, &x134, 0x0, x67, x129); |
| 3335 |
uint64_t x135 = (x134 + x131); |
| 3336 |
uint64_t x136 = ((x133 >> 51) | ((x135 << 13) & UINT64_C(0xffffffffffffffff))); |
| 3337 |
uint64_t x137 = (x133 & UINT64_C(0x7ffffffffffff)); |
| 3338 |
uint64_t x138; |
| 3339 |
uint1 x139; |
| 3340 |
addcarryx_u64(&x138, &x139, 0x0, x136, x113); |
| 3341 |
uint64_t x140 = (x139 + x115); |
| 3342 |
uint64_t x141 = ((x138 >> 51) | ((x140 << 13) & UINT64_C(0xffffffffffffffff))); |
| 3343 |
uint64_t x142 = (x138 & UINT64_C(0x7ffffffffffff)); |
| 3344 |
uint64_t x143; |
| 3345 |
uint1 x144; |
| 3346 |
addcarryx_u64(&x143, &x144, 0x0, x141, x97); |
| 3347 |
uint64_t x145 = (x144 + x99); |
| 3348 |
uint64_t x146 = ((x143 >> 51) | ((x145 << 13) & UINT64_C(0xffffffffffffffff))); |
| 3349 |
uint64_t x147 = (x143 & UINT64_C(0x7ffffffffffff)); |
| 3350 |
uint64_t x148; |
| 3351 |
uint1 x149; |
| 3352 |
addcarryx_u64(&x148, &x149, 0x0, x146, x81); |
| 3353 |
uint64_t x150 = (x149 + x83); |
| 3354 |
uint64_t x151 = ((x148 >> 51) | ((x150 << 13) & UINT64_C(0xffffffffffffffff))); |
| 3355 |
uint64_t x152 = (x148 & UINT64_C(0x7ffffffffffff)); |
| 3356 |
uint64_t x153 = (x151 * (uint64_t)UINT8_C(0x13)); |
| 3357 |
uint64_t x154 = (x68 + x153); |
| 3358 |
uint64_t x155 = (x154 >> 51); |
| 3359 |
uint64_t x156 = (x154 & UINT64_C(0x7ffffffffffff)); |
| 3360 |
uint64_t x157 = (x155 + x137); |
| 3361 |
uint64_t x158 = (x157 >> 51); |
| 3362 |
uint64_t x159 = (x157 & UINT64_C(0x7ffffffffffff)); |
| 3363 |
uint64_t x160 = (x158 + x142); |
| 3364 |
out1[0] = x156; |
| 3365 |
out1[1] = x159; |
| 3366 |
out1[2] = x160; |
| 3367 |
out1[3] = x147; |
| 3368 |
out1[4] = x152; |
| 3369 |
} |
| 3370 |
*) |
| 3371 |
End __. |
| 3372 |
End debugging_remove_mul_split_to_C_uint1_carry. |
| 3373 |
|
| 3374 |
Module debugging_remove_mul_split. |
| 3375 |
Section __. |
| 3376 |
Context (n : nat := 5%nat) |
| 3377 |
(s : Z := 2^255) |
| 3378 |
(c : list (Z * Z) := [(1,19)]) |
| 3379 |
(machine_wordsize : Z := 64) |
| 3380 |
(should_split_mul : should_split_mul_opt := true) |
| 3381 |
(widen_carry : widen_carry_opt := true) |
| 3382 |
(widen_bytes : widen_bytes_opt := true). |
| 3383 |
|
| 3384 |
Local Existing Instances should_split_mul widen_carry widen_bytes. |
| 3385 |
|
| 3386 |
Let limbwidth := (Z.log2_up (s - Associational.eval c) / Z.of_nat n)%Q. |
| 3387 |
Let idxs := (List.seq 0 n ++ [0; 1])%list%nat. |
| 3388 |
|
| 3389 |
Definition possible_values_of_machine_wordsize |
| 3390 |
:= prefix_with_carry [machine_wordsize; 2 * machine_wordsize]%Z. |
| 3391 |
|
| 3392 |
Let possible_values := possible_values_of_machine_wordsize. |
| 3393 |
|
| 3394 |
Local Instance split_mul_to : split_mul_to_opt := split_mul_to_of_should_split_mul machine_wordsize possible_values. |
| 3395 |
|
| 3396 |
Let prime_upperbound_list : list Z |
| 3397 |
:= Partition.partition (weight (Qnum limbwidth) (Qden limbwidth)) n (s-1). |
| 3398 |
Let tight_upperbounds : list Z |
| 3399 |
:= List.map |
| 3400 |
(fun v : Z => Qceiling (11/10 * v)) |
| 3401 |
prime_upperbound_list. |
| 3402 |
Definition tight_bounds : list (ZRange.type.option.interp base.type.Z) |
| 3403 |
:= List.map (fun u => Some r[0~>u]%zrange) tight_upperbounds. |
| 3404 |
Definition loose_bounds : list (ZRange.type.option.interp base.type.Z) |
| 3405 |
:= List.map (fun u => Some r[0 ~> 3*u]%zrange) tight_upperbounds. |
| 3406 |
|
| 3407 |
|
| 3408 |
Let limbwidth_num := Eval vm_compute in Qnum limbwidth. |
| 3409 |
Let limbwidth_den := Eval vm_compute in QDen limbwidth. |
| 3410 |
|
| 3411 |
Set Printing Depth 100000. |
| 3412 |
Local Open Scope string_scope. |
| 3413 |
Local Notation "'uint64,uint64'" := (ident.Z_cast2 |
| 3414 |
(r[0 ~> 18446744073709551615]%zrange, |
| 3415 |
r[0 ~> 18446744073709551615]%zrange)%core) : expr_scope. |
| 3416 |
Local Notation "'uint64'" := (ident.Z_cast r[0 ~> 18446744073709551615]%zrange) : expr_scope. |
| 3417 |
Local Open Scope expr_scope. |
| 3418 |
Local Open Scope core_scope. |
| 3419 |
Redirect "log" Compute |
| 3420 |
Pipeline.BoundsPipeline |
| 3421 |
false (* subst01 *) |
| 3422 |
possible_values |
| 3423 |
ltac:(let r := Reify ((carry_mulmod limbwidth_num limbwidth_den s c n idxs)) in |
| 3424 |
exact r) |
| 3425 |
(Some loose_bounds, (Some loose_bounds, tt)) |
| 3426 |
(Some tight_bounds). |
| 3427 |
(* = ErrorT.Success |
| 3428 |
(fun var : type -> Type => |
| 3429 |
λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 3430 |
expr_let x1 := ((#uint64,uint64)%expr @ |
| 3431 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3432 |
((#uint64)%expr @ ($$x [[4]])) @ |
| 3433 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[4]]))%expr_pat * ##19))))%expr_pat in |
| 3434 |
expr_let x2 := ((#uint64,uint64)%expr @ |
| 3435 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3436 |
((#uint64)%expr @ ($$x [[4]])) @ |
| 3437 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[3]]))%expr_pat * ##19))))%expr_pat in |
| 3438 |
expr_let x3 := ((#uint64,uint64)%expr @ |
| 3439 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3440 |
((#uint64)%expr @ ($$x [[4]])) @ |
| 3441 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[2]]))%expr_pat * ##19))))%expr_pat in |
| 3442 |
expr_let x4 := ((#uint64,uint64)%expr @ |
| 3443 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3444 |
((#uint64)%expr @ ($$x [[4]])) @ |
| 3445 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[1]]))%expr_pat * ##19))))%expr_pat in |
| 3446 |
expr_let x5 := ((#uint64,uint64)%expr @ |
| 3447 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3448 |
((#uint64)%expr @ ($$x [[3]])) @ |
| 3449 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[4]]))%expr_pat * ##19))))%expr_pat in |
| 3450 |
expr_let x6 := ((#uint64,uint64)%expr @ |
| 3451 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3452 |
((#uint64)%expr @ ($$x [[3]])) @ |
| 3453 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[3]]))%expr_pat * ##19))))%expr_pat in |
| 3454 |
expr_let x7 := ((#uint64,uint64)%expr @ |
| 3455 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3456 |
((#uint64)%expr @ ($$x [[3]])) @ |
| 3457 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[2]]))%expr_pat * ##19))))%expr_pat in |
| 3458 |
expr_let x8 := ((#uint64,uint64)%expr @ |
| 3459 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3460 |
((#uint64)%expr @ ($$x [[2]])) @ |
| 3461 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[4]]))%expr_pat * ##19))))%expr_pat in |
| 3462 |
expr_let x9 := ((#uint64,uint64)%expr @ |
| 3463 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3464 |
((#uint64)%expr @ ($$x [[2]])) @ |
| 3465 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[3]]))%expr_pat * ##19))))%expr_pat in |
| 3466 |
expr_let x10 := ((#uint64,uint64)%expr @ |
| 3467 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3468 |
((#uint64)%expr @ ($$x [[1]])) @ |
| 3469 |
((#uint64)%expr @ (((#uint64)%expr @ ($$x0 [[4]]))%expr_pat * ##19))))%expr_pat in |
| 3470 |
expr_let x11 := ((#uint64,uint64)%expr @ |
| 3471 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3472 |
((#uint64)%expr @ ($$x [[4]])) @ ((#uint64)%expr @ ($$x0 [[0]]))))%expr_pat in |
| 3473 |
expr_let x12 := ((#uint64,uint64)%expr @ |
| 3474 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3475 |
((#uint64)%expr @ ($$x [[3]])) @ ((#uint64)%expr @ ($$x0 [[1]]))))%expr_pat in |
| 3476 |
expr_let x13 := ((#uint64,uint64)%expr @ |
| 3477 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3478 |
((#uint64)%expr @ ($$x [[3]])) @ ((#uint64)%expr @ ($$x0 [[0]]))))%expr_pat in |
| 3479 |
expr_let x14 := ((#uint64,uint64)%expr @ |
| 3480 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3481 |
((#uint64)%expr @ ($$x [[2]])) @ ((#uint64)%expr @ ($$x0 [[2]]))))%expr_pat in |
| 3482 |
expr_let x15 := ((#uint64,uint64)%expr @ |
| 3483 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3484 |
((#uint64)%expr @ ($$x [[2]])) @ ((#uint64)%expr @ ($$x0 [[1]]))))%expr_pat in |
| 3485 |
expr_let x16 := ((#uint64,uint64)%expr @ |
| 3486 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3487 |
((#uint64)%expr @ ($$x [[2]])) @ ((#uint64)%expr @ ($$x0 [[0]]))))%expr_pat in |
| 3488 |
expr_let x17 := ((#uint64,uint64)%expr @ |
| 3489 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3490 |
((#uint64)%expr @ ($$x [[1]])) @ ((#uint64)%expr @ ($$x0 [[3]]))))%expr_pat in |
| 3491 |
expr_let x18 := ((#uint64,uint64)%expr @ |
| 3492 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3493 |
((#uint64)%expr @ ($$x [[1]])) @ ((#uint64)%expr @ ($$x0 [[2]]))))%expr_pat in |
| 3494 |
expr_let x19 := ((#uint64,uint64)%expr @ |
| 3495 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3496 |
((#uint64)%expr @ ($$x [[1]])) @ ((#uint64)%expr @ ($$x0 [[1]]))))%expr_pat in |
| 3497 |
expr_let x20 := ((#uint64,uint64)%expr @ |
| 3498 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3499 |
((#uint64)%expr @ ($$x [[1]])) @ ((#uint64)%expr @ ($$x0 [[0]]))))%expr_pat in |
| 3500 |
expr_let x21 := ((#uint64,uint64)%expr @ |
| 3501 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3502 |
((#uint64)%expr @ ($$x [[0]])) @ ((#uint64)%expr @ ($$x0 [[4]]))))%expr_pat in |
| 3503 |
expr_let x22 := ((#uint64,uint64)%expr @ |
| 3504 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3505 |
((#uint64)%expr @ ($$x [[0]])) @ ((#uint64)%expr @ ($$x0 [[3]]))))%expr_pat in |
| 3506 |
expr_let x23 := ((#uint64,uint64)%expr @ |
| 3507 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3508 |
((#uint64)%expr @ ($$x [[0]])) @ ((#uint64)%expr @ ($$x0 [[2]]))))%expr_pat in |
| 3509 |
expr_let x24 := ((#uint64,uint64)%expr @ |
| 3510 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3511 |
((#uint64)%expr @ ($$x [[0]])) @ ((#uint64)%expr @ ($$x0 [[1]]))))%expr_pat in |
| 3512 |
expr_let x25 := ((#uint64,uint64)%expr @ |
| 3513 |
((#ident.Z_mul_split)%expr @ ##18446744073709551616 @ |
| 3514 |
((#uint64)%expr @ ($$x [[0]])) @ ((#uint64)%expr @ ($$x0 [[0]]))))%expr_pat in |
| 3515 |
expr_let x26 := ((#uint64,uint64)%expr @ |
| 3516 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3517 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x7)) @ |
| 3518 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x4))))%expr_pat in |
| 3519 |
expr_let x27 := ((#uint64,uint64)%expr @ |
| 3520 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3521 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x26)) @ |
| 3522 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x7)) @ |
| 3523 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x4))))%expr_pat in |
| 3524 |
expr_let x28 := ((#uint64,uint64)%expr @ |
| 3525 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3526 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x9)) @ |
| 3527 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x26))))%expr_pat in |
| 3528 |
expr_let x29 := ((#uint64,uint64)%expr @ |
| 3529 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3530 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x28)) @ |
| 3531 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x9)) @ |
| 3532 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x27))))%expr_pat in |
| 3533 |
expr_let x30 := ((#uint64,uint64)%expr @ |
| 3534 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3535 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x10)) @ |
| 3536 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x28))))%expr_pat in |
| 3537 |
expr_let x31 := ((#uint64,uint64)%expr @ |
| 3538 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3539 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x30)) @ |
| 3540 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x10)) @ |
| 3541 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x29))))%expr_pat in |
| 3542 |
expr_let x32 := ((#uint64,uint64)%expr @ |
| 3543 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3544 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x25)) @ |
| 3545 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x30))))%expr_pat in |
| 3546 |
expr_let x33 := ((#uint64,uint64)%expr @ |
| 3547 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3548 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x32)) @ |
| 3549 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x25)) @ |
| 3550 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x31))))%expr_pat in |
| 3551 |
expr_let x34 := ((#uint64)%expr @ |
| 3552 |
(((#uint64)%expr @ |
| 3553 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x32))%expr_pat >> ##51))%expr_pat |
| 3554 |
|| ((#uint64)%expr @ |
| 3555 |
((#ident.Z_truncating_shiftl)%expr @ ##64 @ |
| 3556 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x33)) @ ##13))%expr_pat))%expr_pat in |
| 3557 |
expr_let x35 := ((#uint64)%expr @ |
| 3558 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x32))%expr_pat &' |
| 3559 |
##2251799813685247))%expr_pat in |
| 3560 |
expr_let x36 := ((#uint64,uint64)%expr @ |
| 3561 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3562 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x12)) @ |
| 3563 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x11))))%expr_pat in |
| 3564 |
expr_let x37 := ((#uint64,uint64)%expr @ |
| 3565 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3566 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x36)) @ |
| 3567 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x12)) @ |
| 3568 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x11))))%expr_pat in |
| 3569 |
expr_let x38 := ((#uint64,uint64)%expr @ |
| 3570 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3571 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x14)) @ |
| 3572 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x36))))%expr_pat in |
| 3573 |
expr_let x39 := ((#uint64,uint64)%expr @ |
| 3574 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3575 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x38)) @ |
| 3576 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x14)) @ |
| 3577 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x37))))%expr_pat in |
| 3578 |
expr_let x40 := ((#uint64,uint64)%expr @ |
| 3579 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3580 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x17)) @ |
| 3581 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x38))))%expr_pat in |
| 3582 |
expr_let x41 := ((#uint64,uint64)%expr @ |
| 3583 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3584 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x40)) @ |
| 3585 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x17)) @ |
| 3586 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x39))))%expr_pat in |
| 3587 |
expr_let x42 := ((#uint64,uint64)%expr @ |
| 3588 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3589 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x21)) @ |
| 3590 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x40))))%expr_pat in |
| 3591 |
expr_let x43 := ((#uint64,uint64)%expr @ |
| 3592 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3593 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x42)) @ |
| 3594 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x21)) @ |
| 3595 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x41))))%expr_pat in |
| 3596 |
expr_let x44 := ((#uint64,uint64)%expr @ |
| 3597 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3598 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x13)) @ |
| 3599 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x1))))%expr_pat in |
| 3600 |
expr_let x45 := ((#uint64,uint64)%expr @ |
| 3601 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3602 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x44)) @ |
| 3603 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x13)) @ |
| 3604 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x1))))%expr_pat in |
| 3605 |
expr_let x46 := ((#uint64,uint64)%expr @ |
| 3606 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3607 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x15)) @ |
| 3608 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x44))))%expr_pat in |
| 3609 |
expr_let x47 := ((#uint64,uint64)%expr @ |
| 3610 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3611 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x46)) @ |
| 3612 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x15)) @ |
| 3613 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x45))))%expr_pat in |
| 3614 |
expr_let x48 := ((#uint64,uint64)%expr @ |
| 3615 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3616 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x18)) @ |
| 3617 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x46))))%expr_pat in |
| 3618 |
expr_let x49 := ((#uint64,uint64)%expr @ |
| 3619 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3620 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x48)) @ |
| 3621 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x18)) @ |
| 3622 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x47))))%expr_pat in |
| 3623 |
expr_let x50 := ((#uint64,uint64)%expr @ |
| 3624 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3625 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x22)) @ |
| 3626 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x48))))%expr_pat in |
| 3627 |
expr_let x51 := ((#uint64,uint64)%expr @ |
| 3628 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3629 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x50)) @ |
| 3630 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x22)) @ |
| 3631 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x49))))%expr_pat in |
| 3632 |
expr_let x52 := ((#uint64,uint64)%expr @ |
| 3633 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3634 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x5)) @ |
| 3635 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x2))))%expr_pat in |
| 3636 |
expr_let x53 := ((#uint64,uint64)%expr @ |
| 3637 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3638 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x52)) @ |
| 3639 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x5)) @ |
| 3640 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x2))))%expr_pat in |
| 3641 |
expr_let x54 := ((#uint64,uint64)%expr @ |
| 3642 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3643 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x16)) @ |
| 3644 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x52))))%expr_pat in |
| 3645 |
expr_let x55 := ((#uint64,uint64)%expr @ |
| 3646 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3647 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x54)) @ |
| 3648 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x16)) @ |
| 3649 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x53))))%expr_pat in |
| 3650 |
expr_let x56 := ((#uint64,uint64)%expr @ |
| 3651 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3652 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x19)) @ |
| 3653 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x54))))%expr_pat in |
| 3654 |
expr_let x57 := ((#uint64,uint64)%expr @ |
| 3655 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3656 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x56)) @ |
| 3657 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x19)) @ |
| 3658 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x55))))%expr_pat in |
| 3659 |
expr_let x58 := ((#uint64,uint64)%expr @ |
| 3660 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3661 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x23)) @ |
| 3662 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x56))))%expr_pat in |
| 3663 |
expr_let x59 := ((#uint64,uint64)%expr @ |
| 3664 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3665 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x58)) @ |
| 3666 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x23)) @ |
| 3667 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x57))))%expr_pat in |
| 3668 |
expr_let x60 := ((#uint64,uint64)%expr @ |
| 3669 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3670 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x6)) @ |
| 3671 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x3))))%expr_pat in |
| 3672 |
expr_let x61 := ((#uint64,uint64)%expr @ |
| 3673 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3674 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x60)) @ |
| 3675 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x6)) @ |
| 3676 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x3))))%expr_pat in |
| 3677 |
expr_let x62 := ((#uint64,uint64)%expr @ |
| 3678 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3679 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x8)) @ |
| 3680 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x60))))%expr_pat in |
| 3681 |
expr_let x63 := ((#uint64,uint64)%expr @ |
| 3682 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3683 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x62)) @ |
| 3684 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x8)) @ |
| 3685 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x61))))%expr_pat in |
| 3686 |
expr_let x64 := ((#uint64,uint64)%expr @ |
| 3687 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3688 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x20)) @ |
| 3689 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x62))))%expr_pat in |
| 3690 |
expr_let x65 := ((#uint64,uint64)%expr @ |
| 3691 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3692 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x64)) @ |
| 3693 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x20)) @ |
| 3694 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x63))))%expr_pat in |
| 3695 |
expr_let x66 := ((#uint64,uint64)%expr @ |
| 3696 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3697 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x24)) @ |
| 3698 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x64))))%expr_pat in |
| 3699 |
expr_let x67 := ((#uint64,uint64)%expr @ |
| 3700 |
((#ident.Z_add_with_get_carry)%expr @ ##18446744073709551616 @ |
| 3701 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x66)) @ |
| 3702 |
((#uint64)%expr @ ((#ident.snd)%expr @ $$x24)) @ |
| 3703 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x65))))%expr_pat in |
| 3704 |
expr_let x68 := ((#uint64,uint64)%expr @ |
| 3705 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3706 |
((#uint64)%expr @ $$x34) @ ((#uint64)%expr @ ((#ident.fst)%expr @ $$x66))))%expr_pat in |
| 3707 |
expr_let x69 := ((#uint64)%expr @ |
| 3708 |
(((#uint64)%expr @ ((#ident.snd)%expr @ $$x68))%expr_pat + |
| 3709 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x67))%expr_pat))%expr_pat in |
| 3710 |
expr_let x70 := ((#uint64)%expr @ |
| 3711 |
(((#uint64)%expr @ |
| 3712 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x68))%expr_pat >> ##51))%expr_pat |
| 3713 |
|| ((#uint64)%expr @ |
| 3714 |
((#ident.Z_truncating_shiftl)%expr @ ##64 @ ((#uint64)%expr @ $$x69) @ |
| 3715 |
##13))%expr_pat))%expr_pat in |
| 3716 |
expr_let x71 := ((#uint64)%expr @ |
| 3717 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x68))%expr_pat &' |
| 3718 |
##2251799813685247))%expr_pat in |
| 3719 |
expr_let x72 := ((#uint64,uint64)%expr @ |
| 3720 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3721 |
((#uint64)%expr @ $$x70) @ ((#uint64)%expr @ ((#ident.fst)%expr @ $$x58))))%expr_pat in |
| 3722 |
expr_let x73 := ((#uint64)%expr @ |
| 3723 |
(((#uint64)%expr @ ((#ident.snd)%expr @ $$x72))%expr_pat + |
| 3724 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x59))%expr_pat))%expr_pat in |
| 3725 |
expr_let x74 := ((#uint64)%expr @ |
| 3726 |
(((#uint64)%expr @ |
| 3727 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x72))%expr_pat >> ##51))%expr_pat |
| 3728 |
|| ((#uint64)%expr @ |
| 3729 |
((#ident.Z_truncating_shiftl)%expr @ ##64 @ ((#uint64)%expr @ $$x73) @ |
| 3730 |
##13))%expr_pat))%expr_pat in |
| 3731 |
expr_let x75 := ((#uint64)%expr @ |
| 3732 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x72))%expr_pat &' |
| 3733 |
##2251799813685247))%expr_pat in |
| 3734 |
expr_let x76 := ((#uint64,uint64)%expr @ |
| 3735 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3736 |
((#uint64)%expr @ $$x74) @ ((#uint64)%expr @ ((#ident.fst)%expr @ $$x50))))%expr_pat in |
| 3737 |
expr_let x77 := ((#uint64)%expr @ |
| 3738 |
(((#uint64)%expr @ ((#ident.snd)%expr @ $$x76))%expr_pat + |
| 3739 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x51))%expr_pat))%expr_pat in |
| 3740 |
expr_let x78 := ((#uint64)%expr @ |
| 3741 |
(((#uint64)%expr @ |
| 3742 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x76))%expr_pat >> ##51))%expr_pat |
| 3743 |
|| ((#uint64)%expr @ |
| 3744 |
((#ident.Z_truncating_shiftl)%expr @ ##64 @ ((#uint64)%expr @ $$x77) @ |
| 3745 |
##13))%expr_pat))%expr_pat in |
| 3746 |
expr_let x79 := ((#uint64)%expr @ |
| 3747 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x76))%expr_pat &' |
| 3748 |
##2251799813685247))%expr_pat in |
| 3749 |
expr_let x80 := ((#uint64,uint64)%expr @ |
| 3750 |
((#ident.Z_add_get_carry)%expr @ ##18446744073709551616 @ |
| 3751 |
((#uint64)%expr @ $$x78) @ ((#uint64)%expr @ ((#ident.fst)%expr @ $$x42))))%expr_pat in |
| 3752 |
expr_let x81 := ((#uint64)%expr @ |
| 3753 |
(((#uint64)%expr @ ((#ident.snd)%expr @ $$x80))%expr_pat + |
| 3754 |
((#uint64)%expr @ ((#ident.fst)%expr @ $$x43))%expr_pat))%expr_pat in |
| 3755 |
expr_let x82 := ((#uint64)%expr @ |
| 3756 |
(((#uint64)%expr @ |
| 3757 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x80))%expr_pat >> ##51))%expr_pat |
| 3758 |
|| ((#uint64)%expr @ |
| 3759 |
((#ident.Z_truncating_shiftl)%expr @ ##64 @ ((#uint64)%expr @ $$x81) @ |
| 3760 |
##13))%expr_pat))%expr_pat in |
| 3761 |
expr_let x83 := ((#uint64)%expr @ |
| 3762 |
(((#uint64)%expr @ ((#ident.fst)%expr @ $$x80))%expr_pat &' |
| 3763 |
##2251799813685247))%expr_pat in |
| 3764 |
expr_let x84 := ((#uint64)%expr @ (((#uint64)%expr @ $$x82)%expr_pat * ##19))%expr_pat in |
| 3765 |
expr_let x85 := ((#uint64)%expr @ |
| 3766 |
(((#uint64)%expr @ $$x35)%expr_pat + ((#uint64)%expr @ $$x84)%expr_pat))%expr_pat in |
| 3767 |
expr_let x86 := ((#uint64)%expr @ (((#uint64)%expr @ $$x85)%expr_pat >> ##51))%expr_pat in |
| 3768 |
expr_let x87 := ((#uint64)%expr @ (((#uint64)%expr @ $$x85)%expr_pat &' ##2251799813685247))%expr_pat in |
| 3769 |
expr_let x88 := ((#uint64)%expr @ |
| 3770 |
(((#uint64)%expr @ $$x86)%expr_pat + ((#uint64)%expr @ $$x71)%expr_pat))%expr_pat in |
| 3771 |
expr_let x89 := ((#uint64)%expr @ (((#uint64)%expr @ $$x88)%expr_pat >> ##51))%expr_pat in |
| 3772 |
expr_let x90 := ((#uint64)%expr @ (((#uint64)%expr @ $$x88)%expr_pat &' ##2251799813685247))%expr_pat in |
| 3773 |
expr_let x91 := ((#uint64)%expr @ |
| 3774 |
(((#uint64)%expr @ $$x89)%expr_pat + ((#uint64)%expr @ $$x75)%expr_pat))%expr_pat in |
| 3775 |
[((#uint64)%expr @ $$x87)%expr_pat; ((#uint64)%expr @ $$x90)%expr_pat; |
| 3776 |
((#uint64)%expr @ $$x91)%expr_pat; ((#uint64)%expr @ $$x79)%expr_pat; |
| 3777 |
((#uint64)%expr @ $$x83)%expr_pat]) |
| 3778 |
: Pipeline.ErrorT |
| 3779 |
(Expr |
| 3780 |
(type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 3781 |
type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 3782 |
type.base (base.type.list (base.type.type_base base.type.Z)))) |
| 3783 |
*) |
| 3784 |
End __. |
| 3785 |
End debugging_remove_mul_split. |
| 3786 |
|
| 3787 |
Module debugging_remove_mul_split2. |
| 3788 |
Import Crypto.PushButtonSynthesis.WordByWordMontgomery. |
| 3789 |
Import Crypto.Arithmetic.WordByWordMontgomery.WordByWordMontgomery. |
| 3790 |
Section __. |
| 3791 |
Context (m : Z := 2^224 - 2^96 + 1) |
| 3792 |
(machine_wordsize : Z := 64) |
| 3793 |
(should_split_mul : should_split_mul_opt := true) |
| 3794 |
(widen_carry : widen_carry_opt := true) |
| 3795 |
(widen_bytes : widen_bytes_opt := true). |
| 3796 |
|
| 3797 |
Local Existing Instances should_split_mul widen_carry widen_bytes. |
| 3798 |
|
| 3799 |
Let s := 2^Z.log2_up m. |
| 3800 |
Let c := s - m. |
| 3801 |
Let n : nat := Eval compute in Z.to_nat (Qceiling (Z.log2_up s / machine_wordsize)). |
| 3802 |
Let r := 2^machine_wordsize. |
| 3803 |
Let r' := Z.modinv r m. |
| 3804 |
Let m' := Eval vm_compute in Z.modinv (-m) r. |
| 3805 |
|
| 3806 |
Local Notation saturated_bounds := (Primitives.saturated_bounds n machine_wordsize). |
| 3807 |
|
| 3808 |
Definition bounds : list (ZRange.type.option.interp base.type.Z) |
| 3809 |
:= saturated_bounds (*List.map (fun u => Some r[0~>u]%zrange) upperbounds*). |
| 3810 |
|
| 3811 |
Definition possible_values_of_machine_wordsize |
| 3812 |
:= prefix_with_carry [machine_wordsize; 2 * machine_wordsize]%Z. |
| 3813 |
Let possible_values := possible_values_of_machine_wordsize. |
| 3814 |
|
| 3815 |
Local Instance split_mul_to : split_mul_to_opt := split_mul_to_of_should_split_mul machine_wordsize possible_values. |
| 3816 |
|
| 3817 |
(* |
| 3818 |
Time Definition foo := |
| 3819 |
ltac:(let r := Reify ((mulmod machine_wordsize n m m')) in |
| 3820 |
exact r). |
| 3821 |
*) |
| 3822 |
Set Printing Depth 100000. |
| 3823 |
Local Open Scope string_scope. |
| 3824 |
(* |
| 3825 |
Redirect "log" Compute |
| 3826 |
Pipeline.BoundsPipelineToStrings |
| 3827 |
true (* static *) |
| 3828 |
"" (* prefix *) |
| 3829 |
"mul" |
| 3830 |
false (* subst01 *) |
| 3831 |
false (* inline *) |
| 3832 |
None |
| 3833 |
possible_values |
| 3834 |
foo |
| 3835 |
(fun _ _ => []) (* comment *) |
| 3836 |
(Some bounds, (Some bounds, tt)) |
| 3837 |
(Some bounds). |
| 3838 |
*) |
| 3839 |
Redirect "log" Check (fun with_mul_split => with_mul_split). |
| 3840 |
Time Redirect "log" Compute smul m machine_wordsize "" (* prefix *). |
| 3841 |
Redirect "log" Check (fun without_mul_split => without_mul_split). |
| 3842 |
Time Redirect "log" Compute smul m machine_wordsize "" (* prefix *). |
| 3843 |
Goal True. |
| 3844 |
pose (smul m machine_wordsize "") as v; clear -v. |
| 3845 |
cbv in m; subst m machine_wordsize. |
| 3846 |
cbv [smul] in v. |
| 3847 |
set (k := Pipeline.BoundsPipelineWithDebug _ _ _ _ _) in (value of v). |
| 3848 |
clear v. |
| 3849 |
cbv [mul] in k. |
| 3850 |
Import WordByWordMontgomeryReificationCache. |
| 3851 |
cbv -[Pipeline.BoundsPipelineWithDebug reified_mul_gen] in k. |
| 3852 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline LetIn.Let_In] in k. |
| 3853 |
let k' := fresh in rename k into k'; epose (DebugMonad.Debug.eval_result k') as k; subst k'. |
| 3854 |
cbv [Rewriter.Util.LetIn.Let_In DebugMonad.Debug.eval_result DebugMonad.Debug.sequence Pipeline.debug_after_rewrite DebugMonad.Debug.ret] in k. |
| 3855 |
vm_compute Pipeline.debug_rewriting in k. |
| 3856 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 3857 |
set (v := CheckedPartialEvaluateWithBounds _ _ _ _ _ _ _) in (value of k). |
| 3858 |
Notation INL := (inl _). |
| 3859 |
vm_compute in v. |
| 3860 |
Notation IDD := (id _). |
| 3861 |
lazymatch (eval cbv [v] in v) with |
| 3862 |
| @inl ?A ?B ?x => pose (id x) as v'; change v with (@inl A B v') in (value of k); clear v |
| 3863 |
end. |
| 3864 |
cbv beta iota in k. |
| 3865 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 3866 |
unfold DebugMonad.Debug.bind in (value of k) at 1; cbn [snd] in k. |
| 3867 |
set (v := Pipeline.RewriteAndEliminateDeadAndInline _ _ _ _ _ _) in (value of k) at 1. |
| 3868 |
vm_compute in v; clear v'; |
| 3869 |
lazymatch (eval cbv [v] in v) with |
| 3870 |
| ?x => pose (id x) as v'; change v with v' in (value of k); clear v |
| 3871 |
end. |
| 3872 |
cbv beta iota in k. |
| 3873 |
(* |
| 3874 |
set (v'' := MulSplit.Compilers.RewriteRules.RewriteMulSplit _ _ _ _) in (value of k). |
| 3875 |
vm_compute in v; clear v'; |
| 3876 |
lazymatch (eval cbv [v] in v) with |
| 3877 |
| ?x => pose (id x) as v'; change v with v' in (value of v''); clear v |
| 3878 |
end. |
| 3879 |
cbv [id] in v'. |
| 3880 |
vm_compute in v''. |
| 3881 |
*) |
| 3882 |
Abort. |
| 3883 |
End __. |
| 3884 |
End debugging_remove_mul_split2. |
| 3885 |
|
| 3886 |
Local Instance split_mul_to : split_mul_to_opt := None. |
| 3887 |
|
| 3888 |
Module debugging_rewriting. |
| 3889 |
Section __. |
| 3890 |
Context (n : nat := 2%nat) |
| 3891 |
(s : Z := 2^127) |
| 3892 |
(c : list (Z * Z) := [(1,1)]) |
| 3893 |
(machine_wordsize : Z := 64). |
| 3894 |
|
| 3895 |
Let limbwidth := (Z.log2_up (s - Associational.eval c) / Z.of_nat n)%Q. |
| 3896 |
Let idxs := (List.seq 0 n ++ [0; 1])%list%nat. |
| 3897 |
|
| 3898 |
Definition possible_values_of_machine_wordsize |
| 3899 |
:= [0; machine_wordsize; 2 * machine_wordsize]%Z. |
| 3900 |
|
| 3901 |
Let possible_values := possible_values_of_machine_wordsize. |
| 3902 |
|
| 3903 |
|
| 3904 |
Let prime_upperbound_list : list Z |
| 3905 |
:= Partition.partition (weight (Qnum limbwidth) (Qden limbwidth)) n (s-1). |
| 3906 |
Let tight_upperbounds : list Z |
| 3907 |
:= List.map |
| 3908 |
(fun v : Z => Qceiling (11/10 * v)) |
| 3909 |
prime_upperbound_list. |
| 3910 |
Definition tight_bounds : list (ZRange.type.option.interp base.type.Z) |
| 3911 |
:= List.map (fun u => Some r[0~>u]%zrange) tight_upperbounds. |
| 3912 |
Definition loose_bounds : list (ZRange.type.option.interp base.type.Z) |
| 3913 |
:= List.map (fun u => Some r[0 ~> 3*u]%zrange) tight_upperbounds. |
| 3914 |
|
| 3915 |
|
| 3916 |
Let limbwidth_num := Eval vm_compute in Qnum limbwidth. |
| 3917 |
Let limbwidth_den := Eval vm_compute in QDen limbwidth. |
| 3918 |
|
| 3919 |
Redirect "log" Compute |
| 3920 |
(Pipeline.BoundsPipeline |
| 3921 |
true [64; 128] |
| 3922 |
ltac:(let r := Reify (fun f g |
| 3923 |
=> ( (addmod limbwidth_num limbwidth_den n f g) |
| 3924 |
)) in |
| 3925 |
exact r) |
| 3926 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 3927 |
ZRange.type.base.option.None). |
| 3928 |
|
| 3929 |
Redirect "log" Compute |
| 3930 |
(Pipeline.BoundsPipeline |
| 3931 |
true [64; 128] |
| 3932 |
ltac:(let r := Reify (fun f g |
| 3933 |
=> ( (add (weight limbwidth_num limbwidth_den) n f g) |
| 3934 |
)) in |
| 3935 |
exact r) |
| 3936 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 3937 |
ZRange.type.base.option.None). |
| 3938 |
|
| 3939 |
Redirect "log" Compute |
| 3940 |
(Pipeline.BoundsPipeline |
| 3941 |
true [64; 128] |
| 3942 |
ltac:(let r := Reify (fun f g |
| 3943 |
=> let a_a := to_associational (weight limbwidth_num limbwidth_den) n f in |
| 3944 |
let b_a := to_associational (weight limbwidth_num limbwidth_den) n g in from_associational (weight limbwidth_num limbwidth_den) n (a_a ++ b_a) |
| 3945 |
) in |
| 3946 |
exact r) |
| 3947 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 3948 |
ZRange.type.base.option.None). |
| 3949 |
|
| 3950 |
Redirect "log" Compute |
| 3951 |
(Pipeline.BoundsPipeline |
| 3952 |
true [64; 128] |
| 3953 |
ltac:(let r := Reify (fun f (g : list Z) |
| 3954 |
=> let a_a := to_associational (weight limbwidth_num limbwidth_den) n f in |
| 3955 |
a_a) in |
| 3956 |
exact r) |
| 3957 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 3958 |
ZRange.type.base.option.None). |
| 3959 |
|
| 3960 |
Redirect "log" Compute |
| 3961 |
(Pipeline.BoundsPipeline |
| 3962 |
true [64; 128] |
| 3963 |
ltac:(let r := Reify (fun (f g : list Z) |
| 3964 |
=> let a_a := combine (map (weight limbwidth_num limbwidth_den) (seq 0 n)) f in |
| 3965 |
a_a) in |
| 3966 |
exact r) |
| 3967 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 3968 |
ZRange.type.base.option.None). |
| 3969 |
|
| 3970 |
Definition foo := (Pipeline.BoundsPipeline |
| 3971 |
true [64; 128] |
| 3972 |
ltac:(let r := Reify (combine [1; 2] [1; 2]) in |
| 3973 |
exact r) |
| 3974 |
tt |
| 3975 |
ZRange.type.base.option.None). |
| 3976 |
|
| 3977 |
(* |
| 3978 |
Goal True. |
| 3979 |
pose foo as X; cbv [foo] in X. |
| 3980 |
clear -X. |
| 3981 |
cbv [Pipeline.BoundsPipelineWithDebug Pipeline.PreBoundsPipeline LetIn.Let_In] in X. |
| 3982 |
set (Y := (PartialEvaluateWithListInfoFromBounds _ _)) in (value of X). |
| 3983 |
vm_compute in Y. |
| 3984 |
subst Y; set (Y := (Rewriter.Compilers.PartialEvaluate _)) in (value of X). |
| 3985 |
cbv [Rewriter.Compilers.PartialEvaluate Rewriter.Compilers.RewriteRules.RewriteNBE Rewriter.Compilers.RewriteRules.Compile.Rewrite Rewriter.Compilers.RewriteRules.Compile.rewrite] in Y. |
| 3986 |
clear -Y. |
| 3987 |
change (Rewriter.Compilers.RewriteRules.nbe_default_fuel) with (S (pred Rewriter.Compilers.RewriteRules.nbe_default_fuel)) in (value of Y). |
| 3988 |
cbn [Rewriter.Compilers.RewriteRules.Compile.repeat_rewrite] in Y. |
| 3989 |
cbv [Rewriter.Compilers.RewriteRules.Compile.rewrite_bottomup] in Y. |
| 3990 |
Print Rewriter.Compilers.RewriteRules.nbe_rewrite_head. |
| 3991 |
Abort. |
| 3992 |
*) |
| 3993 |
End __. |
| 3994 |
End debugging_rewriting. |
| 3995 |
|
| 3996 |
Section debugging_p448. |
| 3997 |
Context (n : nat := 8%nat) |
| 3998 |
(s : Z := 2^448) |
| 3999 |
(c : list (Z * Z) := [(2^224,1);(1,1)]) |
| 4000 |
(machine_wordsize : Z := 64). |
| 4001 |
|
| 4002 |
Let limbwidth := (Z.log2_up (s - Associational.eval c) / Z.of_nat n)%Q. |
| 4003 |
Let idxs := (List.seq 0 n ++ [0; 1])%list%nat. |
| 4004 |
|
| 4005 |
Definition possible_values_of_machine_wordsize |
| 4006 |
:= [0; machine_wordsize; 2 * machine_wordsize]%Z. |
| 4007 |
|
| 4008 |
Let possible_values := possible_values_of_machine_wordsize. |
| 4009 |
|
| 4010 |
|
| 4011 |
Let prime_upperbound_list : list Z |
| 4012 |
:= Partition.partition (weight (Qnum limbwidth) (Qden limbwidth)) n (s-1). |
| 4013 |
Let tight_upperbounds : list Z |
| 4014 |
:= List.map |
| 4015 |
(fun v : Z => Qceiling (11/10 * v)) |
| 4016 |
prime_upperbound_list. |
| 4017 |
Definition tight_bounds : list (ZRange.type.option.interp base.type.Z) |
| 4018 |
:= List.map (fun u => Some r[0~>u]%zrange) tight_upperbounds. |
| 4019 |
Definition loose_bounds : list (ZRange.type.option.interp base.type.Z) |
| 4020 |
:= List.map (fun u => Some r[0 ~> 3*u]%zrange) tight_upperbounds. |
| 4021 |
|
| 4022 |
|
| 4023 |
Let limbwidth_num := Eval vm_compute in Qnum limbwidth. |
| 4024 |
Let limbwidth_den := Eval vm_compute in QDen limbwidth. |
| 4025 |
|
| 4026 |
Set Printing Depth 100000. |
| 4027 |
Local Open Scope string_scope. |
| 4028 |
Redirect "log" Print squaremod. |
| 4029 |
Time Redirect "log" Compute |
| 4030 |
(Pipeline.BoundsPipeline |
| 4031 |
true [64; 128] |
| 4032 |
ltac:(let r := Reify (fun f |
| 4033 |
=> ( (squaremod (weight limbwidth_num limbwidth_den) s c n f) |
| 4034 |
)) in |
| 4035 |
exact r) |
| 4036 |
(Some (repeat (@None _) n), tt) |
| 4037 |
ZRange.type.base.option.None). |
| 4038 |
|
| 4039 |
Time Redirect "log" Compute |
| 4040 |
Pipeline.BoundsPipelineToStrings |
| 4041 |
"" (* prefix *) |
| 4042 |
"mul" |
| 4043 |
false (* subst01 *) |
| 4044 |
false (* inline *) |
| 4045 |
possible_values machine_wordsize |
| 4046 |
ltac:(let r := Reify ((carry_mulmod limbwidth_num limbwidth_den s c n [3; 7; 4; 0; 5; 1; 6; 2; 7; 3; 4; 0]%nat)) in |
| 4047 |
exact r) |
| 4048 |
(fun _ _ => []) (* comment *) |
| 4049 |
(Some loose_bounds, (Some loose_bounds, tt)) |
| 4050 |
(Some tight_bounds) |
| 4051 |
(None, (None, tt)) |
| 4052 |
None |
| 4053 |
: Pipeline.ErrorT _. |
| 4054 |
|
| 4055 |
Time Redirect "log" Compute |
| 4056 |
Pipeline.BoundsPipeline |
| 4057 |
false (* subst01 *) |
| 4058 |
possible_values |
| 4059 |
ltac:(let r := Reify ((carry_mulmod limbwidth_num limbwidth_den s c n [3; 7; 4; 0; 5; 1; 6; 2; 7; 3; 4; 0]%nat)) in |
| 4060 |
exact r) |
| 4061 |
(Some loose_bounds, (Some loose_bounds, tt)) |
| 4062 |
(Some tight_bounds). |
| 4063 |
|
| 4064 |
Time Redirect "log" Compute |
| 4065 |
(Pipeline.BoundsPipeline |
| 4066 |
true [64; 128] |
| 4067 |
ltac:(let r := Reify ((carry_mulmod limbwidth_num limbwidth_den s c n [3; 7; 4; 0; 5; 1; 6; 2; 7; 3; 4; 0]%nat)) in |
| 4068 |
exact r) |
| 4069 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 4070 |
ZRange.type.base.option.None). |
| 4071 |
|
| 4072 |
Time Redirect "log" Compute |
| 4073 |
(Pipeline.BoundsPipeline |
| 4074 |
true [64; 128] |
| 4075 |
ltac:(let r := Reify ((carry_mulmod limbwidth_num limbwidth_den s c n []%nat)) in |
| 4076 |
exact r) |
| 4077 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 4078 |
ZRange.type.base.option.None). |
| 4079 |
|
| 4080 |
Time Redirect "log" Compute |
| 4081 |
(Pipeline.BoundsPipeline |
| 4082 |
true [64; 128] |
| 4083 |
ltac:(let r := Reify (fun f g |
| 4084 |
=> ( (mulmod (weight limbwidth_num limbwidth_den) s c n f g) |
| 4085 |
)) in |
| 4086 |
exact r) |
| 4087 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 4088 |
ZRange.type.base.option.None). |
| 4089 |
|
| 4090 |
Time Redirect "log" Compute |
| 4091 |
(Pipeline.BoundsPipeline |
| 4092 |
true [64; 128] |
| 4093 |
ltac:(let r := Reify (fun a b |
| 4094 |
=> (let weight := weight limbwidth_num limbwidth_den in |
| 4095 |
let a_a := to_associational weight n a in |
| 4096 |
let b_a := to_associational weight n b in |
| 4097 |
let ab_a := mul a_a b_a in |
| 4098 |
let abm_a := reduce s c ab_a in |
| 4099 |
let abm_a := reduce s c abm_a in |
| 4100 |
let abm_a := reduce s c abm_a in |
| 4101 |
let abm_a := reduce s c abm_a in |
| 4102 |
let abm_a := reduce s c abm_a in |
| 4103 |
let abm_a := reduce s c abm_a in |
| 4104 |
let abm_a := reduce s c abm_a in |
| 4105 |
let abm_a := reduce s c abm_a in |
| 4106 |
from_associational weight n abm_a |
| 4107 |
|
| 4108 |
)) in |
| 4109 |
exact r) |
| 4110 |
(Some (repeat (@None _) n), (Some (repeat (@None _) n), tt)) |
| 4111 |
ZRange.type.base.option.None). |
| 4112 |
End debugging_p448. |
| 4113 |
|
| 4114 |
(* TODO: Figure out what examples should go here *) |
| 4115 |
(* |
| 4116 |
Module X25519_64. |
| 4117 |
Definition n := 5%nat. |
| 4118 |
Definition s := 2^255. |
| 4119 |
Definition c := [(1, 19)]. |
| 4120 |
Definition machine_wordsize := 64. |
| 4121 |
Local Notation tight_bounds := (tight_bounds n s c). |
| 4122 |
Local Notation loose_bounds := (loose_bounds n s c). |
| 4123 |
Local Notation prime_bound := (prime_bound s c). |
| 4124 |
|
| 4125 |
Derive base_51_relax |
| 4126 |
SuchThat (rrelax_correctT n s c machine_wordsize base_51_relax) |
| 4127 |
As base_51_relax_correct. |
| 4128 |
Proof. Time solve_rrelax machine_wordsize. Time Qed. |
| 4129 |
Derive base_51_carry_mul |
| 4130 |
SuchThat (rcarry_mul_correctT n s c machine_wordsize base_51_carry_mul) |
| 4131 |
As base_51_carry_mul_correct. |
| 4132 |
Proof. Time solve_rcarry_mul machine_wordsize. Time Qed. |
| 4133 |
Derive base_51_carry |
| 4134 |
SuchThat (rcarry_correctT n s c machine_wordsize base_51_carry) |
| 4135 |
As base_51_carry_correct. |
| 4136 |
Proof. Time solve_rcarry machine_wordsize. Time Qed. |
| 4137 |
Derive base_51_add |
| 4138 |
SuchThat (radd_correctT n s c machine_wordsize base_51_add) |
| 4139 |
As base_51_add_correct. |
| 4140 |
Proof. Time solve_radd machine_wordsize. Time Qed. |
| 4141 |
Derive base_51_sub |
| 4142 |
SuchThat (rsub_correctT n s c machine_wordsize base_51_sub) |
| 4143 |
As base_51_sub_correct. |
| 4144 |
Proof. Time solve_rsub machine_wordsize. Time Qed. |
| 4145 |
Derive base_51_opp |
| 4146 |
SuchThat (ropp_correctT n s c machine_wordsize base_51_opp) |
| 4147 |
As base_51_opp_correct. |
| 4148 |
Proof. Time solve_ropp machine_wordsize. Time Qed. |
| 4149 |
Derive base_51_to_bytes |
| 4150 |
SuchThat (rto_bytes_correctT n s c machine_wordsize base_51_to_bytes) |
| 4151 |
As base_51_to_bytes_correct. |
| 4152 |
Proof. Time solve_rto_bytes machine_wordsize. Time Qed. |
| 4153 |
Derive base_51_from_bytes |
| 4154 |
SuchThat (rfrom_bytes_correctT n s c machine_wordsize base_51_from_bytes) |
| 4155 |
As base_51_from_bytes_correct. |
| 4156 |
Proof. Time solve_rfrom_bytes machine_wordsize. Time Qed. |
| 4157 |
Derive base_51_encode |
| 4158 |
SuchThat (rencode_correctT n s c machine_wordsize base_51_encode) |
| 4159 |
As base_51_encode_correct. |
| 4160 |
Proof. Time solve_rencode machine_wordsize. Time Qed. |
| 4161 |
Derive base_51_zero |
| 4162 |
SuchThat (rzero_correctT n s c machine_wordsize base_51_zero) |
| 4163 |
As base_51_zero_correct. |
| 4164 |
Proof. Time solve_rzero machine_wordsize. Time Qed. |
| 4165 |
Derive base_51_one |
| 4166 |
SuchThat (rone_correctT n s c machine_wordsize base_51_one) |
| 4167 |
As base_51_one_correct. |
| 4168 |
Proof. Time solve_rone machine_wordsize. Time Qed. |
| 4169 |
Lemma base_51_curve_good |
| 4170 |
: check_args n s c machine_wordsize (ErrorT.Success tt) = ErrorT.Success tt. |
| 4171 |
Proof. vm_compute; reflexivity. Qed. |
| 4172 |
|
| 4173 |
Definition base_51_good : GoodT n s c machine_wordsize |
| 4174 |
:= Good n s c machine_wordsize |
| 4175 |
base_51_curve_good |
| 4176 |
base_51_carry_mul_correct |
| 4177 |
base_51_carry_correct |
| 4178 |
base_51_relax_correct |
| 4179 |
base_51_add_correct |
| 4180 |
base_51_sub_correct |
| 4181 |
base_51_opp_correct |
| 4182 |
base_51_zero_correct |
| 4183 |
base_51_one_correct |
| 4184 |
base_51_encode_correct |
| 4185 |
base_51_to_bytes_correct |
| 4186 |
base_51_from_bytes_correct. |
| 4187 |
|
| 4188 |
Print Assumptions base_51_good. |
| 4189 |
Import PrintingNotations. |
| 4190 |
Set Printing Width 80. |
| 4191 |
Open Scope string_scope. |
| 4192 |
Print base_51_carry_mul. |
| 4193 |
(*base_51_carry_mul = |
| 4194 |
fun var : type -> Type => |
| 4195 |
(λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4196 |
expr_let x1 := (uint64)(x[[0]]) *₁₂₈ (uint64)(x0[[0]]) +₁₂₈ |
| 4197 |
((uint64)(x[[1]]) *₁₂₈ ((uint64)(x0[[4]]) *₆₄ 19) +₁₂₈ |
| 4198 |
((uint64)(x[[2]]) *₁₂₈ ((uint64)(x0[[3]]) *₆₄ 19) +₁₂₈ |
| 4199 |
((uint64)(x[[3]]) *₁₂₈ ((uint64)(x0[[2]]) *₆₄ 19) +₁₂₈ |
| 4200 |
(uint64)(x[[4]]) *₁₂₈ ((uint64)(x0[[1]]) *₆₄ 19)))) in |
| 4201 |
expr_let x2 := (uint64)(x1 >> 51) +₁₂₈ |
| 4202 |
((uint64)(x[[0]]) *₁₂₈ (uint64)(x0[[1]]) +₁₂₈ |
| 4203 |
((uint64)(x[[1]]) *₁₂₈ (uint64)(x0[[0]]) +₁₂₈ |
| 4204 |
((uint64)(x[[2]]) *₁₂₈ ((uint64)(x0[[4]]) *₆₄ 19) +₁₂₈ |
| 4205 |
((uint64)(x[[3]]) *₁₂₈ ((uint64)(x0[[3]]) *₆₄ 19) +₁₂₈ |
| 4206 |
(uint64)(x[[4]]) *₁₂₈ ((uint64)(x0[[2]]) *₆₄ 19))))) in |
| 4207 |
expr_let x3 := (uint64)(x2 >> 51) +₁₂₈ |
| 4208 |
((uint64)(x[[0]]) *₁₂₈ (uint64)(x0[[2]]) +₁₂₈ |
| 4209 |
((uint64)(x[[1]]) *₁₂₈ (uint64)(x0[[1]]) +₁₂₈ |
| 4210 |
((uint64)(x[[2]]) *₁₂₈ (uint64)(x0[[0]]) +₁₂₈ |
| 4211 |
((uint64)(x[[3]]) *₁₂₈ ((uint64)(x0[[4]]) *₆₄ 19) +₁₂₈ |
| 4212 |
(uint64)(x[[4]]) *₁₂₈ ((uint64)(x0[[3]]) *₆₄ 19))))) in |
| 4213 |
expr_let x4 := (uint64)(x3 >> 51) +₁₂₈ |
| 4214 |
((uint64)(x[[0]]) *₁₂₈ (uint64)(x0[[3]]) +₁₂₈ |
| 4215 |
((uint64)(x[[1]]) *₁₂₈ (uint64)(x0[[2]]) +₁₂₈ |
| 4216 |
((uint64)(x[[2]]) *₁₂₈ (uint64)(x0[[1]]) +₁₂₈ |
| 4217 |
((uint64)(x[[3]]) *₁₂₈ (uint64)(x0[[0]]) +₁₂₈ |
| 4218 |
(uint64)(x[[4]]) *₁₂₈ ((uint64)(x0[[4]]) *₆₄ 19))))) in |
| 4219 |
expr_let x5 := (uint64)(x4 >> 51) +₁₂₈ |
| 4220 |
((uint64)(x[[0]]) *₁₂₈ (uint64)(x0[[4]]) +₁₂₈ |
| 4221 |
((uint64)(x[[1]]) *₁₂₈ (uint64)(x0[[3]]) +₁₂₈ |
| 4222 |
((uint64)(x[[2]]) *₁₂₈ (uint64)(x0[[2]]) +₁₂₈ |
| 4223 |
((uint64)(x[[3]]) *₁₂₈ (uint64)(x0[[1]]) +₁₂₈ |
| 4224 |
(uint64)(x[[4]]) *₁₂₈ (uint64)(x0[[0]]))))) in |
| 4225 |
expr_let x6 := ((uint64)(x1) & 2251799813685247) +₆₄ (uint64)(x5 >> 51) *₆₄ 19 in |
| 4226 |
expr_let x7 := (uint64)(x6 >> 51) +₆₄ ((uint64)(x2) & 2251799813685247) in |
| 4227 |
expr_let x8 := ((uint64)(x6) & 2251799813685247) in |
| 4228 |
expr_let x9 := ((uint64)(x7) & 2251799813685247) in |
| 4229 |
expr_let x10 := (uint64)(x7 >> 51) +₆₄ ((uint64)(x3) & 2251799813685247) in |
| 4230 |
expr_let x11 := ((uint64)(x4) & 2251799813685247) in |
| 4231 |
expr_let x12 := ((uint64)(x5) & 2251799813685247) in |
| 4232 |
[x8; x9; x10; x11; x12])%expr |
| 4233 |
: Expr |
| 4234 |
(type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4235 |
type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4236 |
type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4237 |
*) |
| 4238 |
Print base_51_sub. |
| 4239 |
(* |
| 4240 |
base_51_sub = |
| 4241 |
fun var : type -> Type => |
| 4242 |
(λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4243 |
expr_let x1 := (4503599627370458 +₆₄ (uint64)(x[[0]])) -₆₄ (uint64)(x0[[0]]) in |
| 4244 |
expr_let x2 := (4503599627370494 +₆₄ (uint64)(x[[1]])) -₆₄ (uint64)(x0[[1]]) in |
| 4245 |
expr_let x3 := (4503599627370494 +₆₄ (uint64)(x[[2]])) -₆₄ (uint64)(x0[[2]]) in |
| 4246 |
expr_let x4 := (4503599627370494 +₆₄ (uint64)(x[[3]])) -₆₄ (uint64)(x0[[3]]) in |
| 4247 |
expr_let x5 := (4503599627370494 +₆₄ (uint64)(x[[4]])) -₆₄ (uint64)(x0[[4]]) in |
| 4248 |
[x1; x2; x3; x4; x5])%expr |
| 4249 |
: Expr |
| 4250 |
(type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4251 |
type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4252 |
type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4253 |
*) |
| 4254 |
|
| 4255 |
Redirect "log" Compute Compilers.ToString.C.ToFunctionString |
| 4256 |
true true "" "fecarry_mul" [] base_51_carry_mul |
| 4257 |
None (Some loose_bounds, (Some loose_bounds, tt)). |
| 4258 |
(* |
| 4259 |
void fecarry_mul(uint64_t[5] x1, uint64_t[5] x2, uint64_t[5] x3) { |
| 4260 |
uint128_t x4 = (((uint128_t)(x1[0]) * (x2[0])) + (((uint128_t)(x1[1]) * ((x2[4]) * 0x13)) + (((uint128_t)(x1[2]) * ((x2[3]) * 0x13)) + (((uint128_t)(x1[3]) * ((x2[2]) * 0x13)) + ((uint128_t)(x1[4]) * ((x2[1]) * 0x13)))))); |
| 4261 |
uint128_t x5 = ((uint64_t)(x4 >> 51) + (((uint128_t)(x1[0]) * (x2[1])) + (((uint128_t)(x1[1]) * (x2[0])) + (((uint128_t)(x1[2]) * ((x2[4]) * 0x13)) + (((uint128_t)(x1[3]) * ((x2[3]) * 0x13)) + ((uint128_t)(x1[4]) * ((x2[2]) * 0x13))))))); |
| 4262 |
uint128_t x6 = ((uint64_t)(x5 >> 51) + (((uint128_t)(x1[0]) * (x2[2])) + (((uint128_t)(x1[1]) * (x2[1])) + (((uint128_t)(x1[2]) * (x2[0])) + (((uint128_t)(x1[3]) * ((x2[4]) * 0x13)) + ((uint128_t)(x1[4]) * ((x2[3]) * 0x13))))))); |
| 4263 |
uint128_t x7 = ((uint64_t)(x6 >> 51) + (((uint128_t)(x1[0]) * (x2[3])) + (((uint128_t)(x1[1]) * (x2[2])) + (((uint128_t)(x1[2]) * (x2[1])) + (((uint128_t)(x1[3]) * (x2[0])) + ((uint128_t)(x1[4]) * ((x2[4]) * 0x13))))))); |
| 4264 |
uint128_t x8 = ((uint64_t)(x7 >> 51) + (((uint128_t)(x1[0]) * (x2[4])) + (((uint128_t)(x1[1]) * (x2[3])) + (((uint128_t)(x1[2]) * (x2[2])) + (((uint128_t)(x1[3]) * (x2[1])) + ((uint128_t)(x1[4]) * (x2[0]))))))); |
| 4265 |
uint64_t x9 = ((uint64_t)(x4 & 0x7ffffffffffffUL) + ((uint64_t)(x8 >> 51) * 0x13)); |
| 4266 |
uint64_t x10 = ((x9 >> 51) + (uint64_t)(x5 & 0x7ffffffffffffUL)); |
| 4267 |
x3[0] = (x9 & 0x7ffffffffffffUL); |
| 4268 |
x3[1] = (x10 & 0x7ffffffffffffUL); |
| 4269 |
x3[2] = ((x10 >> 51) + (uint64_t)(x6 & 0x7ffffffffffffUL)); |
| 4270 |
x3[3] = (uint64_t)(x7 & 0x7ffffffffffffUL); |
| 4271 |
x3[4] = (uint64_t)(x8 & 0x7ffffffffffffUL); |
| 4272 |
} |
| 4273 |
*) |
| 4274 |
Redirect "log" Compute Compilers.ToString.C.ToFunctionString |
| 4275 |
true true "" "fesub" [] base_51_sub |
| 4276 |
None (Some tight_bounds, (Some tight_bounds, tt)). |
| 4277 |
(* |
| 4278 |
void fesub(uint64_t[5] x1, uint64_t[5] x2, uint64_t[5] x3) { |
| 4279 |
x3[0] = ((0xfffffffffffdaUL + (x1[0])) - (x2[0])); |
| 4280 |
x3[1] = ((0xffffffffffffeUL + (x1[1])) - (x2[1])); |
| 4281 |
x3[2] = ((0xffffffffffffeUL + (x1[2])) - (x2[2])); |
| 4282 |
x3[3] = ((0xffffffffffffeUL + (x1[3])) - (x2[3])); |
| 4283 |
x3[4] = ((0xffffffffffffeUL + (x1[4])) - (x2[4])); |
| 4284 |
} |
| 4285 |
*) |
| 4286 |
End X25519_64. |
| 4287 |
|
| 4288 |
Module X25519_32. |
| 4289 |
Definition n := 10%nat. |
| 4290 |
Definition s := 2^255. |
| 4291 |
Definition c := [(1, 19)]. |
| 4292 |
Definition machine_wordsize := 32. |
| 4293 |
|
| 4294 |
Derive base_25p5_relax |
| 4295 |
SuchThat (rrelax_correctT n s c machine_wordsize base_25p5_relax) |
| 4296 |
As base_25p5_relax_correct. |
| 4297 |
Proof. Time solve_rrelax machine_wordsize. Time Qed. |
| 4298 |
Derive base_25p5_carry_mul |
| 4299 |
SuchThat (rcarry_mul_correctT n s c machine_wordsize base_25p5_carry_mul) |
| 4300 |
As base_25p5_carry_mul_correct. |
| 4301 |
Proof. Time solve_rcarry_mul machine_wordsize. Time Qed. |
| 4302 |
Derive base_25p5_carry |
| 4303 |
SuchThat (rcarry_correctT n s c machine_wordsize base_25p5_carry) |
| 4304 |
As base_25p5_carry_correct. |
| 4305 |
Proof. Time solve_rcarry machine_wordsize. Time Qed. |
| 4306 |
Derive base_25p5_add |
| 4307 |
SuchThat (radd_correctT n s c machine_wordsize base_25p5_add) |
| 4308 |
As base_25p5_add_correct. |
| 4309 |
Proof. Time solve_radd machine_wordsize. Time Qed. |
| 4310 |
Derive base_25p5_sub |
| 4311 |
SuchThat (rsub_correctT n s c machine_wordsize base_25p5_sub) |
| 4312 |
As base_25p5_sub_correct. |
| 4313 |
Proof. Time solve_rsub machine_wordsize. Time Qed. |
| 4314 |
Derive base_25p5_opp |
| 4315 |
SuchThat (ropp_correctT n s c machine_wordsize base_25p5_opp) |
| 4316 |
As base_25p5_opp_correct. |
| 4317 |
Proof. Time solve_ropp machine_wordsize. Time Qed. |
| 4318 |
(* These are very, very, very slow *) |
| 4319 |
(* |
| 4320 |
Derive base_25p5_to_bytes |
| 4321 |
SuchThat (rto_bytes_correctT n s c machine_wordsize base_25p5_to_bytes) |
| 4322 |
As base_25p5_to_bytes_correct. |
| 4323 |
Proof. Time solve_rto_bytes machine_wordsize. Time Qed. |
| 4324 |
Derive base_25p5_from_bytes |
| 4325 |
SuchThat (rfrom_bytes_correctT n s c machine_wordsize base_25p5_from_bytes) |
| 4326 |
As base_25p5_from_bytes_correct. |
| 4327 |
Proof. Time solve_rfrom_bytes machine_wordsize. Time Qed. |
| 4328 |
*) |
| 4329 |
Derive base_25p5_encode |
| 4330 |
SuchThat (rencode_correctT n s c machine_wordsize base_25p5_encode) |
| 4331 |
As base_25p5_encode_correct. |
| 4332 |
Proof. Time solve_rencode machine_wordsize. Time Qed. |
| 4333 |
Derive base_25p5_zero |
| 4334 |
SuchThat (rzero_correctT n s c machine_wordsize base_25p5_zero) |
| 4335 |
As base_25p5_zero_correct. |
| 4336 |
Proof. Time solve_rzero machine_wordsize. Time Qed. |
| 4337 |
Derive base_25p5_one |
| 4338 |
SuchThat (rone_correctT n s c machine_wordsize base_25p5_one) |
| 4339 |
As base_25p5_one_correct. |
| 4340 |
Proof. Time solve_rone machine_wordsize. Time Qed. |
| 4341 |
Lemma base_25p5_curve_good |
| 4342 |
: check_args n s c machine_wordsize (ErrorT.Success tt) = ErrorT.Success tt. |
| 4343 |
Proof. vm_compute; reflexivity. Qed. |
| 4344 |
|
| 4345 |
(* |
| 4346 |
Definition base_25p5_good : GoodT n s c machine_wordsize |
| 4347 |
:= Good n s c machine_wordsize |
| 4348 |
base_25p5_curve_good |
| 4349 |
base_25p5_carry_mul_correct |
| 4350 |
base_25p5_carry_correct |
| 4351 |
base_25p5_relax_correct |
| 4352 |
base_25p5_add_correct |
| 4353 |
base_25p5_sub_correct |
| 4354 |
base_25p5_opp_correct |
| 4355 |
base_25p5_zero_correct |
| 4356 |
base_25p5_one_correct |
| 4357 |
base_25p5_encode_correct |
| 4358 |
base_25p5_to_bytes_correct |
| 4359 |
base_25p5_from_bytes_correct. |
| 4360 |
*) |
| 4361 |
(* |
| 4362 |
Print Assumptions base_25p5_good. |
| 4363 |
*) |
| 4364 |
Import PrintingNotations. |
| 4365 |
Set Printing Width 80. |
| 4366 |
Print base_25p5_carry_mul. |
| 4367 |
(* |
| 4368 |
base_25p5_carry_mul = |
| 4369 |
fun var : type -> Type => |
| 4370 |
(λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4371 |
expr_let x1 := (uint32)(x[[0]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4372 |
((uint64)((uint32)(x[[1]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) << 1) +₆₄ |
| 4373 |
((uint32)(x[[2]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4374 |
((uint64)((uint32)(x[[3]]) *₆₄ ((uint32)(x0[[7]]) *₃₂ 19) << 1) +₆₄ |
| 4375 |
((uint32)(x[[4]]) *₆₄ ((uint32)(x0[[6]]) *₃₂ 19) +₆₄ |
| 4376 |
((uint64)((uint32)(x[[5]]) *₆₄ ((uint32)(x0[[5]]) *₃₂ 19) << 1) +₆₄ |
| 4377 |
((uint32)(x[[6]]) *₆₄ ((uint32)(x0[[4]]) *₃₂ 19) +₆₄ |
| 4378 |
((uint64)((uint32)(x[[7]]) *₆₄ ((uint32)(x0[[3]]) *₃₂ 19) << 1) +₆₄ |
| 4379 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[2]]) *₃₂ 19) +₆₄ |
| 4380 |
(uint64)((uint32)(x[[9]]) *₆₄ |
| 4381 |
((uint32)(x0[[1]]) *₃₂ 19) << 1))))))))) in |
| 4382 |
expr_let x2 := (uint64)(x1 >> 26) +₆₄ |
| 4383 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[1]]) +₆₄ |
| 4384 |
((uint32)(x[[1]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4385 |
((uint32)(x[[2]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) +₆₄ |
| 4386 |
((uint32)(x[[3]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4387 |
((uint32)(x[[4]]) *₆₄ ((uint32)(x0[[7]]) *₃₂ 19) +₆₄ |
| 4388 |
((uint32)(x[[5]]) *₆₄ ((uint32)(x0[[6]]) *₃₂ 19) +₆₄ |
| 4389 |
((uint32)(x[[6]]) *₆₄ ((uint32)(x0[[5]]) *₃₂ 19) +₆₄ |
| 4390 |
((uint32)(x[[7]]) *₆₄ ((uint32)(x0[[4]]) *₃₂ 19) +₆₄ |
| 4391 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[3]]) *₃₂ 19) +₆₄ |
| 4392 |
(uint32)(x[[9]]) *₆₄ ((uint32)(x0[[2]]) *₃₂ 19)))))))))) in |
| 4393 |
expr_let x3 := (uint64)(x2 >> 25) +₆₄ |
| 4394 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4395 |
((uint64)((uint32)(x[[1]]) *₆₄ (uint32)(x0[[1]]) << 1) +₆₄ |
| 4396 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4397 |
((uint64)((uint32)(x[[3]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) << 1) +₆₄ |
| 4398 |
((uint32)(x[[4]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4399 |
((uint64)((uint32)(x[[5]]) *₆₄ ((uint32)(x0[[7]]) *₃₂ 19) << 1) +₆₄ |
| 4400 |
((uint32)(x[[6]]) *₆₄ ((uint32)(x0[[6]]) *₃₂ 19) +₆₄ |
| 4401 |
((uint64)((uint32)(x[[7]]) *₆₄ |
| 4402 |
((uint32)(x0[[5]]) *₃₂ 19) << 1) +₆₄ |
| 4403 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[4]]) *₃₂ 19) +₆₄ |
| 4404 |
(uint64)((uint32)(x[[9]]) *₆₄ |
| 4405 |
((uint32)(x0[[3]]) *₃₂ 19) << 1)))))))))) in |
| 4406 |
expr_let x4 := (uint64)(x3 >> 26) +₆₄ |
| 4407 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[3]]) +₆₄ |
| 4408 |
((uint32)(x[[1]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4409 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[1]]) +₆₄ |
| 4410 |
((uint32)(x[[3]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4411 |
((uint32)(x[[4]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) +₆₄ |
| 4412 |
((uint32)(x[[5]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4413 |
((uint32)(x[[6]]) *₆₄ ((uint32)(x0[[7]]) *₃₂ 19) +₆₄ |
| 4414 |
((uint32)(x[[7]]) *₆₄ ((uint32)(x0[[6]]) *₃₂ 19) +₆₄ |
| 4415 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[5]]) *₃₂ 19) +₆₄ |
| 4416 |
(uint32)(x[[9]]) *₆₄ ((uint32)(x0[[4]]) *₃₂ 19)))))))))) in |
| 4417 |
expr_let x5 := (uint64)(x4 >> 25) +₆₄ |
| 4418 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[4]]) +₆₄ |
| 4419 |
((uint64)((uint32)(x[[1]]) *₆₄ (uint32)(x0[[3]]) << 1) +₆₄ |
| 4420 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4421 |
((uint64)((uint32)(x[[3]]) *₆₄ (uint32)(x0[[1]]) << 1) +₆₄ |
| 4422 |
((uint32)(x[[4]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4423 |
((uint64)((uint32)(x[[5]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) << 1) +₆₄ |
| 4424 |
((uint32)(x[[6]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4425 |
((uint64)((uint32)(x[[7]]) *₆₄ |
| 4426 |
((uint32)(x0[[7]]) *₃₂ 19) << 1) +₆₄ |
| 4427 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[6]]) *₃₂ 19) +₆₄ |
| 4428 |
(uint64)((uint32)(x[[9]]) *₆₄ |
| 4429 |
((uint32)(x0[[5]]) *₃₂ 19) << 1)))))))))) in |
| 4430 |
expr_let x6 := (uint64)(x5 >> 26) +₆₄ |
| 4431 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[5]]) +₆₄ |
| 4432 |
((uint32)(x[[1]]) *₆₄ (uint32)(x0[[4]]) +₆₄ |
| 4433 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[3]]) +₆₄ |
| 4434 |
((uint32)(x[[3]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4435 |
((uint32)(x[[4]]) *₆₄ (uint32)(x0[[1]]) +₆₄ |
| 4436 |
((uint32)(x[[5]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4437 |
((uint32)(x[[6]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) +₆₄ |
| 4438 |
((uint32)(x[[7]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4439 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[7]]) *₃₂ 19) +₆₄ |
| 4440 |
(uint32)(x[[9]]) *₆₄ ((uint32)(x0[[6]]) *₃₂ 19)))))))))) in |
| 4441 |
expr_let x7 := (uint64)(x6 >> 25) +₆₄ |
| 4442 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[6]]) +₆₄ |
| 4443 |
((uint64)((uint32)(x[[1]]) *₆₄ (uint32)(x0[[5]]) << 1) +₆₄ |
| 4444 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[4]]) +₆₄ |
| 4445 |
((uint64)((uint32)(x[[3]]) *₆₄ (uint32)(x0[[3]]) << 1) +₆₄ |
| 4446 |
((uint32)(x[[4]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4447 |
((uint64)((uint32)(x[[5]]) *₆₄ (uint32)(x0[[1]]) << 1) +₆₄ |
| 4448 |
((uint32)(x[[6]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4449 |
((uint64)((uint32)(x[[7]]) *₆₄ |
| 4450 |
((uint32)(x0[[9]]) *₃₂ 19) << 1) +₆₄ |
| 4451 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19) +₆₄ |
| 4452 |
(uint64)((uint32)(x[[9]]) *₆₄ |
| 4453 |
((uint32)(x0[[7]]) *₃₂ 19) << 1)))))))))) in |
| 4454 |
expr_let x8 := (uint64)(x7 >> 26) +₆₄ |
| 4455 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[7]]) +₆₄ |
| 4456 |
((uint32)(x[[1]]) *₆₄ (uint32)(x0[[6]]) +₆₄ |
| 4457 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[5]]) +₆₄ |
| 4458 |
((uint32)(x[[3]]) *₆₄ (uint32)(x0[[4]]) +₆₄ |
| 4459 |
((uint32)(x[[4]]) *₆₄ (uint32)(x0[[3]]) +₆₄ |
| 4460 |
((uint32)(x[[5]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4461 |
((uint32)(x[[6]]) *₆₄ (uint32)(x0[[1]]) +₆₄ |
| 4462 |
((uint32)(x[[7]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4463 |
((uint32)(x[[8]]) *₆₄ ((uint32)(x0[[9]]) *₃₂ 19) +₆₄ |
| 4464 |
(uint32)(x[[9]]) *₆₄ ((uint32)(x0[[8]]) *₃₂ 19)))))))))) in |
| 4465 |
expr_let x9 := (uint64)(x8 >> 25) +₆₄ |
| 4466 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[8]]) +₆₄ |
| 4467 |
((uint64)((uint32)(x[[1]]) *₆₄ (uint32)(x0[[7]]) << 1) +₆₄ |
| 4468 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[6]]) +₆₄ |
| 4469 |
((uint64)((uint32)(x[[3]]) *₆₄ (uint32)(x0[[5]]) << 1) +₆₄ |
| 4470 |
((uint32)(x[[4]]) *₆₄ (uint32)(x0[[4]]) +₆₄ |
| 4471 |
((uint64)((uint32)(x[[5]]) *₆₄ (uint32)(x0[[3]]) << 1) +₆₄ |
| 4472 |
((uint32)(x[[6]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4473 |
((uint64)((uint32)(x[[7]]) *₆₄ (uint32)(x0[[1]]) << 1) +₆₄ |
| 4474 |
((uint32)(x[[8]]) *₆₄ (uint32)(x0[[0]]) +₆₄ |
| 4475 |
(uint64)((uint32)(x[[9]]) *₆₄ |
| 4476 |
((uint32)(x0[[9]]) *₃₂ 19) << 1)))))))))) in |
| 4477 |
expr_let x10 := (uint64)(x9 >> 26) +₆₄ |
| 4478 |
((uint32)(x[[0]]) *₆₄ (uint32)(x0[[9]]) +₆₄ |
| 4479 |
((uint32)(x[[1]]) *₆₄ (uint32)(x0[[8]]) +₆₄ |
| 4480 |
((uint32)(x[[2]]) *₆₄ (uint32)(x0[[7]]) +₆₄ |
| 4481 |
((uint32)(x[[3]]) *₆₄ (uint32)(x0[[6]]) +₆₄ |
| 4482 |
((uint32)(x[[4]]) *₆₄ (uint32)(x0[[5]]) +₆₄ |
| 4483 |
((uint32)(x[[5]]) *₆₄ (uint32)(x0[[4]]) +₆₄ |
| 4484 |
((uint32)(x[[6]]) *₆₄ (uint32)(x0[[3]]) +₆₄ |
| 4485 |
((uint32)(x[[7]]) *₆₄ (uint32)(x0[[2]]) +₆₄ |
| 4486 |
((uint32)(x[[8]]) *₆₄ (uint32)(x0[[1]]) +₆₄ |
| 4487 |
(uint32)(x[[9]]) *₆₄ (uint32)(x0[[0]])))))))))) in |
| 4488 |
expr_let x11 := ((uint32)(x1) & 67108863) +₆₄ (uint64)(x10 >> 25) *₆₄ 19 in |
| 4489 |
expr_let x12 := (uint32)(x11 >> 26) +₃₂ ((uint32)(x2) & 33554431) in |
| 4490 |
expr_let x13 := ((uint32)(x11) & 67108863) in |
| 4491 |
expr_let x14 := ((uint32)(x12) & 33554431) in |
| 4492 |
expr_let x15 := (uint32)(x12 >> 25) +₃₂ ((uint32)(x3) & 67108863) in |
| 4493 |
expr_let x16 := ((uint32)(x4) & 33554431) in |
| 4494 |
expr_let x17 := ((uint32)(x5) & 67108863) in |
| 4495 |
expr_let x18 := ((uint32)(x6) & 33554431) in |
| 4496 |
expr_let x19 := ((uint32)(x7) & 67108863) in |
| 4497 |
expr_let x20 := ((uint32)(x8) & 33554431) in |
| 4498 |
expr_let x21 := ((uint32)(x9) & 67108863) in |
| 4499 |
expr_let x22 := ((uint32)(x10) & 33554431) in |
| 4500 |
[x13; x14; x15; x16; x17; x18; x19; x20; x21; x22])%expr |
| 4501 |
: Expr |
| 4502 |
(type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4503 |
type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4504 |
type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4505 |
*) |
| 4506 |
Print base_25p5_sub. |
| 4507 |
(* |
| 4508 |
base_25p5_sub = |
| 4509 |
fun var : type -> Type => |
| 4510 |
(λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4511 |
expr_let x1 := (134217690 +₃₂ (uint32)(x[[0]])) -₃₂ (uint32)(x0[[0]]) in |
| 4512 |
expr_let x2 := (67108862 +₃₂ (uint32)(x[[1]])) -₃₂ (uint32)(x0[[1]]) in |
| 4513 |
expr_let x3 := (134217726 +₃₂ (uint32)(x[[2]])) -₃₂ (uint32)(x0[[2]]) in |
| 4514 |
expr_let x4 := (67108862 +₃₂ (uint32)(x[[3]])) -₃₂ (uint32)(x0[[3]]) in |
| 4515 |
expr_let x5 := (134217726 +₃₂ (uint32)(x[[4]])) -₃₂ (uint32)(x0[[4]]) in |
| 4516 |
expr_let x6 := (67108862 +₃₂ (uint32)(x[[5]])) -₃₂ (uint32)(x0[[5]]) in |
| 4517 |
expr_let x7 := (134217726 +₃₂ (uint32)(x[[6]])) -₃₂ (uint32)(x0[[6]]) in |
| 4518 |
expr_let x8 := (67108862 +₃₂ (uint32)(x[[7]])) -₃₂ (uint32)(x0[[7]]) in |
| 4519 |
expr_let x9 := (134217726 +₃₂ (uint32)(x[[8]])) -₃₂ (uint32)(x0[[8]]) in |
| 4520 |
expr_let x10 := (67108862 +₃₂ (uint32)(x[[9]])) -₃₂ (uint32)(x0[[9]]) in |
| 4521 |
[x1; x2; x3; x4; x5; x6; x7; x8; x9; x10])%expr |
| 4522 |
: Expr |
| 4523 |
(type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4524 |
type.base (base.type.list (base.type.type_base base.type.Z)) -> |
| 4525 |
type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4526 |
*) |
| 4527 |
End X25519_32. |
| 4528 |
|
| 4529 |
Import Language.Compilers. |
| 4530 |
|
| 4531 |
Module P192_64. |
| 4532 |
Definition s := 2^192. |
| 4533 |
Definition c := [(2^64, 1); (1,1)]. |
| 4534 |
Definition machine_wordsize := 64. |
| 4535 |
|
| 4536 |
Derive mulmod |
| 4537 |
SuchThat (SaturatedSolinas.rmulmod_correctT s c machine_wordsize mulmod) |
| 4538 |
As mulmod_correct. |
| 4539 |
Proof. Time solve_rmulmod machine_wordsize. Time Qed. |
| 4540 |
|
| 4541 |
Import PrintingNotations. |
| 4542 |
Open Scope expr_scope. |
| 4543 |
Set Printing Width 100000. |
| 4544 |
Set Printing Depth 100000. |
| 4545 |
|
| 4546 |
Local Notation "'mul64' '(' x ',' y ')'" := |
| 4547 |
(#(Z_cast2 (uint64, _)%core) @ (#Z_mul_split @ #(ident.Literal (t:=base.type.Z) 18446744073709551616) @ x @ y))%expr (at level 50) : expr_scope. |
| 4548 |
Local Notation "'add64' '(' x ',' y ')'" := |
| 4549 |
(#(Z_cast2 (uint64, bool)%core) @ (#Z_add_get_carry @ #(ident.Literal (t:=base.type.Z) 18446744073709551616) @ x @ y))%expr (at level 50) : expr_scope. |
| 4550 |
Local Notation "'adc64' '(' c ',' x ',' y ')'" := |
| 4551 |
(#(Z_cast2 (uint64, bool)%core) @ (#Z_add_with_get_carry @ #(ident.Literal (t:=base.type.Z) 18446744073709551616) @ c @ x @ y))%expr (at level 50) : expr_scope. |
| 4552 |
Local Notation "'adx64' '(' c ',' x ',' y ')'" := |
| 4553 |
(#(Z_cast bool) @ (#Z_add_with_carry @ c @ x @ y))%expr (at level 50) : expr_scope. |
| 4554 |
|
| 4555 |
Print mulmod. |
| 4556 |
(* |
| 4557 |
mulmod = fun var : type -> Type => λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4558 |
expr_let x1 := mul64 ((uint64)(x[[2]]), (uint64)(x0[[2]])) in |
| 4559 |
expr_let x2 := mul64 ((uint64)(x[[2]]), (uint64)(x0[[1]])) in |
| 4560 |
expr_let x3 := mul64 ((uint64)(x[[2]]), (uint64)(x0[[0]])) in |
| 4561 |
expr_let x4 := mul64 ((uint64)(x[[1]]), (uint64)(x0[[2]])) in |
| 4562 |
expr_let x5 := mul64 ((uint64)(x[[1]]), (uint64)(x0[[1]])) in |
| 4563 |
expr_let x6 := mul64 ((uint64)(x[[1]]), (uint64)(x0[[0]])) in |
| 4564 |
expr_let x7 := mul64 ((uint64)(x[[0]]), (uint64)(x0[[2]])) in |
| 4565 |
expr_let x8 := mul64 ((uint64)(x[[0]]), (uint64)(x0[[1]])) in |
| 4566 |
expr_let x9 := mul64 ((uint64)(x[[0]]), (uint64)(x0[[0]])) in |
| 4567 |
expr_let x10 := add64 (x1₂, x9₂) in |
| 4568 |
expr_let x11 := adc64 (x10₂, 0, x8₂) in |
| 4569 |
expr_let x12 := add64 (x1₁, x10₁) in |
| 4570 |
expr_let x13 := adc64 (x12₂, 0, x11₁) in |
| 4571 |
expr_let x14 := add64 (x2₂, x12₁) in |
| 4572 |
expr_let x15 := adc64 (x14₂, 0, x13₁) in |
| 4573 |
expr_let x16 := add64 (x4₂, x14₁) in |
| 4574 |
expr_let x17 := adc64 (x16₂, x1₂, x15₁) in |
| 4575 |
expr_let x18 := add64 (x2₁, x16₁) in |
| 4576 |
expr_let x19 := adc64 (x18₂, x1₁, x17₁) in |
| 4577 |
expr_let x20 := add64 (x1₂, x9₁) in |
| 4578 |
expr_let x21 := adc64 (x20₂, x3₂, x18₁) in |
| 4579 |
expr_let x22 := adc64 (x21₂, x2₂, x19₁) in |
| 4580 |
expr_let x23 := add64 (x2₁, x20₁) in |
| 4581 |
expr_let x24 := adc64 (x23₂, x4₁, x21₁) in |
| 4582 |
expr_let x25 := adc64 (x24₂, x4₂, x22₁) in |
| 4583 |
expr_let x26 := add64 (x3₂, x23₁) in |
| 4584 |
expr_let x27 := adc64 (x26₂, x5₂, x24₁) in |
| 4585 |
expr_let x28 := adc64 (x27₂, x3₁, x25₁) in |
| 4586 |
expr_let x29 := add64 (x4₁, x26₁) in |
| 4587 |
expr_let x30 := adc64 (x29₂, x7₂, x27₁) in |
| 4588 |
expr_let x31 := adc64 (x30₂, x5₁, x28₁) in |
| 4589 |
expr_let x32 := add64 (x5₂, x29₁) in |
| 4590 |
expr_let x33 := adc64 (x32₂, x6₁, x30₁) in |
| 4591 |
expr_let x34 := adc64 (x33₂, x6₂, x31₁) in |
| 4592 |
expr_let x35 := add64 (x7₂, x32₁) in |
| 4593 |
expr_let x36 := adc64 (x35₂, x8₁, x33₁) in |
| 4594 |
expr_let x37 := adc64 (x36₂, x7₁, x34₁) in |
| 4595 |
[x35₁; x36₁; x37₁] |
| 4596 |
: Expr (type.base (base.type.list (base.type.type_base base.type.Z)) -> type.base (base.type.list (base.type.type_base base.type.Z)) -> type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4597 |
*) |
| 4598 |
|
| 4599 |
End P192_64. |
| 4600 |
|
| 4601 |
Module P192_32. |
| 4602 |
Definition s := 2^192. |
| 4603 |
Definition c := [(2^64, 1); (1,1)]. |
| 4604 |
Definition machine_wordsize := 32. |
| 4605 |
|
| 4606 |
Derive mulmod |
| 4607 |
SuchThat (SaturatedSolinas.rmulmod_correctT s c machine_wordsize mulmod) |
| 4608 |
As mulmod_correct. |
| 4609 |
Proof. Time solve_rmulmod machine_wordsize. Time Qed. |
| 4610 |
|
| 4611 |
Import PrintingNotations. |
| 4612 |
Open Scope expr_scope. |
| 4613 |
Set Printing Width 100000. |
| 4614 |
Set Printing Depth 100000. |
| 4615 |
|
| 4616 |
Local Notation "'mul32' '(' x ',' y ')'" := |
| 4617 |
(#(Z_cast2 (uint32, _)%core) @ (#Z_mul_split @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4618 |
Local Notation "'add32' '(' x ',' y ')'" := |
| 4619 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_add_get_carry @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4620 |
Local Notation "'adc32' '(' c ',' x ',' y ')'" := |
| 4621 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_add_with_get_carry @ #(ident.Literal (t:=base.type.Z) 4294967296) @ c @ x @ y))%expr (at level 50) : expr_scope. |
| 4622 |
|
| 4623 |
Print mulmod. |
| 4624 |
(* |
| 4625 |
mulmod = fun var : type -> Type => λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4626 |
expr_let x1 := mul32 ((uint32)(x[[5]]), (uint32)(x0[[5]])) in |
| 4627 |
expr_let x2 := mul32 ((uint32)(x[[5]]), (uint32)(x0[[4]])) in |
| 4628 |
expr_let x3 := mul32 ((uint32)(x[[5]]), (uint32)(x0[[3]])) in |
| 4629 |
expr_let x4 := mul32 ((uint32)(x[[5]]), (uint32)(x0[[2]])) in |
| 4630 |
expr_let x5 := mul32 ((uint32)(x[[5]]), (uint32)(x0[[1]])) in |
| 4631 |
expr_let x6 := mul32 ((uint32)(x[[5]]), (uint32)(x0[[0]])) in |
| 4632 |
expr_let x7 := mul32 ((uint32)(x[[4]]), (uint32)(x0[[5]])) in |
| 4633 |
expr_let x8 := mul32 ((uint32)(x[[4]]), (uint32)(x0[[4]])) in |
| 4634 |
expr_let x9 := mul32 ((uint32)(x[[4]]), (uint32)(x0[[3]])) in |
| 4635 |
expr_let x10 := mul32 ((uint32)(x[[4]]), (uint32)(x0[[2]])) in |
| 4636 |
expr_let x11 := mul32 ((uint32)(x[[4]]), (uint32)(x0[[1]])) in |
| 4637 |
expr_let x12 := mul32 ((uint32)(x[[4]]), (uint32)(x0[[0]])) in |
| 4638 |
expr_let x13 := mul32 ((uint32)(x[[3]]), (uint32)(x0[[5]])) in |
| 4639 |
expr_let x14 := mul32 ((uint32)(x[[3]]), (uint32)(x0[[4]])) in |
| 4640 |
expr_let x15 := mul32 ((uint32)(x[[3]]), (uint32)(x0[[3]])) in |
| 4641 |
expr_let x16 := mul32 ((uint32)(x[[3]]), (uint32)(x0[[2]])) in |
| 4642 |
expr_let x17 := mul32 ((uint32)(x[[3]]), (uint32)(x0[[1]])) in |
| 4643 |
expr_let x18 := mul32 ((uint32)(x[[3]]), (uint32)(x0[[0]])) in |
| 4644 |
expr_let x19 := mul32 ((uint32)(x[[2]]), (uint32)(x0[[5]])) in |
| 4645 |
expr_let x20 := mul32 ((uint32)(x[[2]]), (uint32)(x0[[4]])) in |
| 4646 |
expr_let x21 := mul32 ((uint32)(x[[2]]), (uint32)(x0[[3]])) in |
| 4647 |
expr_let x22 := mul32 ((uint32)(x[[2]]), (uint32)(x0[[2]])) in |
| 4648 |
expr_let x23 := mul32 ((uint32)(x[[2]]), (uint32)(x0[[1]])) in |
| 4649 |
expr_let x24 := mul32 ((uint32)(x[[2]]), (uint32)(x0[[0]])) in |
| 4650 |
expr_let x25 := mul32 ((uint32)(x[[1]]), (uint32)(x0[[5]])) in |
| 4651 |
expr_let x26 := mul32 ((uint32)(x[[1]]), (uint32)(x0[[4]])) in |
| 4652 |
expr_let x27 := mul32 ((uint32)(x[[1]]), (uint32)(x0[[3]])) in |
| 4653 |
expr_let x28 := mul32 ((uint32)(x[[1]]), (uint32)(x0[[2]])) in |
| 4654 |
expr_let x29 := mul32 ((uint32)(x[[1]]), (uint32)(x0[[1]])) in |
| 4655 |
expr_let x30 := mul32 ((uint32)(x[[1]]), (uint32)(x0[[0]])) in |
| 4656 |
expr_let x31 := mul32 ((uint32)(x[[0]]), (uint32)(x0[[5]])) in |
| 4657 |
expr_let x32 := mul32 ((uint32)(x[[0]]), (uint32)(x0[[4]])) in |
| 4658 |
expr_let x33 := mul32 ((uint32)(x[[0]]), (uint32)(x0[[3]])) in |
| 4659 |
expr_let x34 := mul32 ((uint32)(x[[0]]), (uint32)(x0[[2]])) in |
| 4660 |
expr_let x35 := mul32 ((uint32)(x[[0]]), (uint32)(x0[[1]])) in |
| 4661 |
expr_let x36 := mul32 ((uint32)(x[[0]]), (uint32)(x0[[0]])) in |
| 4662 |
expr_let x37 := add32 (x1₁, x35₂) in |
| 4663 |
expr_let x38 := adc32 (x37₂, 0, x34₂) in |
| 4664 |
expr_let x39 := adc32 (x38₂, 0, x33₂) in |
| 4665 |
expr_let x40 := adc32 (x39₂, 0, x32₂) in |
| 4666 |
expr_let x41 := add32 (x2₂, x37₁) in |
| 4667 |
expr_let x42 := adc32 (x41₂, 0, x38₁) in |
| 4668 |
expr_let x43 := adc32 (x42₂, 0, x39₁) in |
| 4669 |
expr_let x44 := adc32 (x43₂, 0, x40₁) in |
| 4670 |
expr_let x45 := add32 (x7₂, x41₁) in |
| 4671 |
expr_let x46 := adc32 (x45₂, 0, x42₁) in |
| 4672 |
expr_let x47 := adc32 (x46₂, 0, x43₁) in |
| 4673 |
expr_let x48 := adc32 (x47₂, 0, x44₁) in |
| 4674 |
expr_let x49 := add32 (x3₁, x45₁) in |
| 4675 |
expr_let x50 := adc32 (x49₂, 0, x46₁) in |
| 4676 |
expr_let x51 := adc32 (x50₂, 0, x47₁) in |
| 4677 |
expr_let x52 := adc32 (x51₂, 0, x48₁) in |
| 4678 |
expr_let x53 := add32 (x4₂, x49₁) in |
| 4679 |
expr_let x54 := adc32 (x53₂, x1₂, x50₁) in |
| 4680 |
expr_let x55 := adc32 (x54₂, 0, x51₁) in |
| 4681 |
expr_let x56 := adc32 (x55₂, 0, x52₁) in |
| 4682 |
expr_let x57 := add32 (x8₁, x53₁) in |
| 4683 |
expr_let x58 := adc32 (x57₂, x2₁, x54₁) in |
| 4684 |
expr_let x59 := adc32 (x58₂, 0, x55₁) in |
| 4685 |
expr_let x60 := adc32 (x59₂, 0, x56₁) in |
| 4686 |
expr_let x61 := add32 (x9₂, x57₁) in |
| 4687 |
expr_let x62 := adc32 (x61₂, x3₂, x58₁) in |
| 4688 |
expr_let x63 := adc32 (x62₂, 0, x59₁) in |
| 4689 |
expr_let x64 := adc32 (x63₂, 0, x60₁) in |
| 4690 |
expr_let x65 := add32 (x13₁, x61₁) in |
| 4691 |
expr_let x66 := adc32 (x65₂, x7₁, x62₁) in |
| 4692 |
expr_let x67 := adc32 (x66₂, x1₁, x63₁) in |
| 4693 |
expr_let x68 := adc32 (x67₂, 0, x64₁) in |
| 4694 |
expr_let x69 := add32 (x14₂, x65₁) in |
| 4695 |
expr_let x70 := adc32 (x69₂, x8₂, x66₁) in |
| 4696 |
expr_let x71 := adc32 (x70₂, x2₂, x67₁) in |
| 4697 |
expr_let x72 := adc32 (x71₂, 0, x68₁) in |
| 4698 |
expr_let x73 := add32 (x19₂, x69₁) in |
| 4699 |
expr_let x74 := adc32 (x73₂, x13₂, x70₁) in |
| 4700 |
expr_let x75 := adc32 (x74₂, x7₂, x71₁) in |
| 4701 |
expr_let x76 := adc32 (x75₂, x1₂, x72₁) in |
| 4702 |
expr_let x77 := add32 (x5₁, x73₁) in |
| 4703 |
expr_let x78 := adc32 (x77₂, x4₁, x74₁) in |
| 4704 |
expr_let x79 := adc32 (x78₂, x3₁, x75₁) in |
| 4705 |
expr_let x80 := adc32 (x79₂, x2₁, x76₁) in |
| 4706 |
expr_let x81 := add32 (x1₁, x36₁) in |
| 4707 |
expr_let x82 := adc32 (x81₂, 0, x36₂) in |
| 4708 |
expr_let x83 := adc32 (x82₂, x6₂, x77₁) in |
| 4709 |
expr_let x84 := adc32 (x83₂, x5₂, x78₁) in |
| 4710 |
expr_let x85 := adc32 (x84₂, x4₂, x79₁) in |
| 4711 |
expr_let x86 := adc32 (x85₂, x3₂, x80₁) in |
| 4712 |
expr_let x87 := add32 (x2₂, x81₁) in |
| 4713 |
expr_let x88 := adc32 (x87₂, 0, x82₁) in |
| 4714 |
expr_let x89 := adc32 (x88₂, x10₁, x83₁) in |
| 4715 |
expr_let x90 := adc32 (x89₂, x9₁, x84₁) in |
| 4716 |
expr_let x91 := adc32 (x90₂, x8₁, x85₁) in |
| 4717 |
expr_let x92 := adc32 (x91₂, x7₁, x86₁) in |
| 4718 |
expr_let x93 := add32 (x7₂, x87₁) in |
| 4719 |
expr_let x94 := adc32 (x93₂, x1₂, x88₁) in |
| 4720 |
expr_let x95 := adc32 (x94₂, x11₂, x89₁) in |
| 4721 |
expr_let x96 := adc32 (x95₂, x10₂, x90₁) in |
| 4722 |
expr_let x97 := adc32 (x96₂, x9₂, x91₁) in |
| 4723 |
expr_let x98 := adc32 (x97₂, x8₂, x92₁) in |
| 4724 |
expr_let x99 := add32 (x5₁, x93₁) in |
| 4725 |
expr_let x100 := adc32 (x99₂, x4₁, x94₁) in |
| 4726 |
expr_let x101 := adc32 (x100₂, x15₁, x95₁) in |
| 4727 |
expr_let x102 := adc32 (x101₂, x14₁, x96₁) in |
| 4728 |
expr_let x103 := adc32 (x102₂, x13₁, x97₁) in |
| 4729 |
expr_let x104 := adc32 (x103₂, x13₂, x98₁) in |
| 4730 |
expr_let x105 := add32 (x6₂, x99₁) in |
| 4731 |
expr_let x106 := adc32 (x105₂, x5₂, x100₁) in |
| 4732 |
expr_let x107 := adc32 (x106₂, x16₂, x101₁) in |
| 4733 |
expr_let x108 := adc32 (x107₂, x15₂, x102₁) in |
| 4734 |
expr_let x109 := adc32 (x108₂, x14₂, x103₁) in |
| 4735 |
expr_let x110 := adc32 (x109₂, x6₁, x104₁) in |
| 4736 |
expr_let x111 := add32 (x10₁, x105₁) in |
| 4737 |
expr_let x112 := adc32 (x111₂, x9₁, x106₁) in |
| 4738 |
expr_let x113 := adc32 (x112₂, x20₁, x107₁) in |
| 4739 |
expr_let x114 := adc32 (x113₂, x19₁, x108₁) in |
| 4740 |
expr_let x115 := adc32 (x114₂, x19₂, x109₁) in |
| 4741 |
expr_let x116 := adc32 (x115₂, x11₁, x110₁) in |
| 4742 |
expr_let x117 := add32 (x11₂, x111₁) in |
| 4743 |
expr_let x118 := adc32 (x117₂, x10₂, x112₁) in |
| 4744 |
expr_let x119 := adc32 (x118₂, x21₂, x113₁) in |
| 4745 |
expr_let x120 := adc32 (x119₂, x20₂, x114₁) in |
| 4746 |
expr_let x121 := adc32 (x120₂, x12₁, x115₁) in |
| 4747 |
expr_let x122 := adc32 (x121₂, x12₂, x116₁) in |
| 4748 |
expr_let x123 := add32 (x15₁, x117₁) in |
| 4749 |
expr_let x124 := adc32 (x123₂, x14₁, x118₁) in |
| 4750 |
expr_let x125 := adc32 (x124₂, x25₁, x119₁) in |
| 4751 |
expr_let x126 := adc32 (x125₂, x25₂, x120₁) in |
| 4752 |
expr_let x127 := adc32 (x126₂, x17₁, x121₁) in |
| 4753 |
expr_let x128 := adc32 (x127₂, x16₁, x122₁) in |
| 4754 |
expr_let x129 := add32 (x16₂, x123₁) in |
| 4755 |
expr_let x130 := adc32 (x129₂, x15₂, x124₁) in |
| 4756 |
expr_let x131 := adc32 (x130₂, x26₂, x125₁) in |
| 4757 |
expr_let x132 := adc32 (x131₂, x18₁, x126₁) in |
| 4758 |
expr_let x133 := adc32 (x132₂, x18₂, x127₁) in |
| 4759 |
expr_let x134 := adc32 (x133₂, x17₂, x128₁) in |
| 4760 |
expr_let x135 := add32 (x20₁, x129₁) in |
| 4761 |
expr_let x136 := adc32 (x135₂, x19₁, x130₁) in |
| 4762 |
expr_let x137 := adc32 (x136₂, x31₂, x131₁) in |
| 4763 |
expr_let x138 := adc32 (x137₂, x23₁, x132₁) in |
| 4764 |
expr_let x139 := adc32 (x138₂, x22₁, x133₁) in |
| 4765 |
expr_let x140 := adc32 (x139₂, x21₁, x134₁) in |
| 4766 |
expr_let x141 := add32 (x21₂, x135₁) in |
| 4767 |
expr_let x142 := adc32 (x141₂, x20₂, x136₁) in |
| 4768 |
expr_let x143 := adc32 (x142₂, x24₁, x137₁) in |
| 4769 |
expr_let x144 := adc32 (x143₂, x24₂, x138₁) in |
| 4770 |
expr_let x145 := adc32 (x144₂, x23₂, x139₁) in |
| 4771 |
expr_let x146 := adc32 (x145₂, x22₂, x140₁) in |
| 4772 |
expr_let x147 := add32 (x25₁, x141₁) in |
| 4773 |
expr_let x148 := adc32 (x147₂, x25₂, x142₁) in |
| 4774 |
expr_let x149 := adc32 (x148₂, x29₁, x143₁) in |
| 4775 |
expr_let x150 := adc32 (x149₂, x28₁, x144₁) in |
| 4776 |
expr_let x151 := adc32 (x150₂, x27₁, x145₁) in |
| 4777 |
expr_let x152 := adc32 (x151₂, x26₁, x146₁) in |
| 4778 |
expr_let x153 := add32 (x26₂, x147₁) in |
| 4779 |
expr_let x154 := adc32 (x153₂, x30₁, x148₁) in |
| 4780 |
expr_let x155 := adc32 (x154₂, x30₂, x149₁) in |
| 4781 |
expr_let x156 := adc32 (x155₂, x29₂, x150₁) in |
| 4782 |
expr_let x157 := adc32 (x156₂, x28₂, x151₁) in |
| 4783 |
expr_let x158 := adc32 (x157₂, x27₂, x152₁) in |
| 4784 |
expr_let x159 := add32 (x31₂, x153₁) in |
| 4785 |
expr_let x160 := adc32 (x159₂, x35₁, x154₁) in |
| 4786 |
expr_let x161 := adc32 (x160₂, x34₁, x155₁) in |
| 4787 |
expr_let x162 := adc32 (x161₂, x33₁, x156₁) in |
| 4788 |
expr_let x163 := adc32 (x162₂, x32₁, x157₁) in |
| 4789 |
expr_let x164 := adc32 (x163₂, x31₁, x158₁) in |
| 4790 |
[x159₁; x160₁; x161₁; x162₁; x163₁; x164₁] |
| 4791 |
: Expr (type.base (base.type.list (base.type.type_base base.type.Z)) -> type.base (base.type.list (base.type.type_base base.type.Z)) -> type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4792 |
*) |
| 4793 |
|
| 4794 |
End P192_32. |
| 4795 |
|
| 4796 |
Module P384_32. |
| 4797 |
Definition s := 2^384. |
| 4798 |
Definition c := [(2^128, 1); (2^96, 1); (2^32,-1); (1,1)]. |
| 4799 |
Definition machine_wordsize := 32. |
| 4800 |
Import PrintingNotations. |
| 4801 |
Open Scope expr_scope. |
| 4802 |
Set Printing Depth 100000. |
| 4803 |
|
| 4804 |
Derive mulmod |
| 4805 |
SuchThat (SaturatedSolinas.rmulmod_correctT s c machine_wordsize mulmod) |
| 4806 |
As mulmod_correct. |
| 4807 |
Proof. Time solve_rmulmod machine_wordsize. Time Qed. |
| 4808 |
|
| 4809 |
Import PrintingNotations. |
| 4810 |
Open Scope expr_scope. |
| 4811 |
Set Printing Width 100000. |
| 4812 |
Set Printing Depth 100000. |
| 4813 |
|
| 4814 |
Local Notation "'mul32' '(' x ',' y ')'" := |
| 4815 |
(#(Z_cast2 (uint32, _)%core) @ (#Z_mul_split @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4816 |
Local Notation "'add32' '(' x ',' y ')'" := |
| 4817 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_add_get_carry @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4818 |
Local Notation "'adc32' '(' c ',' x ',' y ')'" := |
| 4819 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_add_with_get_carry @ #(ident.Literal (t:=base.type.Z) 4294967296) @ c @ x @ y))%expr (at level 50) : expr_scope. |
| 4820 |
Local Notation "'sub32' '(' x ',' y ')'" := |
| 4821 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_sub_get_borrow @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4822 |
Local Notation "'sbb32' '(' c ',' x ',' y ')'" := |
| 4823 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_sub_with_get_borrow @ #(ident.Literal (t:=base.type.Z) 4294967296) @ c @ x @ y))%expr (at level 50) : expr_scope. |
| 4824 |
|
| 4825 |
Print mulmod. |
| 4826 |
|
| 4827 |
|
| 4828 |
End P384_32. |
| 4829 |
|
| 4830 |
(* TODO : Too slow! Many, many terms in this one. *) |
| 4831 |
|
| 4832 |
Module P256_32. |
| 4833 |
Definition s := 2^256. |
| 4834 |
Definition c := [(2^224, 1); (2^192, -1); (2^96, -1); (1,1)]. |
| 4835 |
Definition machine_wordsize := 32. |
| 4836 |
|
| 4837 |
Derive mulmod |
| 4838 |
SuchThat (SaturatedSolinas.rmulmod_correctT s c machine_wordsize mulmod) |
| 4839 |
As mulmod_correct. |
| 4840 |
Proof. Time solve_rmulmod machine_wordsize. Time Qed. |
| 4841 |
|
| 4842 |
Import PrintingNotations. |
| 4843 |
Open Scope expr_scope. |
| 4844 |
Set Printing Width 100000. |
| 4845 |
|
| 4846 |
Local Notation "'mul32' '(' x ',' y ')'" := |
| 4847 |
(#(Z_cast2 (uint32, _)%core) @ (#Z_mul_split @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4848 |
Local Notation "'add32' '(' x ',' y ')'" := |
| 4849 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_add_get_carry @ #(ident.Literal (t:=base.type.Z) 4294967296) @ x @ y))%expr (at level 50) : expr_scope. |
| 4850 |
Local Notation "'adc32' '(' c ',' x ',' y ')'" := |
| 4851 |
(#(Z_cast2 (uint32, bool)%core) @ (#Z_add_with_get_carry @ #(ident.Literal (t:=base.type.Z) 4294967296) @ c @ x @ y))%expr (at level 50) : expr_scope. |
| 4852 |
|
| 4853 |
(* Print is too slow *) |
| 4854 |
|
| 4855 |
Time Print mulmod. |
| 4856 |
|
| 4857 |
(* |
| 4858 |
mulmod = |
| 4859 |
fun var : type -> Type => |
| 4860 |
λ x x0 : var (type.base (base.type.list (base.type.type_base base.type.Z))), |
| 4861 |
expr_let x1 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4862 |
expr_let x2 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4863 |
expr_let x3 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4864 |
expr_let x4 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4865 |
expr_let x5 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4866 |
expr_let x6 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4867 |
expr_let x7 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4868 |
expr_let x8 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[7]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4869 |
expr_let x9 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4870 |
expr_let x10 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4871 |
expr_let x11 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4872 |
expr_let x12 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4873 |
expr_let x13 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4874 |
expr_let x14 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4875 |
expr_let x15 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4876 |
expr_let x16 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[6]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4877 |
expr_let x17 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4878 |
expr_let x18 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4879 |
expr_let x19 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4880 |
expr_let x20 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4881 |
expr_let x21 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4882 |
expr_let x22 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4883 |
expr_let x23 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4884 |
expr_let x24 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[5]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4885 |
expr_let x25 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4886 |
expr_let x26 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4887 |
expr_let x27 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4888 |
expr_let x28 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4889 |
expr_let x29 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4890 |
expr_let x30 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4891 |
expr_let x31 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4892 |
expr_let x32 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[4]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4893 |
expr_let x33 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4894 |
expr_let x34 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4895 |
expr_let x35 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4896 |
expr_let x36 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4897 |
expr_let x37 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4898 |
expr_let x38 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4899 |
expr_let x39 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4900 |
expr_let x40 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[3]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4901 |
expr_let x41 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4902 |
expr_let x42 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4903 |
expr_let x43 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4904 |
expr_let x44 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4905 |
expr_let x45 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4906 |
expr_let x46 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4907 |
expr_let x47 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4908 |
expr_let x48 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[2]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4909 |
expr_let x49 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4910 |
expr_let x50 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4911 |
expr_let x51 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4912 |
expr_let x52 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4913 |
expr_let x53 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4914 |
expr_let x54 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4915 |
expr_let x55 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4916 |
expr_let x56 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[1]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4917 |
expr_let x57 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[7]])))%expr_pat in |
| 4918 |
expr_let x58 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[6]])))%expr_pat in |
| 4919 |
expr_let x59 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[5]])))%expr_pat in |
| 4920 |
expr_let x60 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[4]])))%expr_pat in |
| 4921 |
expr_let x61 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[3]])))%expr_pat in |
| 4922 |
expr_let x62 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[2]])))%expr_pat in |
| 4923 |
expr_let x63 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[1]])))%expr_pat in |
| 4924 |
expr_let x64 := (#(Z_cast2 (uint32, uint32)%core)%expr @ (#(Z_mul_split_concrete 4294967296)%expr @ (uint32)(x[[0]]) @ (uint32)(x0[[0]])))%expr_pat in |
| 4925 |
expr_let x65 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4926 |
expr_let x66 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4927 |
expr_let x67 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4928 |
expr_let x68 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4929 |
expr_let x69 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4930 |
expr_let x70 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4931 |
expr_let x71 := (#(Z_cast r[-4294967294 ~> 0])%expr @ (- x1₂))%expr_pat in |
| 4932 |
[...] |
| 4933 |
expr_let x2983 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x35₁ @ x2975₁))%expr_pat in |
| 4934 |
expr_let x2984 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2983₂ @ x34₁ @ x2976₁))%expr_pat in |
| 4935 |
expr_let x2985 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2984₂ @ x33₁ @ x2977₁))%expr_pat in |
| 4936 |
expr_let x2986 := (#(Z_cast2 (uint32, r[-1 ~> 1])%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2985₂ @ x826 @ x2978₁))%expr_pat in |
| 4937 |
expr_let x2987 := (#(Z_cast2 (uint32, r[-1 ~> 1])%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2986₂ @ x39₁ @ x2979₁))%expr_pat in |
| 4938 |
expr_let x2988 := (#(Z_cast2 (uint32, r[-1 ~> 1])%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2987₂ @ x38₁ @ x2980₁))%expr_pat in |
| 4939 |
expr_let x2989 := (#(Z_cast2 (uint32, r[-1 ~> 1])%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2988₂ @ x37₁ @ x2981₁))%expr_pat in |
| 4940 |
expr_let x2990 := (#(Z_cast2 (uint32, r[-1 ~> 1])%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2989₂ @ x36₁ @ x2982₁))%expr_pat in |
| 4941 |
expr_let x2991 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x36₂ @ x2983₁))%expr_pat in |
| 4942 |
expr_let x2992 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2991₂ @ x35₂ @ x2984₁))%expr_pat in |
| 4943 |
expr_let x2993 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2992₂ @ x34₂ @ x2985₁))%expr_pat in |
| 4944 |
expr_let x2994 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2993₂ @ x40₁ @ x2986₁))%expr_pat in |
| 4945 |
expr_let x2995 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2994₂ @ x40₂ @ x2987₁))%expr_pat in |
| 4946 |
expr_let x2996 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2995₂ @ x39₂ @ x2988₁))%expr_pat in |
| 4947 |
expr_let x2997 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2996₂ @ x38₂ @ x2989₁))%expr_pat in |
| 4948 |
expr_let x2998 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2997₂ @ x37₂ @ x2990₁))%expr_pat in |
| 4949 |
expr_let x2999 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x42₁ @ x2991₁))%expr_pat in |
| 4950 |
expr_let x3000 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x2999₂ @ x41₁ @ x2992₁))%expr_pat in |
| 4951 |
expr_let x3001 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3000₂ @ x41₂ @ x2993₁))%expr_pat in |
| 4952 |
expr_let x3002 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3001₂ @ x47₁ @ x2994₁))%expr_pat in |
| 4953 |
expr_let x3003 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3002₂ @ x46₁ @ x2995₁))%expr_pat in |
| 4954 |
expr_let x3004 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3003₂ @ x45₁ @ x2996₁))%expr_pat in |
| 4955 |
expr_let x3005 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3004₂ @ x44₁ @ x2997₁))%expr_pat in |
| 4956 |
expr_let x3006 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3005₂ @ x43₁ @ x2998₁))%expr_pat in |
| 4957 |
expr_let x3007 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x43₂ @ x2999₁))%expr_pat in |
| 4958 |
expr_let x3008 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3007₂ @ x42₂ @ x3000₁))%expr_pat in |
| 4959 |
expr_let x3009 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3008₂ @ x48₁ @ x3001₁))%expr_pat in |
| 4960 |
expr_let x3010 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3009₂ @ x48₂ @ x3002₁))%expr_pat in |
| 4961 |
expr_let x3011 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3010₂ @ x47₂ @ x3003₁))%expr_pat in |
| 4962 |
expr_let x3012 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3011₂ @ x46₂ @ x3004₁))%expr_pat in |
| 4963 |
expr_let x3013 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3012₂ @ x45₂ @ x3005₁))%expr_pat in |
| 4964 |
expr_let x3014 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3013₂ @ x44₂ @ x3006₁))%expr_pat in |
| 4965 |
expr_let x3015 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x49₁ @ x3007₁))%expr_pat in |
| 4966 |
expr_let x3016 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3015₂ @ x49₂ @ x3008₁))%expr_pat in |
| 4967 |
expr_let x3017 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3016₂ @ x55₁ @ x3009₁))%expr_pat in |
| 4968 |
expr_let x3018 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3017₂ @ x54₁ @ x3010₁))%expr_pat in |
| 4969 |
expr_let x3019 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3018₂ @ x53₁ @ x3011₁))%expr_pat in |
| 4970 |
expr_let x3020 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3019₂ @ x52₁ @ x3012₁))%expr_pat in |
| 4971 |
expr_let x3021 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3020₂ @ x51₁ @ x3013₁))%expr_pat in |
| 4972 |
expr_let x3022 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3021₂ @ x50₁ @ x3014₁))%expr_pat in |
| 4973 |
expr_let x3023 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x50₂ @ x3015₁))%expr_pat in |
| 4974 |
expr_let x3024 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3023₂ @ x56₁ @ x3016₁))%expr_pat in |
| 4975 |
expr_let x3025 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3024₂ @ x56₂ @ x3017₁))%expr_pat in |
| 4976 |
expr_let x3026 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3025₂ @ x55₂ @ x3018₁))%expr_pat in |
| 4977 |
expr_let x3027 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3026₂ @ x54₂ @ x3019₁))%expr_pat in |
| 4978 |
expr_let x3028 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3027₂ @ x53₂ @ x3020₁))%expr_pat in |
| 4979 |
expr_let x3029 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3028₂ @ x52₂ @ x3021₁))%expr_pat in |
| 4980 |
expr_let x3030 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3029₂ @ x51₂ @ x3022₁))%expr_pat in |
| 4981 |
expr_let x3031 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_get_carry_concrete 4294967296)%expr @ x57₂ @ x3023₁))%expr_pat in |
| 4982 |
expr_let x3032 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3031₂ @ x63₁ @ x3024₁))%expr_pat in |
| 4983 |
expr_let x3033 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3032₂ @ x62₁ @ x3025₁))%expr_pat in |
| 4984 |
expr_let x3034 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3033₂ @ x61₁ @ x3026₁))%expr_pat in |
| 4985 |
expr_let x3035 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3034₂ @ x60₁ @ x3027₁))%expr_pat in |
| 4986 |
expr_let x3036 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3035₂ @ x59₁ @ x3028₁))%expr_pat in |
| 4987 |
expr_let x3037 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3036₂ @ x58₁ @ x3029₁))%expr_pat in |
| 4988 |
expr_let x3038 := (#(Z_cast2 (uint32, bool)%core)%expr @ (#(Z_add_with_get_carry_concrete 4294967296)%expr @ x3037₂ @ x57₁ @ x3030₁))%expr_pat in |
| 4989 |
[x3031₁; x3032₁; x3033₁; x3034₁; x3035₁; x3036₁; x3037₁; x3038₁] |
| 4990 |
: Expr (type.base (base.type.list (base.type.type_base base.type.Z)) -> type.base (base.type.list (base.type.type_base base.type.Z)) -> type.base (base.type.list (base.type.type_base base.type.Z)))%ptype |
| 4991 |
Finished transaction in 211.393 secs (210.924u,0.028s) (successful) |
| 4992 |
*) |
| 4993 |
End P256_32. |
| 4994 |
*) |