Skip to content

Commit a451769

Browse files
committed
Added user script in coqbot.sh for JasonGross in rocq-prover/rocq
Comment Thread ID: I_kwDOABUDh87mfTxp
1 parent 436e1b8 commit a451769

File tree

4 files changed

+143
-16
lines changed

4 files changed

+143
-16
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: coq-community/docker-coq-action@v1.5.2
2323
with:
2424
#custom_image: 'registry.gitlab.com/coq/coq:CACHEKEY'
25-
#coq_version: 'latest'
25+
coq_version: 'dev'
2626
#ocaml_version: 'default'
2727
custom_script: ./timeout-run.sh
2828
timeout-minutes: 330 # Each job in a workflow can run for up to 6 hours of execution time, we want to make sure there's time to upload the files

coqbot-request-stamp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DUMMY
1+
I_kwDOABUDh87mfTxp JasonGross rocq-community/run-coq-bug-minimizer run-coq-bug-minimizer-3533900648153 rocq-prover rocq

coqbot.sh

Lines changed: 140 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,140 @@
1-
opam update -y
2-
opam install -y coq-ext-lib
3-
eval $(opam env)
4-
5-
mkdir temp
6-
cd temp
7-
wget https://github.com/coq/coq/files/4698509/bug.v.zip
8-
unzip bug.v.zip
9-
coqc -q bug.v
10-
#git clone https://github.com/satnam6502/oak-hardware
11-
#cd oak-hardware
12-
#git checkout 38971a7d0f8aa04b6fa4e21d1dfda3990ecf2c66
13-
#cd cava/cava
14-
#make coq
1+
#!/usr/bin/env bash
2+
cat > bug.v <<_EOF
3+
(* depends on a few files of fiat-crypto *)
4+
Module Export AdmitTactic.
5+
Module Import LocalFalse.
6+
Inductive False : Prop := .
7+
End LocalFalse.
8+
Axiom proof_admitted : False.
9+
Import Coq.Init.Ltac.
10+
Tactic Notation "admit" := abstract case proof_admitted.
11+
End AdmitTactic.
12+
Require Stdlib.Structures.Orders.
13+
Require Crypto.Arithmetic.Saturated.
14+
Require Stdlib.ssr.ssreflect.
15+
Import Stdlib.ZArith.ZArith.
16+
Import Crypto.Arithmetic.Core.
17+
Import Crypto.Arithmetic.Partition.
18+
Import Crypto.Arithmetic.Saturated.
19+
Require Import Crypto.Arithmetic.UniformWeight.
20+
Import Crypto.Util.ZUtil.Definitions.
21+
Import Crypto.Util.LetIn.
22+
Local Open Scope Z_scope.
23+
Section with_args.
24+
Context (lgr : Z)
25+
(m : Z).
26+
Local Notation weight := (uweight lgr).
27+
Let T (n : nat) := list Z.
28+
Let r := (2^lgr).
29+
Definition eval {n} : T n -> Z.
30+
exact (Positional.eval weight n).
31+
Defined.
32+
Let zero {n} : T n.
33+
admit.
34+
Defined.
35+
Let divmod {n} : T (S n) -> T n * Z.
36+
admit.
37+
Defined.
38+
Let scmul {n} (c : Z) (p : T n) : T (S n).
39+
admit.
40+
Defined.
41+
Let addT {n} (p q : T n) : T (S n).
42+
admit.
43+
Defined.
44+
Let drop_high_addT' {n} (p : T (S n)) (q : T n) : T (S n).
45+
admit.
46+
Defined.
47+
Let conditional_sub {n} (arg : T (S n)) (N : T n) : T n.
48+
exact (Positional.drop_high_to_length n (Rows.conditional_sub weight (S n) arg (Positional.extend_to_length n (S n) N))).
49+
Defined.
50+
Context (R_numlimbs : nat)
51+
(N : T R_numlimbs).
52+
Section Iteration.
53+
Context (pred_A_numlimbs : nat)
54+
(B : T R_numlimbs) (k : Z)
55+
(A : T (S pred_A_numlimbs))
56+
(S : T (S R_numlimbs)).
57+
Local Definition A'_S3
58+
:= dlet A_a := @divmod _ A in
59+
dlet A' := fst A_a in
60+
dlet a := snd A_a in
61+
dlet S1 := @addT _ S (@scmul _ a B) in
62+
dlet s := snd (@divmod _ S1) in
63+
dlet q := fst (Z.mul_split r s k) in
64+
dlet S2 := @drop_high_addT' _ S1 (@scmul _ q N) in
65+
dlet S3 := fst (@divmod _ S2) in
66+
(A', S3).
67+
End Iteration.
68+
Context (A_numlimbs : nat)
69+
(A : T A_numlimbs)
70+
(B : T R_numlimbs)
71+
(k : Z)
72+
(S' : T (S R_numlimbs)).
73+
Definition redc_body {pred_A_numlimbs} : T (S pred_A_numlimbs) * T (S R_numlimbs)
74+
-> T pred_A_numlimbs * T (S R_numlimbs).
75+
exact (fun '(A, S') => A'_S3 _ B k A S').
76+
Defined.
77+
Definition redc_loop (count : nat) : T count * T (S R_numlimbs) -> T O * T (S R_numlimbs).
78+
exact (nat_rect
79+
(fun count => T count * _ -> _)
80+
(fun A_S => A_S)
81+
(fun count' redc_loop_count' A_S
82+
=> redc_loop_count' (redc_body A_S))
83+
count).
84+
Defined.
85+
Definition pre_redc : T (S R_numlimbs).
86+
exact (snd (redc_loop A_numlimbs (A, @zero (1 + R_numlimbs)%nat))).
87+
Defined.
88+
Definition redc : T R_numlimbs.
89+
exact (conditional_sub pre_redc N).
90+
Defined.
91+
Definition small {n} (v : T n) : Prop.
92+
exact (v = Partition.partition weight n (eval v)).
93+
Defined.
94+
End with_args.
95+
Section modops.
96+
Context (bitwidth : Z)
97+
(n : nat)
98+
(m : Z).
99+
Let r := 2^bitwidth.
100+
Local Notation weight := (uweight bitwidth).
101+
Local Notation eval := (@eval bitwidth n).
102+
Let m_enc := Partition.partition weight n m.
103+
Local Coercion Z.of_nat : nat >-> Z.
104+
Context (r' : Z)
105+
(m' : Z)
106+
(r'_correct : (r * r') mod m = 1)
107+
(m'_correct : (m * m') mod r = (-1) mod r)
108+
(bitwidth_big : 0 < bitwidth)
109+
(m_big : 1 < m)
110+
(n_nz : n <> 0%nat)
111+
(m_small : m < r^n).
112+
Local Notation small := (@small bitwidth n).
113+
Definition mulmod (a b : list Z) : list Z.
114+
exact (@redc bitwidth n m_enc n a b m').
115+
Defined.
116+
Definition valid (a : list Z) := small a /\ 0 <= eval a < m.
117+
Definition onemod : list Z.
118+
Admitted.
119+
Definition R2mod : list Z.
120+
Admitted.
121+
Definition from_montgomerymod (v : list Z) : list Z.
122+
exact (mulmod v onemod).
123+
Defined.
124+
Lemma eval_mulmod
125+
: (forall a (_ : valid a) b (_ : valid b),
126+
eval (from_montgomerymod (mulmod a b)) mod m
127+
= (eval (from_montgomerymod a) * eval (from_montgomerymod b)) mod m).
128+
Admitted.
129+
Goal forall v, eval (from_montgomerymod v) mod m * (eval (from_montgomerymod R2mod) mod m) mod m = eval v mod m.
130+
Proof.
131+
intros.
132+
assert_fails rewrite eval_mulmod.
133+
Import Stdlib.ssr.ssreflect.
134+
timeout 3 try rewrite eval_mulmod.
135+
_EOF
136+
echo testing
137+
cat bug.v
138+
echo end test
139+
opam install -y coq-fiat-crypto
140+
coqc bug.v

coqbot.url

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://coqbot.herokuapp.com/coq-bug-minimizer

0 commit comments

Comments
 (0)