Zulip Chat Archive

Stream: new members

Topic: rw not accepting pattern


Anirudh Suresh (Mar 17 2025 at 16:52):

import Mathlib.Data.Complex.Basic
import Mathlib.Data.Real.Basic
import Mathlib.Data.Real.Sqrt
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Complex.Basic
import Mathlib.Data.Matrix.Kronecker
import Mathlib.LinearAlgebra.UnitaryGroup
open scoped Matrix
open ComplexConjugate

def tensor_product_2 {m n o p : } (A : Matrix (Fin m) (Fin n) )
  (B : Matrix (Fin o) (Fin p) ) : Matrix (Fin (m * o)) (Fin (n * p))  :=
(Matrix.kroneckerMap (fun (a:) (b:) => a*b) A B).reindex finProdFinEquiv finProdFinEquiv

infixl:80 " ⊗ " => tensor_product_2

def conjugate_transpose {m n : Type*} [Fintype m] [Fintype n]
  (A : Matrix m n ) : Matrix n m  :=
Matrix.transpose (Matrix.map A (fun (x:)=> conj x))

theorem t1 (q1 q2 q3 q4: Matrix (Fin 2) (Fin 1) ): ((conjugate_transpose q1 * q2)  (conjugate_transpose q3 * q4)) 0 0 =
  (conjugate_transpose q1 * q2) 0 0 * (conjugate_transpose q3 * q4) 0 0:=by {
    unfold conjugate_transpose
    unfold tensor_product_2
    simp only [Matrix.reindex_apply, Matrix.kroneckerMap_apply]
    rw [Matrix.submatrix_apply]
    have h : finProdFinEquiv.symm (0 : Fin (2*2)) = (0, 0) :=
    by rw [ Equiv.apply_symm_apply finProdFinEquiv (0 : Fin (2*2))]; rfl
    rw [h]
  }

even though there is an instance of the pattern in the goal, Lean says there isn't. Why is this the case?

Aaron Liu (Mar 17 2025 at 16:56):

The hypothesis h says that finProdFinEquiv.symm (0 : Fin (2 * 2)) = ((0 : Fin 2), (0 : Fin 2)).
The pattern in the goal is finProdFinEquiv.symm (0 : Fin (1 * 1)).
These are not the same

Eric Wieser (Mar 17 2025 at 17:56):

Are you aware of docs#Matrix.conjTranspose ?

Notification Bot (Mar 17 2025 at 17:58):

This topic was moved here from #lean4 > rw not accepting pattern by Eric Wieser.


Last updated: May 02 2025 at 03:31 UTC