aboutsummaryrefslogtreecommitdiff
path: root/src/SpecificGen/GF25519_64Reflective/CommonUnOpWireToFE.v
blob: 3e711248032bfc3e197e203a9117cd34961744b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Require Export Crypto.SpecificGen.GF25519_64Reflective.Common.
Require Import Crypto.SpecificGen.GF25519_64BoundedCommon.
Require Import Crypto.Reflection.Z.Interpretations128.
Require Import Crypto.Reflection.Syntax.
Require Import Crypto.Reflection.SmartMap.
Require Import Crypto.Util.Tactics.

Local Opaque Interp.
Lemma ExprUnOpWireToFE_correct_and_bounded
      ropW op (ropZ_sig : rexpr_unop_WireToFE_sig op)
      (Hbounds : correct_and_bounded_genT ropW ropZ_sig)
      (H0 : forall x
                   (x := eta_wire_digitsW x)
                   (Hx : wire_digits_is_bounded (wire_digitsWToZ x) = true),
          let args := unopWireToFE_args_to_bounded x Hx in
          match LiftOption.of'
                  (Interp (@BoundedWordW.interp_op) ropW
                          (LiftOption.to' (Some args)))
          with
          | Some _ => True
          | None => False
          end)
      (H1 : forall x
                   (x := eta_wire_digitsW x)
                   (Hx : wire_digits_is_bounded (wire_digitsWToZ x) = true),
          let args := unopWireToFE_args_to_bounded x Hx in
          let x' := SmartVarfMap (fun _ : base_type => BoundedWordW.BoundedWordToBounds) args in
          match LiftOption.of'
                  (Interp (@ZBounds.interp_op) ropW (LiftOption.to' (Some x')))
          with
          | Some bounds => unopWireToFE_bounds_good bounds = true
          | None => False
          end)
  : unop_WireToFE_correct_and_bounded ropW op.
Proof.
  intros x Hx.
  pose x as x'.
  hnf in x; destruct_head' prod.
  specialize (H0 x' Hx).
  specialize (H1 x' Hx).
  let args := constr:(unopWireToFE_args_to_bounded x' Hx) in
  t_correct_and_bounded ropZ_sig Hbounds H0 H1 args.
Qed.