Mode of #cas
transpose
The transpose of a matrix of any shape with rational entries, with a theorem about Mathlib’s Matrix.transpose.
#cas [transpose] AA.transpose = B.transpose swaps rows and columns. You need it to form , to test symmetry, or to turn a row vector into a column vector and back. The theorem is A.transpose = B for Mathlib’s Matrix.transpose, which Mathlib writes Aᵀ.
Examples (13)#
Basic Examples (2)
The transpose of a matrix is :
#cas [transpose] !![1, 2, 3; 4, 5, 6]
transpose
!![1, 4; 2, 5; 3, 6]- Domain
ℚ^(2×3)- Input (matrix)
!![1, 2, 3; 4, 5, 6]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1, 2, 3; 4, 5, 6].transpose = !![1, 4; 2, 5; 3, 6]
The certificate: 1 checked step
Decided by kernel evaluation
!![1, 2, 3; 4, 5, 6].transpose = !![1, 4; 2, 5; 3, 6]
A row becomes a column:
#cas [transpose] !![1, 2, 3]
transpose
!![1; 2; 3]- Domain
ℚ^(1×3)- Input (matrix)
!![1, 2, 3]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1, 2, 3].transpose = !![1; 2; 3]
The certificate: 1 checked step
Decided by kernel evaluation
!![1, 2, 3].transpose = !![1; 2; 3]
Scope (3)
A column becomes a row:
#cas [transpose] !![1; 2; 3]
transpose
!![1, 2, 3]- Domain
ℚ^(3×1)- Input (matrix)
!![1; 2; 3]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1; 2; 3].transpose = !![1, 2, 3]
The certificate: 1 checked step
Decided by kernel evaluation
!![1; 2; 3].transpose = !![1, 2, 3]
A list of rows works as well as a matrix literal:
#cas [transpose] [[1, 2], [3, 4]]
transpose
!![1, 3; 2, 4]- Domain
ℚ^(2×2)- Input (matrix)
!![1, 2; 3, 4]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1, 2; 3, 4].transpose = !![1, 3; 2, 4]
The certificate: 1 checked step
Decided by kernel evaluation
!![1, 2; 3, 4].transpose = !![1, 3; 2, 4]
A symmetric matrix is its own transpose:
#cas [transpose] !![2, 1; 1, 2]
transpose
!![2, 1; 1, 2]- Domain
ℚ^(2×2)- Input (matrix)
!![2, 1; 1, 2]
Checked by Lean’s kernel: Decided by kernel evaluation
!![2, 1; 1, 2].transpose = !![2, 1; 1, 2]
The certificate: 1 checked step
Decided by kernel evaluation
!![2, 1; 1, 2].transpose = !![2, 1; 1, 2]
Applications (3)
The transpose as a theorem. cas proves it, and only the three standard axioms are used:
theorem transpose_two : !![(1 : ℚ), 2; 3, 4].transpose = !![1, 3; 2, 4] := by cas #print axioms transpose_two
transpose_two depends on the axioms propext, Classical.choice, Quot.sound.
The Gram matrix holds the dot products of the columns of . With the transpose from the first example:
#cas [dot] (!![1, 4; 2, 5; 3, 6], !![1, 2, 3; 4, 5, 6])
product
!![17, 22, 27; 22, 29, 36; 27, 36, 45]- Domain
ℚ^(3×2)- Input (product)
!![1, 4; 2, 5; 3, 6] . !![1, 2, 3; 4, 5, 6]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1, 4; 2, 5; 3, 6] * !![1, 2, 3; 4, 5, 6] = !![17, 22, 27; 22, 29, 36; 27, 36, 45]
The certificate: 1 checked step
Decided by kernel evaluation
!![1, 4; 2, 5; 3, 6] * !![1, 2, 3; 4, 5, 6] = !![17, 22, 27; 22, 29, 36; 27, 36, 45]
The rows of are independent, so is positive definite:
#cas [dot] (!![1, 2, 3; 4, 5, 6], !![1, 4; 2, 5; 3, 6])
product
!![14, 32; 32, 77]- Domain
ℚ^(2×3)- Input (product)
!![1, 2, 3; 4, 5, 6] . !![1, 4; 2, 5; 3, 6]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1, 2, 3; 4, 5, 6] * !![1, 4; 2, 5; 3, 6] = !![14, 32; 32, 77]
The certificate: 1 checked step
Decided by kernel evaluation
!![1, 2, 3; 4, 5, 6] * !![1, 4; 2, 5; 3, 6] = !![14, 32; 32, 77]
#cas [positiveDefinite] !![14, 32; 32, 77]
Boolean
True- Domain
2 × 2 real matrix- Input (matrix)
!![14, 32; 32, 77]
Checked by Lean’s kernel: The matrix is positive definite
!![14, 32; 32, 77].PosDef
The certificate: 1 checked step
The matrix is positive definite
!![14, 32; 32, 77].PosDef
The computation
Certificate
A = L D Lᵀ over ℚ with pivots D = [14, 27/7], all positive
Properties and Relations (2)
Transposing twice gives back the matrix:
#cas [transpose] !![1, 4; 2, 5; 3, 6]
transpose
!![1, 2, 3; 4, 5, 6]- Domain
ℚ^(3×2)- Input (matrix)
!![1, 4; 2, 5; 3, 6]
Checked by Lean’s kernel: Decided by kernel evaluation
!![1, 4; 2, 5; 3, 6].transpose = !![1, 2, 3; 4, 5, 6]
The certificate: 1 checked step
Decided by kernel evaluation
!![1, 4; 2, 5; 3, 6].transpose = !![1, 2, 3; 4, 5, 6]
A matrix and its transpose have the same determinant. This is the transpose of the matrix with determinant on the det page:
#cas [det] !![1, 4, 7; 2, 5, 8; 3, 6, 10]
determinant
-3- Domain
ℚ^(3×3)- Input (matrix)
!![1, 4, 7; 2, 5, 8; 3, 6, 10]
Checked by Lean’s kernel: Determinant
!![1, 4, 7; 2, 5, 8; 3, 6, 10].det = -3
The certificate: 1 checked step
Determinant
!![1, 4, 7; 2, 5, 8; 3, 6, 10].det = -3
Possible Issues (2)
Every row needs the same number of entries:
#cas [transpose] !![1, 2; 3]
Error
the rows of the matrix have different lengths
A vector ![1, 2, 3] is not a matrix. Write a row as !![1, 2, 3], as above:
#cas [transpose] ![1, 2, 3]
Error
expected a matrix `!![a, b; c, d]` or `[[a, b], [c, d]]`
Neat Examples (1)
The Pythagorean triple gives a rotation with rational entries. Its transpose is its inverse:
#cas [transpose] !![3/5, -4/5; 4/5, 3/5]
transpose
!![3/5, 4/5; -4/5, 3/5]- Domain
ℚ^(2×2)- Input (matrix)
!![3/5, -4/5; 4/5, 3/5]
Checked by Lean’s kernel: Decided by kernel evaluation
!![3 / 5, -(4 / 5); 4 / 5, 3 / 5].transpose = !![3 / 5, 4 / 5; -(4 / 5), 3 / 5]
The certificate: 1 checked step
Decided by kernel evaluation
!![3 / 5, -(4 / 5); 4 / 5, 3 / 5].transpose = !![3 / 5, 4 / 5; -(4 / 5), 3 / 5]
#cas [inverse] !![3/5, -4/5; 4/5, 3/5]
inverse
!![3/5, 4/5; -4/5, 3/5]- Domain
ℚ^(2×2)- Input (matrix)
!![3/5, -4/5; 4/5, 3/5]
Checked by Lean’s kernel: Inverse from the product B * A = 1
!![3 / 5, -(4 / 5); 4 / 5, 3 / 5]⁻¹ = !![3 / 5, 4 / 5; -(4 / 5), 3 / 5]
The certificate: 1 checked step
Inverse from the product B * A = 1
!![3 / 5, -(4 / 5); 4 / 5, 3 / 5]⁻¹ = !![3 / 5, 4 / 5; -(4 / 5), 3 / 5]
See Also
dot · trace · positiveDefinite · inverse · det
