Download lean/OAI/Probability/SKGap/Matrix/LiftMatrix.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 5.68 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/SKGap/Matrix/LiftMatrix.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Probability/SKGap/Matrix/LiftMatrix.lean
-
curl -L -o LiftMatrix.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/SKGap/Matrix/LiftMatrix.lean
5.68 kB
| import Mathlib | |
| import OAI.Probability.SKGap.Matrix.OpNorm | |
| namespace OAI | |
| section | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory InformationTheory Real Set | |
| open scoped NNReal ENNReal | |
| open Filter | |
| open scoped Topology | |
| noncomputable section | |
| open Matrix Real | |
| open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal | |
| noncomputable section | |
| open Matrix Real | |
| open scoped BigOperators Matrix.Norms.Frobenius NNReal | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Real Set Filter | |
| open MeasureTheory.Measure | |
| open scoped ENNReal NNReal MeasureTheory Topology | |
| open MeasureTheory | |
| noncomputable section | |
| noncomputable section | |
| open MeasureTheory Set NormedSpace | |
| open scoped Topology | |
| noncomputable section | |
| open Matrix Real | |
| open scoped BigOperators Matrix.Norms.Frobenius | |
| noncomputable section | |
| open Set Real | |
| open scoped Topology | |
| noncomputable section | |
| open Matrix Set Filter | |
| open scoped Topology Matrix.Norms.Frobenius | |
| noncomputable section | |
| open Matrix NormedSpace ContinuousLinearMap | |
| open scoped Matrix.Norms.Frobenius | |
| noncomputable section | |
| open Matrix | |
| namespace SKGap.RealComplex | |
| open scoped Matrix.Norms.Frobenius | |
| variable {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| def liftMatrix (M : Matrix ι ι ℝ) : Matrix ι ι ℂ := M.map Complex.ofReal | |
| abbrev clin (M : Matrix ι ι ℂ) := M.toEuclideanLin.toContinuousLinearMap | |
| abbrev rlin (M : Matrix ι ι ℝ) := M.toEuclideanLin.toContinuousLinearMap | |
| def reVec (x : EuclideanSpace ℂ ι) : EuclideanSpace ℝ ι := | |
| WithLp.toLp 2 (fun i => (x i).re) | |
| def imVec (x : EuclideanSpace ℂ ι) : EuclideanSpace ℝ ι := | |
| WithLp.toLp 2 (fun i => (x i).im) | |
| def liftVec (x : EuclideanSpace ℝ ι) : EuclideanSpace ℂ ι := | |
| WithLp.toLp 2 (fun i => (x i : ℂ)) | |
| omit [DecidableEq ι] in | |
| lemma vec_norm_split (x : EuclideanSpace ℂ ι) : | |
| ‖x‖^2 = ‖reVec x‖^2+‖imVec x‖^2 := by | |
| simp only [EuclideanSpace.norm_sq_eq,← Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| change ‖x i‖^2 = ‖(x i).re‖^2+‖(x i).im‖^2 | |
| rw [Complex.sq_norm,Complex.normSq_apply] | |
| simp only [Real.norm_eq_abs] | |
| rw [sq_abs,sq_abs] | |
| ring | |
| omit [DecidableEq ι] in | |
| lemma norm_liftVec (x : EuclideanSpace ℝ ι) : ‖liftVec x‖ = ‖x‖ := by | |
| have hh : ‖liftVec x‖^2 = ‖x‖^2 := by simp [EuclideanSpace.norm_sq_eq,liftVec] | |
| nlinarith [norm_nonneg (liftVec x),norm_nonneg x] | |
| lemma reVec_clin (M : Matrix ι ι ℝ) (x : EuclideanSpace ℂ ι) : | |
| reVec (clin (liftMatrix M) x) = rlin M (reVec x) := by | |
| ext i | |
| change (∑ j, (M i j : ℂ)*x j).re = ∑ j, M i j*(x j).re | |
| simp | |
| lemma imVec_clin (M : Matrix ι ι ℝ) (x : EuclideanSpace ℂ ι) : | |
| imVec (clin (liftMatrix M) x) = rlin M (imVec x) := by | |
| ext i | |
| change (∑ j, (M i j : ℂ)*x j).im = ∑ j, M i j*(x j).im | |
| simp | |
| lemma clin_liftVec (M : Matrix ι ι ℝ) (x : EuclideanSpace ℝ ι) : | |
| clin (liftMatrix M) (liftVec x) = liftVec (rlin M x) := by | |
| ext i | |
| change (∑ j, (M i j : ℂ)*(x j : ℂ)) = ((∑ j, M i j*x j : ℝ) : ℂ) | |
| simp | |
| lemma operator_norm_lift (M : Matrix ι ι ℝ) : ‖clin (liftMatrix M)‖ = opNorm M := by | |
| apply le_antisymm | |
| · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) | |
| intro x | |
| apply nonneg_le_nonneg_of_sq_le_sq (mul_nonneg (norm_nonneg _) (norm_nonneg _)) | |
| simp only [← sq] | |
| change ‖clin (liftMatrix M) x‖^2 ≤ (opNorm M*‖x‖)^2 | |
| rw [vec_norm_split,reVec_clin,imVec_clin,mul_pow,vec_norm_split,mul_add] | |
| have hr := (rlin M).le_opNorm (reVec x) | |
| have hi := (rlin M).le_opNorm (imVec x) | |
| change ‖rlin M (reVec x)‖ ≤ opNorm M*‖reVec x‖ at hr | |
| change ‖rlin M (imVec x)‖ ≤ opNorm M*‖imVec x‖ at hi | |
| nlinarith [norm_nonneg (rlin M (reVec x)),norm_nonneg (rlin M (imVec x)), | |
| mul_nonneg (norm_nonneg (rlin M)) (norm_nonneg (reVec x)), | |
| mul_nonneg (norm_nonneg (rlin M)) (norm_nonneg (imVec x))] | |
| · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) | |
| intro x | |
| have hh := (clin (liftMatrix M)).le_opNorm (liftVec x) | |
| rwa [clin_liftVec,norm_liftVec,norm_liftVec] at hh | |
| lemma norm_liftMatrix (M : Matrix ι ι ℝ) : ‖liftMatrix M‖ = ‖M‖ := | |
| Matrix.frobenius_norm_map_eq M Complex.ofReal (fun x => by simp) | |
| omit [Fintype ι] [DecidableEq ι] in | |
| lemma liftMatrix_sub (M N : Matrix ι ι ℝ) : | |
| liftMatrix (M-N) = liftMatrix M-liftMatrix N := by ext i j; simp [liftMatrix] | |
| omit [Fintype ι] [DecidableEq ι] in | |
| lemma liftMatrix_add (M N : Matrix ι ι ℝ) : | |
| liftMatrix (M+N) = liftMatrix M+liftMatrix N := by ext i j; simp [liftMatrix] | |
| omit [DecidableEq ι] in | |
| lemma liftMatrix_mul (M N : Matrix ι ι ℝ) : | |
| liftMatrix (M*N) = liftMatrix M*liftMatrix N := by | |
| exact Matrix.map_mul (f := Complex.ofRealHom) | |
| omit [Fintype ι] in | |
| lemma liftMatrix_one : liftMatrix (1 : Matrix ι ι ℝ) = 1 := | |
| Matrix.map_one Complex.ofReal (by simp) (by simp) | |
| omit [Fintype ι] [DecidableEq ι] in | |
| lemma liftMatrix_smul (s : ℝ) (M : Matrix ι ι ℝ) : | |
| liftMatrix (s • M) = s • liftMatrix M := by ext i j; simp [liftMatrix] | |
| omit [Fintype ι] [DecidableEq ι] in | |
| lemma liftMatrix_conjTranspose (M : Matrix ι ι ℝ) : | |
| (liftMatrix M)ᴴ = liftMatrix Mᵀ := by ext i j; simp [liftMatrix] | |
| omit [Fintype ι] [DecidableEq ι] in | |
| lemma liftMatrix_hermitian (M : Matrix ι ι ℝ) (hM : Mᵀ = M) : | |
| (liftMatrix M)ᴴ = liftMatrix M := by rw [liftMatrix_conjTranspose,hM] | |
| omit [Fintype ι] [DecidableEq ι] in | |
| lemma liftMatrix_injective : Function.Injective (liftMatrix (ι := ι)) := by | |
| intro M N h | |
| ext i j | |
| exact Complex.ofReal_injective (congrFun (congrFun h i) j) | |
| end SKGap.RealComplex | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |