Skip to content

Commit

Permalink
Make use of id_tuple_with_alt_cps'
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Nov 6, 2017
1 parent 52a8476 commit 3d3e033
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Arithmetic/Core.v
Expand Up @@ -1076,15 +1076,15 @@ Hint Unfold
Positional.select_cps
Positional.select
modulo div modulo_cps div_cps
id_tuple_with_alt id_tuple'_with_alt
id_tuple_with_alt id_tuple'_with_alt id_tuple_with_alt_cps'
Z.add_get_carry_full Z.add_get_carry_full_cps
: basesystem_partial_evaluation_unfolder.

Hint Unfold
B.limb ListUtil.sum ListUtil.sum_firstn
CPSUtil.Tuple.mapi_with_cps CPSUtil.Tuple.mapi_with'_cps CPSUtil.flat_map_cps CPSUtil.on_tuple_cps CPSUtil.fold_right_cps2
Decidable.dec Decidable.dec_eq_Z
id_tuple_with_alt id_tuple'_with_alt
id_tuple_with_alt id_tuple'_with_alt id_tuple_with_alt_cps'
Z.add_get_carry_full Z.add_get_carry_full_cps Z.mul_split Z.mul_split_cps Z.mul_split_cps'
: basesystem_partial_evaluation_unfolder.

Expand All @@ -1110,7 +1110,7 @@ Ltac basesystem_partial_evaluation_unfolder t :=
Associational.carryterm_cps Associational.carryterm
Associational.carry_cps Associational.carry
Associational.negate_snd_cps Associational.negate_snd div modulo
id_tuple_with_alt id_tuple'_with_alt
id_tuple_with_alt id_tuple'_with_alt id_tuple_with_alt_cps'
Z.add_get_carry_full Z.add_get_carry_full_cps
] in t.

Expand Down
3 changes: 2 additions & 1 deletion src/Arithmetic/CoreUnfolder.v
Expand Up @@ -3,6 +3,7 @@ Require Import Crypto.Util.LetIn.
Require Import Crypto.Util.ZUtil.Definitions.
Require Import Crypto.Util.ZUtil.CPS.
Require Import Crypto.Util.IdfunWithAlt.
Require Import Crypto.Util.CPSUtil.
Require Import Crypto.Arithmetic.Core.
Require Import Crypto.Util.Tactics.VM.

Expand All @@ -16,7 +17,7 @@ Ltac make_parameterized_sig t :=
B.limb ListUtil.sum ListUtil.sum_firstn
CPSUtil.Tuple.mapi_with_cps CPSUtil.Tuple.mapi_with'_cps CPSUtil.flat_map_cps CPSUtil.on_tuple_cps CPSUtil.fold_right_cps2
Decidable.dec Decidable.dec_eq_Z
id_tuple_with_alt id_tuple'_with_alt
id_tuple_with_alt id_tuple'_with_alt id_tuple_with_alt_cps'
Z.add_get_carry_full Z.mul_split
Z.add_get_carry_full_cps Z.mul_split_cps Z.mul_split_cps'
Z.add_get_carry_cps];
Expand Down
11 changes: 6 additions & 5 deletions src/Arithmetic/Karatsuba.v
Expand Up @@ -78,7 +78,7 @@ Context (weight : nat -> Z)
actually run and a version to bounds-check, along with a proof
that they are exactly equal. This works around cases where the
bounds proof requires high-level reasoning. *)
Local Notation id_with_alt_bounds := id_tuple_with_alt.
Local Notation id_with_alt_bounds_cps := id_tuple_with_alt_cps'.

(*
If:
Expand Down Expand Up @@ -134,27 +134,28 @@ Context (weight : nat -> Z)
(fun sum_y => mul_cps weight sum_x sum_y
(fun mul_sumxy =>

dlet z1 := id_with_alt_bounds (unbalanced_sub_cps weight mul_sumxy z0 id) (
id_with_alt_bounds_cps (fun f =>
(unbalanced_sub_cps weight mul_sumxy z0 f)) (fun f =>

(mul_cps weight (fst x0_x1) (snd y0_y1)
(fun x0_y1 => mul_cps weight (snd x0_x1) (fst y0_y1)
(fun x1_y0 => mul_cps weight (fst x0_x1) (fst y0_y1)
(fun z0 => mul_cps weight (snd x0_x1) (snd y0_y1)
(fun z2 => add_cps weight z0 z2
(fun sum_z => add_cps weight x0_y1 x1_y0
(fun z1' => add_cps weight z1' z2 id)))))))) in
(fun z1' => add_cps weight z1' z2 f)))))))) (fun z1 =>

Positional.to_associational_cps weight z1
(fun z1 => Associational.mul_cps (pair s 1::nil) z1
(fun sz1 => Positional.to_associational_cps weight sum_z
(fun sum_z => Positional.from_associational_cps weight _ (sum_z++sz1) f
))))))))))).
)))))))))))).

Definition goldilocks_mul s xs ys := goldilocks_mul_cps s xs ys id.
Lemma goldilocks_mul_id s xs ys R f :
@goldilocks_mul_cps s xs ys R f = f (goldilocks_mul s xs ys).
Proof.
cbv [goldilocks_mul goldilocks_mul_cps id_with_alt_bounds Let_In].
cbv [goldilocks_mul goldilocks_mul_cps Let_In].
repeat autounfold. autorewrite with uncps push_id.
reflexivity.
Qed.
Expand Down

0 comments on commit 3d3e033

Please sign in to comment.