Function of #cas
jacobiSymbol
The Jacobi symbol of an integer and an odd natural number, with a theorem about Mathlib’s jacobiSym.
#cas (jacobiSymbol a n)jacobiSym a n = j.jacobiSymbol computes the Jacobi symbol, and what it’s good for is ruling out squares modulo an odd integer. For a prime it is the Legendre symbol. For every odd the value proves that a is not a square modulo n, but for a composite the value proves nothing of the kind, as Possible Issues shows.
Examples (7)#
Basic Examples (1)
The symbol , with the theorem that the kernel checked:
#cas (jacobiSymbol 1001 9907)
Jacobi symbol
-1- Domain
ℤ × ℕ- Input (an integer and an odd natural number)
(1001 / 9907)
Checked by Lean’s kernel: Jacobi symbol
jacobiSym 1001 9907 = -1
The certificate: 1 checked step
Jacobi symbol
jacobiSym 1001 9907 = -1
Scope (2)
The integer may be negative. For an odd prime , exactly when :
#cas (jacobiSymbol (-1) 7)
Jacobi symbol
-1- Domain
ℤ × ℕ- Input (an integer and an odd natural number)
(-1 / 7)
Checked by Lean’s kernel: Jacobi symbol
jacobiSym (-1) 7 = -1
The certificate: 1 checked step
Jacobi symbol
jacobiSym (-1) 7 = -1
The symbol is 0 exactly when , here :
#cas (jacobiSymbol 6 9)
Jacobi symbol
0- Domain
ℤ × ℕ- Input (an integer and an odd natural number)
(6 / 9)
Checked by Lean’s kernel: Jacobi symbol
jacobiSym 6 9 = 0
The certificate: 1 checked step
Jacobi symbol
jacobiSym 6 9 = 0
Applications (1)
ZMod.nonsquare_of_jacobiSym_eq_neg_one turns the value into a statement about squares, and cas proves the value. Only the three standard axioms are used:
theorem not_square_mod_9907 : ¬IsSquare ((1001 : ℤ) : ZMod 9907) := ZMod.nonsquare_of_jacobiSym_eq_neg_one (by cas) #print axioms not_square_mod_9907
not_square_mod_9907 depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (1)
For an odd prime , Euler’s criterion relates the symbol to powerMod. For and , , and indeed , so 2 is a square modulo 7:
#cas (jacobiSymbol 2 7)
Jacobi symbol
1- Domain
ℤ × ℕ- Input (an integer and an odd natural number)
(2 / 7)
Checked by Lean’s kernel: Jacobi symbol
jacobiSym 2 7 = 1
The certificate: 1 checked step
Jacobi symbol
jacobiSym 2 7 = 1
Possible Issues (2)
For a composite the value 1 does not make a a square modulo n. , while the squares modulo 15 are 0, 1, 4, 6, 9 and 10:
#cas (jacobiSymbol 2 15)
Jacobi symbol
1- Domain
ℤ × ℕ- Input (an integer and an odd natural number)
(2 / 15)
Checked by Lean’s kernel: Jacobi symbol
jacobiSym 2 15 = 1
The certificate: 1 checked step
Jacobi symbol
jacobiSym 2 15 = 1
The Jacobi symbol is defined for odd . Mathlib’s jacobiSym takes every natural number and agrees with the symbol when is odd, and the call takes only odd :
#cas (jacobiSymbol 2 4)
Error
jacobiSymbol: expected an odd natural number
