statement
stringlengths
1
4.15k
proof
stringlengths
0
26.3k
type
stringclasses
26 values
symbolic_name
stringlengths
1
75
library
stringclasses
44 values
filename
stringclasses
463 values
imports
listlengths
0
23
deps
listlengths
0
64
docstring
stringlengths
0
2.4k
source_url
stringclasses
1 value
commit
stringclasses
1 value
fermat_inv [m] (a : Zstar m) (H : Z.prime m) : pow a (m-2) = inv a.
Proof. pose proof Z.prime_ge_2 _ H. eapply mul_cancel_l; rewrite mul_inv_same_r. erewrite <-pow_succ_r, <-euler, ?length_elements_prime; f_equal; trivial; lia. Qed.
Theorem
fermat_inv
Zmod
theories/Zmod/ZstarBase.v
[ "Stdlib", "ZArith", "ZModOffset", "Zcong", "Lia", "Zdivisibility", "Bool.Bool", "Lists.List", "Lists.Finite", "Sorting.Permutation", "ListNotations", "Zmod.ZmodDef", "Zmod.ZmodBase", "Zmod.ZstarDef", "ZmodDef.Zmod", "ZmodBase.Zmod", "ZstarDef.Zstar" ]
[ "Zstar", "euler", "inv", "length_elements_prime", "lia", "mul_cancel_l", "mul_inv_same_r", "pow", "pow_succ_r", "prime", "prime_ge_2", "proof" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
euler_criterion_square [p] (Hp : Z.prime p) (a sqrt_a : Zstar p) (Ha : pow sqrt_a 2 = a) : pow a ((p-1)/2) = one.
Proof. pose proof Z.prime_ge_2 _ Hp. eapply wlog_eq_Zstar_3_pos; try lia; intro Hp'; pose proof Private_odd_prime _ Hp Hp'. rewrite pow_2_r in Ha. rewrite <-(fermat sqrt_a Hp), <-Ha, <-pow_2_r, <-pow_mul_r; f_equal. Z.to_euclidean_division_equations; nia. Qed.
Theorem
euler_criterion_square
Zmod
theories/Zmod/ZstarBase.v
[ "Stdlib", "ZArith", "ZModOffset", "Zcong", "Lia", "Zdivisibility", "Bool.Bool", "Lists.List", "Lists.Finite", "Sorting.Permutation", "ListNotations", "Zmod.ZmodDef", "Zmod.ZmodBase", "Zmod.ZstarDef", "ZmodDef.Zmod", "ZmodBase.Zmod", "ZstarDef.Zstar" ]
[ "Private_odd_prime", "Zstar", "fermat", "lia", "nia", "one", "pow", "pow_2_r", "pow_mul_r", "prime", "prime_ge_2", "proof", "to_euclidean_division_equations", "wlog_eq_Zstar_3_pos" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
Zstar (m : Z)
:= mk { Private_to_Z : Z ; Private_range : Is_true (ZmodDef.Zmod.small Private_to_Z m && (Z.gcd Private_to_Z m =? 1)) }.
Record
Zstar
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Is_true", "Zmod", "ZmodDef", "gcd", "small" ]
See [ZStarDef.Zmod.Zmod] for notes on efficient construction
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
to_Zmod {m : Z} (a : Zstar m) : Zmod m
:= Zmod.of_small_Z m (Private_to_Z a).
Coercion
to_Zmod
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "of_small_Z" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
of_coprime_Zmod_dep {m} (a : Zmod m) (H : True -> Z.gcd a m = 1) : Zstar m.
Proof. refine (mk m (Zmod.to_Z a) (transparent_Is_true' _ (fun _ => _))). abstract ( specialize (H I); specialize (Zmod.Private_range _ a); fold (@to_Z m a); case ZmodDef.Zmod.small; [intros|inversion 1]; cbn [andb]; case Z.eqb_spec; try congruence). Defined.
Definition
of_coprime_Zmod_dep
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "ZmodDef", "Zstar", "eqb_spec", "fold", "gcd", "small", "to_Z", "transparent_Is_true'" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
of_Zmod {m} (x : Zmod m) : Zstar m.
Proof. refine (of_coprime_Zmod_dep (if Z.eqb (Z.gcd x m) 1 then x else Zmod.one) (fun _ => _)). abstract ( case Z.eqb_spec; intros; cbv [Zmod.to_Z Zmod.Private_to_Z Zmod.of_Z Zmod.of_small_Z Zmod.one]; trivial; case ZmodDef.Zmod.small eqn:?; rewrite ?Z.gcd_mod_l, ?Z.gcd_1_l, ?Z.gcd_0_l; trivial; rev...
Definition
of_Zmod
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "ZmodDef", "Zstar", "eqb", "eqb_spec", "gcd", "gcd_0_l", "gcd_1_l", "gcd_mod_l", "lia", "mod_bound_or", "of_Z", "of_coprime_Zmod_dep", "of_small_Z", "one", "small", "to_Z" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
eqb {m} (x y : Zstar m)
:= Zmod.eqb x y.
Definition
eqb
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
one {m} : Zstar m
:= of_Zmod Zmod.one.
Definition
one
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "of_Zmod" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
opp {m} (x : Zstar m) : Zstar m
:= of_Zmod (Zmod.opp x).
Definition
opp
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "of_Zmod" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
abs {m} (x : Zstar m) : Zstar m
:= of_Zmod (Zmod.abs x).
Definition
abs
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "of_Zmod" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
mul {m} (a b : Zstar m) : Zstar m.
Proof. refine (of_coprime_Zmod_dep (Zmod.mul a b) (fun _ => _)). abstract ( case a as [a Ha], b as [b Hb] in *; cbv [Zmod.to_Z Zmod.mul Zmod.of_Z Zmod.of_small_Z Zmod.Private_to_Z]; assert (ZmodDef.Zmod.small _ _ = true) as ->; [ set (Z.mul _ _) as z; specialize (Z.opp_mod_bound_or z m); cbv [ZmodDef.Zm...
Definition
mul
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Is_true_eq_true", "Zmod", "ZmodDef", "Zstar", "andb_prop_elim", "coprime_mul_l", "div_mod_to_equations", "eqb_eq", "gcd_mod_l", "lia", "of_Z", "of_coprime_Zmod_dep", "of_small_Z", "opp_mod_bound_or", "proof", "set", "small", "to_Z" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
inv {m} (x : Zstar m) : Zstar m
:= of_Zmod (Zmod.inv x).
Definition
inv
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "of_Zmod" ]
Inverses and division have a canonical definition
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
div {m} (x y : Zstar m) : Zstar m
:= mul x (inv y).
Definition
div
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zstar", "inv", "mul" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
pow {m} (a : Zstar m) z
:= of_Zmod (Zmod.pow a z).
Definition
pow
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "of_Zmod" ]
Powers
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
prod {m} xs : Zstar m
:= List.fold_right mul one xs.
Definition
prod
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "List", "Zstar", "fold_right", "mul", "one" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
elements m : list (Zstar m)
:= if Z.eqb m 0 then [one; opp one] else map of_Zmod (filter (fun x : Zmod _ => Z.eqb (Z.gcd x m) 1) (Zmod.elements m)).
Definition
elements
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "Zstar", "eqb", "filter", "gcd", "list", "map", "of_Zmod", "one", "opp" ]
Enumerating elements
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
positives m
:= map of_Zmod (filter (fun x : Zmod m => Z.gcd x m =? 1) (Zmod.positives m)).
Definition
positives
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "filter", "gcd", "map", "of_Zmod" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
negatives m
:= map of_Zmod (filter (fun x : Zmod m => Z.gcd x m =? 1) (Zmod.negatives m)).
Definition
negatives
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[ "Zmod", "filter", "gcd", "map", "of_Zmod" ]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36
Zstar
:= Zstar.Zstar.
Notation
Zstar
Zmod
theories/Zmod/ZstarDef.v
[ "Stdlib", "ZArith", "Zdivisibility", "ZModOffset", "Lia", "Bool.Bool", "Lists.List", "ListNotations", "ZmodDef", "Zmod" ]
[]
https://github.com/rocq-prover/stdlib
f76a666b0b2c28c671d4fdf6dd25bcab865b9c36