Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove special conditional subtract #98

Conversation

JasonGross
Copy link
Collaborator

This is on top of #97. Here's the current list of Print Assumptions in 8.6:

Axioms:
WordUtil.wlast_combine : forall (sz : nat) (a : Word.word sz) (b : bool),
                         WordUtil.wlast (Word.combine a (Word.WS b Word.WO)) =
                         b
WordUtil.wlast : forall sz : nat, Word.word (sz + 1) -> bool
WordUtil.winit_combine : forall (sz : nat) (a : Word.word sz)
                           (b : Word.word 1),
                         WordUtil.winit (Word.combine a b) = a
WordUtil.winit : forall sz : nat, Word.word (sz + 1) -> Word.word sz
shiftr_range : forall a n m : Z,
               (0 <= a < 2 ^ (n + m))%Z -> (0 <= Z.shiftr a n < 2 ^ m)%Z
GF25519BoundedCommon.proof_admitted : False
 used in postfreezeW_subproof to prove: GF25519BoundedCommon.fe25519W ->
                                        GF25519BoundedCommon.fe25519W
prime_q : Znumtheory.prime (2 ^ 255 - 19)
prime_l : Znumtheory.prime (2 ^ 252 + 27742317777372353535851937790883648493)
pow2_mod_range : forall a n m : Z,
                 (n <= m)%Z -> (0 <= ZUtil.Z.pow2_mod a n < 2 ^ m)%Z
GF25519BoundedCommon.postfreezeW_correct_and_bounded :
forall x : GF25519BoundedCommon.fe25519W,
GF25519BoundedCommon.is_bounded (GF25519BoundedCommon.fe25519WToZ x) = true ->
GF25519BoundedCommon.fe25519WToZ (GF25519BoundedCommon.postfreezeW x) =
GF25519BoundedCommon.postfreeze (GF25519BoundedCommon.fe25519WToZ x) /\
GF25519BoundedCommon.is_bounded
  (GF25519BoundedCommon.fe25519WToZ (GF25519BoundedCommon.postfreezeW x)) =
true
GF25519BoundedCommon.postfreeze : GF25519.fe25519 -> GF25519.fe25519
Tuple.map_S : forall (n : nat) (A B : Type) (f : A -> B)
                (xs : Tuple.tuple' A n) (x : A),
              Tuple.map f (xs, x) = (Tuple.map f xs, f x)
Tuple.map2_S : forall (n : nat) (A B C : Type) (f : A -> B -> C)
                 (xs : Tuple.tuple' A n) (ys : Tuple.tuple' B n)
                 (x : A) (y : B),
               Tuple.map2 f (xs, x) (ys, y) = (Tuple.map2 f xs ys, f x y)
GF25519BoundedCommon.freeze_prepost_freeze : forall
                                               x :
                                                Z * Z * Z * Z * Z * Z * Z * Z *
                                                Z * Z,
                                             GF25519BoundedCommon.postfreeze
                                               (GF25519BoundedCommon.prefreeze
                                                 x) =
                                             GF25519.freeze x
WordUtil.combine_winit_wlast : forall (sz : nat) (a : Word.word sz)
                                 (b : Word.word 1)
                                 (c : Word.word (sz + 1)),
                               Word.combine a b = c <->
                               a = WordUtil.winit c /\
                               b = Word.WS (WordUtil.wlast c) Word.WO
WordNZ_split2 : forall (n m : nat) (w : Word.word (n + m)),
                Z.of_N (Word.wordToN (Word.split2 n m w)) =
                Z.shiftr (Z.of_N (Word.wordToN w)) (Z.of_nat n)
WordNZ_split1 : forall (n m : nat) (w : Word.word (n + m)),
                Z.of_N (Word.wordToN (Word.split1 n m w)) =
                ZUtil.Z.pow2_mod (Z.of_N (Word.wordToN w)) (Z.of_nat n)
WordNZ_range_mono : forall (n : nat) (m : Z) (w : Word.word n),
                    (Z.of_nat n <= m)%Z ->
                    (0 <= Z.of_N (Word.wordToN w) < 2 ^ m)%Z
WordNZ_range : forall (n : nat) (B : Z) (w : Word.word n),
               (2 ^ Z.of_nat n <= B)%Z ->
               (0 <= Z.of_N (Word.wordToN w) < B)%Z
Proper_sqrt : Proper (GF25519BoundedCommon.eq ==> GF25519BoundedCommon.eq)
                GF25519Bounded.sqrt
H : forall n : nat, Word.word n -> Word.word (b + b)
B_order_l : CompleteEdwardsCurveTheorems.E.eq
              (CompleteEdwardsCurve.E.mul (Z.to_nat l) B)
              CompleteEdwardsCurve.E.zero

(There are also a bunch of admits from feDec_correct in 8.4 only.)

Just in case you're curious where the time in Experiments/Ed25519.v is spent in 8.6:

total time:     35.736s

 tactic                                   local  total   calls       max
────────────────────────────────────────┴──────┴──────┴───────┴─────────┘
─destruct X eqn:? ----------------------  16.3%  16.3%       2    2.920s
─destruct (ModularBaseSystemListProofs.g  14.6%  14.6%       1    5.228s
─discriminate --------------------------  10.7%  10.7%       7    1.964s
─vm_decide -----------------------------   8.9%   9.0%      22    3.144s
─rewrite Hgm in * ----------------------   6.7%   6.7%       1    2.392s
─omega ---------------------------------   3.4%   3.4%     470    0.340s
─rewrite Tuple.to_list_from_list -------   3.4%   3.4%      14    0.408s
─rewrite A in * ------------------------   3.4%   3.4%       1    1.212s
─vm_decide_no_check --------------------   0.0%   2.0%      26    0.660s
─apply dec_bool ------------------------   1.9%   2.0%      27    0.660s

@jadephilipoom
Copy link
Collaborator

Why is Travis failing on the last two commits?

@JasonGross
Copy link
Collaborator Author

It's not?

image

It's failing on the first two commits, though, because I hadn't yet pushed the 8.4 fix for universes.

@jadephilipoom
Copy link
Collaborator

Oops, misunderstood the order there. Never mind. :)

@JasonGross
Copy link
Collaborator Author

Merged via #104

@JasonGross JasonGross closed this Nov 11, 2016
@JasonGross JasonGross deleted the remove-special-conditional-subtract branch November 11, 2016 21:09
JasonGross added a commit to JasonGross/fiat-crypto that referenced this pull request Feb 21, 2022
Probably if the lists are the same lengths, then we want to compare them
element-wise rather than all at once.  It's way too verbose to keep
expanding them, so we only do that when lists are not the same length.

We now get error messages such as
```
Unable to unify: [inr [378, 381, 384]] == [inr [101, 106, 108]]
Could not unify the values at index 0: [mit-plv#378, mit-plv#381, mit-plv#384] != [mit-plv#101, mit-plv#106, mit-plv#108]
index 0: mit-plv#378 != mit-plv#101
(slice 0 44, [mit-plv#377]) != (slice 0 44, [mit-plv#98])
index 0: mit-plv#377 != mit-plv#98
(add 64, [mit-plv#345, mit-plv#375]) != (add 64, [#57, mit-plv#96])
index 0: mit-plv#345 != #57
(slice 0 44, [mit-plv#337]) != (slice 0 44, [#44])
index 0: mit-plv#337 != #44
(add 64, [#41, mit-plv#334]) != (add 64, [#25, #41])
index 1: mit-plv#334 != #25
(mul 64, [#1, mit-plv#331]) != (mul 64, [#0, #1, #22])
[(add 64, [mit-plv#329, mit-plv#329])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [#7, mit-plv#328]), (mul 64, [#7, mit-plv#328])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, mit-plv#327])]), (mul 64, [(const 2, []), (add 64, [#0, mit-plv#327])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, mit-plv#326])])]), (mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, mit-plv#326])])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, (const 4, [])])])]), (mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, (const 4, [])])])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [(old 64 0, []), (mul 64, [(old 64 0, []), (const 4, [])])])]), (mul 64, [(const 2, []), (add 64, [(old 64 0, []), (mul 64, [(old 64 0, []), (const 4, [])])])])])] != [(old 64 0, []), (const 20, [])]
```

The second to last line is generally the one to look at; the last line
adds a bit more detail to it.  Perhaps we should instead list out the
values of indices rather than expanding one additional level?
JasonGross added a commit to JasonGross/fiat-crypto that referenced this pull request Feb 21, 2022
Probably if the lists are the same lengths, then we want to compare them
element-wise rather than all at once.  It's way too verbose to keep
expanding them, so we only do that when lists are not the same length.

We now get error messages such as
```
Unable to unify: [inr [378, 381, 384]] == [inr [101, 106, 108]]
Could not unify the values at index 0: [mit-plv#378, mit-plv#381, mit-plv#384] != [mit-plv#101, mit-plv#106, mit-plv#108]
index 0: mit-plv#378 != mit-plv#101
(slice 0 44, [mit-plv#377]) != (slice 0 44, [mit-plv#98])
index 0: mit-plv#377 != mit-plv#98
(add 64, [mit-plv#345, mit-plv#375]) != (add 64, [#57, mit-plv#96])
index 0: mit-plv#345 != #57
(slice 0 44, [mit-plv#337]) != (slice 0 44, [#44])
index 0: mit-plv#337 != #44
(add 64, [#41, mit-plv#334]) != (add 64, [#25, #41])
index 1: mit-plv#334 != #25
(mul 64, [#1, mit-plv#331]) != (mul 64, [#0, #1, #22])
[(add 64, [mit-plv#329, mit-plv#329])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [#7, mit-plv#328]), (mul 64, [#7, mit-plv#328])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, mit-plv#327])]), (mul 64, [(const 2, []), (add 64, [#0, mit-plv#327])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, mit-plv#326])])]), (mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, mit-plv#326])])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, (const 4, [])])])]), (mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, (const 4, [])])])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [(old 64 0, []), (mul 64, [(old 64 0, []), (const 4, [])])])]), (mul 64, [(const 2, []), (add 64, [(old 64 0, []), (mul 64, [(old 64 0, []), (const 4, [])])])])])] != [(old 64 0, []), (const 20, [])]
```

The second to last line is generally the one to look at; the last line
adds a bit more detail to it.  Perhaps we should instead list out the
values of indices rather than expanding one additional level?
JasonGross added a commit that referenced this pull request Feb 22, 2022
Probably if the lists are the same lengths, then we want to compare them
element-wise rather than all at once.  It's way too verbose to keep
expanding them, so we only do that when lists are not the same length.

We now get error messages such as
```
Unable to unify: [inr [378, 381, 384]] == [inr [101, 106, 108]]
Could not unify the values at index 0: [#378, #381, #384] != [#101, #106, #108]
index 0: #378 != #101
(slice 0 44, [#377]) != (slice 0 44, [#98])
index 0: #377 != #98
(add 64, [#345, #375]) != (add 64, [#57, #96])
index 0: #345 != #57
(slice 0 44, [#337]) != (slice 0 44, [#44])
index 0: #337 != #44
(add 64, [#41, #334]) != (add 64, [#25, #41])
index 1: #334 != #25
(mul 64, [#1, #331]) != (mul 64, [#0, #1, #22])
[(add 64, [#329, #329])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [#7, #328]), (mul 64, [#7, #328])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, #327])]), (mul 64, [(const 2, []), (add 64, [#0, #327])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, #326])])]), (mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, #326])])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, (const 4, [])])])]), (mul 64, [(const 2, []), (add 64, [#0, (mul 64, [#0, (const 4, [])])])])])] != [#0, (const 20, [])]
[(add 64, [(mul 64, [(const 2, []), (add 64, [(old 64 0, []), (mul 64, [(old 64 0, []), (const 4, [])])])]), (mul 64, [(const 2, []), (add 64, [(old 64 0, []), (mul 64, [(old 64 0, []), (const 4, [])])])])])] != [(old 64 0, []), (const 20, [])]
```

The second to last line is generally the one to look at; the last line
adds a bit more detail to it.  Perhaps we should instead list out the
values of indices rather than expanding one additional level?
dderjoel added a commit to dderjoel/fiat-crypto that referenced this pull request Mar 22, 2022
Unable to unify: [inr [351, 349, 350]] == [inr [103, 108, 110]]
Could not unify the values at index 0: [mit-plv#351, mit-plv#349, mit-plv#350] != [mit-plv#103, mit-plv#108, mit-plv#110]
index 0: mit-plv#351 != mit-plv#103
(slice 0 44, [mit-plv#345]) != (slice 0 44, [mit-plv#100])
index 0: mit-plv#345 != mit-plv#100
(add 64, [mit-plv#58, mit-plv#95, mit-plv#343]) != (add 64, [mit-plv#58, mit-plv#98])
(add 64, [mit-plv#95, mit-plv#343]) != (add 64, [mit-plv#98])
(add 64, [mit-plv#95, (mul 64, [mit-plv#95, mit-plv#331])]) != (add 64, [(mul 64, [#3, mit-plv#95])])
(add 64, [mit-plv#95, (mul 64, [mit-plv#95, (const 4, [])])]) != (add 64, [(mul 64, [#3, mit-plv#95])])
(add 64, [(or 64, [mit-plv#91, mit-plv#93]), (mul 64, [(or 64, [mit-plv#91, mit-plv#93]), (const 4, [])])]) != (add 64, [(mul 64, [(const 5, []), (or 64, [mit-plv#91, mit-plv#93])])])
JasonGross pushed a commit to dderjoel/fiat-crypto that referenced this pull request Mar 22, 2022
Unable to unify: [inr [351, 349, 350]] == [inr [103, 108, 110]]
Could not unify the values at index 0: [mit-plv#351, mit-plv#349, mit-plv#350] != [mit-plv#103, mit-plv#108, mit-plv#110]
index 0: mit-plv#351 != mit-plv#103
(slice 0 44, [mit-plv#345]) != (slice 0 44, [mit-plv#100])
index 0: mit-plv#345 != mit-plv#100
(add 64, [mit-plv#58, mit-plv#95, mit-plv#343]) != (add 64, [mit-plv#58, mit-plv#98])
(add 64, [mit-plv#95, mit-plv#343]) != (add 64, [mit-plv#98])
(add 64, [mit-plv#95, (mul 64, [mit-plv#95, mit-plv#331])]) != (add 64, [(mul 64, [#3, mit-plv#95])])
(add 64, [mit-plv#95, (mul 64, [mit-plv#95, (const 4, [])])]) != (add 64, [(mul 64, [#3, mit-plv#95])])
(add 64, [(or 64, [mit-plv#91, mit-plv#93]), (mul 64, [(or 64, [mit-plv#91, mit-plv#93]), (const 4, [])])]) != (add 64, [(mul 64, [(const 5, []), (or 64, [mit-plv#91, mit-plv#93])])])
JasonGross pushed a commit that referenced this pull request Mar 23, 2022
Unable to unify: [inr [351, 349, 350]] == [inr [103, 108, 110]]
Could not unify the values at index 0: [#351, #349, #350] != [#103, #108, #110]
index 0: #351 != #103
(slice 0 44, [#345]) != (slice 0 44, [#100])
index 0: #345 != #100
(add 64, [#58, #95, #343]) != (add 64, [#58, #98])
(add 64, [#95, #343]) != (add 64, [#98])
(add 64, [#95, (mul 64, [#95, #331])]) != (add 64, [(mul 64, [#3, #95])])
(add 64, [#95, (mul 64, [#95, (const 4, [])])]) != (add 64, [(mul 64, [#3, #95])])
(add 64, [(or 64, [#91, #93]), (mul 64, [(or 64, [#91, #93]), (const 4, [])])]) != (add 64, [(mul 64, [(const 5, []), (or 64, [#91, #93])])])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants